diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/controller/material/MdMeMaterialbaseController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/controller/material/MdMeMaterialbaseController.java index a064f3c7..ae9fbc0c 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/controller/material/MdMeMaterialbaseController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/controller/material/MdMeMaterialbaseController.java @@ -1,9 +1,23 @@ package org.nl.wms.masterdata_manage.controller.material; +import io.swagger.annotations.ApiOperation; +import org.nl.common.anno.Log; +import org.nl.common.utils.RedissonUtils; +import org.nl.wms.masterdata_manage.service.material.IMdMeMaterialbaseService; +import org.nl.wms.masterdata_manage.备份master.service.MaterialbaseService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** *

@@ -14,8 +28,19 @@ import org.springframework.web.bind.annotation.RestController; * @since 2023-04-26 */ @RestController -@RequestMapping("/mdMeMaterialbase") +@RequestMapping("/api/mdMeMaterialbase") public class MdMeMaterialbaseController { + @Autowired + private IMdMeMaterialbaseService materialBaseService; + @PostMapping("/excelImport") + @Log("excel导入") + @ApiOperation("excel导入") + public ResponseEntity excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) { + RedissonUtils.lock(() -> { + materialBaseService.excelImport(file, request, response); + }, "物料基础信息导入", null); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/classstandard/ClassstandardController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/classstandard/ClassstandardController.java index 0033725e..4f852a36 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/classstandard/ClassstandardController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/classstandard/ClassstandardController.java @@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.common.TableDataInfo; import org.nl.common.anno.Log; +import org.nl.common.utils.RedissonUtils; import org.nl.modules.wql.core.bean.WQLObject; import org.nl.wms.masterdata_manage.master.service.classstandard.IMdPbClassstandardService; import org.nl.wms.masterdata_manage.备份master.service.ClassstandardService; @@ -22,7 +23,10 @@ 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 javax.servlet.http.HttpServletResponse; import java.util.Map; /** @@ -135,5 +139,14 @@ public class ClassstandardController { return new ResponseEntity<>(ClassstandardService.getClassName(), HttpStatus.OK); } + @PostMapping("/excelImport") + @Log("excel导入") + @ApiOperation("excel导入") + public ResponseEntity excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) { + RedissonUtils.lock(() -> { + mdPbClassstandardService.excelImport(file, request, response); + }, "基础分类导入", null); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/customer/MdCsCustomerbaseController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/customer/MdCsCustomerbaseController.java index 1deb9f7b..f590128f 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/customer/MdCsCustomerbaseController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/controller/customer/MdCsCustomerbaseController.java @@ -11,6 +11,7 @@ import org.nl.common.TableDataInfo; import org.nl.common.anno.Log; import lombok.extern.slf4j.Slf4j; import org.nl.common.domain.query.PageQuery; +import org.nl.common.utils.RedissonUtils; import org.nl.wms.masterdata_manage.master.service.customer.IMdCsCustomerbaseService; import org.nl.wms.masterdata_manage.master.service.customer.dto.CustomerQuery; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +19,10 @@ 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 javax.servlet.http.HttpServletResponse; import java.util.Arrays; import java.util.Map; @@ -69,4 +73,14 @@ public class MdCsCustomerbaseController { } return new ResponseEntity<>(HttpStatus.OK); } + + @PostMapping("/excelImport") + @Log("excel导入") + @ApiOperation("excel导入") + public ResponseEntity excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) { + RedissonUtils.lock(() -> { + icustomerbaseService.excelImport(file, request, response); + }, "客户信息导入", null); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/IMdPbClassstandardService.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/IMdPbClassstandardService.java index a30236fa..c2aba243 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/IMdPbClassstandardService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/IMdPbClassstandardService.java @@ -3,7 +3,11 @@ package org.nl.wms.masterdata_manage.master.service.classstandard; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.service.IService; import org.nl.wms.masterdata_manage.master.service.classstandard.dao.MdPbClassstandard; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; import java.util.Map; import java.util.Set; @@ -65,4 +69,6 @@ public interface IMdPbClassstandardService extends IService { List getChildIdStr(String class_id); Set getAllChildIdSet(String class_idStr); + + void excelImport(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException; } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/impl/MdPbClassstandardServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/impl/MdPbClassstandardServiceImpl.java index eb19ac12..3d73518b 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/impl/MdPbClassstandardServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/classstandard/impl/MdPbClassstandardServiceImpl.java @@ -5,6 +5,8 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.hash.Hash; 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.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -29,7 +31,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; @@ -46,23 +53,24 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl dropdownList(Map whereJson) { - Assert.notNull(whereJson,"参数不能为空"); + Assert.notNull(whereJson, "参数不能为空"); QueryWrapper query = new QueryWrapper() .eq("parent_class_id", "0") - .eq("is_delete",false); - if (whereJson.get("class_code") !=null) { - query.eq("class_code",whereJson.get("class_code")); + .eq("is_delete", false); + if (whereJson.get("class_code") != null) { + query.eq("class_code", whereJson.get("class_code")); } - return getMaps(this.listMaps(query)); + return getMaps(this.listMaps(query)); } @Override - public List loadClass(Map whereJson) { + public List loadClass(Map whereJson) { List> list = this.listMaps(new QueryWrapper() .eq("is_delete", false) - .eq("parent_class_id", whereJson.get("pid") == null ? "0":whereJson.get("pid"))); + .eq("parent_class_id", whereJson.get("pid") == null ? "0" : whereJson.get("pid"))); List result = getMaps(list); return result; } @@ -72,7 +80,7 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl result = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { Map item = list.get(i); - if ((int)item.get("sub_count") > 0) { + if ((int) item.get("sub_count") > 0) { item.put("hasChildren", true); item.put("leaf", false); } else { @@ -98,15 +106,15 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl query = new QueryWrapper().eq("is_delete",false); + QueryWrapper query = new QueryWrapper().eq("is_delete", false); if (ObjectUtil.isNotEmpty(whereJson.get("class_code"))) { - query.in("class_code",whereJson.get("class_code")); + query.in("class_code", whereJson.get("class_code")); } - if (ObjectUtil.isNotEmpty(whereJson.get("parent_class_code"))&&!whereJson.get("parent_class_code").equals("0")){ - query.eq("class_id",classstandard.getClass_id()); + if (ObjectUtil.isNotEmpty(whereJson.get("parent_class_code")) && !whereJson.get("parent_class_code").equals("0")) { + query.eq("class_id", classstandard.getClass_id()); } - if (ObjectUtil.isNotEmpty(whereJson.get("parent_class_code")) || whereJson.get("parent_class_code").equals("0")){ - query.eq("parent_class_id","0").or().isNull("parent_class_id"); + if (ObjectUtil.isNotEmpty(whereJson.get("parent_class_code")) || whereJson.get("parent_class_code").equals("0")) { + query.eq("parent_class_id", "0").or().isNull("parent_class_id"); } return getMaps(this.listMaps(query)); } @@ -115,19 +123,19 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl queryClassById(Map whereJson) { QueryWrapper query = new QueryWrapper<>(); - query.eq("1","1"); + query.eq("1", "1"); if (ObjectUtil.isNotEmpty(whereJson.get("material_id"))) { MdMeMaterialbase one = materialbaseService.getOne(new QueryWrapper().eq("material_id", whereJson.get("material_id"))); - whereJson.put("class_idStr",one.getMaterial_type_id()); + whereJson.put("class_idStr", one.getMaterial_type_id()); } if (ObjectUtil.isNotEmpty(whereJson.get("whereStr"))) { query.last((String) whereJson.get("whereStr")); } if (ObjectUtil.isNotEmpty(whereJson.get("parent_class_id"))) { - query.eq("parent_class_id",whereJson.get("parent_class_id")); + query.eq("parent_class_id", whereJson.get("parent_class_id")); } if (ObjectUtil.isNotEmpty(whereJson.get("class_idStr"))) { - query.in("class_id",whereJson.get("class_idStr")); + query.in("class_id", whereJson.get("class_idStr")); } List> list = this.listMaps(query); return getMaps(list); @@ -138,7 +146,7 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl().eq("class_code", form.getString("class_code"))); if (one != null) { - throw new BadRequestException(form.getString("class_code")+"存在相同的基础类别编号"); + throw new BadRequestException(form.getString("class_code") + "存在相同的基础类别编号"); } MdPbClassstandard classstandard = form.toJavaObject(MdPbClassstandard.class); classstandard.setClass_id(IdUtil.getStringId()); @@ -158,16 +166,16 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl().eq("class_id", class_id).eq("is_delete",false)); - if (one == null){ - throw new BadRequestException(class_id+"没有对应分类数据"); + if (!StringUtils.isEmpty(class_id)) { + MdPbClassstandard one = this.getOne(new QueryWrapper().eq("class_id", class_id).eq("is_delete", false)); + if (one == null) { + throw new BadRequestException(class_id + "没有对应分类数据"); } int count = this.count(new QueryWrapper() .eq("parent_class_id", class_id)); - one.setSub_count( count); - one.setIs_leaf(count > 0?false:true); + one.setSub_count(count); + one.setIs_leaf(count > 0 ? false : true); this.updateById(one); } } @@ -190,10 +198,10 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl().eq("class_id", form.getString("class_id"))); if (onebyid == null) { - throw new BadRequestException(form.getString("class_id")+"被删除或无权限,操作失败!"); + throw new BadRequestException(form.getString("class_id") + "被删除或无权限,操作失败!"); } if (form.getString("parent_class_id") != null && form.getString("class_id").equals(form.getString("parent_class_id"))) { throw new BadRequestException("上级不能为自己"); @@ -203,7 +211,7 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl list = CopyUtil.copyList(this.list(), MdPbClassstandardTree.class); @@ -213,31 +221,31 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl top_parent = collect.remove(id); - if (!CollectionUtils.isEmpty(top_parent)){ + if (!CollectionUtils.isEmpty(top_parent)) { this.getChildTree(top_parent, collect, removeCollect); } } - if (!CollectionUtils.isEmpty(removeCollect)){ + if (!CollectionUtils.isEmpty(removeCollect)) { this.update(new UpdateWrapper() - .set("is_delete",true) - .set("update_id",SecurityUtils.getCurrentUserId()) - .set("update_name",SecurityUtils.getCurrentNickName()).set("update_time",DateUtil.now()).in("class_id",removeCollect)); + .set("is_delete", true) + .set("update_id", SecurityUtils.getCurrentUserId()) + .set("update_name", SecurityUtils.getCurrentNickName()).set("update_time", DateUtil.now()).in("class_id", removeCollect)); } } - private List getChildTree(List top_parent, Map> collect,Set removeCollect){ + private List getChildTree(List top_parent, Map> collect, Set removeCollect) { removeCollect.addAll(top_parent.stream().map(MdPbClassstandardTree::getClass_id).collect(Collectors.toList())); - if (CollectionUtils.isEmpty(collect)){ + if (CollectionUtils.isEmpty(collect)) { return top_parent; } for (MdPbClassstandardTree parent : top_parent) { List child = collect.remove(parent.getClass_id()); - if (CollectionUtils.isEmpty(child)){ + if (CollectionUtils.isEmpty(child)) { continue; } - List childMenuTree = getChildTree(child, collect,removeCollect); - if (!CollectionUtils.isEmpty(childMenuTree)){ + List childMenuTree = getChildTree(child, collect, removeCollect); + if (!CollectionUtils.isEmpty(childMenuTree)) { parent.setItemClassstrandard(childMenuTree); } } @@ -247,7 +255,7 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl getChildIdStr(String class_id) { - if (StringUtils.isEmpty(class_id)){ + if (StringUtils.isEmpty(class_id)) { return new ArrayList<>(); } return this.baseMapper.getChildIdStr(class_id); @@ -263,4 +271,69 @@ public class MdPbClassstandardServiceImpl extends ServiceImpl> read = excelReader.read(); + + Map errorMap = new HashMap(); + for (int i = 1; i < read.size(); i++) { + List list = read.get(i); + if (ObjectUtil.isEmpty(list)) { + continue; + } + if (ObjectUtil.isEmpty(list.get(0))) { + errorMap.put("第" + (i + 1) + "行:", "分类编码为空!"); + continue; + } + String class_code = String.valueOf(list.get(0)); + MdPbClassstandard one = this.getOne(new QueryWrapper().eq("class_code", class_code).eq("is_delete",false)); + if (one != null) { + errorMap.put("第" + (i + 1) + "行:", "存在相同的分类编码:"+class_code); + continue; + }else { + one = new MdPbClassstandard(); + } + + String class_name = (String) list.get(1); + if (ObjectUtil.isEmpty(class_name)) { + errorMap.put("第" + (i + 1) + "行:", "分类名称为空!"); + continue; + } + String class_desc = (String) list.get(2); + if (StrUtil.isNotEmpty(class_desc)){ + one.setClass_desc(class_desc); + } + + one.setClass_id(IdUtil.getStringId()); + one.setClass_code(class_code); + one.setClass_name(class_name); + one.setCreate_id(SecurityUtils.getCurrentUserId()); + one.setCreate_name(SecurityUtils.getCurrentNickName()); + one.setCreate_time(DateUtil.now()); + one.setIs_leaf(true); + one.setSub_count(0); + + if (ObjectUtil.isNotEmpty(list.get(3))){ + String pareant_class_code = String.valueOf(list.get(3)); + ///更新节点 + if (StrUtil.isNotEmpty(pareant_class_code)) { + MdPbClassstandard parent_one = this.getOne(new QueryWrapper().eq("class_code", pareant_class_code).eq("is_delete",false)); + if (ObjectUtil.isEmpty(parent_one)){ + errorMap.put("第" + (i + 1) + "行:", "父节点对应的编码:"+pareant_class_code+"不存在!"); + }else { + one.setParent_class_id(parent_one.getClass_id()); + this.save(one); + updateSubCnt(parent_one.getParent_class_id()); + } + + } + } + } + if (!CollectionUtils.isEmpty(errorMap)) { + throw new BadRequestException(JSON.toJSONString(errorMap)); + } + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/IMdCsCustomerbaseService.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/IMdCsCustomerbaseService.java index 335bea76..bdaf6817 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/IMdCsCustomerbaseService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/IMdCsCustomerbaseService.java @@ -3,6 +3,11 @@ package org.nl.wms.masterdata_manage.master.service.customer; import com.alibaba.fastjson.JSONObject; import org.nl.wms.masterdata_manage.master.service.customer.dao.MdCsCustomerbase; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** *

@@ -18,4 +23,6 @@ public interface IMdCsCustomerbaseService extends IService { void update(JSONObject dto); + void excelImport(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException; + } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/impl/MdCsCustomerbaseServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/impl/MdCsCustomerbaseServiceImpl.java index 97628d92..3fc09a2b 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/impl/MdCsCustomerbaseServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/master/service/customer/impl/MdCsCustomerbaseServiceImpl.java @@ -2,10 +2,14 @@ package org.nl.wms.masterdata_manage.master.service.customer.impl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; -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.QueryWrapper; +import org.nl.common.utils.IdUtil; import org.nl.common.utils.SecurityUtils; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.wql.core.bean.WQLObject; @@ -20,6 +24,15 @@ import org.nl.wms.masterdata_manage.备份master.service.dto.CustomerbaseDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** *

@@ -35,7 +48,7 @@ public class MdCsCustomerbaseServiceImpl extends ServiceImpl().eq("cust_code", cust_code)); if (custCode != null) { @@ -58,4 +71,53 @@ public class MdCsCustomerbaseServiceImpl extends ServiceImpl> read = excelReader.read(); + + Map errorMap = new HashMap(); + for (int i = 1; i < read.size(); i++) { + List list = read.get(i); + if (ObjectUtil.isEmpty(list)) { + continue; + } + String cust_code = (String) list.get(0); + if (StrUtil.isEmpty(cust_code)) { + errorMap.put("第" + (i + 1) + "行:", "客户编码为空!"); + } + + String cust_name = (String) list.get(1); + if (StrUtil.isEmpty(cust_name)) { + errorMap.put("第" + (i + 1) + "行:", "客户名称为空!"); + } + + boolean need_update = false; + MdCsCustomerbase cust_jo = this.getOne(new QueryWrapper().eq("cust_code", cust_code)); + if (ObjectUtil.isNotEmpty(cust_jo)){ + need_update = true; + }else { + cust_jo = new MdCsCustomerbase(); + } + if (need_update){ + cust_jo.setCust_name(cust_name); + cust_jo.setUpdate_id(SecurityUtils.getCurrentUserId()); + cust_jo.setUpdate_name(SecurityUtils.getCurrentNickName()); + cust_jo.setUpdate_time(DateUtil.now()); + this.updateById(cust_jo); + }else { + cust_jo.setCust_code(cust_code); + cust_jo.setCust_name(cust_name); + cust_jo.setCust_id(IdUtil.getStringId()); + cust_jo.setCreate_id(SecurityUtils.getCurrentUserId()); + cust_jo.setCreate_name(SecurityUtils.getCurrentNickName()); + cust_jo.setCreate_time(DateUtil.now()); + cust_jo.setIs_delete("0"); + cust_jo.setIs_used("1"); + this.save(cust_jo); + } + } + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/mdme.xls b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/mdme.xls index 4a913b1b..c66039cf 100644 Binary files a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/mdme.xls and b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/mdme.xls differ diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/IMdMeMaterialbaseService.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/IMdMeMaterialbaseService.java index 048cfe18..88af7609 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/IMdMeMaterialbaseService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/IMdMeMaterialbaseService.java @@ -3,7 +3,11 @@ package org.nl.wms.masterdata_manage.service.material; import com.alibaba.fastjson.JSONObject; import org.nl.wms.masterdata_manage.service.material.dao.MdMeMaterialbase; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; /** @@ -17,4 +21,6 @@ import java.util.List; public interface IMdMeMaterialbaseService extends IService { List getPdaBcpGetMaterial(JSONObject whereJson); + + void excelImport(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException; } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/dao/MdMeMaterialbase.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/dao/MdMeMaterialbase.java index e98f1d4e..3202950c 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/dao/MdMeMaterialbase.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/dao/MdMeMaterialbase.java @@ -139,7 +139,7 @@ public class MdMeMaterialbase implements Serializable { /** * 创建时间 */ - private Date create_time; + private String create_time; /** * 修改人 @@ -154,12 +154,12 @@ public class MdMeMaterialbase implements Serializable { /** * 修改时间 */ - private Date update_time; + private String update_time; /** * 启用时间 */ - private Date is_used_time; + private String is_used_time; /** * 是否启用 diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/impl/MdMeMaterialbaseServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/impl/MdMeMaterialbaseServiceImpl.java index 536ddbcf..e7d61e23 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/impl/MdMeMaterialbaseServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/service/material/impl/MdMeMaterialbaseServiceImpl.java @@ -1,13 +1,37 @@ package org.nl.wms.masterdata_manage.service.material.impl; +import cn.hutool.core.date.DateUtil; +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.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.nl.common.utils.IdUtil; +import org.nl.common.utils.SecurityUtils; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.wms.masterdata_manage.master.service.classstandard.IMdPbClassstandardService; +import org.nl.wms.masterdata_manage.master.service.classstandard.dao.MdPbClassstandard; +import org.nl.wms.masterdata_manage.service.master.IMdPbMeasureunitService; +import org.nl.wms.masterdata_manage.service.master.dao.MdPbMeasureunit; import org.nl.wms.masterdata_manage.service.material.IMdMeMaterialbaseService; import org.nl.wms.masterdata_manage.service.material.dao.MdMeMaterialbase; import org.nl.wms.masterdata_manage.service.material.dao.mapper.MdMeMaterialbaseMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** *

@@ -20,8 +44,113 @@ import java.util.List; @Service public class MdMeMaterialbaseServiceImpl extends ServiceImpl implements IMdMeMaterialbaseService { + @Autowired + IMdPbClassstandardService classstandardService; + @Autowired + IMdPbMeasureunitService measureunitService; + @Override public List getPdaBcpGetMaterial(JSONObject whereJson) { return this.baseMapper.getPdaBcpGetMaterial(whereJson); } + + @Override + public void excelImport(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException { + InputStream inputStream = file.getInputStream(); + ExcelReader excelReader = ExcelUtil.getReader(inputStream); + List> read = excelReader.read(); + + Map errorMap = new HashMap(); + for (int i = 1; i < read.size(); i++) { + List list = read.get(i); + if (ObjectUtil.isEmpty(list)) { + continue; + } + String material_code = (String) list.get(0); + if (StrUtil.isEmpty(material_code)) { + errorMap.put("第" + (i + 1) + "行:", "物料编码为空!"); + } + boolean need_update = true; + MdMeMaterialbase material_jo = this.getOne(new QueryWrapper().eq("material_code", material_code)); + if (ObjectUtil.isEmpty(material_jo)) { + material_jo = new MdMeMaterialbase(); + material_jo.setMaterial_code(material_code); + need_update = false; + } + String material_name = (String) list.get(1); + if (StrUtil.isEmpty(material_name)) { + errorMap.put("第" + (i + 1) + "行:", "物料名称为空!"); + } else { + material_jo.setMaterial_name(material_name); + } + String material_spec = (String) list.get(2); + if (StrUtil.isNotEmpty(material_spec)) { + material_jo.setMaterial_spec(material_spec); + } + + String material_model = (String) list.get(3); + if (StrUtil.isNotEmpty(material_model)) { + material_jo.setMaterial_model(material_model); + } + + String material_type = (String) list.get(4); + if (StrUtil.isEmpty(material_type)) { + errorMap.put("第" + (i + 1) + "行:", "物料分类编码为空!"); + }else { + //查询对应的系列名称 + MdPbClassstandard class_jo = classstandardService.getOne(new QueryWrapper().eq("class_name", material_type).eq("is_delete", false)); + if (ObjectUtil.isEmpty(class_jo)) { + errorMap.put("第" + (i + 1) + "行:", "物料分类编码对应的分类不存在!"); + continue; + } + material_jo.setMaterial_type_id(class_jo.getClass_id()); + } + + String product_series = (String) list.get(5); + if (StrUtil.isNotEmpty(product_series)) { + //查询对应的系列名称 + MdPbClassstandard class_jo = classstandardService.getOne(new QueryWrapper().eq("class_name", product_series).eq("is_delete", false)); + if (ObjectUtil.isEmpty(class_jo)) { + errorMap.put("第" + (i + 1) + "行:", "系列分类编码对应的分类不存在!"); + continue; + } + material_jo.setProduct_series(class_jo.getClass_id()); + } + + String unit_name = (String) list.get(6); + if (StrUtil.isEmpty(unit_name)) { + errorMap.put("第" + (i + 1) + "行:", "单位为空!"); + }else { + MdPbMeasureunit unit_jo = measureunitService.getOne(new QueryWrapper().eq("unit_name", unit_name)); + if (ObjectUtil.isEmpty(unit_jo)) { + errorMap.put("第" + (i + 1) + "行:", "单位:"+unit_name+"不存在!"); + continue; + } + material_jo.setBase_unit_id(unit_jo.getMeasure_unit_id()); + } + + String net_weight = String.valueOf(list.get(7)); + if (StrUtil.isEmpty(net_weight)) { + errorMap.put("第" + (i + 1) + "行:", "单重为空!"); + }else { + material_jo.setNet_weight(new BigDecimal(net_weight)); + } + + if (need_update){ + this.updateById(material_jo); + material_jo.setUpdate_id(SecurityUtils.getCurrentUserId()); + material_jo.setUpdate_name(SecurityUtils.getCurrentNickName()); + material_jo.setUpdate_time(DateUtil.now()); + }else { + material_jo.setMaterial_id(IdUtil.getStringId()); + material_jo.setCreate_id(SecurityUtils.getCurrentUserId()); + material_jo.setCreate_name(SecurityUtils.getCurrentNickName()); + material_jo.setCreate_time(DateUtil.now()); + this.save(material_jo); + } + } + if (!CollectionUtils.isEmpty(errorMap)) { + throw new BadRequestException(JSON.toJSONString(errorMap)); + } + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/MaterialbaseController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/MaterialbaseController.java index 6904fa19..8016a2c4 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/MaterialbaseController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/MaterialbaseController.java @@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.nl.common.anno.Log; import lombok.extern.slf4j.Slf4j; +import org.nl.common.utils.RedissonUtils; import org.nl.wms.masterdata_manage.备份master.constant.MaterOptTypeEnum; import org.nl.wms.masterdata_manage.备份master.service.MaterialbaseService; import org.nl.wms.masterdata_manage.备份master.service.dto.MaterialbaseDto; @@ -17,7 +18,10 @@ 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 javax.servlet.http.HttpServletResponse; import java.util.Map; /** diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/SemirealrawmaterialController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/SemirealrawmaterialController.java index af1d4ec5..fb17084e 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/SemirealrawmaterialController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/rest/SemirealrawmaterialController.java @@ -8,6 +8,7 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.nl.common.anno.Log; import lombok.extern.slf4j.Slf4j; +import org.nl.common.utils.RedissonUtils; import org.nl.wms.masterdata_manage.备份master.service.SemirealrawmaterialService; import org.nl.wms.masterdata_manage.备份master.service.dto.SemirealrawmaterialDto; import org.springframework.data.domain.Pageable; @@ -15,7 +16,10 @@ 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 javax.servlet.http.HttpServletResponse; import java.util.Map; /** @@ -66,4 +70,13 @@ public class SemirealrawmaterialController { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } + @PostMapping("/excelImport") + @Log("excel导入") + @ApiOperation("excel导入") + public ResponseEntity excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) { + RedissonUtils.lock(() -> { + semirealrawmaterialService.excelImport(file, request, response); + }, "半成品原材料导入", null); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/MaterialbaseService.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/MaterialbaseService.java index 2d386d5c..bc908800 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/MaterialbaseService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/MaterialbaseService.java @@ -5,7 +5,11 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.nl.wms.masterdata_manage.备份master.service.dto.MaterialbaseDto; import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -93,5 +97,4 @@ public interface MaterialbaseService { JSONArray getProductSeries(String parent_class_id); - } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/SemirealrawmaterialService.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/SemirealrawmaterialService.java index b28736d4..97cba873 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/SemirealrawmaterialService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/SemirealrawmaterialService.java @@ -4,7 +4,11 @@ package org.nl.wms.masterdata_manage.备份master.service; import com.alibaba.fastjson.JSONObject; import org.nl.wms.masterdata_manage.备份master.service.dto.SemirealrawmaterialDto; import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -63,4 +67,6 @@ public interface SemirealrawmaterialService { */ void deleteAll(Long[] ids); + void excelImport(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException; + } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/MaterialbaseServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/MaterialbaseServiceImpl.java index e17110a4..b9191905 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/MaterialbaseServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/MaterialbaseServiceImpl.java @@ -5,6 +5,8 @@ import cn.hutool.core.map.MapUtil; 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.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -37,8 +39,13 @@ import org.springframework.data.domain.Pageable; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; @@ -177,7 +184,7 @@ public class MaterialbaseServiceImpl implements MaterialbaseService{ public void update(JSONObject dto) { MdMeMaterialbase materialbase = dto.toJavaObject(MdMeMaterialbase.class); - materialbase.setUpdate_time(new Date()); + materialbase.setUpdate_time(DateUtil.now()); materialbase.setUpdate_id(SecurityUtils.getCurrentUserId()); materialbase.setUpdate_name(SecurityUtils.getCurrentNickName()); materialbaseService.updateById(materialbase); @@ -302,7 +309,7 @@ public class MaterialbaseServiceImpl implements MaterialbaseService{ material.setMaterial_type_id(class_jo.getString("class_id")); material.setCreate_id(SecurityUtils.getCurrentUserId()); material.setCreate_name(SecurityUtils.getCurrentNickName()); - material.setCreate_time(new Date()); + material.setCreate_time(DateUtil.now()); material.setIs_used(true); material.setIs_delete(false); materialbaseService.save(material); @@ -323,7 +330,7 @@ public class MaterialbaseServiceImpl implements MaterialbaseService{ material.setMaterial_type_id(class_jo.getString("class_id")); material.setCreate_id(SecurityUtils.getCurrentUserId()); material.setCreate_name(SecurityUtils.getCurrentNickName()); - material.setCreate_time(new Date()); + material.setCreate_time(DateUtil.now()); material.setIs_used(true); material.setIs_delete(false); materialbaseService.updateById(material); diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/SemirealrawmaterialServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/SemirealrawmaterialServiceImpl.java index c61e0d22..c94cfcd0 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/SemirealrawmaterialServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/service/impl/SemirealrawmaterialServiceImpl.java @@ -7,22 +7,38 @@ import cn.hutool.core.map.MapUtil; 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.JSONArray; import com.alibaba.fastjson.JSONObject; - import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.common.utils.SecurityUtils; +import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.wql.WQL; import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.util.WqlUtil; +import org.nl.wms.masterdata_manage.service.material.IMdMeMaterialbaseService; +import org.nl.wms.masterdata_manage.service.material.dao.MdMeMaterialbase; import org.nl.wms.masterdata_manage.备份master.service.SemirealrawmaterialService; import org.nl.wms.masterdata_manage.备份master.service.dto.SemirealrawmaterialDto; +import org.nl.wms.product_manage.service.workprocedure.IPdmBiWorkprocedureService; +import org.nl.wms.product_manage.service.workprocedure.dao.PdmBiWorkprocedure; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,6 +52,11 @@ import java.util.Map; @Slf4j public class SemirealrawmaterialServiceImpl implements SemirealrawmaterialService { + @Autowired + private IPdmBiWorkprocedureService workprocedureService; + @Autowired + private IMdMeMaterialbaseService materialbaseService; + @Override public Map queryAll(Map whereJson, Pageable page) { String search = MapUtil.getStr(whereJson, "search"); @@ -105,9 +126,11 @@ public class SemirealrawmaterialServiceImpl implements SemirealrawmaterialServic String relation_id = param.getString("relation_id"); String raw_material_id = param.getString("material_id"); String rate_qty = param.getString("rate_qty"); + String workprocedure_id = param.getString("workprocedure_id"); JSONObject map = new JSONObject(); map.put("raw_material_id", raw_material_id); map.put("rate_qty", rate_qty); + map.put("workprocedure_id", workprocedure_id); map.put("update_optid", currentUserId); map.put("update_optname", nickName); map.put("update_time", DateUtil.now()); @@ -133,4 +156,87 @@ public class SemirealrawmaterialServiceImpl implements SemirealrawmaterialServic } } + @Override + public void excelImport(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException { + InputStream inputStream = file.getInputStream(); + ExcelReader excelReader = ExcelUtil.getReader(inputStream); + List> read = excelReader.read(); + + Map errorMap = new HashMap(); + for (int i = 1; i < read.size(); i++) { + List list = read.get(i); + if (ObjectUtil.isEmpty(list)) { + continue; + } + String workprocedure_code = (String) list.get(0); + if (StrUtil.isEmpty(workprocedure_code)){ + errorMap.put("第" + (i + 1) + "行:", "工序编码为空!"); + continue; + } + + PdmBiWorkprocedure workprocedure = workprocedureService.getOne(new QueryWrapper().eq("workprocedure_code", workprocedure_code)); + if (ObjectUtil.isEmpty(workprocedure)) { + errorMap.put("第" + (i + 1) + "行:", "为查询到该工序编号对应的工序!"); + continue; + } + + String semi_material_code = (String) list.get(1); + if (StrUtil.isEmpty(semi_material_code)){ + errorMap.put("第" + (i + 1) + "行:", "半成品物料编码为空!"); + continue; + } + + MdMeMaterialbase semi_jo = materialbaseService.getOne(new QueryWrapper().eq("material_code", semi_material_code)); + + if (ObjectUtil.isEmpty(semi_jo)){ + errorMap.put("第" + (i + 1) + "行:", "未查询到:"+semi_material_code+"对应的物料!"); + continue; + } + + String raw_material_code = String.valueOf(list.get(2)); + if (StrUtil.isEmpty(raw_material_code)){ + errorMap.put("第" + (i + 1) + "行:", "原材料物料编码为空!"); + continue; + } + + MdMeMaterialbase raw_jo = materialbaseService.getOne(new QueryWrapper().eq("material_code", raw_material_code)); + + if (ObjectUtil.isEmpty(raw_jo)){ + errorMap.put("第" + (i + 1) + "行:", "未查询到:"+semi_material_code+"对应的物料!"); + continue; + } + + String rate_qty = String.valueOf(list.get(3)); + if (StrUtil.isEmpty(rate_qty)){ + errorMap.put("第" + (i + 1) + "行:", "原材料消耗重量为空!"); + continue; + } + + //查询当前原材料和半成品是否存在对应关系 + JSONObject jo = WQLObject.getWQLObject("md_me_semirealrawmaterial").query("semi_material_id = '"+semi_jo.getMaterial_id()+"' AND raw_material_id = '"+raw_jo.getMaterial_id()+"'").uniqueResult(0); + + if (ObjectUtil.isNotEmpty(jo)){ + jo.put("rate_qty",rate_qty); + jo.put("workprocedure_id",workprocedure.getWorkprocedure_id()); + WQLObject.getWQLObject("md_me_semirealrawmaterial").update(jo); + }else { + jo = new JSONObject(); + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + jo.put("relation_id",IdUtil.getSnowflake(1, 1).nextId()); + jo.put("semi_material_id",semi_jo.getMaterial_id()); + jo.put("raw_material_id",semi_jo.getMaterial_id()); + jo.put("create_id",currentUserId); + jo.put("create_name",nickName); + jo.put("create_time",DateUtil.now()); + jo.put("rate_qty",rate_qty); + jo.put("workprocedure_id",workprocedure.getWorkprocedure_id()); + WQLObject wo = WQLObject.getWQLObject("md_me_semirealrawmaterial"); + wo.insert(jo); + } + } + if (!CollectionUtils.isEmpty(errorMap)) { + throw new BadRequestException(JSON.toJSONString(errorMap)); + } + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/wql/QMD_ME_SEMIREALRAWMATERIAL001.wql b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/wql/QMD_ME_SEMIREALRAWMATERIAL001.wql index 351dd048..4611ac21 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/wql/QMD_ME_SEMIREALRAWMATERIAL001.wql +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/masterdata_manage/备份master/wql/QMD_ME_SEMIREALRAWMATERIAL001.wql @@ -53,13 +53,15 @@ material1.material_name ymaterial_name, material1.material_spec ymaterial_spec, material1.product_series yproduct_series, - classstandard1.class_name yclass_name + classstandard1.class_name yclass_name, + wp.workprocedure_name FROM MD_ME_SemiRealRawMaterial semiRealRawMaterial LEFT JOIN MD_ME_MaterialBase material ON semiRealRawMaterial.semi_material_id = material.material_id LEFT JOIN md_pb_classstandard classstandard on material.product_series = classstandard.class_id LEFT JOIN MD_ME_MaterialBase material1 ON semiRealRawMaterial.raw_material_id = material1.material_id LEFT JOIN md_pb_classstandard classstandard1 on material1.product_series = classstandard1.class_id + LEFT JOIN pdm_bi_workprocedure wp ON wp.workprocedure_id = semiRealRawMaterial.workprocedure_id WHERE material.is_delete = '0' OPTION 输入.search <> "" diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/controller/productProcessRoute/ProductprocessrouteController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/controller/productProcessRoute/ProductprocessrouteController.java index 1461ba8f..27076756 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/controller/productProcessRoute/ProductprocessrouteController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/controller/productProcessRoute/ProductprocessrouteController.java @@ -1,4 +1,3 @@ - package org.nl.wms.product_manage.controller.productProcessRoute; @@ -14,6 +13,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.common.TableDataInfo; import org.nl.common.anno.Log; +import org.nl.common.utils.RedissonUtils; import org.nl.wms.product_manage.service.processroute.IPdmBiProcessrouteService; import org.nl.wms.product_manage.service.processroute.dao.PdmBiProcessroute; import org.nl.wms.product_manage.service.productProcessRoute.IPdmBiProductprocessrouteService; @@ -25,14 +25,17 @@ import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; /** -* @author zhouz -* @date 2022-03-22 -**/ + * @author zhouz + * @date 2022-03-22 + **/ @RestController @RequiredArgsConstructor @Api(tags = "产品工艺路线管理") @@ -41,27 +44,27 @@ import java.util.Map; public class ProductprocessrouteController { @Autowired - private IPdmBiProductprocessrouteService ipdmBiProductprocessrouteService; + private IPdmBiProductprocessrouteService ipdmBiProductprocessrouteService; @Autowired - private IPdmBiProductprocessroutedtlService iPdmBiProductprocessroutedtlService; + private IPdmBiProductprocessroutedtlService iPdmBiProductprocessroutedtlService; @Autowired private IPdmBiProcessrouteService pdmBiProcessrouteService; @GetMapping @Log("查询产品工艺路线") @ApiOperation("查询产品工艺路线") - public ResponseEntity query(@RequestParam Map whereJson, Pageable pageQuery){ + public ResponseEntity query(@RequestParam Map whereJson, Pageable pageQuery) { Page page = PageHelper.startPage(pageQuery.getPageNumber() + 1, pageQuery.getPageSize()); List list = ipdmBiProductprocessrouteService.queryAll(whereJson); TableDataInfo build = TableDataInfo.build(list); build.setTotalElements(page.getTotal()); - return new ResponseEntity<>(build,HttpStatus.OK); + return new ResponseEntity<>(build, HttpStatus.OK); } @PostMapping @Log("新增产品工艺路线") @ApiOperation("新增产品工艺路线") - public ResponseEntity create(@RequestBody Map whereJson){ + public ResponseEntity create(@RequestBody Map whereJson) { ipdmBiProductprocessrouteService.create(whereJson); return new ResponseEntity<>(HttpStatus.CREATED); } @@ -70,7 +73,7 @@ public class ProductprocessrouteController { @Log("修改产品工艺路线") @ApiOperation("修改产品工艺路线") //@PreAuthorize("@el.check('productprocessroute:edit')") - public ResponseEntity update(@RequestBody Map whereJson){ + public ResponseEntity update(@RequestBody Map whereJson) { ipdmBiProductprocessrouteService.update(whereJson); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -90,16 +93,15 @@ public class ProductprocessrouteController { @ApiOperation("获取工艺路线") //@PreAuthorize("@el.check('materialtype:list')") public ResponseEntity getRoute(@RequestBody Map whereJson) { - List list = pdmBiProcessrouteService.list(new QueryWrapper() - .eq("is_delete", "0").eq("processroute_status", 20)); - return new ResponseEntity<>(list,HttpStatus.OK); + List list = pdmBiProcessrouteService.list(new QueryWrapper().eq("is_delete", "0").eq("processroute_status", 20)); + return new ResponseEntity<>(list, HttpStatus.OK); } @PostMapping("/getRouteDtl") @Log("获取工艺路线明细") @ApiOperation("获取工艺路线明细") public ResponseEntity getRouteDtl(@RequestBody Map whereJson) { - return new ResponseEntity<>(ipdmBiProductprocessrouteService.getRouteDtl(whereJson),HttpStatus.OK); + return new ResponseEntity<>(ipdmBiProductprocessrouteService.getRouteDtl(whereJson), HttpStatus.OK); } @PostMapping("/getProductRouteDtl") @@ -107,9 +109,8 @@ public class ProductprocessrouteController { @ApiOperation("查询产品工艺路线明细") public ResponseEntity getProductRouteDtl(@RequestBody Map whereJson) { JSONObject jo = JSONObject.parseObject(JSON.toJSONString(whereJson)); - List list = iPdmBiProductprocessroutedtlService.list(new QueryWrapper() - .eq("productprocess_id", jo.getString("productprocess_id"))); - return new ResponseEntity<>(list,HttpStatus.OK); + List list = iPdmBiProductprocessroutedtlService.list(new QueryWrapper().eq("productprocess_id", jo.getString("productprocess_id"))); + return new ResponseEntity<>(list, HttpStatus.OK); } @Log("提交") @@ -127,4 +128,29 @@ public class ProductprocessrouteController { ipdmBiProductprocessrouteService.unSubmit(whereJson); return new ResponseEntity<>(HttpStatus.OK); } + + @Log("获取设备列表") + @ApiOperation("获取设备列表") + @PutMapping("/queryDevice") + public ResponseEntity queryDevice(@RequestBody JSONObject whereJson) { + return new ResponseEntity<>(ipdmBiProductprocessrouteService.queryDevice(whereJson), HttpStatus.OK); + } + + @Log("获取设备列表") + @ApiOperation("获取设备列表") + @PostMapping("/saveDevice") + public ResponseEntity saveDevice(@RequestBody JSONObject row) { + ipdmBiProductprocessrouteService.saveDevice(row); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PostMapping("/excelImport") + @Log("excel导入") + @ApiOperation("excel导入") + public ResponseEntity excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) { + RedissonUtils.lock(() -> { + ipdmBiProductprocessrouteService.excelImport(file, request, response); + }, "系列工艺路线导入", null); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/device/dao/PdmBiDevice.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/device/dao/PdmBiDevice.java index 1d9a26c6..f6b6cdc9 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/device/dao/PdmBiDevice.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/device/dao/PdmBiDevice.java @@ -1,13 +1,13 @@ package org.nl.wms.product_manage.service.device.dao; -import java.math.BigDecimal; - import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serializable; +import java.math.BigDecimal; + /** *

* 生产设备基础信息表 diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/dao/PdmBiProcessroute.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/dao/PdmBiProcessroute.java index a75ff4ca..a4a79fd7 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/dao/PdmBiProcessroute.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/dao/PdmBiProcessroute.java @@ -116,5 +116,10 @@ public class PdmBiProcessroute implements Serializable { */ private String ext_id; + /** + * 生产区域 + */ + private String product_area; + } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/impl/PdmBiProcessrouteServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/impl/PdmBiProcessrouteServiceImpl.java index aa86317e..3a3bc229 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/impl/PdmBiProcessrouteServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/product_manage/service/processroute/impl/PdmBiProcessrouteServiceImpl.java @@ -62,8 +62,10 @@ public class PdmBiProcessrouteServiceImpl extends ServiceImpl 1){ + processroutedtl.setNextworkprocedure_id(jsonDataArr.getJSONObject(i + 1).getString("workprocedure_id")); + } } else if ( i == jsonDataArr.size() - 1) { processroutedtl.setPreworkprocedure_id(jsonDataArr.getJSONObject(i - 1).getString("workprocedure_id")); processroutedtl.setNextworkprocedure_id(" "); @@ -84,12 +86,15 @@ public class PdmBiProcessrouteServiceImpl extends ServiceImpl SELECT pp.*, - mb.material_code, (case when pp.productprocess_status = '10' then '生成' when pp.productprocess_status = '20' then '提交' end) AS status_name, - mb.material_name, route.processroute_name, - route.processroute_code + route.processroute_code, + class.class_name FROM pdm_bi_productprocessroute pp - LEFT JOIN md_me_materialbase mb ON mb.material_id = pp.material_id + LEFT JOIN md_pb_classstandard class ON class.class_id = pp.class_id LEFT JOIN PDM_BI_ProcessRoute route ON route.processroute_id = pp.processroute_id WHERE pp.is_delete = '0' @@ -25,9 +24,6 @@ and pp.productprocess_status = #{productprocess_status} - - and mb.material_code like '%${material_code}%' -