jiangping
2023-08-16 7ea82c44c119e30f13451e86911b32ad40ff86d8
server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
@@ -34,6 +34,7 @@
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;
@@ -197,6 +198,14 @@
//                p.setDistributNum(tp.getDistributNum());
//                p.setDoneNum(tp.getDoneNum());
                p.setIsStock(wStockExtService.isStockForPlan(p));
                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()));
                    }else {
                        p.setHasExpire(false);
                    }
                }
            }
        }
        return PageData.from(new PageInfo<>(result));
@@ -1563,14 +1572,17 @@
        if(Objects.isNull(plans)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到工序计划数据");
        }
        if(plans.getStatus().equals(Constants.PLAN_STATUS.create)){
        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 = workorderExtMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId()));
        List<Workorder> workorderList = workorderExtMapper.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){
@@ -1601,6 +1613,15 @@
        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);
    }