|
|
@ -1,29 +1,8 @@ |
|
|
|
package com.win.module.qms.service.inspectionRequest; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
|
|
|
import static com.win.module.qms.enums.ErrorCodeConstants.*; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.INSPECT_REQUEST_CANNOT_CLOSE; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.PLEASE_DO_NOT_RESUBMIT; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern; |
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
@ -84,12 +63,30 @@ import com.win.module.system.api.serialnumber.SerialNumberApi; |
|
|
|
import com.win.module.system.enums.serialNumber.RuleCodeEnum; |
|
|
|
import com.win.module.wms.api.requestsetting.RequestsettingApi; |
|
|
|
import com.win.module.wms.api.requestsetting.dto.RequestsettingDto; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern; |
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import io.swagger.v3.oas.annotations.media.Schema; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
|
|
|
import static com.win.module.qms.enums.ErrorCodeConstants.*; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.INSPECT_REQUEST_CANNOT_CLOSE; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.PLEASE_DO_NOT_RESUBMIT; |
|
|
|
|
|
|
|
/** |
|
|
|
* 检验申请 Service 实现类 |
|
|
@ -154,7 +151,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
validateInspectionRequestMainExists(updateReqVO.getId()); |
|
|
|
// 更新
|
|
|
|
InspectionRequestMainDO inspectionRequestMainDO = InspectionRequestMainConvert.INSTANCE.convert(updateReqVO); |
|
|
|
trendsApi.createTrendsByTask(inspectionRequestMainDO.getId(), "request_inspection_main", "修改了检验申请", TrendsTypeEnum.UPDATE, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(inspectionRequestMainDO.getId(), "request_inspection_main", "修改了检验申请", TrendsTypeEnum.UPDATE, String.valueOf(getLoginUserId())); |
|
|
|
return inspectionRequestMainMapper.updateById(inspectionRequestMainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -167,7 +164,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
} |
|
|
|
// 删除
|
|
|
|
int result = inspectionRequestMainMapper.deleteById(id); |
|
|
|
trendsApi.createTrendsByTask(id, "request_inspection_main", "删除了检验申请", TrendsTypeEnum.DELETE, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(id, "request_inspection_main", "删除了检验申请", TrendsTypeEnum.DELETE, String.valueOf(getLoginUserId())); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -204,8 +201,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
try { |
|
|
|
inspectionRequestMainCreateReqVO.setExistException(false); |
|
|
|
InspectionRequestMainDO inspectionRequestMainDO = this.createInspectionRequestMainVo(inspectionRequestMainCreateReqVO); |
|
|
|
inspectionRequestMainCreateReqVO.setRemark( |
|
|
|
"检验申请创建成功,物料代码:" + inspectionRequestMainDO.getItemCode() + ",创建时间:" + LocalDateTimeUtil.format(inspectionRequestMainDO.getCreateTime(), DatePattern.NORM_DATETIME_FORMATTER)); |
|
|
|
inspectionRequestMainCreateReqVO.setRemark("检验申请创建成功,物料代码:" + inspectionRequestMainDO.getItemCode() + ",创建时间:" + LocalDateTimeUtil.format(inspectionRequestMainDO.getCreateTime(), DatePattern.NORM_DATETIME_FORMATTER)); |
|
|
|
} catch (Exception ex) { |
|
|
|
inspectionRequestMainCreateReqVO.setRemark(ex.getMessage()); |
|
|
|
inspectionRequestMainCreateReqVO.setExistException(true); |
|
|
@ -316,7 +312,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
} |
|
|
|
} |
|
|
|
inspectionRequestMainCreateReqVO.setNumber(number); |
|
|
|
trendsApi.createTrendsByTask(inspectionRequestMainDO.getId(), "request_inspection_main", "创建了检验申请", TrendsTypeEnum.CREATE, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(inspectionRequestMainDO.getId(), "request_inspection_main", null, "创建了检验申请", JSONUtil.toJsonStr(inspectionRequestMainDO), TrendsTypeEnum.CREATE, String.valueOf(getLoginUserId())); |
|
|
|
return inspectionRequestMainDO; |
|
|
|
} |
|
|
|
|
|
|
@ -335,7 +331,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
throw new ServiceException(INSPECT_REQUEST_CANNOT_CLOSE); |
|
|
|
} |
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode());// 增加操作记录
|
|
|
|
trendsApi.createTrendsByTask(id, "request_inspection_main", "关闭了检验申请", TrendsTypeEnum.REQUEST_CLOSE, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(id, "request_inspection_main", "关闭了检验申请", TrendsTypeEnum.REQUEST_CLOSE, String.valueOf(getLoginUserId())); |
|
|
|
return inspectionRequestMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -353,7 +349,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
if (RequestStatusEnum.HANDLING.getCode().equals(mainDO.getStatus())) { |
|
|
|
this.generateJob(mainDO); |
|
|
|
} |
|
|
|
trendsApi.createTrendsByTask(id, "request_inspection_main", "提交了检验申请", TrendsTypeEnum.REQUEST_SUBMIT, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(id, "request_inspection_main", "提交了检验申请", TrendsTypeEnum.REQUEST_SUBMIT, String.valueOf(getLoginUserId())); |
|
|
|
return inspectionRequestMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -372,7 +368,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
throw new ServiceException(INSPECTION_REQUEST_CANNOT_RE_ADD); |
|
|
|
} |
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode());// 增加操作记录
|
|
|
|
trendsApi.createTrendsByTask(id, "request_inspection_main", "重新打开了检验申请", TrendsTypeEnum.REQUEST_RE_ADD, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(id, "request_inspection_main", "重新打开了检验申请", TrendsTypeEnum.REQUEST_RE_ADD, String.valueOf(getLoginUserId())); |
|
|
|
return inspectionRequestMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -391,7 +387,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
if (RequestStatusEnum.HANDLING.getCode().equals(mainDO.getStatus())) { |
|
|
|
this.generateJob(mainDO); |
|
|
|
} |
|
|
|
trendsApi.createTrendsByTask(id, "request_inspection_main", "审批同意了检验申请", TrendsTypeEnum.REQUEST_AGREE, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(id, "request_inspection_main", "审批同意了检验申请", TrendsTypeEnum.REQUEST_AGREE, String.valueOf(getLoginUserId())); |
|
|
|
return inspectionRequestMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -408,7 +404,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
|
// 调用执行方法
|
|
|
|
this.generateJob(mainDO); |
|
|
|
trendsApi.createTrendsByTask(id, "request_inspection_main", "处理了检验申请", TrendsTypeEnum.REQUEST_HANDLE, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(id, "request_inspection_main", "处理了检验申请", TrendsTypeEnum.REQUEST_HANDLE, String.valueOf(getLoginUserId())); |
|
|
|
int updateCnt = inspectionRequestMainMapper.updateById(mainDO); |
|
|
|
if (updateCnt == 0) { |
|
|
|
throw exception(PLEASE_DO_NOT_RESUBMIT); |
|
|
@ -427,7 +423,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
throw new ServiceException(INSPECTION_REQUEST_CANNOT_REFUSED); |
|
|
|
} |
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
|
trendsApi.createTrendsByTask(id, "request_inspection_main", "审批拒绝了检验申请", TrendsTypeEnum.REQUEST_REFUSED, getLoginUserId().toString()); |
|
|
|
trendsApi.createTrends(id, "request_inspection_main", "审批拒绝了检验申请", TrendsTypeEnum.REQUEST_REFUSED, String.valueOf(getLoginUserId())); |
|
|
|
return inspectionRequestMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -439,7 +435,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
queryWrapper.eq("callback_request_number", callbackRequestNumber); |
|
|
|
queryWrapper.eq("available", "TRUE"); |
|
|
|
List<InspectionRequestMainDO> inspectionRequestMainDOList = inspectionRequestMainMapper.selectList(queryWrapper); |
|
|
|
if (inspectionRequestMainDOList.size() > 0) { |
|
|
|
if (!inspectionRequestMainDOList.isEmpty()) { |
|
|
|
result = true; |
|
|
|
} |
|
|
|
return result; |
|
|
@ -556,8 +552,8 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
inspectionJobCharacteristicsDO.setCreator(inspectionRequestMainDO.getCreator()); |
|
|
|
inspectionJobCharacteristicsDO.setUpdater(inspectionRequestMainDO.getCreator()); |
|
|
|
inspectionJobCharacteristicsMainMapper.insert(inspectionJobCharacteristicsDO); |
|
|
|
trendsApi.createTrends(inspectionJobMainDO.getId(), "job_inspection_main", null, "创建了检验任务", JSONUtil.toJsonStr(inspectionJobDetailDO) ,TrendsTypeEnum.CREATE, inspectionRequestMainDO.getCreator()); |
|
|
|
} |
|
|
|
trendsApi.createTrendsByTask(inspectionJobMainDO.getId(), "job_inspection_main", "创建了检验任务", TrendsTypeEnum.CREATE, inspectionRequestMainDO.getCreator()); |
|
|
|
return number; |
|
|
|
} |
|
|
|
|
|
|
@ -705,6 +701,7 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
inspectionRecordCharacteristicsDO.setCreator(inspectionRequestMainDO.getCreator()); |
|
|
|
inspectionRecordCharacteristicsDO.setUpdater(inspectionRequestMainDO.getUpdater()); |
|
|
|
inspectionRecordCharacteristicsMainMapper.insert(inspectionRecordCharacteristicsDO); |
|
|
|
trendsApi.createTrends(inspectionRecordMainDO.getId(), "record_inspection_main", null, "创建了检验记录", JSONUtil.toJsonStr(inspectionRecordDetailDO), TrendsTypeEnum.CREATE, String.valueOf(getLoginUserId())); |
|
|
|
} |
|
|
|
// 生成记录之后修改状态为完成
|
|
|
|
inspectionRequestMainDO.setStatus(RequestStatusEnum.COMPLETED.getCode()); |
|
|
@ -721,12 +718,10 @@ public class InspectionRequestMainServiceImpl implements InspectionRequestMainSe |
|
|
|
} |
|
|
|
inspectionRecordMainUpdateReqVO.setPackageList(inspectionRecordPackageUpdateReqVOList); |
|
|
|
inspectionRecordMainUpdateReqVO.setAvailable(Schema.AdditionalPropertiesValue.TRUE.toString()); |
|
|
|
trendsApi.createTrendsByTask(inspectionRecordMainDO.getId(), "record_inspection_main", "创建了检验记录", TrendsTypeEnum.CREATE, getLoginUserId().toString()); |
|
|
|
// 更新使用决策
|
|
|
|
inspectionRecordMainService.updateInspectionRecordMain(inspectionRecordMainUpdateReqVO); |
|
|
|
// 发布
|
|
|
|
inspectionRecordMainService.publishInspectionRecordMain(inspectionRecordMainDO.getId()); |
|
|
|
trendsApi.createTrendsByTask(inspectionRecordMainDO.getId(), "record_inspection_main", "创建了检验记录", TrendsTypeEnum.CREATE, inspectionRequestMainDO.getCreator()); |
|
|
|
} |
|
|
|
|
|
|
|
private InspectionRequestMainDO validateInspectionRequestMainExists(Long id) { |
|
|
|