Browse Source

add:物料信息导入

master
gengby 8 months ago
parent
commit
a81a164ed0
  1. 9
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/controller/MdBaseMaterialController.java
  2. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java
  3. 31
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java
  4. 27
      lms/nladmin-ui/src/views/wms/basedata/material/index.vue
  5. 10
      lms/nladmin-ui/src/views/wms/basedata/material/mdBaseMaterial.js

9
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/database/material/controller/MdBaseMaterialController.java

@ -14,7 +14,9 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.Set;
@ -73,4 +75,11 @@ public class MdBaseMaterialController {
wmsToMesService.synchronizeMaterialInfo();
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/excelImport")
@Log("excel导入")
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
wmsToMesService.excelImport(file, request);
return new ResponseEntity<>(HttpStatus.OK);
}
}

4
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java

@ -6,7 +6,9 @@ import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo;
import org.nl.wms.ext.mes.service.dto.*;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@ -193,4 +195,6 @@ public interface WmsToMesService {
* @param entity
*/
void addScrap(ScrapDto entity);
void excelImport(MultipartFile file, HttpServletRequest request);
}

31
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java

@ -3,13 +3,18 @@ package org.nl.wms.ext.mes.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.system.service.notice.ISysNoticeService;
import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo;
import org.nl.wms.database.material.service.IMdBaseMaterialService;
@ -31,7 +36,11 @@ import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@ -510,6 +519,28 @@ public class WmsToMesServiceImpl implements WmsToMesService {
mesRequestMapper.reportSemiProductGXPF(semiProductGXPFDo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void excelImport(MultipartFile file, HttpServletRequest request) {
if (file.isEmpty()) {
throw new BadRequestException("文件为空,请添加数据后重新导入");
}
// 1.获取上传文件输入流
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
// 调用用 hutool 方法读取数据 默认调用第一个sheet
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
// 循环获取的数据
for (int i = 0; i < read.size(); i++) {
}
}
/**
* 转换
*

27
lms/nladmin-ui/src/views/wms/basedata/material/index.vue

@ -48,15 +48,25 @@
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" >
<!-- <el-button-->
<!-- slot="right"-->
<!-- class="filter-item"-->
<!-- type="success"-->
<!-- icon="el-icon-position"-->
<!-- size="mini"-->
<!-- @click="synchronize()"-->
<!-- >-->
<!-- 同步-->
<!-- </el-button>-->
<el-button
slot="right"
class="filter-item"
type="success"
icon="el-icon-position"
type="warning"
icon="el-icon-upload2"
size="mini"
@click="synchronize()"
@click="uploadShow = true"
>
同步
导入
</el-button>
</crudOperation>
<!--表单组件-->
@ -202,6 +212,7 @@
<!--分页组件-->
<pagination />
</div>
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3" />
</div>
</template>
@ -214,6 +225,8 @@ import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import UploadDialog from './UploadDialog'
const defaultForm = {
material_id: null,
@ -240,7 +253,7 @@ const defaultForm = {
export default {
name: 'MdBaseMaterial',
dicts: ['vehicle_type'],
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect, UploadDialog },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
@ -258,6 +271,7 @@ export default {
},
rules: {
},
uploadShow: false,
fullscreenLoading: false,
workShopList: []
}
@ -284,6 +298,9 @@ export default {
this.workShopList = res
})
},
tableChanged3() {
this.crud.toQuery()
},
//
loadChildNodes({ action, parentNode, callback }) {
// if (action === LOAD_CHILDREN_OPTIONS) {

10
lms/nladmin-ui/src/views/wms/basedata/material/mdBaseMaterial.js

@ -32,4 +32,12 @@ export function synchronize(data) {
})
}
export default { add, edit, del, synchronize }
export function excelImport(data) {
return request({
url: 'api/mdBaseMaterial/excelImport',
method: 'post',
data
})
}
export default { add, edit, del, synchronize, excelImport }

Loading…
Cancel
Save