电测试开发

tags/yfai-pcn-ext-v2.3
臧学普 7 months ago
parent a536b82cfd
commit ad2a7f8722

@ -0,0 +1,20 @@
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
public interface IDcsForEquipmentService {
String doGetConsoleItemCode(String organizeCode,String barcode,String custCode,String custPlantCode,String workCenterCode, String workCellCode);
/**
*
* @param organizeCode
* @param barcode
* @param partNo
* @param result
* @param workCenterCode
* @param workCellCode
* @param custCode
* @return
*/
String doFillConsoleResultExt(String organizeCode,String barcode,String partNo,String result,String workCenterCode, String workCellCode,String custCode);
}

@ -14,6 +14,11 @@
<packaging>jar</packaging>
<dependencies>
<!-- CXF依赖 -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>

@ -0,0 +1,59 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache ImppLicense, Version 2.0 (the
* "ImppLicense"); you may not use this file except in compliance
* with the ImppLicense. You may obtain a copy of the ImppLicense at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the ImppLicense is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the ImppLicense for the
* specific language governing permissions and limitations
* under the ImppLicense.
*/
package cn.estsh.i3plus.ext.mes.pcn.apiservice.config;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.DcsForEquipmentServer;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;
/**
* @Description : WebService Server
* WSDL URL: /block/softswitch/server/web-service?wsdl
* @Reference :
* @Author : wei.peng
* @CreateDate : 2019/9/10 3:13
* @Modify:
**/
@Configuration
public class WebServiceConfig {
@Autowired
private Bus bus;
@Bean("cxfServletRegistration")
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/*");
}
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, new DcsForEquipmentServer());
endpoint.publish("/DCSForEquipmentService");
return endpoint;
}
}

@ -0,0 +1,23 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.model;
import lombok.Data;
/**
* GetConsoleItemCodeExt
*/
@Data
public class MesConsoleItemCodeExt {
//条码
private String barcode;
//客户编码
private String custCode;
//客户工厂
private String custPlantCode;
//装配线
private String assemblyLine;
//工位
private String location;
//工厂代码
private String organizeCode;
}

@ -0,0 +1,15 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.model;
import lombok.Data;
@Data
public class MesConsoleResultExt {
private String barcode;
private String partNO;
private String result;
private String assemblyLine;
private String location;
private String custCode;
private String organizeCode;
}

@ -0,0 +1,141 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IDcsForEquipmentService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
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.repository.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class DcsForEquipmentServiceImpl implements IDcsForEquipmentService {
@Autowired
private MesCustomerSnTransformService mesCustomerSnTransformService;
@Autowired
private MesProduceSnRepository mesProduceSnRao;
@Autowired
private MesConfigRepository mesConfigRao;
@Autowired
private MesPcScanLogRepository scanLogRao;
@Autowired
private MesCustomerPartRepository customerPartRao;
@Override
public String doGetConsoleItemCode(String organizeCode,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'
//包含ASCII码的条码 65位不包含的 58位
barcode = mesCustomerSnTransformService.transformBarCodeGm(barcode);
//todo 读取配置文件 获取工厂
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();
}
}
//2.根据条码表查询一条,排序条码表条码唯一
DdlPackBean producePackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(barcode,"custSn",producePackBean);
DdlPreparedPack.getOrderBy("createDatetime", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), producePackBean);
List<MesProduceSn> produceSnList = mesProduceSnRao.findByHqlTopWhere(producePackBean, 1);
//4.如果在条码表中能查询出数据插入到scanMonitor一条记录
if (!produceSnList.isEmpty()) {
MesPcScanLog scanLog = new MesPcScanLog();
scanLog.setScanTime(TimeTool.getNowTime(true));
scanLog.setWorkCenterCode(workCenterCode);
scanLog.setWorkCellCode(workCellCode);
scanLog.setCustSn(barcode);
scanLog.setOrganizeCode(organizeCode);
ConvertBean.saveOrUpdate(scanLog,"JOB");
scanLogRao.insert(scanLog);
//4.返回客户条码
return produceSnList.get(0).getCustPartNo();
}
return "";
}
@Override
public String doFillConsoleResultExt(String organizeCode, String barcode, String partNo, String result, String workCenterCode, String workCellCode, String custCode) {
barcode = mesCustomerSnTransformService.transformBarCodeGm(barcode);
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);
String erpPartNo = "";
//查询erp零件号 根据客户零件号
DdlPackBean custPartPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partNo,"custPartNo",custPartPackBean);
DdlPreparedPack.getStringEqualPack(custCode,"custCode",custPartPackBean);
List<MesCustomerPart> customerPartList = customerPartRao.findByHqlTopWhere(custPartPackBean, 1);
if (!customerPartList.isEmpty()){
erpPartNo = customerPartList.get(0).getErpPartNo();
}
if (StringUtils.isNotBlank(erpPartNo)){
//更新条码表的状态
//插入生产记录表
//插入装配件生产记录表
}
return "1";
}
private String createBarCode(String barcode){
String barcodeResult = "";
if (StringUtils.isEmpty(barcode)){
return barcodeResult;
}
//缺少了ascii码,根据规则拼接出来
//正常65 [)>06Y4110000000000XP2656085012V545238347T1A24269A2B4C0003
//异常58 [)>06Y4110000000000XP2656085012V545238347T1A24269A2B4C0003
if (barcode.length() == 58){
String part1 = barcode.substring(0, 3);
String part2 = barcode.substring(3, 5);
String part3 = barcode.substring(5, 20);
String part4 = barcode.substring(20, 29);
String part5 = barcode.substring(29,41);
String part6 = barcode.substring(41);
barcodeResult = part1 + (char)30 + part2 +(char)29 + part3 + (char)29 + part4 +(char)29 + part5 +(char)29 + part6 + (char)30 + (char)04;
}
return barcodeResult;
}
}

@ -16,6 +16,7 @@ public class MesCustomerSnTransformService implements IMesCustomerSnTransformSer
if (StringUtils.isEmpty(barCode)) return barCode;
if (barCode.length() != MesPcnExtConstWords.CUSTOMER_SN_LENGTH_GM) return barCode;
String a = barCode.substring(0, 3);
//todo 增加3-5截取
String b = barCode.substring(5, 20);
String c = barCode.substring(20, 29);
String d = barCode.substring(29, 41);

@ -114,8 +114,8 @@ public class MesShippingScanSnAndOrderStrategyServiceImpl implements IMesShippin
throw new ImppBusiException(String.format("目视单【%s】状态为【%s】质量状态为【%s】不允许发运", model.getSn(), MesExtEnumUtil.ORDER_STATUS.valueOfDescription(workOrder.getWorkOrderStatus()), MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(workOrder.getQcStatus())));
}
//校验条码是否匹配
if (!Objects.equals(detail.getBarcode(), workOrder.getSn())) {
throw new ImppBusiException(String.format("目视单【%s】条码【%s】与扫描条码【%s】不匹配", model.getSn(), workOrder.getSn(), detail.getBarcode()));
if (!Objects.equals(detail.getBarcode(), workOrder.getCustSn())) {
throw new ImppBusiException(String.format("目视单【%s】条码【%s】与扫描条码【%s】不匹配", model.getSn(), workOrder.getCustSn(), detail.getBarcode()));
}
//校验零件是否匹配
if (!Objects.equals(detail.getPartNo(), workOrder.getPartNo())) {

@ -0,0 +1,50 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.model.MesConsoleItemCodeExt;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.model.MesConsoleResultExt;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.DcsForEquipmentServiceImpl;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@Component
@WebService(targetNamespace = "http://tempuri.org/")
public class DcsForEquipmentServer {
public static final Logger LOGGER = LoggerFactory.getLogger(DcsForEquipmentServer.class);
// @WebMethod(action = "GetConsoleItemCodeExt", operationName = "GetConsoleItemCodeExt")
// public String getConsoleItemCodeExt(@WebParam(name = "GetConsoleItemCodeExt") MesConsoleItemCodeExt mesConsoleItemCodeExt) {
// DcsForEquipmentServiceImpl bean = (DcsForEquipmentServiceImpl) SpringContextsUtil.getBean("DcsForEquipmentServiceImpl");
// String organizeCode = mesConsoleItemCodeExt.getOrganizeCode();
// String custCode = mesConsoleItemCodeExt.getCustCode();
// String assemblyLine = mesConsoleItemCodeExt.getAssemblyLine();
// String location = mesConsoleItemCodeExt.getLocation();
// String barcode = mesConsoleItemCodeExt.getBarcode();
// String custPlantCode = mesConsoleItemCodeExt.getCustPlantCode();
// return bean.doGetConsoleItemCode(organizeCode,barcode,custCode,custPlantCode,assemblyLine,location);
// }
@WebMethod(action = "GetConsoleItemCodeExt", operationName = "GetConsoleItemCodeExt")
public String getConsoleItemCodeExt(@WebParam(name = "organizeCode") String organizeCode, @WebParam(name = "custCode") String custCode,@WebParam(name = "assemblyLine")String assemblyLine,@WebParam(name = "location")String location,@WebParam(name = "barcode")String barcode,@WebParam(name = "custPlantCode")String custPlantCode) {
DcsForEquipmentServiceImpl bean = (DcsForEquipmentServiceImpl) SpringContextsUtil.getBean("DcsForEquipmentServiceImpl");
return bean.doGetConsoleItemCode(organizeCode,barcode,custCode,custPlantCode,assemblyLine,location);
}
@WebMethod(action = "FillConsoleResultExt", operationName = "FillConsoleResultExt")
public String getConsoleItemCodeExt(@WebParam(name = "FillConsoleResultExt") MesConsoleResultExt mesConsoleResultExt) {
DcsForEquipmentServiceImpl bean = (DcsForEquipmentServiceImpl) SpringContextsUtil.getBean("DcsForEquipmentServiceImpl");
String organizeCode = mesConsoleResultExt.getOrganizeCode();
String custCode = mesConsoleResultExt.getCustCode();
String assemblyLine = mesConsoleResultExt.getAssemblyLine();
String location = mesConsoleResultExt.getLocation();
String barcode = mesConsoleResultExt.getBarcode();
String result = mesConsoleResultExt.getResult();
String partNo = mesConsoleResultExt.getPartNO();
return bean.doFillConsoleResultExt(organizeCode,barcode,partNo,result,assemblyLine,location,custCode);
}
}

@ -41,7 +41,18 @@
<dependencyManagement>
<dependencies>
<!-- CXF依赖 -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.3.6</version>
<exclusions><!-- CXF uses java.util.logging by default -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>

Loading…
Cancel
Save