From 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期三, 06 十二月 2023 08:41:32 +0800 Subject: [PATCH] bug --- server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java | 94 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 77 insertions(+), 17 deletions(-) diff --git a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java index c8a744d..3b866da 100644 --- a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java +++ b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java @@ -26,6 +26,7 @@ import doumeemes.dao.ext.dto.*; import doumeemes.dao.ext.vo.*; import doumeemes.dao.system.model.SystemDictData; +import doumeemes.service.business.UnqualifiedRecordService; import doumeemes.service.business.WOutboundService; import doumeemes.service.ext.*; import doumeemes.service.system.SystemDictDataService; @@ -87,6 +88,11 @@ private DeviceExtMapper deviceExtMapper; @Autowired private UnqualifiedRecordMapper unqualifiedRecordMapper; + @Autowired + private CompanyUserExtMapper companyUserExtMapper; + + @Autowired + private UnqualifiedRecordService unqualifiedRecordService; @Transactional(rollbackFor = {BusinessException.class,Exception.class}) @Override @@ -185,6 +191,7 @@ } if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create) && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material) + && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.producing) && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.check) && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠姸鎬佸凡娴佽浆锛屼笉鑳借繘琛岃鎿嶄綔锛�"); @@ -295,15 +302,15 @@ wrModel.setMaterialId(wStock.getMaterialId()); wrModel.setDepartId(mp.getDepartId()); wrModel.setCreateTime(DateUtil.getCurrentDate()); - wrModel.setCreateUser(user.getId()); + wrModel.setCreateUser(mp.getCreateUser()); wrModel.setMaterialBatch(mp.getBatch()); wrModel.setType(Constants.WORKORDER_RECORD_TYPE.materail); wrModel.setFactoryId(mp.getFactoryId()); - wrModel.setProcedureId(mp.getProcedureId()); - wrModel.setBatch(mp.getBatch()); - wrModel.setUnitId(mp.getUnitId()); + wrModel.setProcedureId(wStock.getProcedureId()); + wrModel.setBatch(wStock.getBatch()); + wrModel.setUnitId(wStock.getUnitId()); wrModel.setPlanId(mp.getPlanId()); - //TODO 鐩墠浣跨敤宸ヨ涓婚敭瀛樺偍璐т綅涓婚敭 + //鐩墠浣跨敤宸ヨ涓婚敭瀛樺偍璐т綅涓婚敭 wrModel.setAppliancesId(wStock.getId()); wrModel.setMaterialDonetype(wStock.getQualityType()); wrModel.setMaterialProcedureId(wStock.getProcedureId()); @@ -519,10 +526,27 @@ if(mp== null){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇ヨ褰曚笉瀛樺湪锛�"); } - + Plans plans = plansExtMapper.selectById(mp.getPlanId()); + if(Objects.isNull(plans)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝宸ュ簭璁″垝璁板綍涓嶅瓨鍦紒"); + } + //鏌ヨ宸ュ簭璁″垝涓� 鎵�鏈夊伐鍗曞凡鎶ュ伐鏁伴噺 + QueryWorkorderExtDTO dto = new QueryWorkorderExtDTO(); + dto.setPlanId(mp.getPlanId()); + dto.setDeleted(Constants.ZERO); + dto.setStatus(Constants.WORKORDER_STATUS.baogong); + List<WorkorderExtListVO> workorderList = workorderExtMapper.selectList(dto); + Integer plansQualifiedNum = 0 , plansUnQualifiedNum = 0; + plansQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getQualifiedNum()).reduce(Constants.ZERO, Integer::sum); + plansUnQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getUnqualifiedNum()).reduce(Constants.ZERO, Integer::sum); + if((BigDecimal.valueOf(plansQualifiedNum).add(BigDecimal.valueOf(plansUnQualifiedNum).add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum()) + .add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum()))).compareTo(BigDecimal.valueOf(plans.getNum()))>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鎶ュ伐鏁伴噺瓒呭嚭宸ュ簭璁″垝鎬绘暟锛�"); + } Workorder param = new Workorder(); param.setPlanId(mp.getPlanId()); + param.setId(autoWorkReportDTO.getCreateWorkorderRecordDTO().getWorkorderId()); if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝宸ュ崟宸叉殏鍋滐紒"); } @@ -541,13 +565,13 @@ List<Appliances> updateApplianceProList = new ArrayList<>(); //寰呮洿鏂板簱瀛橀泦鍚� List<WStock> stockList = new ArrayList<>(); + //澶勭悊浜у嚭鏁版嵁 + WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user,null); //鏌ヨ鎶曟枡鍜屾姤宸ヨ褰曞垪琛� List<WorkorderRecordExtListVO> allRecordList = workorderRecordExtMapper.selectAllList(getQueryRecordParam(param)); if(Objects.isNull(allRecordList)||allRecordList.size()==Constants.ZERO){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈡姇鏂欏拰鎶ュ伐璁板綍!"); } - //澶勭悊浜у嚭鏁版嵁 - WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); //妫�鏌ユ暟鎹俊鎭� // caculateCheckRecord(user, mp,allRecordList); QueryBomDetailExtDTO bdparam = initBomParam(user,mp); @@ -572,6 +596,8 @@ } } //鏇存柊宸ュ崟鐘舵�佷负宸叉姤宸� + mp.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue()); + mp.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue()); updateOrderInfo(user,mp,Constants.WORKORDER_HISTORY_STATUS.baogong); //鎵归噺鎻掑叆鍑哄叆搴撴槑缁嗚褰� @@ -705,8 +731,12 @@ List<WOutbound> outboundList = new ArrayList<>(); //濡傛灉闇�瑕佹姇鏂欑殑鐗╂枡闆嗗悎锛屽湪搴撳瓨涓鎵炬姇鏂欐潵婧� for(WStock model : materialList){ + List<WStock> useList = allList.stream().filter(wStock -> Constants.equalsInteger(model.getMaterialId(),wStock.getMaterialId())).collect(Collectors.toList()); + BigDecimal wStockNum = useList.stream().map(s -> s.getNum()).reduce(BigDecimal.ZERO, BigDecimal::add); + if(wStockNum.compareTo(Constants.formatBigdecimal(model.getNum()))<Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鐢熶骇鐗╂枡涓嶈冻锛屾棤娉曡繘琛岃鎿嶄綔锛�"); + } for(WStock ts : allList){ - if(Constants.equalsInteger(model.getMaterialId(),ts.getMaterialId())){ //杩橀渶瑕佹姇鏂欐暟閲� BigDecimal actNum = Constants.formatBigdecimal(model.getNum()).subtract(Constants.formatBigdecimal(model.getTNum())); @@ -1116,7 +1146,7 @@ //濡傛灉鏄骇鍑� mp.setHasProduceNum(Constants.formatBigdecimal(tModel.getNum()).intValue()+Constants.formatIntegerNum(mp.getHasProduceNum())); //浜у嚭鍚堟牸 - this.createOutDetail(user,outbound,mp,tModel,Constants.ZERO,detailList,stockList); + this.createOutDetail(user,outbound,mp,tModel,Constants.ZERO,detailList,stockList); //浜у嚭涓嶈壇 this.createOutDetail(user,outbound,mp,tModel,Constants.ONE,detailList,stockList); } @@ -1150,6 +1180,9 @@ detail.setWarehouseId(outbound.getWarehouseId()); detail.setLocationId(mp.getFinishWarehouseLocationId()); detail.setNum(BigDecimal.valueOf(doneType.equals(Constants.ZERO)?tModel.getQualifiedNum():tModel.getUnqualifiedNum())); + if(detail.getNum().compareTo(BigDecimal.ZERO)==Constants.ZERO){ + return; + } detail.setStatus(Constants.ONE); detail.setDoneNum(detail.getNum()); detail.setDoneDate(new Date()); @@ -1372,6 +1405,15 @@ public List<WorkorderRecord> getWorkorderRecordList(Integer workorderId) { List<WorkorderRecord> workorderRecordList = workorderRecordExtMapper.selectList( new QueryWrapper<WorkorderRecord>().eq("WORKORDER_ID",workorderId).eq("TYPE",Constants.ONE).eq("DELETED",Constants.ZERO).orderByAsc(" DONE_TYPE ")); + if(!Objects.isNull(workorderRecordList)&workorderRecordList.size()>Constants.ZERO){ + for (WorkorderRecord workorderRecord:workorderRecordList) { + //鏌ヨ涓嶈壇浜у嚭璁板綍璇︽儏 浜у嚭 涓� 涓嶈壇 鎵嶅瓨鍦ㄨ鏁版嵁 + if(workorderRecord.getType().equals(Constants.ONE)&&workorderRecord.getUnqualifiedNum().compareTo(BigDecimal.ZERO)>Constants.ZERO){ + List<UnqualifiedRecord> unqualifiedRecordList = unqualifiedRecordService.findJoinList(workorderRecord.getId()); + workorderRecord.setUnqualifiedRecordList(unqualifiedRecordList); + } + } + } return workorderRecordList; } @@ -1468,7 +1510,7 @@ @Override @Transactional(rollbackFor = {BusinessException.class,Exception.class}) - public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo){ + public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo ,Integer userId){ Workorder workorder = workorderExtMapper.selectById(createWorkorderRecordDTO.getWorkorderId()); if(Objects.isNull(workorder)){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌璇ュ伐鍗曚俊鎭紒"); @@ -1497,11 +1539,24 @@ //鏁版嵁瀛樺偍 workorderRecord = new WorkorderRecord(); workorderRecord.setDeleted(Constants.ZERO); - workorderRecord.setCreateUser(loginUserInfo.getId()); + if(!Objects.isNull(userId)){ + CompanyUser companyUser = new CompanyUser(); + companyUser.setUserId(userId); + companyUser.setRootDepartId(loginUserInfo.getRootDepartment().getId()); + companyUser = companyUserExtMapper.selectOne(new QueryWrapper<>(companyUser).last("limit 1")); + if(Objects.isNull(companyUser)){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌鐢熶骇浜哄憳瀵瑰簲浼佷笟鐢ㄦ埛淇℃伅锛�"); + } + workorderRecord.setCreateUser(userId); + workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId()); + workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId()); + }else{ + workorderRecord.setCreateUser(loginUserInfo.getId()); + workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId()); + workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId()); + } workorderRecord.setCreateTime(new Date()); workorderRecord.setNum(num); - workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId()); - workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId()); workorderRecord.setPlanId(workorder.getPlanId()); workorderRecord.setWorkorderId(createWorkorderRecordDTO.getWorkorderId()); workorderRecord.setBatch(workorder.getBatch()); @@ -1516,18 +1571,23 @@ workorderRecord.setQualifiedNum(createWorkorderRecordDTO.getQualifiedNum()); //璁$畻宸ヨ祫淇℃伅 SalaryParam salaryParam = salaryParamMapper.selectOne(new QueryWrapper<SalaryParam>().eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",workorderRecord.getMaterialId()) - .eq("DEPART_ID",workorderRecord.getFactoryId()).eq("PROCEDURE_ID",workorderRecord.getProcedureId()).last(" limit 1 ")); + .eq("DEPART_ID",workorderRecord.getFactoryId()).eq("PROCEDURE_ID",workorderRecord.getProcedureId()).eq("TYPE",createWorkorderRecordDTO.getType()).last(" limit 1 ")); if(!Objects.isNull(salaryParam)){ workorderRecord.setSalaryPrice(salaryParam.getSalary()); workorderRecord.setSalaryType(salaryParam.getType()); workorderRecord.setSalaryUnqualified(salaryParam.getUnqualified()); + workorderRecord.setSalaryTimes(salaryParam.getTimes()); //璁′欢宸ヨ祫 if(salaryParam.getType().equals(Constants.ZERO)){ workorderRecord.setSalaryNum(salaryParam.getNum()); + workorderRecord.setDuration(createWorkorderRecordDTO.getDuration()); workorderRecord.setSalary(salaryParam.getSalary().multiply(salaryParam.getUnqualified()==Constants.ONE?num:createWorkorderRecordDTO.getQualifiedNum())); }else{ - workorderRecord.setDuration(createWorkorderRecordDTO.getDuration()); - workorderRecord.setSalary(BigDecimal.valueOf(createWorkorderRecordDTO.getDuration()).multiply(salaryParam.getSalary()).divide(new BigDecimal(3600),BigDecimal.ROUND_HALF_UP)); + if(!Objects.isNull(createWorkorderRecordDTO.getDuration())&&Constants.formatIntegerNum(createWorkorderRecordDTO.getDuration())>Constants.ZERO){ + workorderRecord.setSalaryNum(salaryParam.getNum()); + workorderRecord.setDuration(createWorkorderRecordDTO.getDuration()); + workorderRecord.setSalary(BigDecimal.valueOf(createWorkorderRecordDTO.getDuration()).multiply(salaryParam.getSalary()).divide(new BigDecimal(3600),BigDecimal.ROUND_HALF_UP)); + } } } //鎻掑叆宸ュ崟鎿嶄綔璁板綍锛屽苟涓斿垽鏂槸鍚︽洿鏀逛负宸ュ崟鐨勭姸鎬併�愮敓浜т腑銆� -- Gitblit v1.9.3