|
|
|
@ -7,13 +7,17 @@ import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.MesReturnModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.*;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class DcsForEquipmentServiceImpl implements IDcsForEquipmentService {
|
|
|
|
|
|
|
|
|
@ -33,8 +37,12 @@ public class DcsForEquipmentServiceImpl implements IDcsForEquipmentService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesCustomerPartRepository customerPartRao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesProductionRecordRepository recordRao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String doGetConsoleItemCode(String organizeCode,String barcode, String custCode, String custPlantCode, String workCenterCode, String workCellCode) {
|
|
|
|
|
public String doGetConsoleItemCode(String barcode, String custCode, String custPlantCode, String workCenterCode, String workCellCode) {
|
|
|
|
|
//通用二维码组成部分('RS'为记录分隔符ASCII:30,'GS'为分组符ASCII:29,'EOT'为传输结束符ASCII:04)
|
|
|
|
|
//[)>+'RS'+06+'GS'+Y+vpps+'GS'+P+8位客户零件号+'GS'+12V+DUNS+'GS'+T+1位line num+1位班次号+2位年份+3位天数+1位追溯(精确追溯A,批次追溯@)+2工程更改记录+2位自定义+4位流水号+'RS'+'EOT'
|
|
|
|
|
//如:[)>+'RS'+06+'GS'+Y+4110000000000X+'GS'+P+12345678+'GS'+12V+545295227+'GS'+T+1A13304A2B4C0001+'RS'+'EOT'
|
|
|
|
@ -43,21 +51,23 @@ public class DcsForEquipmentServiceImpl implements IDcsForEquipmentService {
|
|
|
|
|
barcode = mesCustomerSnTransformService.transformBarCodeGm(barcode);
|
|
|
|
|
|
|
|
|
|
//todo 读取配置文件 获取工厂
|
|
|
|
|
if (StringUtils.isBlank(organizeCode)) {
|
|
|
|
|
String organizeCode;
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getStringEqualPack("ORGANIZE_CODE","cfgCode",ddlPackBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack("ORGANIZE_CODE","cfgKey",ddlPackBean);
|
|
|
|
|
List<MesConfig> organizeConfig = mesConfigRao.findByHqlWhere(ddlPackBean);
|
|
|
|
|
if (!organizeConfig.isEmpty()) {
|
|
|
|
|
organizeCode = organizeConfig.get(0).getCfgValue();
|
|
|
|
|
}else {
|
|
|
|
|
log.error("请在mes_cfg中配置工厂代码,cfgCode为ORGANIZE_CODE");
|
|
|
|
|
return "2";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//2.根据条码表查询一条,排序条码表条码唯一
|
|
|
|
|
DdlPackBean producePackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(barcode,"custSn",producePackBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(barcode,"productSn",producePackBean);
|
|
|
|
|
DdlPreparedPack.getOrderBy("createDatetime", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), producePackBean);
|
|
|
|
|
List<MesProduceSn> produceSnList = mesProduceSnRao.findByHqlTopWhere(producePackBean, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String custPartNo="";
|
|
|
|
|
//4.如果在条码表中能查询出数据,插入到scanMonitor一条记录
|
|
|
|
|
if (!produceSnList.isEmpty()) {
|
|
|
|
|
MesPcScanLog scanLog = new MesPcScanLog();
|
|
|
|
@ -69,23 +79,35 @@ public class DcsForEquipmentServiceImpl implements IDcsForEquipmentService {
|
|
|
|
|
ConvertBean.saveOrUpdate(scanLog,"JOB");
|
|
|
|
|
scanLogRao.insert(scanLog);
|
|
|
|
|
//4.返回客户条码
|
|
|
|
|
return produceSnList.get(0).getCustPartNo();
|
|
|
|
|
custPartNo = produceSnList.get(0).getCustPartNo();
|
|
|
|
|
String partNo = produceSnList.get(0).getPartNo();
|
|
|
|
|
if (StringUtils.isEmpty(custPartNo)){
|
|
|
|
|
//根据erpPartNo查询客户零件号
|
|
|
|
|
DdlPackBean custPartPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partNo,"erpPartNo",custPartPackBean);
|
|
|
|
|
if (!StringUtils.isEmpty(custCode)){
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(custPartNo,"custCode",custPartPackBean);
|
|
|
|
|
}
|
|
|
|
|
List<MesCustomerPart> customerPartList = customerPartRao.findByHqlTopWhere(custPartPackBean, 1);
|
|
|
|
|
if (!customerPartList.isEmpty()) {
|
|
|
|
|
custPartNo = customerPartList.get(0).getCustPartNo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return custPartNo;
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String doFillConsoleResultExt(String organizeCode, String barcode, String partNo, String result, String workCenterCode, String workCellCode, String custCode) {
|
|
|
|
|
public String doFillConsoleResultExt( String barcode, String partNo, String result, String workCenterCode, String workCellCode, String custCode) {
|
|
|
|
|
barcode = mesCustomerSnTransformService.transformBarCodeGm(barcode);
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(organizeCode)) {
|
|
|
|
|
String organizeCode="";
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getStringEqualPack("ORGANIZE_CODE","cfgCode",ddlPackBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack("ORGANIZE_CODE","cfgKey",ddlPackBean);
|
|
|
|
|
List<MesConfig> organizeConfig = mesConfigRao.findByHqlWhere(ddlPackBean);
|
|
|
|
|
if (!organizeConfig.isEmpty()) {
|
|
|
|
|
organizeCode = organizeConfig.get(0).getCfgValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesPcScanLog scanLog = new MesPcScanLog();
|
|
|
|
|
scanLog.setScanTime(TimeTool.getNowTime(true));
|
|
|
|
@ -117,6 +139,95 @@ public class DcsForEquipmentServiceImpl implements IDcsForEquipmentService {
|
|
|
|
|
return "1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String doGetConsoleItemCode(String organizeCode, String barcode, String custCode, String custPlantCode) {
|
|
|
|
|
//1.根据barcode 和 organizeCode查询条码表mes_produce_sn
|
|
|
|
|
DdlPackBean snPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(barcode,"produceSn",snPackBean);
|
|
|
|
|
List<MesProduceSn> produceSnList = mesProduceSnRao.findByHqlTopWhere(snPackBean, 1);
|
|
|
|
|
if (!produceSnList.isEmpty()) {
|
|
|
|
|
|
|
|
|
|
//2.查询生产记录表,如果生产记录数量 <= 0 return ""
|
|
|
|
|
DdlPackBean productionLogPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(barcode,"sn",productionLogPackBean);
|
|
|
|
|
int count = recordRao.findByHqlWhereCount(productionLogPackBean);
|
|
|
|
|
if (count <= 0){
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
//3.
|
|
|
|
|
MesProduceSn mesProduceSn = produceSnList.get(0);
|
|
|
|
|
|
|
|
|
|
MesPcScanLog scanLog = new MesPcScanLog();
|
|
|
|
|
scanLog.setScanTime(TimeTool.getNowTime(true));
|
|
|
|
|
scanLog.setWorkCenterCode("ZP1008");
|
|
|
|
|
scanLog.setWorkCellCode("ZP1008");
|
|
|
|
|
scanLog.setCustSn(barcode);
|
|
|
|
|
scanLog.setOrganizeCode(organizeCode);
|
|
|
|
|
ConvertBean.saveOrUpdate(scanLog,"webService-doGetConsoleItemCode");
|
|
|
|
|
scanLogRao.insert(scanLog);
|
|
|
|
|
return mesProduceSn.getCustPartNo();
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String doFillConsoleResult(String organizeCode,String barcode, String partNO, String result, String workCenterCode, String workCellCode) {
|
|
|
|
|
if (StringUtils.isBlank(organizeCode)) {
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getStringEqualPack("ORGANIZE_CODE","cfgCode",ddlPackBean);
|
|
|
|
|
List<MesConfig> organizeConfig = mesConfigRao.findByHqlWhere(ddlPackBean);
|
|
|
|
|
if (!organizeConfig.isEmpty()) {
|
|
|
|
|
organizeCode = organizeConfig.get(0).getCfgValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesPcScanLog scanLog = new MesPcScanLog();
|
|
|
|
|
scanLog.setScanTime(TimeTool.getNowTime(true));
|
|
|
|
|
scanLog.setWorkCenterCode(workCenterCode);
|
|
|
|
|
scanLog.setWorkCellCode(workCellCode);
|
|
|
|
|
scanLog.setCustSn(barcode);
|
|
|
|
|
scanLog.setOrganizeCode(organizeCode);
|
|
|
|
|
scanLog.setRemark(partNO+":"+result);
|
|
|
|
|
ConvertBean.saveOrUpdate(scanLog,"JOB");
|
|
|
|
|
scanLogRao.insert(scanLog);
|
|
|
|
|
|
|
|
|
|
return "1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesReturnModel doGetConsoleItemCodeAndProcess(String organizeCode, String barcode, String custCode, String custPlantCode) {
|
|
|
|
|
MesReturnModel mesReturnModel = new MesReturnModel();
|
|
|
|
|
//1.根据barcode 和 organizeCode查询条码表mes_produce_sn
|
|
|
|
|
DdlPackBean snPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(barcode,"productSn",snPackBean);
|
|
|
|
|
List<MesProduceSn> produceSnList = mesProduceSnRao.findByHqlTopWhere(snPackBean, 1);
|
|
|
|
|
if (!produceSnList.isEmpty()) {
|
|
|
|
|
|
|
|
|
|
//2.查询生产记录表,如果生产记录数量 <= 0 return ""
|
|
|
|
|
DdlPackBean productionLogPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(barcode,"productSn",productionLogPackBean);
|
|
|
|
|
DdlPreparedPack.getOrderBy("createDatetime",CommonEnumUtil.ASC_OR_DESC.DESC.getValue(),productionLogPackBean);
|
|
|
|
|
List<MesProductionRecord> productionRecords = recordRao.findByHqlTopWhere(productionLogPackBean,1);
|
|
|
|
|
if (!productionRecords.isEmpty()){
|
|
|
|
|
String processCode = productionRecords.get(0).getProcessCode();
|
|
|
|
|
mesReturnModel.setProcessCode(processCode);
|
|
|
|
|
}
|
|
|
|
|
//3.
|
|
|
|
|
MesProduceSn mesProduceSn = produceSnList.get(0);
|
|
|
|
|
mesReturnModel.setPartNo(mesProduceSn.getPartNo());
|
|
|
|
|
MesPcScanLog scanLog = new MesPcScanLog();
|
|
|
|
|
scanLog.setScanTime(TimeTool.getNowTime(true));
|
|
|
|
|
scanLog.setWorkCenterCode("ZP1008");
|
|
|
|
|
scanLog.setWorkCellCode("ZP1008");
|
|
|
|
|
scanLog.setCustSn(barcode);
|
|
|
|
|
scanLog.setOrganizeCode(organizeCode);
|
|
|
|
|
ConvertBean.saveOrUpdate(scanLog,"webService-doGetConsoleItemCodeAndProcess");
|
|
|
|
|
scanLogRao.insert(scanLog);
|
|
|
|
|
return mesReturnModel;
|
|
|
|
|
}
|
|
|
|
|
return mesReturnModel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String createBarCode(String barcode){
|
|
|
|
|
String barcodeResult = "";
|
|
|
|
|