From f2cd828d3719efd7796f5bd7692b3d9946b5b772 Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期四, 11 七月 2024 11:37:21 +0800
Subject: [PATCH] check process used can not change product
---
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java | 38 +++++++++++-------
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java | 28 ++++++++++++++
2 files changed, 51 insertions(+), 15 deletions(-)
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
index 7b99040..961200e 100644
--- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
@@ -3,6 +3,7 @@
import com.dy.common.webFilter.UserTokenContext;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoOth.OthFileMapper;
+import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
import com.dy.pmsGlobal.daoPr.PrProductionNodeMapper;
import com.dy.pmsGlobal.daoPr.PrProductionProcessMapper;
import com.dy.pmsGlobal.daoPr.PrWorkingInstructionMapper;
@@ -10,10 +11,12 @@
import com.dy.pmsGlobal.dyFile.FileRestVo;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.pojoOth.OthFile;
+import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
import com.dy.pmsGlobal.pojoPr.PrProductionNode;
import com.dy.pmsGlobal.pojoPr.PrProductionProcess;
import com.dy.pmsGlobal.pojoPr.PrWorkingInstruction;
import com.dy.pmsGlobal.util.UserUtil;
+import com.dy.pmsProduct.taskPlan.PlanStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.dubbo.common.utils.PojoUtils;
@@ -30,6 +33,7 @@
@Slf4j
@Service
public class ProcessSv {
+ private PrAssemblyPlanMapper assemblyDao;
private PrProductionProcessMapper processDao;
private PrProductionNodeMapper nodeDao;
private PrWorkingInstructionMapper workDao;
@@ -38,6 +42,10 @@
private OthFileMapper othFileMapper;
@Value("${dy.webFile.fmUrl}")
private String fmUrl ;
+ @Autowired
+ public void setAssemblyDao(PrAssemblyPlanMapper assemblyDao) {
+ this.assemblyDao = assemblyDao;
+ }
@Autowired
public void setProcessDao(PrProductionProcessMapper dao){
processDao = dao;
@@ -80,6 +88,26 @@
if (processDao.exists(process.name, process.id)) {
throw new RuntimeException("娴佺▼鍚嶇О涓嶈兘閲嶅");
}
+ PrProductionProcess originProductionProcess = processDao.selectByPrimaryKey(process.id);
+ //濡傛灉宸茬粡缁戝畾浠诲姟(鐩墠涓嶅寘鎷殏鍋淺缁撴潫鐘舵�� 鎶曞叆鏁颁负0鐨勪换鍔� 浠ュ鐨� 鎵�鏈変换鍔�),浜у搧\鑺傜偣id涓嶈兘鍒犻櫎涓嶈兘淇敼
+ if(!originProductionProcess.getProName().equals(process.getProName())){
+ //缁勮浠诲姟璁″垝
+ PrAssemblyPlan params = new PrAssemblyPlan();
+ params.setProcessId(process.id);
+ List<PrAssemblyPlan> planList = assemblyDao.selectAssyPlanSimplify(params);
+ List<PrAssemblyPlan> onlinePlanList = planList.stream().filter(plan -> plan.getStatus() == PlanStatusEnum.NORMAL.getCode()).collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(planList)) {
+ if (planList.stream().anyMatch(plan -> plan.getInputNumber() > 0)) {
+ throw new RuntimeException("瀛樺湪缁戝畾鐨勪换鍔�,骞朵笖鎶曞叆鐢熶骇,浜у搧涓嶈兘淇敼");
+ }else if(CollectionUtils.isNotEmpty(onlinePlanList)){
+ //鍏堝皢缁勮浠诲姟缃负鏆傚仠鐘舵��
+ onlinePlanList.forEach(plan -> {
+ plan.status = PlanStatusEnum.PAUSE.getCode();
+ assemblyDao.updateByPrimaryKeySelective(plan);
+ });
+ }
+ }
+ }
prepareProcess(process);
int count = processDao.updateByPrimaryKeySelective(process);
// 浼樺寲锛氬彧鏈夊綋鑺傜偣鏈夊彉鏇存椂鎵嶅垹闄ゅ苟閲嶆柊鎻掑叆
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 8e318f6..885bebd 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
@@ -102,10 +102,6 @@
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);
//濡傛灉鏈夋姇鍏�,浜у搧鍜屾祦绋嬩笉鑳藉彉鏇�
@@ -114,17 +110,7 @@
throw new RuntimeException("璁″垝宸叉姇鍏�,浜у搧涓庣敓浜ф祦绋嬩笉鑳藉彉鏇�");
}
}
- //Fancy add 2024/07/09 濡傛灉鐘舵�佷负鎵ц ,鍒欑粨鏉熸棩鏈熷繀椤诲ぇ浜庣瓑浜庡綋鍓嶆棩鏈�
- if(plan.status == PlanStatusEnum.NORMAL.getCode()){
- String endDateStr = plan.getEndDate();
- LocalDate endDate = LocalDate.parse(endDateStr, DateTimeFormatter.ISO_LOCAL_DATE);
- LocalDate nextDay = endDate.plusDays(1);
- LocalDate today = LocalDate.now(); // 鑾峰彇褰撳墠鏃ユ湡
- if (nextDay.isBefore(today)) {
- throw new RuntimeException("鎵ц鐘舵�佺粨鏉熸棩鏈熷繀椤诲ぇ浜庣瓑浜庡綋鍓嶆棩鏈�");
- }
- }
-
+ extractedCheck(plan);
//浜у搧鏀瑰彉鍒欐洿鏂板叏閮ㄥ凡鐢熸垚璁惧鍙�
if(origPlan.proId != plan.proId){
batch.proId = plan.proId;
@@ -137,6 +123,23 @@
insertDevice(plan.proId,origPlan.batchId,batch.batchNumber,plan.number,origPlan.number+1);
}
return assemblyDao.updateByPrimaryKeySelective(plan);
+ }
+
+ private void extractedCheck(PrAssemblyPlan plan) {
+ PrProductionProcess process = processDao.selectByPrimaryKey(plan.processId);
+ if(process == null || !process.proId.equals(plan.proId)){
+ throw new RuntimeException("浜у搧涓庣敓浜ф祦绋嬩笉鍖归厤");
+ }
+ //Fancy add 2024/07/09 濡傛灉鐘舵�佷负鎵ц ,鍒欑粨鏉熸棩鏈熷繀椤诲ぇ浜庣瓑浜庡綋鍓嶆棩鏈�
+ if(plan.status == PlanStatusEnum.NORMAL.getCode()){
+ String endDateStr = plan.getEndDate();
+ LocalDate endDate = LocalDate.parse(endDateStr, DateTimeFormatter.ISO_LOCAL_DATE);
+ LocalDate nextDay = endDate.plusDays(1);
+ LocalDate today = LocalDate.now(); // 鑾峰彇褰撳墠鏃ユ湡
+ if (nextDay.isBefore(today)) {
+ throw new RuntimeException("鎵ц鐘舵�佺粨鏉熸棩鏈熷繀椤诲ぇ浜庣瓑浜庡綋鍓嶆棩鏈�,璇蜂慨鏀圭粨鏉熸棩鏈�");
+ }
+ }
}
@@ -272,6 +275,11 @@
*/
@Transactional
public int updateStatus(PrAssemblyPlan plan) {
+ if(plan.status == PlanStatusEnum.NORMAL.getCode()){
+ PrAssemblyPlan assemblyPlan = assemblyDao.selectByPrimaryKey(plan.id);
+ assemblyPlan.status = plan.status;
+ extractedCheck(assemblyPlan);
+ }
PrAssemblyPlan param = new PrAssemblyPlan();
param.id =plan.id;
param.status = plan.status;
--
Gitblit v1.8.0