bug
jiangping
2023-12-06 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5
server/src/main/java/doumeemes/service/ext/impl/WorkPlansExtServiceImpl.java
@@ -33,6 +33,7 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -97,7 +98,9 @@
                || Objects.isNull(workPlansSaveDTO.getNum())
                || Objects.isNull(workPlansSaveDTO.getFactoryId())
                || Objects.isNull(workPlansSaveDTO.getUnitId())
                || Objects.isNull(workPlansSaveDTO.getMaterialId())){
                || Objects.isNull(workPlansSaveDTO.getMaterialId())
                || Objects.isNull(workPlansSaveDTO.getStartDate())
                || workPlansSaveDTO.getStartDate().getTime() > workPlansSaveDTO.getPlanDate().getTime()){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        WorkPlans workPlans = new WorkPlans();
@@ -173,11 +176,15 @@
                    i.setFinishUnQualifiedNum(Objects.isNull(plansExtListVO.getUnqulifiedNum())?Constants.ZERO:plansExtListVO.getUnqulifiedNum());
                    i.setFinishNum(Objects.isNull(plansExtListVO.getDoneNum())?Constants.ZERO:plansExtListVO.getDoneNum());
                }
                if (Objects.nonNull(i.getPlanDate())){
                    i.setHasExpire(DateUtil.toDateLocalDateTime(i.getPlanDate()).toLocalDate().isBefore(LocalDate.now()));
                }else {
                    i.setHasExpire(false);
                i.setHasExpire(false);
                i.setStatus(Constants.formatIntegerNum(i.getStatus()));
                if ( !i.getStatus().equals(Constants.WORKPLANHISTORY_TYPE.done) &&
                        !i.getStatus().equals(Constants.WORKPLANHISTORY_TYPE.close)){
                    if (Objects.nonNull(i.getPlanDate())){
                        i.setHasExpire(DateUtil.toDateLocalDateTime(i.getPlanDate()).toLocalDate().isBefore(LocalDate.now()));
                    }
                }
            });
        }
@@ -372,8 +379,14 @@
        if(Constants.formatIntegerNum(p.getNum())<=0){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(index+2)+"】行【计划生产数量】数据错误!");
        }
        if(p.getStartDate() == null){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(index+2)+"】行【计划开始日期】数据错误,正确格式为:yyyy-MM-dd(如2022-06-07)!");
        }
        if(p.getPlanDate() == null){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(index+2)+"】行【计划日期】数据错误,正确格式为:yyyy-MM-dd(如2022-06-07)!");
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(index+2)+"】行【计划结束日期】数据错误,正确格式为:yyyy-MM-dd(如2022-06-07)!");
        }
        if(p.getPlanDate().getTime() < p.getStartDate().getTime()){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(index+2)+"】行【计划开始日期】要早于【计划结束日期】!");
        }
        if(StringUtils.isBlank(p.getMaterialCode())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(index+2)+"】行【产品编码】数据错误!");
@@ -385,9 +398,8 @@
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(index+2)+"】行【生产批次】数据错误!");
        }
        Date pDate = DateUtil.getDateFromString(DateUtil.getShortTime(p.getPlanDate()) +" 00:00:00");
        Date nDate =  DateUtil.getDateFromString(DateUtil.getShortTime(DateUtil.getCurrentDate()) +" 00:00:00");
        if( nDate.getTime() > pDate.getTime()){
        LocalDateTime localLocalDateTime = DateUtil.toDateLocalDateTime(p.getStartDate());
        if( localLocalDateTime.toLocalDate().isBefore(LocalDate.now())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,计划生产日期必须为今天以后的日期!");
        }
        p.setMaterialCode(p.getMaterialCode().trim());