forked from I3-YF/i3plus-mes-pcn-yfai
装配件匹配
parent
5a954457a4
commit
594edc20ae
@ -0,0 +1,44 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正则表达式匹配
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MesNumberRuleMatchCompareRangeService implements IMesNumberRuleMatchDispatchService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean matchNumberRule(String organizeCode, String sn, Object... params) {
|
||||||
|
Object obj = params[0].toString();
|
||||||
|
if (obj instanceof MesProductionAssemblyNosortContext) {
|
||||||
|
MesProductionAssemblyNosortContext context = (MesProductionAssemblyNosortContext) obj;
|
||||||
|
if (StringUtils.isEmpty(context.getMaxValue()) || StringUtils.isEmpty(context.getMinValue())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Double snValue = Double.parseDouble(sn);
|
||||||
|
if (snValue > context.getMaxValue()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (snValue < context.getMinValue()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base.MesPojoVersionServiceImpl;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自制件规则匹配
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MesNumberRuleMatchSnService implements IMesNumberRuleMatchDispatchService {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(MesNumberRuleMatchSnService.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesProduceSnExtService produceSnExtService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean matchNumberRule(String organizeCode, String sn, Object... params) {
|
||||||
|
|
||||||
|
List<MesProduceSn> produceSnList = produceSnExtService.getProduceSnList(organizeCode, Arrays.asList(sn));
|
||||||
|
if (CollectionUtils.isEmpty(produceSnList)) {
|
||||||
|
LOGGER.info("条码不存在");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
List<MesProduceSn> standardList = produceSnList.stream()
|
||||||
|
.filter(o -> (null != o && o.getSnStatus().compareTo(MesExtEnumUtil.PRODUCE_SN_STATUS.UNKNOW.getValue()) != 0))
|
||||||
|
.sorted(Comparator.comparing(MesProduceSn::getCreateDatetime).reversed())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(standardList)) {
|
||||||
|
LOGGER.info("匹配到的条码不存在");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MesProduceSn mesProduceSn = standardList.get(0);
|
||||||
|
if (StringUtils.isEmpty(mesProduceSn.getSnStatus()) || StringUtils.isEmpty(mesProduceSn.getQcStatus()) || StringUtils.isEmpty(mesProduceSn.getPartNo())) {
|
||||||
|
LOGGER.info("snStatus 为空, 或者 qcStatus为空, 或者 partNo 为空");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Objects.equal(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue(), mesProduceSn.getQcStatus())) {
|
||||||
|
LOGGER.info("条码:{}, 质量状态不合格 qcStatus={}", mesProduceSn.getProductSn(), mesProduceSn.getQcStatus());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Objects.equal(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue(), mesProduceSn.getSnStatus())) {
|
||||||
|
LOGGER.info("条码:{}, 条码状态未完成 snStatus={}", mesProduceSn.getProductSn(), mesProduceSn.getSnStatus());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Object obj = params[0].toString();
|
||||||
|
if (!(obj instanceof MesProductionAssemblyNosortContext)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MesProductionAssemblyNosortContext context = (MesProductionAssemblyNosortContext) obj;
|
||||||
|
if (!Objects.equal(context.getAssemblyPartNo(), mesProduceSn.getPartNo())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 需要校验时效性
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue