From 5311711ce3972e02349d65978976e87ab1e5ee2d Mon Sep 17 00:00:00 2001
From: jiaosong <jiaosong6760@dingtalk.com>
Date: 星期五, 18 八月 2023 10:49:55 +0800
Subject: [PATCH] #产出计算
---
server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java | 66 +++++++++++++++++++++++++++------
1 files changed, 54 insertions(+), 12 deletions(-)
diff --git a/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java b/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
index 4bb8e2c..4fa1d66 100644
--- a/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
@@ -16,6 +16,7 @@
import doumeemes.core.utils.excel.EasyExcelUtil;
import doumeemes.core.utils.redis.RedisUtil;
import doumeemes.dao.business.PlansMapper;
+import doumeemes.dao.business.UnqualifiedRecordMapper;
import doumeemes.dao.business.WorkorderMapper;
import doumeemes.dao.business.dto.*;
import doumeemes.dao.business.model.*;
@@ -92,6 +93,8 @@
private WStockExtService wStockExtService;
@Autowired
private WorkorderRecordStandardService workorderRecordStandardService;
+ @Autowired
+ private UnqualifiedRecordMapper unqualifiedRecordMapper;
@Override
public PlansExtListVO findById(Integer id){
@@ -658,6 +661,8 @@
order.setUrgent(mp.getUrgent());
order.setFactoryId(mp.getFactoryId());
order.setBackorderId(mp.getBackorderId());
+ order.setUnqualifiedNum(param.getUnqualifiedNum());
+ order.setQualifiedNum(param.getQualifiedNum());
order.setOriginId(systemDictDataBiz.queryByCode(Constants.WORKORDER_SOURCE,Constants.WORKORDER_SOURCE_PLAN).getId());
//宸ュ崟缂栫爜
order.setCode(workorderExtService.getNextCode(user.getCompany().getId()));
@@ -702,9 +707,9 @@
if(ulist == null){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鐢熶骇浜哄憳淇℃伅涓嶆纭紝璇峰埛鏂伴〉闈㈤噸璇曪紒");
}
- if(ulist.size() < param.getProUserList().size()){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝瀛樺湪鐢熶骇浜哄憳淇℃伅涓嶆纭紝璇峰埛鏂伴〉闈㈤噸璇曪紒");
- }
+// if(ulist.size() < param.getProUserList().size()){
+// throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝瀛樺湪鐢熶骇浜哄憳淇℃伅涓嶆纭紝璇峰埛鏂伴〉闈㈤噸璇曪紒");
+// }
List<WorkorderUser> userList = new ArrayList<>();
for(UserDeviceExtListVO uModel : ulist){
WorkorderUser u = new WorkorderUser();
@@ -1582,23 +1587,29 @@
@Transactional(rollbackFor = {BusinessException.class,Exception.class})
@Override
public void autoWorkReport(LoginUserInfo user, AutoWorkReportDTO autoWorkReportDTO){
+ if(Objects.isNull(autoWorkReportDTO)
+ || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO())
+ || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum())|| autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().compareTo(BigDecimal.ZERO) < Constants.ZERO
+ || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum())|| autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().compareTo(BigDecimal.ZERO) < Constants.ZERO){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
//鏌ヨ宸ュ伐搴忚鍒掔姸鎬�
Plans plans = plansExtMapper.selectById(autoWorkReportDTO.getPlansId());
if(Objects.isNull(plans)){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌宸ュ簭璁″垝鏁版嵁");
}
- if(!(plans.getStatus().equals(Constants.PLAN_STATUS.create)||plans.getStatus().equals(Constants.PLAN_STATUS.distribute))){
+ if(!(plans.getStatus().equals(Constants.PLAN_STATUS.create)||plans.getStatus().equals(Constants.PLAN_STATUS.publish)||plans.getStatus().equals(Constants.PLAN_STATUS.distribute))){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"宸ュ簭璁″垝宸叉祦杞紝鏃犳硶鎿嶄綔");
}
if(plans.getPaused().equals(Constants.ONE)){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"宸ュ簭璁″垝宸叉殏鍋滐紝鏃犳硶鎿嶄綔");
}
if(Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO())){
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍙傛暟閿欒锛氫骇鍑烘暟鎹�");
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鍙傛暟閿欒锛氫骇鍑烘暟鎹�");
}
//鏌ヨ宸ュ簭璁″垝宸插垎閰嶆暟閲�
List<Workorder> workorderList = workorderMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId())
- .notIn("STATUS",7,8));
+ .eq("STATUS",Constants.WORKORDER_STATUS.baogong));
//鏈浜у嚭鏁伴噺
BigDecimal num = autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum());
if(num.compareTo(BigDecimal.ZERO)<=Constants.ZERO){
@@ -1615,9 +1626,11 @@
param.setPlanDate(new Date());
param.setProGroupId(autoWorkReportDTO.getProGroupId());
param.setProUserList(autoWorkReportDTO.getProUserList());
- param.setPlanNum(plans.getNum());
+ param.setPlanNum(num.intValue());
//鐢熸垚宸ュ崟淇℃伅
- Workorder workorder = this.distributeDone(user,param,plans.getNum());
+ param.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue());
+ param.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue());
+ Workorder workorder = this.distributeDone(user,param,num.intValue());
//宸ュ崟鎶曟枡璁板綍
CreateMaterialDTO createMaterialDTO = new CreateMaterialDTO();
if(!Objects.isNull(autoWorkReportDTO.getRecordList())&&autoWorkReportDTO.getRecordList().size()>Constants.ZERO){
@@ -1627,9 +1640,9 @@
}
//宸ュ崟浜у嚭璁板綍
autoWorkReportDTO.getCreateWorkorderRecordDTO().setWorkorderId(workorder.getId());
- workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user);
+ WorkorderRecord workorderRecord = workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user);
//宸ュ崟鎶ュ伐
- workorderRecordStandardService.comfirmDone(workorder);
+ workorderRecordStandardService.comfirmDone(workorder,false);
//鏇存柊宸ュ崟鐘舵��
if(num.compareTo(BigDecimal.valueOf(surplusNum))==Constants.ZERO){
plans.setStatus(Constants.PLAN_STATUS.done);
@@ -1639,8 +1652,37 @@
}
}
plansExtMapper.updateById(plans);
-
-
+ //鍙戦�佹秷鎭槦鍒楀鐞嗗垎浜搷浣�
+ workorderExtService.statisticNum(workorder);
+ //瀛樺偍鎶ュ伐涓嶈壇椤规暟鎹�
+ if(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().compareTo(BigDecimal.ZERO)<=Constants.ZERO){
+ if(!Objects.isNull(autoWorkReportDTO.getCreateUnqualifiedDTOList())&&autoWorkReportDTO.getCreateUnqualifiedDTOList().size()>Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓嶈壇椤归敊璇細璇锋鏌ヤ笉鑹」鏁版嵁");
+ }
+ }else{
+ List<CreateUnqualifiedDTO> createUnqualifiedDTOList = autoWorkReportDTO.getCreateUnqualifiedDTOList();
+ BigDecimal unqualified = createUnqualifiedDTOList.stream().map(s -> s.getUnQualifiedNum()).reduce(BigDecimal.ZERO, BigDecimal::add);
+ if(unqualified.compareTo(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum())!=Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓嶈壇椤归敊璇細璇锋鏌ヤ笉鑹」鏁版嵁");
+ }
+ for (CreateUnqualifiedDTO createUnqualifiedDTO:createUnqualifiedDTOList) {
+ if(createUnqualifiedDTO.getUnQualifiedNum().compareTo(BigDecimal.ZERO)==Constants.ZERO
+ ||Objects.isNull(createUnqualifiedDTO.getCategoryId())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓嶈壇椤归敊璇細璇锋鏌ヤ笉鑹」鏁版嵁");
+ }
+ UnqualifiedRecord unqualifiedRecord = new UnqualifiedRecord();
+ unqualifiedRecord.setDeleted(Constants.ZERO);
+ unqualifiedRecord.setCreateUser(user.getId());
+ unqualifiedRecord.setCreateTime(new Date());
+ unqualifiedRecord.setRootDepartId(plans.getRootDepartId());
+ unqualifiedRecord.setDepartId(plans.getDepartId());
+ unqualifiedRecord.setWorkorderId(workorder.getId());
+ unqualifiedRecord.setRecordId(workorderRecord.getId());
+ unqualifiedRecord.setCategoryId(createUnqualifiedDTO.getCategoryId());
+ unqualifiedRecord.setUnqualifiedNum(createUnqualifiedDTO.getUnQualifiedNum());
+ unqualifiedRecordMapper.insert(unqualifiedRecord);
+ }
+ }
}
--
Gitblit v1.9.3