| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 生产计划Service实现 |
| | |
| | | private WorkorderRecordStandardService workorderRecordStandardService; |
| | | @Autowired |
| | | private UnqualifiedRecordMapper unqualifiedRecordMapper; |
| | | @Autowired |
| | | private CompanyUserExtMapper companyUserExtMapper; |
| | | |
| | | @Override |
| | | public PlansExtListVO findById(Integer id){ |
| | |
| | | if(user.getProcedureIds()!=null){ |
| | | pageWrap.setProcedureIds(user.getProcedureIds()); |
| | | }else{ |
| | | pageWrap.setUserId(user.getId()); |
| | | pageWrap.setCreateUser(user.getId()); |
| | | } |
| | | List<PlansExtListVO> result = plansExtMapper.selectList(pageWrap); |
| | | if(result==null||result.size()==0){ |
| | |
| | | initPlanStatisticInfo(t); |
| | | PlansExtListH5VO plan = new PlansExtListH5VO(); |
| | | BeanUtils.copyProperties(t,plan); |
| | | // plan.setDoneNum(); |
| | | plan.setWorkorderList(workorderExtService.findByPlanId(plan,true)); |
| | | return plan; |
| | | } |
| | |
| | | pageWrap.getModel().setCreateUser(user.getId()); |
| | | //否则走数据权限 |
| | | pageWrap.getModel().setDepartIds(dataPermission); |
| | | /* if(dataPermission.size() == 0){ |
| | | //只能看自己的 |
| | | pageWrap.getModel().setCreateUser(user.getId()); |
| | | }else{ |
| | | |
| | | }*/ |
| | | } |
| | | if(user.getProcedureIds()!=null){ |
| | | pageWrap.getModel().setProcedureIds(user.getProcedureIds()); |
| | |
| | | List<WorkorderHistory> whList = new ArrayList<>(); |
| | | Workorder order = new Workorder(); |
| | | order.setCreateTime(DateUtil.getCurrentDate()); |
| | | order.setCreateUser(user.getId()); |
| | | order.setCreateUser(param.getCreateUser()); |
| | | order.setDeleted(Constants.ZERO); |
| | | order.setStatus(Constants.WORKORDER_STATUS.create); |
| | | order.setPlanId(mp.getId()); |
| | |
| | | order.setQrcodeId(barcodeParamExtService.getByType(user.getCompany().getId(),mp.getDepartId(),Constants.BARCODEPARAM_TYPE.workorder)); |
| | | order.setProUserList(param.getProUserList()); |
| | | order.setProGroupId(param.getProGroupId()); |
| | | //查询生产班组和人员是否合法 |
| | | checkUserAndGroup(order,mp,user); |
| | | workorderExtMapper.insert(order); |
| | | //查询生产班组和人员是否合法 |
| | | checkUserAndGroupNew(order,mp,user); |
| | | //工单历史数据 |
| | | whList.add(WorkorderExtServiceImpl.initHistoryByModel(order,user.getId(),Constants.WORKORDER_HISTORY_STATUS.create)); |
| | | workorderHistoryExtMapper.insertBatch(whList); |
| | |
| | | workorderUserExtMapper.insert(wu); |
| | | } |
| | | return order; |
| | | } |
| | | |
| | | |
| | | private void checkUserAndGroupNew(Workorder param, PlansExtListVO model,LoginUserInfo user) throws BusinessException{ |
| | | QueryDeviceExtDTO ud = new QueryDeviceExtDTO(); |
| | | ud.setDeleted(Constants.ZERO); |
| | | ud.setId(param.getProGroupId()); |
| | | ud.setRootDepartId(user.getRootDepartment().getId()); |
| | | //查询用户设备关联关系 |
| | | DeviceExtListVO d = deviceExtMapper.selectByModel( ud ); |
| | | if(d == null){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,生产设备信息不正确,请刷新页面重试!"); |
| | | } |
| | | |
| | | List<WorkorderUser> userList = new ArrayList<>(); |
| | | for(Integer userId : param.getProUserList()){ |
| | | WorkorderUser u = new WorkorderUser(); |
| | | u.setProUserId(userId); |
| | | u.setPlanId(model.getId()); |
| | | u.setCreateUser(user.getId()); |
| | | u.setDeleted(Constants.ZERO); |
| | | u.setCreateTime(DateUtil.getCurrentDate()); |
| | | u.setRootDepartId(model.getRootDepartId()); |
| | | u.setDepartId(model.getDepartId()); |
| | | userList.add(u); |
| | | } |
| | | param.setWorkorderUserList(userList); |
| | | |
| | | } |
| | | |
| | | private void checkUserAndGroup(Workorder param, PlansExtListVO model,LoginUserInfo user) throws BusinessException{ |
| | |
| | | public void autoWorkReport(LoginUserInfo user, AutoWorkReportDTO autoWorkReportDTO){ |
| | | if(Objects.isNull(autoWorkReportDTO) |
| | | || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO()) |
| | | || Objects.isNull(autoWorkReportDTO.getProUserList()) |
| | | || Objects.isNull(autoWorkReportDTO.getProUserList().size()==0) |
| | | || 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); |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"参数错误:产出数据"); |
| | | } |
| | | //工单已分配数量 |
| | | Integer produceNum = workorderList.stream().map(s -> s.getPlanNum()).reduce(Constants.ZERO, Integer::sum); |
| | | Integer produceNum = workorderList.stream().map(s -> s.getUnqualifiedNum() + s.getQualifiedNum()).reduce(Constants.ZERO, Integer::sum); |
| | | Integer surplusNum = plans.getNum() - produceNum; |
| | | if(num.compareTo(BigDecimal.valueOf(surplusNum))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"超出当前工序计划可报工数量"); |
| | |
| | | Workorder param = new Workorder(); |
| | | param.setPlanId(autoWorkReportDTO.getPlansId()); |
| | | param.setPlanDate(new Date()); |
| | | // CompanyUser companyUser= companyUserExtMapper.selectById(autoWorkReportDTO.getProUserList().get(Constants.ZERO)); |
| | | param.setCreateUser(autoWorkReportDTO.getProUserList().get(Constants.ZERO)); |
| | | param.setProGroupId(autoWorkReportDTO.getProGroupId()); |
| | | param.setProUserList(autoWorkReportDTO.getProUserList()); |
| | | param.setPlanNum(num.intValue()); |
| | |
| | | } |
| | | //工单产出记录 |
| | | autoWorkReportDTO.getCreateWorkorderRecordDTO().setWorkorderId(workorder.getId()); |
| | | WorkorderRecord workorderRecord = workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); |
| | | WorkorderRecord workorderRecord = workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user,autoWorkReportDTO.getProUserList().get(Constants.ZERO)); |
| | | //工单报工 |
| | | workorderRecordStandardService.comfirmDone(workorder,false); |
| | | //更新工单状态 |