From af00e89990ae9757cc9261cbe560873c2066b69c Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期五, 18 八月 2023 14:34:11 +0800 Subject: [PATCH] 大屏统计 --- server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java | 94 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 79 insertions(+), 15 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 271a637..cea6336 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,8 @@ 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.*; import doumeemes.dao.ext.*; @@ -34,6 +36,7 @@ import org.springframework.web.multipart.MultipartFile; import java.math.BigDecimal; +import java.time.LocalDate; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -64,7 +67,8 @@ private WorkorderHistoryExtMapper workorderHistoryExtMapper; @Autowired private WorkorderRecordExtMapper workorderRecordExtMapper; - + @Autowired + private WorkorderMapper workorderMapper; @Autowired private RouteProcedureExtMapper routeProcedureExtMapper; @Autowired @@ -89,6 +93,8 @@ private WStockExtService wStockExtService; @Autowired private WorkorderRecordStandardService workorderRecordStandardService; + @Autowired + private UnqualifiedRecordMapper unqualifiedRecordMapper; @Override public PlansExtListVO findById(Integer id){ @@ -139,6 +145,19 @@ // //缁熻宸插畬宸ユ暟閲� // param.setStatus(Constants.WORKORDER_STATUS.done); // plan.setDoneNum(workorderExtMapper.sumOrderNum(param)); + QueryBomExtDTO bb = new QueryBomExtDTO(); + bb.setDepartId(plan.getDepartId()); + bb.setDeleted(Constants.ZERO); + bb.setRootDepartId(user.getRootDepartment().getId()); + bb.setMaterialId(plan.getMaterialId()); + bb.setProcedureId(plan.getProcedureId()); + BomExtListVO versionBom = bomExtMapper.selectByModel( bb); + if(versionBom == null || StringUtils.isBlank(versionBom.getVersion()) || versionBom.getBomVersionId() == null){ + plan.setHasBom(Constants.ZERO); + }else { + plan.setBomType(Constants.formatIntegerNum(versionBom.getType())); + plan.setHasBom(Constants.ONE); + } return plan; } @@ -197,6 +216,14 @@ // p.setDistributNum(tp.getDistributNum()); // p.setDoneNum(tp.getDoneNum()); p.setIsStock(wStockExtService.isStockForPlan(p)); + p.setHasExpire(false); + p.setStatus(Constants.formatIntegerNum(p.getStatus())); + if ( !p.getStatus().equals(Constants.PLAN_STATUS.done) && + !p.getStatus().equals(Constants.PLAN_STATUS.close)){ + if (Objects.nonNull(p.getPlanDate())){ + p.setHasExpire(DateUtil.toDateLocalDateTime(p.getWorkPlanPlanDate()).toLocalDate().isBefore(LocalDate.now())); + } + } } } return PageData.from(new PageInfo<>(result)); @@ -592,7 +619,7 @@ if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璁″垝宸叉殏鍋滐紒"); } - if(Constants.formatIntegerNum(mp.getDistributNum())+thisPlanNum > Constants.formatIntegerNum(mp.getNum())){ + if(Constants.formatIntegerNum(mp.getWorkorderDistributNum())+thisPlanNum > Constants.formatIntegerNum(mp.getNum())){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝绱鍒嗛厤鏁伴噺澶т簬璁″垝鏁伴噺锛�"); } if(!Constants.equalsInteger(mp.getStatus(),Constants.PLAN_STATUS.publish)&&!Constants.equalsInteger(mp.getStatus(),Constants.PLAN_STATUS.distribute)){ @@ -678,9 +705,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(); @@ -1507,7 +1534,7 @@ } /** * 鎭㈠璁″垝 - * @param p + * @param */ @Transactional(rollbackFor = {BusinessException.class,Exception.class}) @Override @@ -1558,22 +1585,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 = workorderExtMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId()).notIn("STATUS",7,8)); + List<Workorder> workorderList = workorderMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId()) + .eq("STATUS",Constants.WORKORDER_STATUS.baogong)); //鏈浜у嚭鏁伴噺 BigDecimal num = autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum()); if(num.compareTo(BigDecimal.ZERO)<=Constants.ZERO){ @@ -1590,9 +1624,9 @@ 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()); + Workorder workorder = this.distributeDone(user,param,num.intValue()); //宸ュ崟鎶曟枡璁板綍 CreateMaterialDTO createMaterialDTO = new CreateMaterialDTO(); if(!Objects.isNull(autoWorkReportDTO.getRecordList())&&autoWorkReportDTO.getRecordList().size()>Constants.ZERO){ @@ -1601,9 +1635,10 @@ workorderRecordStandardService.createMaterialStandard(createMaterialDTO); } //宸ュ崟浜у嚭璁板綍 - workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); + autoWorkReportDTO.getCreateWorkorderRecordDTO().setWorkorderId(workorder.getId()); + 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); @@ -1613,8 +1648,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