|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.foreverwin.mesnac.common.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
@ -7,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.foreverwin.mesnac.common.constant.Constants;
|
|
|
|
|
import com.foreverwin.mesnac.common.enums.HandleEnum;
|
|
|
|
|
import com.foreverwin.mesnac.common.enums.InspectionTypeEnum;
|
|
|
|
|
import com.foreverwin.mesnac.common.mapper.InspectionItemMapper;
|
|
|
|
|
import com.foreverwin.mesnac.common.model.InspectionItem;
|
|
|
|
|
import com.foreverwin.mesnac.common.model.InspectionItemAddition;
|
|
|
|
@ -16,16 +18,19 @@ import com.foreverwin.mesnac.common.service.InspectionItemDetailService;
|
|
|
|
|
import com.foreverwin.mesnac.common.service.InspectionItemService;
|
|
|
|
|
import com.foreverwin.mesnac.common.util.StringUtil;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.Item;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.Operation;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.ResourceType;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.service.ItemService;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.service.OperationService;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.service.ResourceTypeService;
|
|
|
|
|
import com.foreverwin.modular.core.exception.BaseException;
|
|
|
|
|
import com.foreverwin.modular.core.util.CommonMethods;
|
|
|
|
|
import com.foreverwin.modular.core.util.FrontPage;
|
|
|
|
|
import com.visiprise.common.exception.BaseException;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -46,6 +51,8 @@ public class InspectionItemServiceImpl extends ServiceImpl<InspectionItemMapper,
|
|
|
|
|
@Autowired
|
|
|
|
|
private ItemService itemService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private OperationService operationService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ResourceTypeService resourceTypeService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private InspectionItemMapper inspectionItemMapper;
|
|
|
|
@ -229,5 +236,210 @@ public class InspectionItemServiceImpl extends ServiceImpl<InspectionItemMapper,
|
|
|
|
|
return inspectionItemDetails;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void insert(JSONObject jsonObject) {
|
|
|
|
|
String user = CommonMethods.getUser();
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
String description = jsonObject.getString("description");
|
|
|
|
|
String site = jsonObject.getString("site");
|
|
|
|
|
String inspectionType = jsonObject.getString("inspectionType");
|
|
|
|
|
inspectionType = InspectionTypeEnum.getValue(inspectionType);
|
|
|
|
|
if (inspectionType==null){
|
|
|
|
|
throw new BaseException("不存在的检验类型");
|
|
|
|
|
}
|
|
|
|
|
String inspectionItemNo = jsonObject.getString("inspectionItemNo");
|
|
|
|
|
if (StringUtil.isBlank(inspectionItemNo)){
|
|
|
|
|
throw new BaseException("检验项目编号不能为空");
|
|
|
|
|
}
|
|
|
|
|
String revision = jsonObject.getString("revision");
|
|
|
|
|
if (StringUtil.isBlank(revision)){
|
|
|
|
|
throw new BaseException("版本不能为空");
|
|
|
|
|
}
|
|
|
|
|
String item = jsonObject.getString("item");
|
|
|
|
|
String operation = jsonObject.getString("operation");
|
|
|
|
|
if (StringUtil.isBlank(operation)){
|
|
|
|
|
throw new BaseException("工序不能为空");
|
|
|
|
|
}
|
|
|
|
|
String resrceType = jsonObject.getString("resrceType");
|
|
|
|
|
String paramNo = jsonObject.getString("paramNo");
|
|
|
|
|
if (StringUtil.isBlank(paramNo)){
|
|
|
|
|
throw new BaseException("参数名称不能为空");
|
|
|
|
|
}
|
|
|
|
|
String paramDescription = jsonObject.getString("paramDescription");
|
|
|
|
|
String inspectionMethod = jsonObject.getString("inspectionMethod");
|
|
|
|
|
if (StringUtil.isBlank(inspectionMethod)){
|
|
|
|
|
throw new BaseException("检验方法不能为空");
|
|
|
|
|
}
|
|
|
|
|
String paramType = jsonObject.getString("paramType");
|
|
|
|
|
paramType = InspectionTypeEnum.getValue(paramType);
|
|
|
|
|
if (StringUtil.isBlank(paramType)){
|
|
|
|
|
throw new BaseException("不存在的参数类型");
|
|
|
|
|
}
|
|
|
|
|
String decimalNum = jsonObject.getString("decimalNum");
|
|
|
|
|
String paramUnit = jsonObject.getString("paramUnit");
|
|
|
|
|
String maxValue = jsonObject.getString("maxValue");
|
|
|
|
|
String standardValue = jsonObject.getString("standardValue");
|
|
|
|
|
String minValue = jsonObject.getString("minValue");
|
|
|
|
|
String falseValue = jsonObject.getString("falseValue");
|
|
|
|
|
String trueValue = jsonObject.getString("trueValue");
|
|
|
|
|
String isRequired = jsonObject.getString("isRequired");
|
|
|
|
|
if (StringUtil.isBlank(isRequired)){
|
|
|
|
|
throw new BaseException("是否重要项不能为空");
|
|
|
|
|
}
|
|
|
|
|
String checkNum = jsonObject.getString("checkNum");
|
|
|
|
|
String handle = HandleEnum.INSPECTION_ITEM.getHandle(site, inspectionItemNo, revision);
|
|
|
|
|
InspectionItem byId = getById(handle);
|
|
|
|
|
if (byId==null){
|
|
|
|
|
InspectionItem entity=new InspectionItem();
|
|
|
|
|
entity.setHandle(HandleEnum.INSPECTION_ITEM.getHandle(site,inspectionItemNo,revision));
|
|
|
|
|
entity.setSite(site);
|
|
|
|
|
entity.setInspectionItemNo(inspectionItemNo);
|
|
|
|
|
if (inspectionType.length() > 1) {
|
|
|
|
|
entity.setCategory("EQ");
|
|
|
|
|
} else {
|
|
|
|
|
entity.setCategory("QC");
|
|
|
|
|
}
|
|
|
|
|
entity.setInspectionType(inspectionType);
|
|
|
|
|
entity.setRevision(revision);
|
|
|
|
|
entity.setCurrentRevision(Constants.BOOL_TRUE);
|
|
|
|
|
entity.setDescription(description);
|
|
|
|
|
entity.setStatus(Constants.STATUS_Y);
|
|
|
|
|
entity.setCreateUser(user);
|
|
|
|
|
entity.setCreatedDateTime(now);
|
|
|
|
|
entity.setModifyUser(user);
|
|
|
|
|
entity.setModifiedDateTime(now);
|
|
|
|
|
entity.setCategory(user);
|
|
|
|
|
save(entity);
|
|
|
|
|
}
|
|
|
|
|
ResourceType selectResourceType = null;
|
|
|
|
|
Item currentItem = null;
|
|
|
|
|
Operation currentRevisionRef = null;
|
|
|
|
|
if (inspectionType.length() == 1) {
|
|
|
|
|
if (StringUtil.isBlank(item)){
|
|
|
|
|
throw new BaseException("物料不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isBlank(operation)){
|
|
|
|
|
throw new BaseException("工序不能为空");
|
|
|
|
|
}
|
|
|
|
|
if ( !item.equals("*")) {
|
|
|
|
|
currentItem = itemService.selectCurrent(CommonMethods.getSite(), item);
|
|
|
|
|
if (currentItem == null) {
|
|
|
|
|
throw new BaseException("物料[" + item + "]不存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!operation.equals("*")) {
|
|
|
|
|
String[] split = operation.split("/");
|
|
|
|
|
String op = split[0];
|
|
|
|
|
currentRevisionRef = operationService.getCurrentRevisionRef(site, op);
|
|
|
|
|
String step = split[1];
|
|
|
|
|
Integer integer = inspectionItemMapper.checkRouterStep(site, op, step);
|
|
|
|
|
if (integer < 1) {
|
|
|
|
|
throw new BaseException("工序/步骤[" + operation + "]不存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
if (StringUtil.notBlank(resrceType)&&!resrceType.equals("*")) {
|
|
|
|
|
String resourceTypeHandle = HandleEnum.RESOURCE_TYPE.getHandle(site, resrceType);
|
|
|
|
|
selectResourceType = resourceTypeService.getById(resourceTypeHandle);
|
|
|
|
|
if (selectResourceType == null) {
|
|
|
|
|
throw new BaseException("设备类型[" + resrceType + "]不存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QueryWrapper queryWrapper=new QueryWrapper<InspectionItemAddition>();
|
|
|
|
|
queryWrapper.eq(InspectionItemAddition.INSPECTION_ITEM_BO,handle);
|
|
|
|
|
List<InspectionItemAddition> additionList = inspectionItemAdditionService.list(queryWrapper);
|
|
|
|
|
if (additionList.size()>0){
|
|
|
|
|
for (InspectionItemAddition inspectionItemAddition : additionList) {
|
|
|
|
|
if (inspectionItemAddition.getAdditionalObjectType().equals(Constants.ADDITIONAL_OBJECT_TYPE_ITEM)&&!inspectionItemAddition.getAdditionalObject().equals(item)){
|
|
|
|
|
throw new BaseException("检验项目中物料[" + item + "]不相同");
|
|
|
|
|
}
|
|
|
|
|
if (inspectionItemAddition.getAdditionalObjectType().equals(Constants.ADDITIONAL_OBJECT_TYPE_OPERATION)&&!inspectionItemAddition.getAdditionalObject().equals(operation)){
|
|
|
|
|
throw new BaseException("检验项目中工序[" + operation + "]不相同");
|
|
|
|
|
}
|
|
|
|
|
if (inspectionItemAddition.getAdditionalObjectType().equals(Constants.ADDITIONAL_OBJECT_TYPE_RESOURCE_TYPE)&&!inspectionItemAddition.getAdditionalObject().equals(resrceType)){
|
|
|
|
|
throw new BaseException("检验项目中设备类型[" + resrceType + "]不相同");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
if (inspectionType.length()==1){
|
|
|
|
|
InspectionItemAddition itemAddition = new InspectionItemAddition();
|
|
|
|
|
itemAddition.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
itemAddition.setInspectionItemBo(handle);
|
|
|
|
|
itemAddition.setSeq(1L);
|
|
|
|
|
itemAddition.setAdditionalObjectType(Constants.ADDITIONAL_OBJECT_TYPE_ITEM);
|
|
|
|
|
itemAddition.setAdditionalObject(item);
|
|
|
|
|
itemAddition.setDescription(currentItem.getDescription());
|
|
|
|
|
itemAddition.setCreateUser(user);
|
|
|
|
|
itemAddition.setCreatedDateTime(now);
|
|
|
|
|
itemAddition.setModifyUser(user);
|
|
|
|
|
itemAddition.setModifiedDateTime(now);
|
|
|
|
|
inspectionItemAdditionService.save(itemAddition);
|
|
|
|
|
InspectionItemAddition operationAddition = new InspectionItemAddition();
|
|
|
|
|
operationAddition.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
operationAddition.setInspectionItemBo(handle);
|
|
|
|
|
operationAddition.setSeq(2L);
|
|
|
|
|
operationAddition.setAdditionalObjectType(Constants.ADDITIONAL_OBJECT_TYPE_OPERATION);
|
|
|
|
|
operationAddition.setAdditionalObject(operation);
|
|
|
|
|
operationAddition.setDescription(currentRevisionRef.getDescription());
|
|
|
|
|
operationAddition.setCreateUser(user);
|
|
|
|
|
operationAddition.setCreatedDateTime(now);
|
|
|
|
|
operationAddition.setModifyUser(user);
|
|
|
|
|
operationAddition.setModifiedDateTime(now);
|
|
|
|
|
inspectionItemAdditionService.save(operationAddition);
|
|
|
|
|
}else {
|
|
|
|
|
if (StringUtil.notBlank(resrceType)){
|
|
|
|
|
InspectionItemAddition inspectionItemAddition = new InspectionItemAddition();
|
|
|
|
|
inspectionItemAddition.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
inspectionItemAddition.setInspectionItemBo(handle);
|
|
|
|
|
inspectionItemAddition.setSeq(1L);
|
|
|
|
|
inspectionItemAddition.setAdditionalObjectType(Constants.ADDITIONAL_OBJECT_TYPE_RESOURCE_TYPE);
|
|
|
|
|
inspectionItemAddition.setAdditionalObject(resrceType);
|
|
|
|
|
inspectionItemAddition.setDescription(selectResourceType.getDescription());
|
|
|
|
|
inspectionItemAddition.setCreateUser(user);
|
|
|
|
|
inspectionItemAddition.setCreatedDateTime(now);
|
|
|
|
|
inspectionItemAddition.setModifyUser(user);
|
|
|
|
|
inspectionItemAddition.setModifiedDateTime(now);
|
|
|
|
|
inspectionItemAdditionService.save(inspectionItemAddition);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
queryWrapper=new QueryWrapper<InspectionItemDetail>();
|
|
|
|
|
queryWrapper.eq(InspectionItemDetail.INSPECTION_ITEM_BO,handle);
|
|
|
|
|
List<InspectionItemDetail> inspectionItemDetailList = inspectionItemDetailService.list(queryWrapper);
|
|
|
|
|
if (inspectionItemDetailList.size()>0){
|
|
|
|
|
long count = inspectionItemDetailList.stream().filter(inspectionItemDetail ->
|
|
|
|
|
inspectionItemDetail.getParamNo().equals(paramNo)
|
|
|
|
|
).count();
|
|
|
|
|
if (count>0){
|
|
|
|
|
throw new BaseException("检验名称不能重复");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
InspectionItemDetail inspectionItemDetail = new InspectionItemDetail();
|
|
|
|
|
inspectionItemDetail.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
inspectionItemDetail.setInspectionItemBo(handle);
|
|
|
|
|
inspectionItemDetail.setSeq(new Long(inspectionItemDetailList.size())+1L);
|
|
|
|
|
inspectionItemDetail.setParamNo(paramNo);
|
|
|
|
|
inspectionItemDetail.setDescription(paramDescription);
|
|
|
|
|
inspectionItemDetail.setInspectionMethod(inspectionMethod);
|
|
|
|
|
inspectionItemDetail.setParamType(paramType);
|
|
|
|
|
inspectionItemDetail.setParamUnit(paramUnit);
|
|
|
|
|
inspectionItemDetail.setDecimalNum(StringUtil.isBlank(decimalNum)?null:new Long(decimalNum));
|
|
|
|
|
inspectionItemDetail.setMinValue(StringUtil.isBlank(minValue)?null:new BigDecimal(minValue));
|
|
|
|
|
inspectionItemDetail.setStandardValue(standardValue);
|
|
|
|
|
inspectionItemDetail.setMaxValue(StringUtil.isBlank(maxValue)?null:new BigDecimal(maxValue));
|
|
|
|
|
inspectionItemDetail.setFalseValue(falseValue);
|
|
|
|
|
inspectionItemDetail.setTrueValue(trueValue);
|
|
|
|
|
inspectionItemDetail.setIsRequired(isRequired.equals("是")?"Y":"N");
|
|
|
|
|
inspectionItemDetail.setCheckNum(StringUtil.isBlank(checkNum)?null:new Long(checkNum));
|
|
|
|
|
inspectionItemDetail.setCreateUser(user);
|
|
|
|
|
inspectionItemDetail.setCreatedDateTime(now);
|
|
|
|
|
inspectionItemDetail.setModifyUser(user);
|
|
|
|
|
inspectionItemDetail.setModifiedDateTime(now);
|
|
|
|
|
inspectionItemDetailService.save(inspectionItemDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|