From 16f70ba4a40dfe11aa3440da224351cfd92406ff Mon Sep 17 00:00:00 2001 From: hy2250089 Date: Thu, 26 Mar 2020 19:55:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=8E=E7=BB=86=E6=89=B9=E9=87=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=BE=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/ProduceManagePublicMethod.java | 14 +- .../dao/ProductBatchDetectDetMapper.java | 2 + .../manage/dao/ProductBatchDetectMapper.java | 2 + .../dao/ProductProcessBatchDetMapper.java | 8 +- .../mapper/ProductBatchDetectDetMapper.xml | 10 ++ .../mapper/ProductBatchDetectMapper.xml | 10 ++ .../mapper/ProductProcessBatchDetMapper.xml | 34 +++++ .../model/BatchDetListAndProductProcess.java | 31 +++++ .../model/ProductBatchDetectParams.java | 12 ++ .../service/ProductBatchDetectDetService.java | 2 + .../service/ProductBatchDetectService.java | 2 + .../ProductProcessBatchDetService.java | 14 +- .../ProductBatchDetectDetServiceImpl.java | 5 + .../impl/ProductBatchDetectServiceImpl.java | 6 + .../ProductProcessBatchDetServiceImpl.java | 124 ++++++++++++++++-- .../impl/ProductProcessServiceImpl.java | 2 +- .../web/ProductProcessBatchDetController.java | 16 ++- 17 files changed, 257 insertions(+), 37 deletions(-) create mode 100644 wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/BatchDetListAndProductProcess.java diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/constant/ProduceManagePublicMethod.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/constant/ProduceManagePublicMethod.java index 4704955..d67d045 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/constant/ProduceManagePublicMethod.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/constant/ProduceManagePublicMethod.java @@ -28,20 +28,10 @@ public class ProduceManagePublicMethod { * 自动生成唯一的批次明细条码,规则:PCMX+八位日期+批次加工单id+批次号+卷号 * @return */ - public static String creatBatchDetCode(Date createDate, Integer productProcessId, String batchCode, Integer piNum, String volumeNum) { + public static String creatBatchDetCode(Date createDate, Integer productProcessId, String batchCode, String volumeNum) { SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd"); String timePartStr = sdf1.format(createDate); - int count=0; //位数计数 - while(piNum>=1) { - piNum/=10; - count++; - } - - for (int i = 0; i < count-1 ; i++) { - volumeNum = 0+volumeNum;//如果是一位数,卷号为1,如果是两位数,卷号为01,如果是三位数,卷号为001,以此类推 - } - String batchDetCode = "PCMX"+timePartStr+productProcessId+batchCode+volumeNum; return batchDetCode; @@ -49,7 +39,7 @@ public class ProduceManagePublicMethod { public static void main(String[] args){ - String code = creatBatchDetCode(new Date(), 10, "1", 100, "1"); + String code = creatBatchDetCode(new Date(), 10, "1", "1"); System.out.println("----------"+code); } } diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectDetMapper.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectDetMapper.java index b8be2a6..0057db4 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectDetMapper.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectDetMapper.java @@ -12,4 +12,6 @@ public interface ProductBatchDetectDetMapper extends Mapper findList(ProductBatchDetectDetParams params); List findDetectDetVoListByBatchDetAndProcess(ProductBatchDetectParams params); + + void deleteByBatchDet(ProductBatchDetectParams batchDetectParams); } \ No newline at end of file diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectMapper.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectMapper.java index 744f09f..32cbb29 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectMapper.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductBatchDetectMapper.java @@ -10,4 +10,6 @@ public interface ProductBatchDetectMapper extends Mapper { List findList(ProductBatchDetectParams params); ProductBatchDetect findDetectByBatchDetAndProcess(ProductBatchDetectParams params); + + void deleteByBatchDet(ProductBatchDetectParams batchDetectParams); } \ No newline at end of file diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductProcessBatchDetMapper.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductProcessBatchDetMapper.java index c81f4e5..04e396d 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductProcessBatchDetMapper.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/dao/ProductProcessBatchDetMapper.java @@ -11,9 +11,13 @@ import java.util.List; public interface ProductProcessBatchDetMapper extends Mapper { List findList(ProductProcessBatchDetParams params); - //List volumeStepListByProdprocid(ProductProcessParams params); - List findListByProductProcess(ProductProcessParams params); ProductProcessBatchDet findBatchDetById(ProductProcessBatchDetParams batchDetParams); + + Integer findMaxVolumeNumByProductProcess(ProductProcessParams productProcessId); + + void deleteByIdsList(List deleteIdsDB); + + void updateList(List updateList); } \ No newline at end of file diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectDetMapper.xml b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectDetMapper.xml index c771e63..c26ce15 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectDetMapper.xml +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectDetMapper.xml @@ -51,4 +51,14 @@ ORDER BY detectdet.position + + + DELETE FROM mt_alone_product_batch_detect_det WHERE 1>2 OR ( batch_det_id IN + + #{params.batchDetIdList[${item}]} + + + AND company_id = #{params.companyId} + ) + \ No newline at end of file diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectMapper.xml b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectMapper.xml index eabb6e2..696fdf9 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectMapper.xml +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductBatchDetectMapper.xml @@ -36,4 +36,14 @@ + + DELETE FROM mt_alone_product_batch_detect WHERE 1>2 OR ( batch_det_id IN + + #{params.batchDetIdList[${item}]} + + + AND company_id = #{params.companyId} + ) + + \ No newline at end of file diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductProcessBatchDetMapper.xml b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductProcessBatchDetMapper.xml index bace72d..1b0dffd 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductProcessBatchDetMapper.xml +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/mapper/ProductProcessBatchDetMapper.xml @@ -99,5 +99,39 @@ + + + + + UPDATE mt_alone_product_process_batch_det + + update_time = #{item.updateTime}, + len = #{item.len}, + delivery_len = #{item.deliveryLen}, + detection_len = #{item.detectionLen}, + shrinkage = #{item.shrinkage} + + WHERE id = #{item.id} + + + + + DELETE FROM mt_alone_product_process_batch_det WHERE 1>2 OR id IN + + #{item} + + + + \ No newline at end of file diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/BatchDetListAndProductProcess.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/BatchDetListAndProductProcess.java new file mode 100644 index 0000000..dbcf294 --- /dev/null +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/BatchDetListAndProductProcess.java @@ -0,0 +1,31 @@ +package com.deer.wms.produce.manage.model; + +import java.util.List; + +/**批量修改明细时传入的参数 + * @Author: hy + * @Date: 2020/3/26 15:13 + * @Version 1.0 + */ +public class BatchDetListAndProductProcess { + + private Integer productProcessId; + + private List productProcessBatchDetList; + + public Integer getProductProcessId() { + return productProcessId; + } + + public void setProductProcessId(Integer productProcessId) { + this.productProcessId = productProcessId; + } + + public List getProductProcessBatchDetList() { + return productProcessBatchDetList; + } + + public void setProductProcessBatchDetList(List productProcessBatchDetList) { + this.productProcessBatchDetList = productProcessBatchDetList; + } +} diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/ProductBatchDetectParams.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/ProductBatchDetectParams.java index 5871c60..549d7d9 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/ProductBatchDetectParams.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/model/ProductBatchDetectParams.java @@ -2,6 +2,8 @@ package com.deer.wms.produce.manage.model; import com.deer.wms.project.seed.core.service.QueryParams; +import java.util.List; + /** * Created by on 2019/09/09. */ @@ -13,6 +15,8 @@ public class ProductBatchDetectParams extends QueryParams { private Integer processId;//工序id + private List batchDetIdList;//批次明细id的list + public Integer getProductBatchDetectId() { return productBatchDetectId; } @@ -36,4 +40,12 @@ public class ProductBatchDetectParams extends QueryParams { public void setProcessId(Integer processId) { this.processId = processId; } + + public List getBatchDetIdList() { + return batchDetIdList; + } + + public void setBatchDetIdList(List batchDetIdList) { + this.batchDetIdList = batchDetIdList; + } } diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectDetService.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectDetService.java index a55a04b..313fed5 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectDetService.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectDetService.java @@ -17,4 +17,6 @@ public interface ProductBatchDetectDetService extends Service findList(ProductBatchDetectDetParams params) ; List findDetectDetVoListByBatchDetAndProcess(ProductBatchDetectParams params); + + void deleteByBatchDet(ProductBatchDetectParams batchDetectParams); } diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectService.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectService.java index 2c3c5b0..51f3cd5 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectService.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/ProductBatchDetectService.java @@ -20,4 +20,6 @@ public interface ProductBatchDetectService extends Service findList(ProductProcessBatchDetParams params) ; - //List volumeStepListByProdprocid(ProductProcessParams params); - List findListByProductProcess(ProductProcessParams params); ProductProcessBatchDet findBatchDetById(ProductProcessBatchDetParams batchDetParams); - void batchUpdate(List productProcessBatchDetList); + void batchModify(BatchDetListAndProductProcess batchDetListAndProductProcess, CurrentUser currentUser); + + void deleteByIdsList(List deleteIdsDB); + + void updateList(List updateList); } diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectDetServiceImpl.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectDetServiceImpl.java index 2994acd..9891dd9 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectDetServiceImpl.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectDetServiceImpl.java @@ -33,4 +33,9 @@ public class ProductBatchDetectDetServiceImpl extends AbstractService findDetectDetVoListByBatchDetAndProcess(ProductBatchDetectParams params) { return productBatchDetectDetMapper.findDetectDetVoListByBatchDetAndProcess(params); } + + @Override + public void deleteByBatchDet(ProductBatchDetectParams batchDetectParams) { + productBatchDetectDetMapper.deleteByBatchDet(batchDetectParams); + } } diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectServiceImpl.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectServiceImpl.java index 93bc634..5baf210 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectServiceImpl.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductBatchDetectServiceImpl.java @@ -77,4 +77,10 @@ public class ProductBatchDetectServiceImpl extends AbstractService findList(ProductProcessBatchDetParams params) { return productProcessBatchDetMapper.findList(params); } - //@Override - //public List volumeStepListByProdprocid(ProductProcessParams params) { - // return productProcessBatchDetMapper.volumeStepListByProdprocid(params); - //} - @Override public List findListByProductProcess(ProductProcessParams params) { return productProcessBatchDetMapper.findListByProductProcess(params); @@ -45,7 +55,99 @@ public class ProductProcessBatchDetServiceImpl extends AbstractService productProcessBatchDetList) { - + public void batchModify(BatchDetListAndProductProcess batchDetListAndProductProcess, CurrentUser currentUser) { + //前端获取的所有明细 + List batchDetListFront = batchDetListAndProductProcess.getProductProcessBatchDetList(); + ProductProcessParams productProcessParams = new ProductProcessParams(); + productProcessParams.setProductProcessId(batchDetListAndProductProcess.getProductProcessId()); + productProcessParams.setCompanyId(currentUser.getCompanyId()); + ProductProcess currentProductProcess = productProcessService.findById(batchDetListAndProductProcess.getProductProcessId()); + //获取当前加工单下库表中所有的明细 + List batchDetVoListDB = productProcessBatchDetService.findListByProductProcess(productProcessParams); + //设置加工单的总卷数与前端明细个数相同,并更新加工单信息 + currentProductProcess.setPiNum(null==batchDetListFront?0:batchDetListFront.size()); + productProcessService.update(currentProductProcess); + + Date date = new Date(); + //获取库表中该加工单下所有明细中最大的卷号,默认为0 + Integer maxVolumeNumDB = productProcessBatchDetMapper.findMaxVolumeNumByProductProcess(productProcessParams); + if(null == maxVolumeNumDB) + maxVolumeNumDB = 0; + + /**原则:从前端的明细list中判断,先拿出有id的明细更新,再插入没id的明细,最后删除前端已移除的明细(即库表中在前端找不到对应id的明细)**/ + if(null!=batchDetListFront && batchDetListFront.size()!=0){//如果前端有明细 + //将已有(非新增)明细放入一个list + List updateList = new ArrayList(); + //将新增明细放入一个list + List addList = new ArrayList(); + for (ProductProcessBatchDet productProcessBatchDet : batchDetListFront){ + if(null!=productProcessBatchDet.getId()){//已有的明细(非新增明细),有id + productProcessBatchDet.setUpdateTime(date); + productProcessBatchDet.setShrinkage(productProcessBatchDet.getLen()/productProcessBatchDet.getDetectionLen()+""); + updateList.add(productProcessBatchDet); + }else{//新增明细,没有id + productProcessBatchDet.setCreateTime(date); + productProcessBatchDet.setUpdateTime(date); + productProcessBatchDet.setOperatorId(currentUser.getUserId()); + productProcessBatchDet.setVersion("1.1"); + productProcessBatchDet.setStatus(0); + productProcessBatchDet.setBatchCode(currentProductProcess.getBatchCode()); + productProcessBatchDet.setDeliveryCode(currentProductProcess.getDeliveryCode()); + productProcessBatchDet.setProductProcessId(currentProductProcess.getId()); + productProcessBatchDet.setVolumeNum((maxVolumeNumDB++)+""); + productProcessBatchDet.setBatchCode(ProduceManagePublicMethod.creatBatchDetCode(date, currentProductProcess.getId(), currentProductProcess.getBatchCode(), productProcessBatchDet.getVolumeNum())); + productProcessBatchDet.setShrinkage(productProcessBatchDet.getLen()/productProcessBatchDet.getDetectionLen()+""); + productProcessBatchDet.setCompanyId(currentUser.getCompanyId()); + addList.add(productProcessBatchDet); + } + } + + //批量删除前端已移除的明细及其瑕疵 + if(null!=batchDetVoListDB && batchDetVoListDB.size()!=0){ + //获取所有前端明细的id + List idsFront = batchDetListFront.stream().map(ProductProcessBatchDet::getId).collect(Collectors.toList()); + //获取该加工单下所有库表明细的id + List idsDB = batchDetVoListDB.stream().map(ProductProcessBatchDetVo::getId).collect(Collectors.toList()); + if(null!=idsDB && idsDB.size()!=0) { + List deleteIdsDB = new ArrayList(idsDB); + deleteIdsDB.removeAll(idsFront); + productProcessBatchDetService.deleteByIdsList(deleteIdsDB); + ProductBatchDetectParams batchDetectParams = new ProductBatchDetectParams(); + batchDetectParams.setBatchDetIdList(deleteIdsDB); + batchDetectParams.setCompanyId(currentProductProcess.getCompanyId()); + productBatchDetectService.deleteByBatchDet(batchDetectParams); + } + } + + if(updateList.size()!=0)//批量更新对应的明细 + productProcessBatchDetService.updateList(updateList); + + if(addList.size()!=0)//批量插入前端新增的明细 + productProcessBatchDetService.save(addList); + + }else{//如果前端无明细,则批量删除库表中的明细及其瑕疵 + if(null!=batchDetVoListDB && batchDetVoListDB.size()!=0){ + //获取该加工单下所有库表明细的id + List idsDB = batchDetVoListDB.stream().map(ProductProcessBatchDetVo::getId).collect(Collectors.toList()); + if(null!=idsDB && idsDB.size()!=0) { + productProcessBatchDetService.deleteByIdsList(idsDB); + ProductBatchDetectParams batchDetectParams = new ProductBatchDetectParams(); + batchDetectParams.setBatchDetIdList(idsDB); + batchDetectParams.setCompanyId(currentProductProcess.getCompanyId()); + productBatchDetectService.deleteByBatchDet(batchDetectParams); + } + } + } } + + @Override + public void deleteByIdsList(List deleteIdsDB) { + productProcessBatchDetMapper.deleteByIdsList(deleteIdsDB); + } + + @Override + public void updateList(List updateList) { + productProcessBatchDetMapper.updateList(updateList); + } + } diff --git a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductProcessServiceImpl.java b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductProcessServiceImpl.java index 12ca1b8..52ec3db 100644 --- a/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductProcessServiceImpl.java +++ b/wms-produce-manage/src/main/java/com/deer/wms/produce/manage/service/impl/ProductProcessServiceImpl.java @@ -255,7 +255,7 @@ public class ProductProcessServiceImpl extends AbstractService productProcessBatchDetList) { - productProcessBatchDetService.batchUpdate(productProcessBatchDetList); + @PostMapping("/batchModify") + public Result batchModify(@RequestBody BatchDetListAndProductProcess batchDetListAndProductProcess, @ApiIgnore @User CurrentUser currentUser) { + productProcessBatchDetService.batchModify(batchDetListAndProductProcess, currentUser); return ResultGenerator.genSuccessResult(); }