| | |
| | | import doumeemes.core.utils.redis.RedisUtil; |
| | | 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.model.*; |
| | |
| | | private WOutboundRecordExtMapper wOutboundRecordExtMapper; |
| | | @Autowired |
| | | private MaterialExtMapper materialExtMapper; |
| | | @Autowired |
| | | private SalaryParamMapper salaryParamMapper; |
| | | |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | @Override |
| | |
| | | recordList.add(getWorkrecordModel(user,wStock,mp,materialListDTO.getNum())); |
| | | } |
| | | } |
| | | |
| | | //批量插入投料记录 |
| | | workorderRecordExtMapper.insertBatch(recordList); |
| | | //单添加历史记录(不更新状态) |
| | | //单添加历史记录(判断更新为生产中) |
| | | updateOrderInfo(user,mp,Constants.WORKORDER_HISTORY_STATUS.material); |
| | | return param.getId(); |
| | | } |
| | |
| | | order.setStatus(Constants.WORKORDER_STATUS.material); |
| | | }else if(status ==Constants.WORKORDER_HISTORY_STATUS.done){ |
| | | order.setStatus(Constants.WORKORDER_STATUS.done); |
| | | }else if(status ==Constants.WORKORDER_HISTORY_STATUS.material){ |
| | | //投料操作 |
| | | if(Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create) |
| | | ||Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material)){ |
| | | //如果是已创建或者已备料状态的工单,修改其状态为【生产中】 |
| | | order.setStatus(Constants.WORKORDER_STATUS.producing); |
| | | } |
| | | } |
| | | workorderExtMapper.updateById(order); |
| | | workorderHistoryExtMapper.insertBatch(whList); |
| | |
| | | dealAppliancePro(mp,user,allRecordList,updateApplianceList,updateApplianceProList, outboundDetailList,stockList); |
| | | } |
| | | |
| | | if(1==1){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"123"); |
| | | } |
| | | |
| | | //如果有没bom配置,检查产出(包含检验的不良和报废品)和投料数量是否相等匹配,不一致提示错误 |
| | | if(bdparam==null){ |
| | |
| | | //如果需要投料的物料集合,在库存中寻找投料来源 |
| | | for(WStock model : materialList){ |
| | | for(WStock ts : allList){ |
| | | |
| | | if(Constants.equalsInteger(model.getMaterialId(),ts.getMaterialId())){ |
| | | //还需要投料数量 |
| | | BigDecimal actNum = Constants.formatBigdecimal(model.getNum()).subtract(Constants.formatBigdecimal(model.getTNum())); |
| | |
| | | //如果已经满足剩余需求量 |
| | | isfull =true; |
| | | } |
| | | |
| | | //添加投料记录 |
| | | workorderRecordExtMapper.insert(getWorkrecordModel(user,ts,mp,actNum)); |
| | | |
| | | //更新已经投料数量 |
| | | model.setTNum(Constants.formatBigdecimal(model.getTNum()).add(actNum)); |
| | | WOutbound outbound = getFromOutboundList(ts.getWarehouseId(),outboundList); |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,该工单信息!"); |
| | | } |
| | | if(Objects.isNull(dealWorkorderRecordDTO.getDownType()) |
| | | ||Objects.isNull(dealWorkorderRecordDTO.getWorkorderId()) |
| | | ||Objects.isNull(dealWorkorderRecordDTO.getNum()) |
| | | ||Objects.isNull(dealWorkorderRecordDTO.getWorkorderId()) |
| | | ||Objects.isNull(dealWorkorderRecordDTO.getNum()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | WorkorderRecord workorderRecord = new WorkorderRecord(); |
| | | if(Objects.isNull(dealWorkorderRecordDTO.getRecordId())){ |
| | | //查询工单下是否存在对应记录 |
| | | workorderRecord = workorderRecordExtMapper.selectOne(new QueryWrapper<WorkorderRecord>() |
| | | workorderRecord = workorderRecordExtMapper.selectOne(new QueryWrapper<WorkorderRecord>() |
| | | .eq("WORKORDER_ID",dealWorkorderRecordDTO.getWorkorderId()) |
| | | .eq("DONE_TYPE",dealWorkorderRecordDTO.getDownType()) |
| | | .eq("TYPE",Constants.ONE) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo){ |
| | | Workorder workorder = workorderExtMapper.selectById(createWorkorderRecordDTO.getWorkorderId()); |
| | | if(Objects.isNull(workorder)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到该工单信息!"); |
| | | } |
| | | if(Objects.isNull(createWorkorderRecordDTO.getUnQualifiedNum()) |
| | | ||Objects.isNull(createWorkorderRecordDTO.getUnQualifiedNum()) |
| | | ||Objects.isNull(createWorkorderRecordDTO.getWorkorderId()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | BigDecimal num = createWorkorderRecordDTO.getQualifiedNum().add(createWorkorderRecordDTO.getUnQualifiedNum()); |
| | | WorkorderRecord workorderRecord = new WorkorderRecord(); |
| | | //查询工单下是否存在对应记录 |
| | | workorderRecord = workorderRecordExtMapper.selectOne(new QueryWrapper<WorkorderRecord>() |
| | | .eq("WORKORDER_ID",createWorkorderRecordDTO.getWorkorderId()) |
| | | .eq("TYPE",Constants.ONE) |
| | | .eq("DELETED",Constants.ZERO) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(!Objects.isNull(workorderRecord)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,该工单的该类产出记录已存在!"); |
| | | } |
| | | if(num.compareTo(BigDecimal.valueOf(workorder.getPlanNum()))>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,该工单的产出数量不能大于工单计划数量!"); |
| | | } |
| | | //数据存储 |
| | | workorderRecord = new WorkorderRecord(); |
| | | workorderRecord.setDeleted(Constants.ZERO); |
| | | workorderRecord.setCreateUser(loginUserInfo.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()); |
| | | workorderRecord.setFactoryId(workorder.getFactoryId()); |
| | | workorderRecord.setProcedureId(workorder.getProcedureId()); |
| | | workorderRecord.setProDate(new Date()); |
| | | workorderRecord.setType(Constants.ONE); |
| | | workorderRecord.setMaterialId(workorder.getMaterialId()); |
| | | workorderRecord.setUnitId(workorder.getUnitId()); |
| | | workorderRecord.setMaterialBatch(workorder.getBatch()); |
| | | workorderRecord.setUnqualifiedNum(createWorkorderRecordDTO.getUnQualifiedNum()); |
| | | 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.ZERO?num:createWorkorderRecordDTO.getUnQualifiedNum())); |
| | | }else{ |
| | | workorderRecord.setDuration(createWorkorderRecordDTO.getDuration()); |
| | | workorderRecord.setSalary(BigDecimal.valueOf(createWorkorderRecordDTO.getDuration()).multiply(salaryParam.getSalary()).divide(new BigDecimal(3600))); |
| | | } |
| | | |
| | | workorderRecordExtMapper.insert(workorderRecord); |
| | | return workorderRecord; |
| | | } |
| | | |
| | | } |