This commit is contained in:
zj
2026-01-05 21:22:27 +08:00
parent ec7a04d461
commit e0e0427ac0
11 changed files with 215 additions and 44 deletions

View File

@@ -2,6 +2,7 @@ package com.ruoyi.api.service;
import com.ruoyi.bas.BasCustomer.domain.BasCustomer;
import com.ruoyi.bas.BasProduct.domain.BasProduct;
import com.ruoyi.bas.BasProductCode.domain.BasProductCode;
import com.ruoyi.bas.BasSupplier.domain.BasSupplier;
import com.ruoyi.common.core.domain.AjaxResult;
@@ -16,4 +17,6 @@ public interface IToErpService {
void callbackTransferBill();
AjaxResult createWorkshopInboundOrder(BasProduct basProduct,String erpBill);
AjaxResult getInCode(BasProductCode basProductCode);
}

View File

@@ -5,13 +5,12 @@ import cn.hutool.json.JSONUtil;
import com.ruoyi.api.domain.*;
import com.ruoyi.api.service.IToErpService;
import com.ruoyi.bas.BasProduct.domain.BasProduct;
import com.ruoyi.bas.BasProduct.service.IBasProductService;
import com.ruoyi.bas.BasProductCode.domain.BasProductCode;
import com.ruoyi.bas.basJobId.service.IBasJobIdService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.in.erp.domain.TransferBillCallback;
import com.ruoyi.in.erp.service.ITransferBillCallbackService;
import com.ruoyi.job.mydojob.service.IMydoJobService;
import com.ruoyi.job.mydojobdetail.domain.MydoJobDetail;
import com.ruoyi.job.mydojobdetail.service.IMydoJobDetailService;
import com.ruoyi.log.domain.RequestLog;
import com.ruoyi.log.service.IRequestLogService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,25 +28,15 @@ public class ToErpServiceImpl implements IToErpService {
@Autowired
private ITransferBillCallbackService transferBillCallbackService;
@Autowired
private IMydoJobService mydoJobService;
@Autowired
private IMydoJobDetailService mydoJobDetailService;
@Autowired
private IBasJobIdService basJobIdService;
@Autowired
private IRequestLogService requestLogService;
@Autowired
private IBasProductService basProductService;
private static final String TO_ERP_URL = "http://223.113.254.106:9990/CROSS/RESTful";
//todo 需要调试
private static final String WORKSHOP_INBOUND_ORDER_URL = TO_ERP_URL;
//todo 需要调试
private static final String OTHER_IN_OUTBOUND_ORDER_URL = TO_ERP_URL;
@Override
public void callbackTransferBill() {
TransferBillCallback param = new TransferBillCallback();
@@ -74,14 +63,14 @@ public class ToErpServiceImpl implements IToErpService {
wipTransferDoc.setDOC_NO(basJobIdService.getJobIdBy("5C21"));
wipTransferDoc.setDOC_ID_DOC_CODE("5C21");
wipTransferDoc.setDOC_DATE(DateUtil.formatDateTime(new Date()));
wipTransferDoc.setSOURCE_ID_WORK_CENTER_WORK_CENTER_CODE("QD09");
wipTransferDoc.setFROM_ADMIN_UNIT_ID_ADMIN_UNIT_CODE("HM01G");
wipTransferDoc.setSOURCE_ID_WORK_CENTER_WORK_CENTER_CODE("QC06");
wipTransferDoc.setFROM_ADMIN_UNIT_ID_ADMIN_UNIT_CODE("EF08G");
wipTransferDoc.setFROM_ADMIN_UNIT_ID_START_DATE(DateUtil.formatDateTime(new Date()));
wipTransferDoc.setOwner_Dept_ADMIN_UNIT_CODE("HM01G");
wipTransferDoc.setOwner_Dept_ADMIN_UNIT_CODE("EF08G");
wipTransferDoc.setOwner_Dept_START_DATE(DateUtil.formatDateTime(new Date()));
wipTransferDoc.setOwner_Emp_EMPLOYEE_CODE("HM01G");
wipTransferDoc.setOwner_Emp_EMPLOYEE_CODE("EF08G");
String docNo = requestLogService.getRequestLogDoc(WORKSHOP_INBOUND_ORDER_URL,erpBill, basProduct.getProductId() , "获取工艺单号", "wms", "erp");
String docNo = requestLogService.getRequestLogDoc(TO_ERP_URL,erpBill, basProduct.getProductId() , "获取工艺单号", "wms", "erp");
if("".equals(docNo) || docNo == null) {
return AjaxResult.error();
}
@@ -92,7 +81,7 @@ public class ToErpServiceImpl implements IToErpService {
wipTransferDocD.setITEM_ID_ITEM_CODE(basProduct.getProductId());
wipTransferDocD.setITEM_NAME(basProduct.getProductName());
wipTransferDocD.setITEM_SPECIFICATION(basProduct.getSpec());
wipTransferDocD.setSOURCE_ID_WAREHOUSE_WAREHOUSE_CODE("H041-1");
wipTransferDocD.setSOURCE_ID_WAREHOUSE_WAREHOUSE_CODE("C041-1");
wipTransferDocD.setFROM_MO_ROUTING_D_ID_SequenceNumber(1);
wipTransferDocD.setFROM_MO_ROUTING_D_ID_Parent_MO_ID_DOC_NO(docNo);
list.add(wipTransferDocD);
@@ -100,7 +89,7 @@ public class ToErpServiceImpl implements IToErpService {
objectErpParameter.setDatas(List.of(wipTransferDoc));
erpStdData.setParameter(objectErpParameter);
param.setStd_data(erpStdData);
RequestLog requestLog = requestLogService.getRequestLogGd(WORKSHOP_INBOUND_ORDER_URL, JSONUtil.toJsonStr(param), "创建工艺单","wms","erp");
RequestLog requestLog = requestLogService.getRequestLogGd(TO_ERP_URL, JSONUtil.toJsonStr(param), "创建工艺单","wms","erp");
// String post = requestLog.getResponseBody();
// ErpInterfaceParam bean = JSONUtil.toBean(post, ErpInterfaceParam.class);
// if ("0".equals(bean.getStd_data().getExecution().getCode())) {
@@ -113,6 +102,17 @@ public class ToErpServiceImpl implements IToErpService {
}
}
@Override
public AjaxResult getInCode(BasProductCode basProductCode) {
String billNo = basProductCode.getSpare1();
RequestLog requestLog = requestLogService.getRequestLogCode(TO_ERP_URL, billNo, "获取入库条码数据","wms","erp");
if(requestLog != null && "1".equals(requestLog.getIsSuccessful())){
return AjaxResult.success();
}else{
return AjaxResult.error();
}
}
public AjaxResult createOtherInOutboundOrder(TransferBillCallback transferBillCallback) {
ErpInterfaceParam<ErpInOutBoundOrder> param = new ErpInterfaceParam<>();
@@ -129,19 +129,20 @@ public class ToErpServiceImpl implements IToErpService {
docNo = basJobIdService.getJobIdBy("11T2");
docIdDocCode = "11T2";
}
BasProduct basProduct = basProductService.selectBasProductByProductId(transferBillCallback.getSpare1());
erpInOutBoundOrder.setDOC_NO(docNo);
erpInOutBoundOrder.setDOC_ID_DOC_CODE(docIdDocCode);
erpInOutBoundOrder.setDOC_ID_Owner_Org_PLANT_PLANT_CODE("B0504");
erpInOutBoundOrder.setDOC_DATE(DateUtil.formatDateTime(new Date()));
erpInOutBoundOrder.setTRANSACTION_DATE(DateUtil.formatDateTime(new Date()));
erpInOutBoundOrder.setOwner_Emp_EMPLOYEE_CODE("E11173");
erpInOutBoundOrder.setOwner_Emp_EMPLOYEE_CODE("AGV");
erpInOutBoundOrder.setOwner_Org_PLANT_PLANT_CODE("B0504");
erpInOutBoundOrder.setApproveStatus("N");
erpInOutBoundOrder.setCATEGORY("11");
erpInOutBoundOrder.setCOMPANY_ID_COMPANY_CODE("B05");
erpInOutBoundOrder.setOwner_Dept_ADMIN_UNIT_CODE("HM01F");
erpInOutBoundOrder.setOwner_Dept_ADMIN_UNIT_CODE("EF08G");
erpInOutBoundOrder.setSTOCK_ACTION(1);
//List<MydoJobDetail> mydoJobDetails = mydoJobDetailService.selectMydoJobDetailListByJobId(transferBillCallback.getJobId());
ArrayList<ErpTransactionDocD> erpTransactionDocDS = new ArrayList<>();
ErpTransactionDocD erpTransactionDocD = new ErpTransactionDocD();
erpTransactionDocD.setSequenceNumber(1);
@@ -149,9 +150,9 @@ public class ToErpServiceImpl implements IToErpService {
erpTransactionDocD.setITEM_DESCRIPTION(transferBillCallback.getSpare2());
erpTransactionDocD.setITEM_SPECIFICATION(transferBillCallback.getSpare3());
erpTransactionDocD.setBUSINESS_QTY(1.0);
erpTransactionDocD.setWAREHOUSE_ID_WAREHOUSE_CODE("H041-1");
erpTransactionDocD.setWAREHOUSE_ID_WAREHOUSE_CODE("C281");
erpTransactionDocD.setWAREHOUSE_ID_Owner_Org_PLANT_PLANT_CODE("B0504");
erpTransactionDocD.setBUSINESS_UNIT_ID_UNIT_CODE("TAI");
erpTransactionDocD.setBUSINESS_UNIT_ID_UNIT_CODE(basProduct.getUnit());
erpTransactionDocD.setGENERATE_SOURCE("");
erpTransactionDocDS.add(erpTransactionDocD);
@@ -160,18 +161,12 @@ public class ToErpServiceImpl implements IToErpService {
objectErpParameter.setDatas(list);
erpStdData.setParameter(objectErpParameter);
param.setStd_data(erpStdData);
RequestLog requestLog = requestLogService.getRequestLogOther(OTHER_IN_OUTBOUND_ORDER_URL, JSONUtil.toJsonStr(param), "创建其他入出库单", "wms", "erp");
RequestLog requestLog = requestLogService.getRequestLogOther(TO_ERP_URL, JSONUtil.toJsonStr(param), "创建其他入出库单", "wms", "erp");
if (requestLog != null && "1".equals(requestLog.getIsSuccessful())) {
return AjaxResult.success();
} else {
return AjaxResult.error();
}
// String post = requestLog.getResponseBody();
// ErpInterfaceParam bean = JSONUtil.toBean(post, ErpInterfaceParam.class);
// if ("0".equals(bean.getStd_data().getExecution().getCode())) {
// return AjaxResult.success();
// }
// return AjaxResult.error();
}
}

View File

@@ -1,6 +1,8 @@
package com.ruoyi.bas.BasProductCode.controller;
import java.util.List;
import com.ruoyi.api.service.IToErpService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +36,9 @@ public class BasProductCodeController extends BaseController
@Autowired
private IBasProductCodeService basProductCodeService;
@Autowired
private IToErpService toErpService;
/**
* 查询条码打印列表
*/
@@ -101,4 +106,10 @@ public class BasProductCodeController extends BaseController
{
return toAjax(basProductCodeService.deleteBasProductCodeByIds(ids));
}
@PostMapping("/getInCode")
public AjaxResult getInCode(BasProductCode basProductCode)
{
return toErpService.getInCode(basProductCode);
}
}

View File

@@ -2,6 +2,7 @@ package com.ruoyi.bas.BasProductCode.service;
import java.util.List;
import com.ruoyi.bas.BasProductCode.domain.BasProductCode;
import com.ruoyi.common.core.domain.AjaxResult;
/**
* 条码打印Service接口

View File

@@ -1,6 +1,8 @@
package com.ruoyi.bas.BasProductCode.service.impl;
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@@ -83,4 +83,6 @@ public interface IRequestLogService
RequestLog getRequestLogOther(String otherInOutboundOrderUrl, String jsonStr, String 创建其他入出库单, String wms, String erp);
String getRequestLogDoc(String workshopInboundOrderUrl, String erpBill, String productId, String 获取工艺单号, String wms, String erp);
RequestLog getRequestLogCode(String workshopInboundOrderUrl, String billNo, String 获取入库条码数据, String wms, String erp);
}

View File

@@ -6,6 +6,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ruoyi.api.domain.Condition;
import com.ruoyi.bas.BasProductCode.domain.BasProductCode;
import com.ruoyi.bas.BasProductCode.mapper.BasProductCodeMapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.log.domain.RequestLog;
import com.ruoyi.log.mapper.RequestLogMapper;
@@ -31,6 +33,9 @@ public class RequestLogServiceImpl implements IRequestLogService {
@Autowired
private RequestLogMapper requestLogMapper;
@Autowired
private BasProductCodeMapper basProductCodeMapper;
/**
* 查询接口记录
*
@@ -305,6 +310,93 @@ public class RequestLogServiceImpl implements IRequestLogService {
return docNo;
}
@Override
public RequestLog getRequestLogCode(String url, String billNo, String remark, String source, String target) {
String param = "{ \"std_data\": {\n" +
" \"parameter\": {\n" +
" \"pageSize\": 20,\n" +
" \"pageNo\": 1,\n" +
" \"isGetSchema\": false,\n" +
" \"isGetCount\": false,\n" +
" \"conditions\": [\n" +
" {\n" +
" \"field_name\":\"DOC_NO\",\n" +
" \"value\":\""+billNo+"\"\n" +
" }\n" +
" ],\n" +
" \"orders\": []\n" +
" }\n" +
" }\n" +
"}";
RequestLog requestLog = new RequestLog();
requestLog.setRequestTime(DateUtil.formatDateTime(new Date()));
requestLog.setSourceSystem(source);
requestLog.setTargetSystem(target);
requestLog.setEndpoint(remark);
requestLog.setRequestMethod("post");
requestLog.setRequestHeaders(null);
requestLog.setRequestBody(param);
requestLog.setRequestUrl(url);
try {
String resStr = HttpUtils.sendPostCode(url, param, "application/json");
System.out.println(param);
// 判断resStr的状态码,如果不是200抛出异常让catch捕获
if (!JSONUtil.isJsonObj(resStr)) {
throw new RuntimeException("返回结果不是有效的JSON对象");
}
JSONObject jsonObject = JSONUtil.parseObj(resStr);
if (jsonObject == null) {
throw new RuntimeException("请求失败");
}
Object codeObj = jsonObject.get("std_data");
JSONObject obj = JSONUtil.parseObj(codeObj.toString());
String docArr = JSONUtil.parseObj(obj.get("parameter").toString()).get("rows").toString();
if (docArr.length() > 0 && JSONUtil.parseArray(docArr).size() > 0) {
for(int i = 0; i < JSONUtil.parseArray(docArr).size(); i++) {
Object docObj = JSONUtil.parseArray(docArr).get(i);
BasProductCode basProductCode = new BasProductCode();
basProductCode.setModel(JSONUtil.parseObj(docObj.toString()).get("SHORTCUT").toString());
basProductCode.setColor(JSONUtil.parseObj(docObj.toString()).get("YQueryViewColumnElement_001").toString());
basProductCode.setSerial(JSONUtil.parseObj(docObj.toString()).get("YQueryViewColumnElement_002").toString());
String message = JSONUtil.parseObj(docObj.toString()).get("XDYYQ").toString();
String []split = message.split("\\\\");
if(split.length == 3) {
basProductCode.setV(split[0]);
basProductCode.setHz(split[1]);
basProductCode.setPh(split[2]);
}
basProductCode.setNW(JSONUtil.parseObj(docObj.toString()).get("ITEM_NET_WEIGHT").toString());
basProductCode.setGW(JSONUtil.parseObj(docObj.toString()).get("YQueryViewColumnElement_003").toString());
basProductCode.setType("1");
basProductCode.setSpare1(JSONUtil.parseObj(docObj.toString()).get("billNo").toString());
basProductCode.setSpare2(JSONUtil.parseObj(docObj.toString()).get("YQueryViewColumnElement_004").toString());
basProductCode.setSpare3(JSONUtil.parseObj(docObj.toString()).get("YQueryViewColumnElement_005").toString());
basProductCode.setCreateTime(new Date());
basProductCode.setSpare4(JSONUtil.parseObj(docObj.toString()).get("ITEM_CODE").toString());
basProductCode.setSpare5(JSONUtil.parseObj(docObj.toString()).get("BUSINESS_QTY").toString());
basProductCodeMapper.insertBasProductCode(basProductCode);
}
requestLog.setResponseBody(resStr);
requestLog.setResponseTime(DateUtil.formatDateTime(new Date()));
requestLog.setResponseStatus("1");
requestLog.setDuration(Convert.toStr(DateUtil.between(Convert.toDate(requestLog.getRequestTime()), Convert.toDate(requestLog.getResponseTime()), DateUnit.MS)));
requestLog.setIsSuccessful("1");
} else {
throw new RuntimeException("请求失败");
}
} catch (Exception e) {
requestLog.setErrorDetails(e.getMessage());
requestLog.setIsSuccessful("0");
requestLog.setResponseStatus("0");
} finally {
insertRequestLog(requestLog);
}
return requestLog;
}
/**
* 插入请求日志
*

View File

@@ -134,11 +134,11 @@ public class ViewHandAllotStock extends BaseEntity
/** 净重 */
@Excel(name = "净重")
private BigDecimal netWeight;
private String netWeight;
/** 毛重 */
@Excel(name = "毛重")
private BigDecimal grossWeight;
private String grossWeight;
/** 分销 */
@Excel(name = "分销")
@@ -407,19 +407,19 @@ public class ViewHandAllotStock extends BaseEntity
this.phase = phase;
}
public BigDecimal getNetWeight() {
public String getNetWeight() {
return netWeight;
}
public void setNetWeight(BigDecimal netWeight) {
public void setNetWeight(String netWeight) {
this.netWeight = netWeight;
}
public BigDecimal getGrossWeight() {
public String getGrossWeight() {
return grossWeight;
}
public void setGrossWeight(BigDecimal grossWeight) {
public void setGrossWeight(String grossWeight) {
this.grossWeight = grossWeight;
}

View File

@@ -451,6 +451,71 @@ public class HttpUtils
return result.toString();
}
public static String sendPostCode(String url, String param, String contentType) {
PrintWriter out = null;
BufferedReader in = null;
StringBuilder result = new StringBuilder();
try
{
log.info("sendPost - {}", url);
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("digi-key", "286119CC713C6FEBA545E034AD2315A6");
conn.setRequestProperty("digi-host", "{\"ver\":\"5.7\",\"prod\":\"YLTK\",\"timezone\":\"+8\",\"ip\":\"192.168.116.1\",\"id\":\"\",\"lang\":\"zh_CN\",\"acct\":\"dcms\",\"timestamp\":\"2018071990007275\"}");
conn.setRequestProperty("digi-service", "{\"prod\":\"E10\",\"ip\":\"192.168.116.179\",\"name\":\"yltk.sales_order_doc.query\",\"id\":\"E10_BLS_ZS_External\"}");
conn.setRequestProperty("digi-data-exchange-protocol", "1.0");
conn.setRequestProperty("digi-type", "sync");
conn.setRequestProperty("Content-Type", contentType);
conn.setDoOutput(true);
conn.setDoInput(true);
out = new PrintWriter(conn.getOutputStream());
out.print(param);
out.flush();
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
String line;
while ((line = in.readLine()) != null)
{
result.append(line);
}
log.info("recv - {}", result);
}
catch (ConnectException e)
{
log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
}
catch (SocketTimeoutException e)
{
log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
}
catch (IOException e)
{
log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
}
catch (Exception e)
{
log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
}
finally
{
try
{
if (out != null)
{
out.close();
}
if (in != null)
{
in.close();
}
}
catch (IOException ex)
{
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
}
}
return result.toString();
}
private static class TrustAnyTrustManager implements X509TrustManager
{

View File

@@ -107,9 +107,9 @@
<dict-tag :options="dict.type.stock_status" :value="scope.row.stockStatus"/>
</template>
</el-table-column>
<el-table-column label="品号" align="center" prop="productId" />
<el-table-column label="品号" align="center" prop="productId" sortable/>
<el-table-column label="品名" align="center" prop="productName" width="160"/>
<el-table-column label="批次号" align="center" prop="lotNo" sortable width="160"/>
<el-table-column label="规格" align="center" prop="spare1" width="300"/>
<el-table-column label="订单号" align="center" prop="orderId" width="160" sortable/>
<el-table-column label="入库时间" align="center" prop="inDate" width="160" sortable/>
<el-table-column label="数量" align="center" prop="quantity" sortable/>
@@ -119,7 +119,7 @@
<el-table-column label="入库单号" align="center" prop="stockinId" width="160" sortable/>
<!-- <el-table-column label="入库类型" align="center" prop="inType" />-->
<!-- <el-table-column label="仓库编码" align="center" prop="warehouseId" />-->
<el-table-column label="规格" align="center" prop="spare1" />
<el-table-column label="单位" align="center" prop="spare3" />
<el-table-column label="型号" align="center" prop="spare4" />
<el-table-column label="颜色" align="center" prop="spare5" />

View File

@@ -93,7 +93,7 @@
<el-table-column label="入库日期" align="center" prop="inDate" width="160" sortable/>
<el-table-column label="品号" align="center" prop="productId" sortable/>
<el-table-column label="品名" align="center" prop="productName"/>
<el-table-column label="规格" align="center" prop="spare1"/>
<el-table-column label="规格" align="center" prop="spare1" width="300" />
<el-table-column label="单位" align="center" prop="spare3"/>
<el-table-column label="序列号" align="center" prop="trayCode" width="130" sortable/>
<el-table-column label="订单号" align="center" prop="orderId" width="160" sortable/>