| | |
| | | .eq("MATERIAL_ID",w.getMaterialId()) |
| | | .eq("DEPART_ID",w.getDepartId()) |
| | | .eq("DELETED",Constants.ZERO) |
| | | .eq("STATUS",Constants.ONE) |
| | | // .eq("STATUS",Constants.ONE) |
| | | ); |
| | | w.setPapercode(b.getPapercode()); |
| | | w.setPapercode(b!=null ?b.getPapercode():null); |
| | | |
| | | /* RouteProcedure currentRouteProcedure = routeProcedureExtMapper.selectOne(new QueryWrapper<RouteProcedure>() |
| | | .eq("ROUTE_ID",b.getRouteId()) |
| | |
| | | result.setStartNum(workorderExtMapper.selectCount(param)); |
| | | param.setStatusList(new ArrayList<>()); |
| | | param.getStatusList().add(Constants.WORKORDER_STATUS.done); |
| | | param.getStatusList().add(Constants.WORKORDER_STATUS.producing); |
| | | param.getStatusList().add(Constants.WORKORDER_STATUS.check); |
| | | //进行中数量 |
| | | result.setIngNum(workorderExtMapper.selectCount(param)); |
| | |
| | | tModle.setUrgent(w.getUrgent()); |
| | | tModle.setUpdateTime(w.getUpdateTime()); |
| | | tModle.setRemark(w.getRemark()); |
| | | tModle.setQualifiedNum(0); |
| | | tModle.setUnqualifiedNum(0); |
| | | tModle.setQualifiedNum(w.getQualifiedNum()); |
| | | tModle.setUnqualifiedNum(w.getUnqualifiedNum()); |
| | | tModle.setProUserId(w.getProUserId()); |
| | | tModle.setProUserName(w.getProUserName()); |
| | | tModle.setProUserName(w.getProUserName()); |
| | | tModle.setCreateUser(w.getCreateUser()); |
| | | tModle.setCreateUserName(w.getCreateUserName()); |
| | | if(w.getProUserId()!=null){ |
| | | //查询班组信息 |
| | | QueryCompanyUserExtDTO queryCompanyUserExtDTO = new QueryCompanyUserExtDTO(); |
| | |
| | | //产出日期 |
| | | tModle.setProduceDate(r.getCreateTime()); |
| | | } |
| | | if(Constants.equalsInteger(r.getDoneType(),Constants.ZERO)){ |
| | | // if(Constants.equalsInteger(r.getDoneType(),Constants.ZERO)){ |
| | | //如果是合格产出 |
| | | tModle.setQualifiedNum(tModle.getQualifiedNum()+Constants.formatBigdecimal(r.getNum()).intValue()); |
| | | }else{ |
| | | // tModle.setQualifiedNum(tModle.getQualifiedNum()+Constants.formatBigdecimal(r.getNum()).intValue()); |
| | | // }else{ |
| | | //如果是不良品 |
| | | tModle.setUnqualifiedNum(tModle.getUnqualifiedNum()+Constants.formatBigdecimal(r.getNum()).intValue()); |
| | | } |
| | | // tModle.setUnqualifiedNum(tModle.getUnqualifiedNum()+Constants.formatBigdecimal(r.getNum()).intValue()); |
| | | // } |
| | | //如果是合格产出 |
| | | tModle.setQualifiedNum(tModle.getQualifiedNum()); |
| | | //如果是不良品 |
| | | tModle.setUnqualifiedNum(tModle.getUnqualifiedNum()); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param param |
| | | */ |
| | | @Override |
| | | @Async |
| | | // @Async |
| | | public void statisticNum(Workorder param){ |
| | | if(param.getPlanId()== null){ |
| | | if(param.getId()== null){ |
| | |
| | | } |
| | | if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.create) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.material) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.check) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.done)){ |
| | | //统计已分配未报工数量 |
| | | distributeNoDoneNum += Constants.formatIntegerNum(order.getPlanNum()); |
| | | } |
| | | if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.baogong) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing) |
| | | || Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.instock)){ |
| | | doneNum += Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum()); |
| | | int tNum =Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum()); |
| | |
| | | && item.getOmodel()!=null |
| | | && (Constants.equalsInteger(item.getOmodel().getStatus() ,Constants.WORKORDER_STATUS.baogong) |
| | | ||Constants.equalsInteger(item.getOmodel().getStatus() ,Constants.WORKORDER_STATUS.instock))){ |
| | | //如果是产出 |
| | | if(Constants.equalsInteger(item.getDoneType(),Constants.ZERO)){ |
| | | //如果是合格产出,累计数量 |
| | | qulifiedNum += Constants.formatBigdecimal(item.getNum()).intValue(); |
| | | }else{ |
| | | //如果是不良产出,累计数量 |
| | | unqulifiedNum += Constants.formatBigdecimal(item.getNum()).intValue(); |
| | | } |
| | | //如果是合格产出,累计数量 |
| | | qulifiedNum += Constants.formatBigdecimal(BigDecimal.valueOf(item.getQualifiedNum())).intValue(); |
| | | //如果是不良产出,累计数量 |
| | | unqulifiedNum += Constants.formatBigdecimal(BigDecimal.valueOf(item.getUnqualifiedNum())).intValue(); |
| | | } |
| | | } |
| | | } |
| | |
| | | if(!Objects.isNull(plan.getWorkPlansId())){ |
| | | //更新主订单数据信息 |
| | | if(plansMapper.selectCount(new QueryWrapper<Plans>() |
| | | .in("STATUS",0,1,4) |
| | | .in("STATUS",0,1,4,5) |
| | | .eq("DELETED",Constants.ZERO) |
| | | .ne("id",p.getId()) |
| | | .eq("WORK_PLANS_ID",plan.getWorkPlansId()))<=Constants.ZERO){ |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Async |
| | | public void statisticNumAsync(Workorder param){ |
| | | if(param.getPlanId()== null){ |
| | | if(param.getId()== null){ |
| | | return; |
| | | } |
| | | Workorder wModel = new Workorder(); |
| | | wModel.setDeleted(Constants.ZERO); |
| | | wModel.setId(param.getId()); |
| | | wModel = workorderExtMapper.selectOne(wModel); |
| | | if(wModel== null){ |
| | | return; |
| | | } |
| | | param.setPlanId(wModel.getPlanId()); |
| | | } |
| | | Plans plan = plansExtMapper.selectById(param.getPlanId()); |
| | | if(plan == null){ |
| | | return; |
| | | } |
| | | JSONObject json = new JSONObject(); |
| | | QueryWorkorderExtDTO qw = new QueryWorkorderExtDTO(); |
| | | qw.setPlanId(param.getPlanId()); |
| | | qw.setDeleted(Constants.ZERO); |
| | | //查询全部工单数据 |
| | | List<WorkorderExtListVO> orderList = workorderExtMapper.selectList(qw); |
| | | //已完工数量 |
| | | int doneNum=0; |
| | | //已分配数量 |
| | | //已报工工单(包括工单状态:已报工、已入库)的完工数量(包括:合格、不良、报废) |
| | | //+未报工工单(包括工单状态:已创建、已备料、已检验、已完工)的已分配数量 |
| | | int distributNum=0; |
| | | //已分配未报工数量=未报工工单(工单状态:已创建、已备料、已检验、已完工)的计划生产数量之和; |
| | | int distributeNoDoneNum=0; |
| | | //合格数量=已报工工单(工单状态:已报工、已入库)产出为合格的数量之和; |
| | | int qulifiedNum=0; |
| | | //不良数量=已报工工单(工单状态:已报工、已入库)产出为不良的数量之和; |
| | | int unqulifiedNum =0; |
| | | int allOrderNum =0; |
| | | if(orderList!=null && orderList.size()>0){ |
| | | QueryWorkorderRecordExtDTO rw = new QueryWorkorderRecordExtDTO(); |
| | | rw.setPlanId(param.getPlanId()); |
| | | rw.setDeleted(Constants.ZERO); |
| | | //查询全部工单产出和投料数据 |
| | | List<WorkorderRecordExtListVO> allRecordList = workorderRecordExtMapper.selectListNew(rw); |
| | | for(WorkorderExtListVO order : orderList){ |
| | | if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.cancel)){ |
| | | //取消的工单不累计数量 |
| | | continue; |
| | | } |
| | | if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.create) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.material) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.check) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.done)){ |
| | | //统计已分配未报工数量 |
| | | distributeNoDoneNum += Constants.formatIntegerNum(order.getPlanNum()); |
| | | } |
| | | if(Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.baogong) |
| | | ||Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.producing) |
| | | || Constants.equalsInteger(order.getStatus(),Constants.WORKORDER_STATUS.instock)){ |
| | | doneNum += Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum()); |
| | | int tNum =Constants.formatIntegerNum(order.getUnqualifiedNum()) + Constants.formatIntegerNum(order.getQualifiedNum()); |
| | | distributNum += tNum; |
| | | allOrderNum += tNum; |
| | | }else { |
| | | distributNum += Constants.formatIntegerNum(order.getPlanNum()); |
| | | } |
| | | |
| | | List<WorkorderRecordExtListVO> rList = getRecordListById(order.getId(),allRecordList); |
| | | if(rList!=null){ |
| | | for(WorkorderRecordExtListVO item : rList){ |
| | | if(Constants.equalsInteger(item.getType(),Constants.WORKORDER_RECORD_TYPE.produce) |
| | | && item.getOmodel()!=null |
| | | && (Constants.equalsInteger(item.getOmodel().getStatus() ,Constants.WORKORDER_STATUS.baogong) |
| | | ||Constants.equalsInteger(item.getOmodel().getStatus() ,Constants.WORKORDER_STATUS.instock))){ |
| | | //如果是合格产出,累计数量 |
| | | qulifiedNum += Constants.formatBigdecimal(BigDecimal.valueOf(item.getQualifiedNum())).intValue(); |
| | | //如果是不良产出,累计数量 |
| | | unqulifiedNum += Constants.formatBigdecimal(BigDecimal.valueOf(item.getUnqualifiedNum())).intValue(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | json.put(Constants.STATISTIC.distributeNoDone,distributeNoDoneNum); |
| | | json.put(Constants.STATISTIC.done,doneNum); |
| | | json.put(Constants.STATISTIC.distribute,distributNum); |
| | | json.put(Constants.STATISTIC.qulified,qulifiedNum); |
| | | json.put(Constants.STATISTIC.unqulified,unqulifiedNum); |
| | | |
| | | UpdateWrapper updateWrapper = new UpdateWrapper(); |
| | | Plans p = new Plans(); |
| | | p.setId(param.getPlanId()); |
| | | p.setStatisticInfo(json.toJSONString()); |
| | | p.setUpdateTime(DateUtil.getCurrentDate()); |
| | | if( Constants.formatIntegerNum(plan.getNum()) <= allOrderNum){ |
| | | //如果满足计划已完工,更新计划状态 |
| | | p.setStatus(Constants.PLAN_STATUS.done); |
| | | if(!Objects.isNull(plan.getWorkPlansId())){ |
| | | //更新主订单数据信息 |
| | | if(plansMapper.selectCount(new QueryWrapper<Plans>() |
| | | .in("STATUS",0,1,4,5) |
| | | .eq("DELETED",Constants.ZERO) |
| | | .ne("id",p.getId()) |
| | | .eq("WORK_PLANS_ID",plan.getWorkPlansId()))<=Constants.ZERO){ |
| | | WorkPlans workPlans = workPlansExtMapper.selectById(plan.getWorkPlansId()); |
| | | if(!Objects.isNull(workPlans)){ |
| | | workPlans.setStatus(Constants.WORKPLANHISTORY_TYPE.done); |
| | | workPlans.setUpdateTime(new Date()); |
| | | workPlansExtMapper.updateById(workPlans); |
| | | planHistoryExtMapper.insert(initPlanHistoryByModel(workPlans,null,Constants.WORKPLANHISTORY_TYPE.done)); |
| | | } |
| | | }; |
| | | } |
| | | // |
| | | plan.getWorkPlansId(); |
| | | |
| | | updateWrapper.set("STATUS",p.getStatus()); |
| | | if(Constants.equalsInteger(plan.getStatus(),Constants.PLAN_STATUS.distribute)){ |
| | | //如果已分配 |
| | | planHistoryExtMapper.insertBatch(Arrays.asList(PlansExtServiceImpl.initHistoryByModel(plan,null,Constants.PLANHISTORY_TYPE.done))); |
| | | } |
| | | // planHistoryService.create(PlansExtServiceImpl.initHistoryByModel(plan,null,Constants.PLANHISTORY_TYPE.done)); |
| | | } |
| | | //更新统计信息 |
| | | // plansExtMapper.updateById(p); |
| | | updateWrapper.eq("ID",param.getPlanId()); |
| | | updateWrapper.set("STATISTIC_INFO",json.toJSONString()); |
| | | updateWrapper.set("UPDATE_TIME",DateUtil.getCurrentDate()); |
| | | plansExtMapper.update(null,updateWrapper); |
| | | // Workorder order = new Workorder(); |
| | | // order.setUpdateTime(DateUtil.getCurrentDate()); |
| | | // //已关闭 |
| | | // order.setId(param.getId()); |
| | | // workorderExtMapper.updateById(order); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 检测数据有效性 |
| | | * @param param |