From 07931d7a6c4dde03adf3ef48a3610c9072ce4959 Mon Sep 17 00:00:00 2001
From: 刘小明 <liuxm_a@163.com>
Date: 星期二, 09 七月 2024 11:02:10 +0800
Subject: [PATCH] 名称统一

---
 pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java |   70 ++++++++++++++++++++++------------
 1 files changed, 45 insertions(+), 25 deletions(-)

diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
index 3466bb7..fa39ad9 100644
--- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java
@@ -7,17 +7,18 @@
 import com.dy.pmsGlobal.daoPlt.PltProductMapper;
 import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
 import com.dy.pmsGlobal.daoPr.PrBatchNumberMapper;
-import com.dy.pmsGlobal.daoPr.PrEquipMapper;
+import com.dy.pmsGlobal.daoPr.PrDeviceMapper;
+import com.dy.pmsGlobal.daoPr.PrProductionProcessMapper;
 import com.dy.pmsGlobal.pojoBa.BaUser;
 import com.dy.pmsGlobal.pojoPlt.PltProduct;
 import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
 import com.dy.pmsGlobal.pojoPr.PrBatchNumber;
-import com.dy.pmsGlobal.pojoPr.PrEquip;
+import com.dy.pmsGlobal.pojoPr.PrDevice;
+import com.dy.pmsGlobal.pojoPr.PrProductionProcess;
 import com.dy.pmsGlobal.util.QrCodeUtil;
 import com.dy.pmsGlobal.util.UserUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.common.utils.PojoUtils;
-import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -36,9 +37,9 @@
     private PrAssemblyPlanMapper assemblyDao;
     private UserUtil userUtil;
     private PrBatchNumberMapper batchDao;
-    private PrEquipMapper equipDao;
+    private PrDeviceMapper equipDao;
     private PltProductMapper productDao;
-    private SqlSessionFactory sqlSessionFactory;
+    private PrProductionProcessMapper processDao;
     @Autowired
     public void setAssemblyDao(PrAssemblyPlanMapper assemblyDao) {
         this.assemblyDao = assemblyDao;
@@ -52,7 +53,7 @@
         this.userUtil = userUtil;
     }
     @Autowired
-    public void setEquipDao(PrEquipMapper equipDao) {
+    public void setEquipDao(PrDeviceMapper equipDao) {
         this.equipDao = equipDao;
     }
     @Autowired
@@ -61,12 +62,20 @@
     }
 
     @Autowired
-    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
-        this.sqlSessionFactory = sqlSessionFactory;
+    public void setProcessDao(PrProductionProcessMapper processDao) {
+        this.processDao = processDao;
     }
 
     @Transactional
     public int save(PrAssemblyPlan plan){
+        //璁″垝鍚嶇О涓嶈兘閲嶅
+        if(assemblyDao.exists(plan.name,plan.id)){
+            throw new RuntimeException("璁″垝鍚嶇О涓嶈兘閲嶅");
+        }
+        PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId);
+        if(process == null || !process.proId.equals(plan.proId)){
+            throw new RuntimeException("浜у搧涓庣敓浜ф祦绋嬩笉鍖归厤");
+        }
         PrBatchNumber batch = new PrBatchNumber();
         batch.batchNumber = getNextCode();
         batch.proId = plan.proId;
@@ -87,10 +96,21 @@
 
     @Transactional
     public int update(PrAssemblyPlan plan){
+        //璁″垝鍚嶇О涓嶈兘閲嶅
+        if(assemblyDao.exists(plan.name,plan.id)){
+            throw new RuntimeException("璁″垝鍚嶇О涓嶈兘閲嶅");
+        }
+        PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId);
+        if(process == null || !process.proId.equals(plan.proId)){
+            throw new RuntimeException("浜у搧涓庣敓浜ф祦绋嬩笉鍖归厤");
+        }
         PrAssemblyPlan origPlan = assemblyDao.selectByPrimaryKey(plan.id);
         PrBatchNumber batch = batchDao.selectByPrimaryKey(origPlan.batchId);
         //浜у搧鏀瑰彉鍒欐洿鏂板叏閮ㄥ凡鐢熸垚璁惧鍙�
         if(origPlan.proId != plan.proId){
+            batch.proId = plan.proId;
+            batchDao.updateByPrimaryKeySelective(batch);
+
             equipDao.deleteByBatchId(origPlan.batchId);
             insertEquip(plan.proId,origPlan.batchId,batch.batchNumber,plan.number,1);
         }else if(origPlan.number < plan.number){
@@ -106,8 +126,8 @@
         PrAssemblyPlan plan = assemblyDao.selectByPrimaryKey(planId);
         PrBatchNumber batch = batchDao.selectByPrimaryKey(plan.batchId);
         int count =insertEquip(plan.proId,plan.batchId,batch.batchNumber,num + plan.number,plan.number+1);
-        plan.number = plan.number + num;
-        assemblyDao.updateByPrimaryKeySelective(plan);
+//        plan.number = plan.number + num;
+//        assemblyDao.updateByPrimaryKeySelective (plan);
         return count;
     }
 
@@ -123,22 +143,22 @@
     private int insertEquip(Long proId,Long batchId,String batchCode,Integer number,int startIndex){
         log.info("鎵归噺鎻掑叆璁惧");
         PltProduct product = productDao.selectByPrimaryKey(proId);
-        List<PrEquip> list = new java.util.ArrayList<>();
+        List<PrDevice> list = new java.util.ArrayList<>();
         for(int i= startIndex ;i<= number;i++){
-            PrEquip equip = new PrEquip();
+            PrDevice equip = new PrDevice();
             equip.proId = proId;
             equip.batchId = batchId;
-            equip.equipNo = getEquipNo(product.code,batchCode,i);
+            equip.deviceNo = getEquipNo(product.code,batchCode,i);
             equip.status = 0;
             list.add(equip);
         }
         return insertBatchEquip(list);
     }
 
-    private int insertBatchEquip(List<PrEquip> list) {
+    private int insertBatchEquip(List<PrDevice> list) {
         int count = 0;
         for (int i = 0; i < list.size(); i += BATCH_SIZE) {
-            List<PrEquip> subList = list.subList(i, Math.min(i + BATCH_SIZE, list.size()));
+            List<PrDevice> subList = list.subList(i, Math.min(i + BATCH_SIZE, list.size()));
             // 璋冪敤MyBatis鎻掑叆杩欐壒鏁版嵁
             count += equipDao.insertBatch(subList);
         }
@@ -167,19 +187,19 @@
     }
 
     public static void main(String[] args) {
-        List<PrEquip> list = new java.util.ArrayList<>();
+        List<PrDevice> list = new java.util.ArrayList<>();
         for(int i= 1 ;i<= 10000;i++){
 
-            PrEquip equip = new PrEquip();
+            PrDevice equip = new PrDevice();
             equip.proId = 2024052310512000003l;
             equip.batchId = 2024053017154400004l;
-            equip.equipNo = getEquipNo("002","2024001",i);
+            equip.deviceNo = getEquipNo("002","2024001",i);
             equip.status = 0;
 
             list.add(equip);
         }
         list.forEach(equip->{
-            System.out.println(equip.equipNo);
+            System.out.println(equip.deviceNo);
         });
     }
 
@@ -207,22 +227,22 @@
         return rsVo ;
     }
 
-    public QueryResultVo<List<PrEquip>> selectSomeEquip(QueryVo queryVo) {
+    public QueryResultVo<List<PrDevice>> selectSomeEquip(QueryVo queryVo) {
         Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
         //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
-        Long itemTotal = assemblyDao.selectSomeCount(params);
-        QueryResultVo<List<PrEquip>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
+        Long itemTotal = equipDao.selectSomeCount(params);
+        QueryResultVo<List<PrDevice>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
         //璁$畻鍒嗛〉绛変俊鎭�
         rsVo.calculateAndSet(itemTotal, params);
         //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
         rsVo.obj = equipDao.selectSome(params);
         rsVo.obj.forEach(equip->{
-            equip.qrCode = QrCodeUtil.genQrCodeString(equip.equipNo);
+            equip.qrCode = QrCodeUtil.genQrCodeString(equip.deviceNo);
         });
         return rsVo ;
     }
 
-    public List<PrEquip> selectEquipByBatchId(Long batchId) {
+    public List<PrDevice> selectEquipByBatchId(Long batchId) {
         return equipDao.selectByBatchId(batchId);
     }
 
@@ -236,6 +256,6 @@
         PrAssemblyPlan param = new PrAssemblyPlan();
         param.id =plan.id;
         param.status = plan.status;
-        return assemblyDao.updateByPrimaryKeySelective(plan);
+        return assemblyDao.updateByPrimaryKeySelective(param);
     }
 }

--
Gitblit v1.8.0