forked from I3-YF/i3plus-mes-pcn-yfai
规则策略
parent
22560a0a8b
commit
e1f5ed5610
@ -0,0 +1,69 @@
|
||||
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.pojo.context.MesProductionAssemblyNosortContext;
|
||||
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly;
|
||||
import cn.estsh.i3plus.pojo.mes.repository.MesProductionAssemblyRepository;
|
||||
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.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 外协件规则匹配且唯一
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MesNumberRuleMatchAndUniqueService implements IMesNumberRuleMatchDispatchService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MesNumberRuleMatchAndUniqueService.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private IMesProduceSnExtService produceSnExtService;
|
||||
@Resource
|
||||
@Qualifier("mesNumberRuleMatchRegularExpressionService")
|
||||
private IMesNumberRuleMatchDispatchService mesNumberRuleMatchDispatchService;
|
||||
@Autowired
|
||||
private MesProductionAssemblyRepository productionAssemblyRepository;
|
||||
@Override
|
||||
public Boolean matchNumberRule(String organizeCode, String sn, Object... params) {
|
||||
// 校验正则表达式
|
||||
boolean flag = mesNumberRuleMatchDispatchService.matchNumberRule(organizeCode, sn, params);
|
||||
// 校验是否唯一
|
||||
boolean uniqueFlag = validateUnique(sn);
|
||||
|
||||
return flag && uniqueFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证唯一
|
||||
* @param sn
|
||||
* @return
|
||||
*/
|
||||
private boolean validateUnique(String sn) {
|
||||
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
|
||||
DdlPreparedPack.getStringEqualPack(sn,"assemblySn", ddlPackBean);
|
||||
MesProductionAssembly productionAssembly = productionAssemblyRepository.getByProperty(ddlPackBean);
|
||||
if (productionAssembly != null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue