| | |
| | | import doumeemes.core.utils.excel.EasyExcelUtil; |
| | | import doumeemes.core.utils.redis.RedisUtil; |
| | | import doumeemes.dao.business.PlansMapper; |
| | | import doumeemes.dao.business.WorkorderMapper; |
| | | import doumeemes.dao.business.dto.*; |
| | | import doumeemes.dao.business.model.*; |
| | | import doumeemes.dao.ext.*; |
| | | import doumeemes.dao.ext.dto.*; |
| | | import doumeemes.dao.ext.vo.*; |
| | | import doumeemes.service.ext.*; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 生产计划Service实现 |
| | |
| | | private WorkorderHistoryExtMapper workorderHistoryExtMapper; |
| | | @Autowired |
| | | private WorkorderRecordExtMapper workorderRecordExtMapper; |
| | | |
| | | @Autowired |
| | | private WorkorderMapper workorderMapper; |
| | | @Autowired |
| | | private RouteProcedureExtMapper routeProcedureExtMapper; |
| | | @Autowired |
| | |
| | | private MaterialDistributeExtMapper materialDistributeExtMapper; |
| | | @Autowired |
| | | private WStockExtService wStockExtService; |
| | | @Autowired |
| | | private WorkorderRecordStandardService workorderRecordStandardService; |
| | | |
| | | @Override |
| | | public PlansExtListVO findById(Integer id){ |
| | |
| | | // //统计已完工数量 |
| | | // param.setStatus(Constants.WORKORDER_STATUS.done); |
| | | // plan.setDoneNum(workorderExtMapper.sumOrderNum(param)); |
| | | QueryBomExtDTO bb = new QueryBomExtDTO(); |
| | | bb.setDepartId(plan.getDepartId()); |
| | | bb.setDeleted(Constants.ZERO); |
| | | bb.setRootDepartId(user.getRootDepartment().getId()); |
| | | bb.setMaterialId(plan.getMaterialId()); |
| | | bb.setProcedureId(plan.getProcedureId()); |
| | | BomExtListVO versionBom = bomExtMapper.selectByModel( bb); |
| | | if(versionBom == null || StringUtils.isBlank(versionBom.getVersion()) || versionBom.getBomVersionId() == null){ |
| | | plan.setHasBom(Constants.ZERO); |
| | | }else { |
| | | plan.setBomType(Constants.formatIntegerNum(versionBom.getType())); |
| | | plan.setHasBom(Constants.ONE); |
| | | } |
| | | return plan; |
| | | } |
| | | |
| | |
| | | // p.setDistributNum(tp.getDistributNum()); |
| | | // p.setDoneNum(tp.getDoneNum()); |
| | | p.setIsStock(wStockExtService.isStockForPlan(p)); |
| | | p.setHasExpire(false); |
| | | p.setStatus(Constants.formatIntegerNum(p.getStatus())); |
| | | if ( !p.getStatus().equals(Constants.PLAN_STATUS.done) && |
| | | !p.getStatus().equals(Constants.PLAN_STATUS.close)){ |
| | | if (Objects.nonNull(p.getPlanDate())){ |
| | | p.setHasExpire(DateUtil.toDateLocalDateTime(p.getWorkPlanPlanDate()).toLocalDate().isBefore(LocalDate.now())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return PageData.from(new PageInfo<>(result)); |
| | |
| | | distributeDone(user, param,param.getPlanNum()); |
| | | } |
| | | |
| | | private void distributeDone(LoginUserInfo user, Workorder param,int thisPlanNum) { |
| | | private Workorder distributeDone(LoginUserInfo user, Workorder param,int thisPlanNum) { |
| | | if(param.getPlanId()== null |
| | | ||param.getPlanDate() == null |
| | | || param.getProGroupId()==null |
| | |
| | | if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,计划已暂停!"); |
| | | } |
| | | if(Constants.formatIntegerNum(mp.getDistributNum())+thisPlanNum > Constants.formatIntegerNum(mp.getNum())){ |
| | | if(Constants.formatIntegerNum(mp.getWorkorderDistributNum())+thisPlanNum > Constants.formatIntegerNum(mp.getNum())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,累计分配数量大于计划数量!"); |
| | | } |
| | | if(!Constants.equalsInteger(mp.getStatus(),Constants.PLAN_STATUS.publish)&&!Constants.equalsInteger(mp.getStatus(),Constants.PLAN_STATUS.distribute)){ |
| | |
| | | //生产人员记录 |
| | | workorderUserExtMapper.insert(wu); |
| | | } |
| | | |
| | | return order; |
| | | } |
| | | |
| | | private void checkUserAndGroup(Workorder param, PlansExtListVO model,LoginUserInfo user) throws BusinessException{ |
| | |
| | | } |
| | | /** |
| | | * 恢复计划 |
| | | * @param p |
| | | * @param |
| | | */ |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | @Override |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 一键报工 |
| | | * @param user |
| | | */ |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | @Override |
| | | public void autoWorkReport(LoginUserInfo user, AutoWorkReportDTO autoWorkReportDTO){ |
| | | //查询工工序计划状态 |
| | | Plans plans = plansExtMapper.selectById(autoWorkReportDTO.getPlansId()); |
| | | if(Objects.isNull(plans)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到工序计划数据"); |
| | | } |
| | | if(!(plans.getStatus().equals(Constants.PLAN_STATUS.create)||plans.getStatus().equals(Constants.PLAN_STATUS.distribute))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"工序计划已流转,无法操作"); |
| | | } |
| | | if(plans.getPaused().equals(Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"工序计划已暂停,无法操作"); |
| | | } |
| | | if(Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"参数错误:产出数据"); |
| | | } |
| | | //查询工序计划已分配数量 |
| | | List<Workorder> workorderList = workorderMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId()) |
| | | .notIn("STATUS",7,8)); |
| | | //本次产出数量 |
| | | BigDecimal num = autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum()); |
| | | if(num.compareTo(BigDecimal.ZERO)<=Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"参数错误:产出数据"); |
| | | } |
| | | //工单已分配数量 |
| | | Integer produceNum = workorderList.stream().map(s -> s.getPlanNum()).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()); |
| | | param.setProGroupId(autoWorkReportDTO.getProGroupId()); |
| | | param.setProUserList(autoWorkReportDTO.getProUserList()); |
| | | param.setPlanNum(plans.getNum()); |
| | | //生成工单信息 |
| | | Workorder workorder = this.distributeDone(user,param,plans.getNum()); |
| | | //工单投料记录 |
| | | CreateMaterialDTO createMaterialDTO = new CreateMaterialDTO(); |
| | | if(!Objects.isNull(autoWorkReportDTO.getRecordList())&&autoWorkReportDTO.getRecordList().size()>Constants.ZERO){ |
| | | createMaterialDTO.setId(workorder.getId()); |
| | | createMaterialDTO.setRecordList(autoWorkReportDTO.getRecordList()); |
| | | workorderRecordStandardService.createMaterialStandard(createMaterialDTO); |
| | | } |
| | | //工单产出记录 |
| | | autoWorkReportDTO.getCreateWorkorderRecordDTO().setWorkorderId(workorder.getId()); |
| | | workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); |
| | | //工单报工 |
| | | workorderRecordStandardService.comfirmDone(workorder); |
| | | //更新工单状态 |
| | | if(num.compareTo(BigDecimal.valueOf(surplusNum))==Constants.ZERO){ |
| | | plans.setStatus(Constants.PLAN_STATUS.done); |
| | | }else{ |
| | | if(plans.getStatus().equals(Constants.PLAN_STATUS.create)){ |
| | | plans.setStatus(Constants.PLAN_STATUS.distribute); |
| | | } |
| | | } |
| | | plansExtMapper.updateById(plans); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |