| | |
| | | import doumeemes.core.utils.excel.EasyExcelUtil; |
| | | import doumeemes.core.utils.redis.RedisUtil; |
| | | import doumeemes.dao.business.PlansMapper; |
| | | 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 java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 生产计划Service实现 |
| | |
| | | private MaterialDistributeExtMapper materialDistributeExtMapper; |
| | | @Autowired |
| | | private WStockExtService wStockExtService; |
| | | @Autowired |
| | | private WorkorderRecordStandardService workorderRecordStandardService; |
| | | |
| | | @Override |
| | | public PlansExtListVO findById(Integer id){ |
| | |
| | | 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 |
| | |
| | | //生产人员记录 |
| | | workorderUserExtMapper.insert(wu); |
| | | } |
| | | |
| | | return order; |
| | | } |
| | | |
| | | private void checkUserAndGroup(Workorder param, PlansExtListVO model,LoginUserInfo user) throws BusinessException{ |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 一键报工 |
| | | * @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)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"工序计划已流转,无法操作"); |
| | | } |
| | | if(Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"参数错误:产出数据"); |
| | | } |
| | | //查询工序计划已分配数量 |
| | | List<Workorder> workorderList = workorderExtMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId())); |
| | | //本次产出数量 |
| | | 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()); |
| | | List<Integer> proUserList = new ArrayList<Integer>(); |
| | | //TODO |
| | | proUserList.add(user.getId()); |
| | | param.setProUserList(proUserList); |
| | | 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); |
| | | } |
| | | //工单产出记录 |
| | | workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); |
| | | //工单报工 |
| | | workorderRecordStandardService.comfirmDone(workorder); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |