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 | 307 ++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 264 insertions(+), 43 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 596283d..3b866da 100644 --- a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java +++ b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java @@ -17,10 +17,8 @@ import doumeemes.dao.business.BackOrderDetailMapper; import doumeemes.dao.business.BackorderMapper; import doumeemes.dao.business.SalaryParamMapper; -import doumeemes.dao.business.dto.CreateMaterialDTO; -import doumeemes.dao.business.dto.CreateWorkorderRecordDTO; -import doumeemes.dao.business.dto.DealWorkorderRecordDTO; -import doumeemes.dao.business.dto.MaterialListDTO; +import doumeemes.dao.business.UnqualifiedRecordMapper; +import doumeemes.dao.business.dto.*; import doumeemes.dao.business.model.*; import doumeemes.dao.ext.*; import doumeemes.dao.ext.bean.EndCheckApBean; @@ -28,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 +86,13 @@ private PlansExtMapper plansExtMapper; @Autowired 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()); @@ -360,7 +367,7 @@ @Transactional(rollbackFor = {BusinessException.class,Exception.class}) @Override - public Integer comfirmDone(Workorder param){ + public Integer comfirmDone(Workorder param,Boolean needCheck){ LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鎮ㄦ棤鏉冮檺杩涜璇ユ搷浣滐紒"); @@ -388,7 +395,7 @@ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝宸ュ崟宸叉殏鍋滐紒"); } //濡傛灉闇�瑕佸畬宸ユ鎵嶈兘妫�楠� - if(Constants.equalsInteger(mp.getNeedcheck(),Constants.ZERO)){ + if(Constants.equalsInteger(mp.getNeedcheck(),Constants.ZERO)&&needCheck){ //鍙湁宸插畬宸ョ姸鎬佹墠鑳界‘璁ゆ姤宸� if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠姸鎬佸凡娴佽浆锛屼笉鑳借繘琛岃鎿嶄綔锛�"); @@ -494,6 +501,186 @@ return param.getId(); } + + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) + @Override + public Workorder comfirmDoneNew(AutoWorkReportDTO autoWorkReportDTO, Boolean needCheck){ + LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); + if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鎮ㄦ棤鏉冮檺杩涜璇ユ搷浣滐紒"); + } + 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); + } + if(autoWorkReportDTO.getCreateWorkorderRecordDTO().getWorkorderId()== null ){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇锋寜瑕佹眰濉啓鍜岄�夋嫨鎻愪氦鏁版嵁锛�"); + } + Workorder mp = new Workorder(); + mp.setDeleted(Constants.ZERO); + mp.setId(autoWorkReportDTO.getCreateWorkorderRecordDTO().getWorkorderId()); + mp.setRootDepartId(user.getRootDepartment().getId()); + mp = workorderExtMapper.selectOne(mp); + 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(), "瀵逛笉璧凤紝宸ュ崟宸叉殏鍋滐紒"); + } + //濡傛灉闇�瑕佸畬宸ユ鎵嶈兘妫�楠� + if(Constants.equalsInteger(mp.getNeedcheck(),Constants.ZERO)&&needCheck){ + //鍙湁宸插畬宸ョ姸鎬佹墠鑳界‘璁ゆ姤宸� + if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠姸鎬佸凡娴佽浆锛屼笉鑳借繘琛岃鎿嶄綔锛�"); + } + } + //鍑哄叆搴撴槑缁嗚褰曢泦鍚� + List<WOutboundDetail> outboundDetailList = new ArrayList<>(); + //寰呮洿鏂板伐瑁呴泦鍚堟姇鏂� + List<Appliances> updateApplianceList = new ArrayList<>(); + //寰呮洿鏂板伐瑁呴泦鍚堜骇鍑� + 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(),"鏈煡璇㈡姇鏂欏拰鎶ュ伐璁板綍!"); + } + //妫�鏌ユ暟鎹俊鎭� +// caculateCheckRecord(user, mp,allRecordList); + QueryBomDetailExtDTO bdparam = initBomParam(user,mp); + if(mp.getBomModel()!=null&&Constants.equalsInteger(mp.getBomModel().getType(),Constants.BOM_TYPE.pull)){ + //濡傛灉鏄媺寮忔姇鏂欙紝绯荤粺鏍规嵁BOM鑷姩鎵e噺搴撳瓨 + dealApplianceMateialPull(mp,user,bdparam,updateApplianceList, stockList); + } + if(allRecordList!=null && allRecordList.size()>0){ + if(mp.getBomModel()==null||Constants.equalsInteger(mp.getBomModel().getType(),Constants.BOM_TYPE.push)){ + //濡傛灉鏄帹寮忔姇鏂欙紝璧版甯哥敓浜ф墜鍔ㄦ姇鏂� + dealApplianceMateial(mp,user,bdparam,allRecordList,updateApplianceList, outboundDetailList,stockList); + } + //澶勭悊浜у嚭鏁版嵁 + dealAppliancePro(mp,user,allRecordList,updateApplianceList,updateApplianceProList, outboundDetailList,stockList); + } + + //濡傛灉鏈夋病bom閰嶇疆,妫�鏌ヤ骇鍑猴紙鍖呭惈妫�楠岀殑涓嶈壇鍜屾姤搴熷搧锛夊拰鎶曟枡鏁伴噺鏄惁鐩哥瓑鍖归厤锛屼笉涓�鑷存彁绀洪敊璇� + if(bdparam==null){ + //鎶曟枡鏁伴噺 鍜� 浜у嚭鏁伴噺涓嶇浉绛� + if(Constants.formatBigdecimal(mp.getHasMaterialNum()).intValue() != Constants.formatIntegerNum(mp.getHasProduceNum())){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曟姇鏂欏拰浜у嚭鏁伴噺涓嶄竴鑷达紝璇风‘璁ゅ悗閲嶈瘯锛�"); + } + } + //鏇存柊宸ュ崟鐘舵�佷负宸叉姤宸� + mp.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue()); + mp.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue()); + updateOrderInfo(user,mp,Constants.WORKORDER_HISTORY_STATUS.baogong); + + //鎵归噺鎻掑叆鍑哄叆搴撴槑缁嗚褰� + if(outboundDetailList!=null && outboundDetailList.size()>0){ + wOutboundDetailExtMapper.insertBatch(outboundDetailList); + } + if(stockList != null && stockList.size()>0){ + for(WStock s : stockList){ + WStock s1 = new WStock(); + s1.setLocationId(s.getLocationId()); + s1.setWarehouseId(s.getWarehouseId()); + s1.setDeleted(Constants.ZERO); + s1.setMaterialId(s.getMaterialId()); + s1.setQualityType(s.getQualityType()); + s1.setProcedureId(s.getProcedureId()); + if(StringUtils.isBlank(s.getBatch() )){ + s1 = wStockExtMapper.selectOne(new QueryWrapper<>(s1).isNull("batch").last(" limit 1")); + }else{ + s1.setBatch(s.getBatch()); + s1 = wStockExtMapper.selectOne(new QueryWrapper<>(s1).last(" limit 1")); + } + if(s1 ==null){ + //濡傛灉搴撳瓨璁板綍涓嶅瓨鍦紝鎻掑叆鏁版嵁 + s.setDeleted(Constants.ZERO); + s.setCreateTime(DateUtil.getCurrentDate()); + s.setCreateUser(user.getId()); + s.setRootDepartId(mp.getRootDepartId()); + if(Constants.formatBigdecimal(s.getNum()).compareTo(new BigDecimal(0)) == -1){ + //濡傛灉搴撳瓨涓嶈冻 + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝浠撳簱浣欐枡涓嶈冻锛岃鑱旂郴浠撳簱绠$悊鍛橈紒"); + } + wStockExtMapper.insert(s); + }else{ + //濡傛灉搴撳瓨璁板綍瀛樺湪锛屽垯鏇存柊搴撳瓨閲� + s.setId(s1.getId()); + s.setUpdateTime(DateUtil.getCurrentDate()); + s.setUpdateUser(user.getId()); + s.setNum(Constants.formatBigdecimal(s1.getNum()).add(Constants.formatBigdecimal(s.getNum()))); + if(Constants.formatBigdecimal(s.getNum()).compareTo(new BigDecimal(0)) == -1){ + //濡傛灉搴撳瓨涓嶈冻 + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝浠撳簱浣欐枡涓嶈冻锛岃鑱旂郴浠撳簱绠$悊鍛�!锛�"); + } + wStockExtMapper.updateById(s); + } + + } + } + + //瀛樺偍鎶ュ伐涓嶈壇椤规暟鎹� + 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(mp.getRootDepartId()); + unqualifiedRecord.setDepartId(mp.getDepartId()); + unqualifiedRecord.setWorkorderId(mp.getId()); + unqualifiedRecord.setRecordId(workorderRecord.getId()); + unqualifiedRecord.setCategoryId(createUnqualifiedDTO.getCategoryId()); + unqualifiedRecord.setUnqualifiedNum(createUnqualifiedDTO.getUnQualifiedNum()); + unqualifiedRecordMapper.insert(unqualifiedRecord); + } + } + + return param; + } + + + private QueryWorkorderRecordExtDTO getQueryRecordParam(Workorder param) { QueryWorkorderRecordExtDTO mParam = new QueryWorkorderRecordExtDTO(); mParam.setWorkorderId(param.getId()); @@ -544,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())); @@ -669,13 +860,14 @@ if (bomDetailList == null || bomDetailList.size() == 0) { throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ョ敓浜х墿鏂欑殑bom閰嶇疆鏈夎锛岃鑱旂郴绠$悊鍛橈紒"); } -// for (BomDetailExtListVO i :bomDetailList) { -// //鏌ヨ鏄惁鎶曟枡 -// if(workorderRecordExtMapper.selectCount(new QueryWrapper<WorkorderRecord>() -// .eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",i.getMaterialId()).eq("TYPE",Constants.ZERO))<=0){ -// throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪鏈姇鏂橞OM鐗╂枡锛屾棤娉曡繘琛屾姤宸�"); -// } -// } + for (BomDetailExtListVO i :bomDetailList) { + //鏌ヨ鏄惁鎶曟枡 + if(workorderRecordExtMapper.selectCount(new QueryWrapper<WorkorderRecord>() + .eq("WORKORDER_ID",mp.getId()) + .eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",i.getMaterialId()).eq("TYPE",Constants.ZERO))<=0){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪鏈姇鏂橞OM鐗╂枡锛屾棤娉曡繘琛屾姤宸�"); + } + } } WOutbound outbound = new WOutbound(); @@ -954,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); } @@ -988,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()); @@ -1006,7 +1201,7 @@ record.setAppliancesId(tModel.getAppliancesId()); record.setBatch(detail.getBatch()); record.setRootDepartId(mp.getRootDepartId()); - record.setNum(tModel.getNum()); + record.setNum(detail.getNum()); record.setOutboundId(detail.getOutboundId()); record.setUnitId(detail.getUnitId()); record.setWarehouseId(detail.getWarehouseId()); @@ -1017,10 +1212,10 @@ detail.getWOutboundRecordInList().add(record); WStock stock = getFromStockList(mp.getFinishWarehouseLocationId(),detail.getWarehouseId(),detail.getMaterialId(),detail.getBatch(), - tModel.getProcedureId(),tModel.getDoneType(),stockList); + tModel.getProcedureId(),doneType,stockList); if(stock!=null){ //濡傛灉搴撳瓨瀵硅薄宸插瓨鍦紝鐩存帴澧炲姞瀵瑰簲鐨勫簱瀛橀噺 - stock.setNum(Constants.formatBigdecimal(stock.getNum()).add(Constants.formatBigdecimal(tModel.getNum()))); + stock.setNum(Constants.formatBigdecimal(stock.getNum()).add(Constants.formatBigdecimal(detail.getNum()))); }else{ stock = new WStock(); stock.setMaterialId(detail.getMaterialId()); @@ -1028,9 +1223,9 @@ stock.setWarehouseId(outbound.getWarehouseId()); stock.setLocationId(mp.getFinishWarehouseLocationId()); stock.setUnitId(detail.getUnitId()); - stock.setNum(Constants.formatBigdecimal(tModel.getNum())); + stock.setNum(Constants.formatBigdecimal(detail.getNum())); stock.setProcedureId(tModel.getProcedureId()); - stock.setQualityType(tModel.getDoneType()); + stock.setQualityType(doneType); //寰呮洿鏂板簱瀛樹俊鎭� stockList.add(stock); } @@ -1210,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; } @@ -1306,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(), "瀵逛笉璧凤紝鏈煡璇㈠埌璇ュ伐鍗曚俊鎭紒"); @@ -1335,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()); @@ -1354,20 +1571,24 @@ 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 ")); - if(Objects.isNull(salaryParam)){ - throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈厤缃伐璧勭哗鏁堥厤缃紒"); - } - workorderRecord.setSalaryPrice(salaryParam.getSalary()); - workorderRecord.setSalaryType(salaryParam.getType()); - workorderRecord.setSalaryUnqualified(salaryParam.getUnqualified()); - //璁′欢宸ヨ祫 - if(salaryParam.getType().equals(Constants.ZERO)){ - workorderRecord.setSalaryNum(salaryParam.getNum()); - 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))); + .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{ + 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)); + } + } } //鎻掑叆宸ュ崟鎿嶄綔璁板綍锛屽苟涓斿垽鏂槸鍚︽洿鏀逛负宸ュ崟鐨勭姸鎬併�愮敓浜т腑銆� updateOrderInfo(loginUserInfo,workorder,Constants.WORKORDER_HISTORY_STATUS.produce); -- Gitblit v1.9.3