From 9000814f7ceba006c7d36c51d06666ba6dfddf6c Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期二, 09 七月 2024 11:33:08 +0800
Subject: [PATCH] change equip to device
---
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblySv.java | 82 ++++++++++++++++++++++++++++------------
1 files changed, 57 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..ca1a2ac 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,21 +7,24 @@
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;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -36,9 +39,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 +55,7 @@
this.userUtil = userUtil;
}
@Autowired
- public void setEquipDao(PrEquipMapper equipDao) {
+ public void setEquipDao(PrDeviceMapper equipDao) {
this.equipDao = equipDao;
}
@Autowired
@@ -61,12 +64,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 +98,31 @@
@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("浜у搧涓庣敓浜ф祦绋嬩笉鍖归厤");
+ }
+ //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("鎵ц鐘舵�佺粨鏉熸棩鏈熷繀椤诲ぇ浜庣瓑浜庡綋鍓嶆棩鏈�");
+ }
+ }
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 +138,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 +155,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 +199,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 +239,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 +268,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