Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
58bc3369e8
|
@ -12,6 +12,8 @@ import nc.impl.pubapp.pattern.rule.IRule;
|
|||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||
import nc.jdbc.framework.processor.MapListProcessor;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import nc.vo.bc.pmpub.project.ProjectHeadVO;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||
|
@ -22,8 +24,6 @@ import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
|||
import nc.vo.scmpub.util.ArrayUtil;
|
||||
import nccloud.commons.lang.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -40,7 +40,8 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
|
||||
private static final Log obmlog = Log.getInstance(LOG_INFO_NAME);
|
||||
|
||||
private static final String MES_PMO_SYNC_URL = "/prj-v5-web/ext/api/wrokOrder";
|
||||
private static final String MES_PMO_URL = "/prj-v5-web/ext/api/workOrder";
|
||||
private static final String MES_CODE_URL = "/prj-v5-web/ext/api/releaseNo";
|
||||
|
||||
private static final BaseDAO dao = new BaseDAO();
|
||||
|
||||
|
@ -68,18 +69,17 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
continue;
|
||||
}
|
||||
JSONObject data = buildSyncData(aggVO);
|
||||
pushData(data);
|
||||
pushOrderData(data);
|
||||
|
||||
JSONObject buildSyncData = buildSyncData1(aggVO);
|
||||
JSONObject buildSyncData = buildSyncCodeData(aggVO);
|
||||
jsonArray.add(buildSyncData);
|
||||
}
|
||||
if (jsonArray.size() > 0) {
|
||||
pushNoData("/prj-v5-web/ext/api/releaseNo", jsonArray);
|
||||
if (!jsonArray.isEmpty()) {
|
||||
pushCodeData(jsonArray);
|
||||
}
|
||||
|
||||
obmlog.info("生产订单同步到艾普MES系统处理完成。");
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
obmlog.error("同步生产订单到艾普MES系统失败: " + e.getMessage(), e);
|
||||
ExceptionUtils.wrappException(e);
|
||||
|
@ -87,16 +87,16 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 调用MES接口并处理特定错误
|
||||
* 调用MES的生产工单接口推送ERP的流程生产订单和备料计划
|
||||
*
|
||||
* @param param 请求体
|
||||
* @throws BusinessException 如果发生非特定可忽略的错误
|
||||
*/
|
||||
private void pushData(JSONObject param) throws BusinessException {
|
||||
private void pushOrderData(JSONObject param) throws BusinessException {
|
||||
String responseString = null;
|
||||
try {
|
||||
String baseUrl = SysParaInitQuery.getParaString("GLOBLE00000000000000", "EPICMESURL");
|
||||
String requestUrl = baseUrl + MES_PMO_SYNC_URL;
|
||||
String requestUrl = baseUrl + MES_PMO_URL;
|
||||
responseString = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, param.toJSONString());
|
||||
obmlog.info(" 艾普MES系统原始返回: " + responseString);
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
aggvoList.add(aggVo);
|
||||
}
|
||||
}
|
||||
// 按照部门区分生产订单,只传消弧车间、电容车间、成套车间(部门是配置项)
|
||||
// 按照部门筛选生产订单,只传消弧车间、电容车间、成套车间(部门是配置项)
|
||||
|
||||
return aggvoList;
|
||||
}
|
||||
|
@ -129,36 +129,55 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
* 组装数据-流程生产订单+备料计划
|
||||
*/
|
||||
private JSONObject buildSyncData(PMOAggVO aggVO) throws BusinessException {
|
||||
JSONObject data = new JSONObject();
|
||||
PMOHeadVO headVo = aggVO.getParentVO();
|
||||
// PMOItemVO[] pmoItems = aggVO.getChildrenVO();
|
||||
JSONObject orderParam = new JSONObject();
|
||||
orderParam.put("id", null); // 唯一标识(主键)
|
||||
orderParam.put("siteCode", null);// 工厂编码
|
||||
orderParam.put("contractNo", null);// 合同号
|
||||
orderParam.put("workOrderCode", headVo.getVbillcode());// 工单号
|
||||
orderParam.put("qty", null); // 计划数量,字符串类型
|
||||
orderParam.put("produCode", null); // 产品编码
|
||||
orderParam.put("produName", null); // 产品名称
|
||||
orderParam.put("bomCode", null); // BOM 编码
|
||||
orderParam.put("planBeginDate", null); // 计划开始时间(毫秒级时间戳)
|
||||
orderParam.put("planEndDate", null); // 计划完成时间(毫秒级时间戳)
|
||||
orderParam.put("endDate", null); // 试验结束时间(毫秒级时间戳)
|
||||
orderParam.put("type", "I"); // 类型:I:新增 U:修改 D:删除
|
||||
orderParam.put("auditCode", "Y"); // 审核状态(Y:已审核 N:未审核)
|
||||
orderParam.put("contractName", null); // 合同名称
|
||||
orderParam.put("transferPlanTime", null); // 生产转检计划时间(格式为YYYY-MM-DD)
|
||||
orderParam.put("receiptScheduledTime", null); // 完工入库时间(格式为YYYY-MM-DD)
|
||||
// 目前电力电子只做一个表体的订单,故只处理的流程生产订单第一个子表行
|
||||
PMOItemVO pmoItem = aggVO.getChildrenVO()[0];
|
||||
// 翻译字段值
|
||||
// 组织
|
||||
String pkOrg = headVo.getPk_org();
|
||||
String selectFields = FactoryVO.CODE + "," + FactoryVO.NAME;
|
||||
Map<String, Object> orgMap = MyHelper.transferFields(FactoryVO.getDefaultTableName(), selectFields, FactoryVO.PK_FACTORY, pkOrg);
|
||||
// 物料
|
||||
String cmaterialid = pmoItem.getCmaterialid();
|
||||
selectFields = MaterialVO.CODE + "," + MaterialVO.NAME;
|
||||
Map<String, Object> goodsMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), selectFields, MaterialVO.PK_MATERIAL, cmaterialid);
|
||||
// 项目
|
||||
String cprojectid = pmoItem.getCprojectid();
|
||||
selectFields = ProjectHeadVO.PROJECT_CODE + "," + ProjectHeadVO.PROJECT_NAME;
|
||||
Map<String, Object> projectMap = MyHelper.transferFields(MaterialVO.getDefaultTableName(), selectFields, ProjectHeadVO.PK_PROJECT, cprojectid);
|
||||
// 组装数据
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject orderParam = new JSONObject();
|
||||
orderParam.put("id", null); // 唯一标识(主键)
|
||||
orderParam.put("siteCode", null);// 工厂编码
|
||||
if (projectMap != null) {
|
||||
orderParam.put("contractNo", projectMap.get(ProjectHeadVO.PROJECT_CODE));// 合同号
|
||||
orderParam.put("contractName", projectMap.get(ProjectHeadVO.PROJECT_NAME)); // 合同名称
|
||||
}
|
||||
orderParam.put("workOrderCode", headVo.getVbillcode());// 工单号
|
||||
orderParam.put("qty", String.valueOf(pmoItem.getNastnum())); // 计划数量,字符串类型
|
||||
if (goodsMap != null) {
|
||||
orderParam.put("produCode", goodsMap.get(MaterialVO.CODE)); // 产品编码
|
||||
orderParam.put("produName", goodsMap.get(MaterialVO.NAME)); // 产品名称
|
||||
}
|
||||
// cbomversionid 生产BOM版本
|
||||
orderParam.put("bomCode", null); // BOM 编码
|
||||
orderParam.put("planBeginDate", pmoItem.getTplanstarttime().getMillis()); // 计划开始时间(毫秒级时间戳)
|
||||
orderParam.put("planEndDate", pmoItem.getTplanendtime()); // 计划完成时间(毫秒级时间戳)
|
||||
// orderParam.put("endDate", null); // 试验结束时间(毫秒级时间戳)
|
||||
orderParam.put("type", "I"); // 类型:I:新增 U:修改 D:删除
|
||||
orderParam.put("auditCode", "Y"); // 审核状态(Y:已审核 N:未审核)
|
||||
// orderParam.put("transferPlanTime", null); // 生产转检计划时间(格式为YYYY-MM-DD)
|
||||
// orderParam.put("receiptScheduledTime", null); // 完工入库时间(格式为YYYY-MM-DD)
|
||||
if (orgMap != null) {
|
||||
orderParam.put("companyCode", orgMap.get(FactoryVO.CODE)); // 公司编码
|
||||
orderParam.put("companyName", orgMap.get(FactoryVO.NAME)); // 公司名称
|
||||
}
|
||||
JSONArray orderArr = new JSONArray();
|
||||
orderArr.add(orderParam);
|
||||
// 流程生产订单
|
||||
data.put("workOrders", orderArr);
|
||||
data.put("mrls", getPickmInfo(headVo.getPrimaryKey())); // 备料计划
|
||||
data.put("mrls", getPickmInfo(pmoItem.getPrimaryKey())); // 备料计划
|
||||
// {
|
||||
// "workOrders": [// 流程生产订单
|
||||
// {
|
||||
|
@ -204,6 +223,7 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
* @throws BusinessException
|
||||
*/
|
||||
private JSONArray getPickmInfo(String sourceId) throws BusinessException {
|
||||
// vsourcemorowid 来源生产订单明细id
|
||||
JSONArray pickmArr = new JSONArray();
|
||||
if (StringUtils.isEmpty(sourceId) || "~".equals(sourceId)) {
|
||||
return pickmArr;
|
||||
|
@ -216,7 +236,8 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
sqlBuilder.append(" left join bd_measdoc d on b.cbastunitid = d.pk_measdoc");
|
||||
sqlBuilder.append(" where b.dr = 0");
|
||||
sqlBuilder.append(" and ");
|
||||
sqlBuilder.append("a.csourcebillid", sourceId);
|
||||
// sqlBuilder.append("a.csourcebillid", sourceId);
|
||||
sqlBuilder.append("a.vsourcemorowid", sourceId);// 来源生产订单明细id
|
||||
List<Map<String, Object>> result = (List<Map<String, Object>>) dao.executeQuery(sqlBuilder.toString(), new MapListProcessor());
|
||||
for (Map<String, Object> objectMap : result) {
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
|
@ -230,32 +251,7 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换特殊字段 如 1/1 转换为小数 1.0
|
||||
*/
|
||||
private String transferSpecialField(String field) {
|
||||
if (field == null || field.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String[] split = field.split("/");
|
||||
if (split.length == 2) {
|
||||
String numStr = split[0].trim();
|
||||
String denStr = split[1].trim();
|
||||
if (denStr.equals("0")) {
|
||||
return "0.00"; // 分母不能为零
|
||||
}
|
||||
try {
|
||||
BigDecimal numerator = new BigDecimal(numStr);
|
||||
BigDecimal denominator = new BigDecimal(denStr);
|
||||
return numerator.divide(denominator, 2, RoundingMode.HALF_UP).toString();
|
||||
} catch (NumberFormatException e) {
|
||||
return field; // 非法数字,返回原字段
|
||||
}
|
||||
}
|
||||
return field;
|
||||
}
|
||||
|
||||
private JSONObject buildSyncData1(PMOAggVO vo) throws BusinessException {
|
||||
private JSONObject buildSyncCodeData(PMOAggVO vo) throws BusinessException {
|
||||
// [
|
||||
// {
|
||||
// "siteCode": "", // 工厂编码
|
||||
|
@ -288,18 +284,24 @@ public class AfterApproveSyncEpicMesRule implements IRule<PMOAggVO> {
|
|||
return obj;
|
||||
}
|
||||
|
||||
private void pushNoData(String requestUrl, JSONArray param) throws BusinessException {
|
||||
/**
|
||||
* 推送出厂编号
|
||||
*
|
||||
* @param param 传参
|
||||
* @throws BusinessException
|
||||
*/
|
||||
private void pushCodeData(JSONArray param) throws BusinessException {
|
||||
String baseUrl = SysParaInitQuery.getParaString("GLOBLE00000000000000", "EPICMESURL");
|
||||
baseUrl = "http://192.168.55.39:8080";
|
||||
requestUrl = baseUrl + requestUrl;
|
||||
String requestUrl = baseUrl + MES_CODE_URL;
|
||||
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, param.toJSONString());
|
||||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
obmlog.error("AfterApproveSyncEpicMesRule-pushData-req = " + result);
|
||||
obmlog.error("AfterApproveSyncEpicMesRule-pushCodeData-req = " + result);
|
||||
|
||||
if ("false".equals(resultObj.getString("success"))) {
|
||||
throw new BusinessException("AfterApproveSyncEpicMesRule-pushData-failerror:" + resultObj.getString("msg"));
|
||||
obmlog.error("AfterApproveSyncEpicMesRule-pushCodeData-fail:" + resultObj.getString("msg"));
|
||||
} else {
|
||||
obmlog.error("AfterApproveSyncEpicMesRule-pushData-suc,result[" + resultObj.toJSONString() + "]");
|
||||
obmlog.error("AfterApproveSyncEpicMesRule-pushCodeData-suc,result[" + resultObj.toJSONString() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1316,8 +1316,8 @@ public class InvoiceTransferUtil {
|
|||
|
||||
// 数电特殊票种字段
|
||||
pinvoice.setBdcdz(headvo.getBdcdz());
|
||||
pinvoice.setZlqq(getFormatDate(headvo.getZlqq()));
|
||||
pinvoice.setZlqz(getFormatDate(headvo.getZlqz()));
|
||||
pinvoice.setZlqq(getFormatDateTime(headvo.getZlqq()));
|
||||
pinvoice.setZlqz(getFormatDateTime(headvo.getZlqz()));
|
||||
pinvoice.setKdsbz(headvo.getKdsbz());
|
||||
pinvoice.setTdzzsxmbh(headvo.getTdzzsxmbh());
|
||||
pinvoice.setWqhtbabh(headvo.getWqhtbabh());
|
||||
|
@ -1353,10 +1353,10 @@ public class InvoiceTransferUtil {
|
|||
// 0:不显示 1:仅显示销地址、电话 2:仅显示购买方地址、电话 3:购销方地址、电话都显示
|
||||
int einvoiceShowGxfDzDh = 0;
|
||||
|
||||
if ("Y".equals(def17)) {
|
||||
if ("Y".equals(def4)) {
|
||||
einvoiceShowGxfDzDh += 1; // 销方地址电话显示
|
||||
}
|
||||
if ("Y".equals(def3)) {
|
||||
if ("Y".equals(def17)) {
|
||||
einvoiceShowGxfDzDh += 2; // 购方地址电话显示
|
||||
}
|
||||
|
||||
|
@ -1365,10 +1365,10 @@ public class InvoiceTransferUtil {
|
|||
// 0:不显示 1:仅显示销售方银行、账号 2:仅显示购买方银行、账号 3:购销方银行、账号都显示
|
||||
int einvoiceShowGxfYhZh = 0;
|
||||
|
||||
if ("Y".equals(def18)) {
|
||||
if ("Y".equals(def3)) {
|
||||
einvoiceShowGxfYhZh += 1; // 销方银行账户显示
|
||||
}
|
||||
if ("Y".equals(def4)) {
|
||||
if ("Y".equals(def18)) {
|
||||
einvoiceShowGxfYhZh += 2; // 购方银行账户显示
|
||||
}
|
||||
|
||||
|
@ -1711,4 +1711,20 @@ public class InvoiceTransferUtil {
|
|||
return format.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* °ÑUFDateת»»³Éyyyy-MM-dd¸ñʽ
|
||||
*
|
||||
* @param ufDate
|
||||
* @return
|
||||
*/
|
||||
public static String getFormatDateTime(UFDateTime ufDate) {
|
||||
if (ufDate == null) {
|
||||
return null;
|
||||
}
|
||||
Date date = ufDate.getDate().toDate();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -182,8 +182,8 @@ public class IVApplicationHeadVO extends SuperVO {
|
|||
private java.lang.String tspzdef99;
|
||||
private java.lang.String kdsbz;
|
||||
private java.lang.String bdcdz;
|
||||
private UFDate zlqq;
|
||||
private UFDate zlqz;
|
||||
private UFDateTime zlqq;
|
||||
private UFDateTime zlqz;
|
||||
private java.lang.String tdzzsxmbh;
|
||||
private java.lang.String wqhtbabh;
|
||||
private java.lang.String bdcdwdm;
|
||||
|
@ -1665,16 +1665,16 @@ public class IVApplicationHeadVO extends SuperVO {
|
|||
|
||||
|
||||
/**
|
||||
* 属性redrush_falg的Getter方法.属性名:redrush_falg
|
||||
* 红冲来源标识:
|
||||
* 属性redrush_falg的Getter方法.属性名:redrush_falg 红冲来源标识:
|
||||
*
|
||||
* @param java.lang.String
|
||||
*/
|
||||
public java.lang.String getRedrush_falg() {
|
||||
return redrush_falg;
|
||||
}
|
||||
/**
|
||||
* 属性redrush_falg的Setter方法.属性名:redrush_falg
|
||||
* 红冲来源标识:
|
||||
* 属性redrush_falg的Setter方法.属性名:redrush_falg 红冲来源标识:
|
||||
*
|
||||
* @param java.lang.String
|
||||
*/
|
||||
public void setRedrush_falg(java.lang.String redrush_falg) {
|
||||
|
@ -2081,16 +2081,20 @@ public class IVApplicationHeadVO extends SuperVO {
|
|||
public void setBdcdz(java.lang.String bdcdz) {
|
||||
this.bdcdz = bdcdz;
|
||||
}
|
||||
public UFDate getZlqq() {
|
||||
|
||||
public UFDateTime getZlqq() {
|
||||
return zlqq;
|
||||
}
|
||||
public void setZlqq(UFDate zlqq) {
|
||||
|
||||
public void setZlqq(UFDateTime zlqq) {
|
||||
this.zlqq = zlqq;
|
||||
}
|
||||
public UFDate getZlqz() {
|
||||
|
||||
public UFDateTime getZlqz() {
|
||||
return zlqz;
|
||||
}
|
||||
public void setZlqz(UFDate zlqz) {
|
||||
|
||||
public void setZlqz(UFDateTime zlqz) {
|
||||
this.zlqz = zlqz;
|
||||
}
|
||||
public java.lang.String getTdzzsxmbh() {
|
||||
|
|
Loading…
Reference in New Issue