备料审批后推送高压MES修改接口
This commit is contained in:
parent
2fc6dd67e5
commit
fb975ac137
|
|
@ -62,6 +62,7 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
|
||||||
HYPubBO hybo = new HYPubBO();
|
HYPubBO hybo = new HYPubBO();
|
||||||
JSONObject list = new JSONObject();
|
JSONObject list = new JSONObject();
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
String flags = "";//判断是否新增或修改
|
||||||
for (AggPickmVO vo : useVOs) {
|
for (AggPickmVO vo : useVOs) {
|
||||||
PickmHeadVO pickmHeadVO = vo.getParentVO();
|
PickmHeadVO pickmHeadVO = vo.getParentVO();
|
||||||
PickmItemVO[] itemVOS = (PickmItemVO[]) vo.getChildrenVO();
|
PickmItemVO[] itemVOS = (PickmItemVO[]) vo.getChildrenVO();
|
||||||
|
|
@ -72,6 +73,15 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
JSONObject singleObj = new JSONObject();
|
JSONObject singleObj = new JSONObject();
|
||||||
|
// 创建子项数组
|
||||||
|
JSONArray contentArray = new JSONArray();
|
||||||
|
//自定义项19是Y时调用修改口,若不是则调用新增口
|
||||||
|
String saleDef = pickmHeadVO.getVdef19() == null ? "" : pickmHeadVO.getVdef19();
|
||||||
|
if (!saleDef.equals("Y")) {
|
||||||
|
// 更新自定义项19为“Y”
|
||||||
|
String sql = "update mm_pickm set vdef19 = '" + "Y" + "' where vbillcode = '" + pickmHeadVO.getVbillcode() + "'";
|
||||||
|
baseDAO.executeUpdate(sql);
|
||||||
|
|
||||||
singleObj.put("materialPreparationPlanNumber", pickmHeadVO.getVbillcode());// 备料计划单号
|
singleObj.put("materialPreparationPlanNumber", pickmHeadVO.getVbillcode());// 备料计划单号
|
||||||
singleObj.put("bipId", pickmHeadVO.getCpickmid());// 主键ID
|
singleObj.put("bipId", pickmHeadVO.getCpickmid());// 主键ID
|
||||||
// 生产部门
|
// 生产部门
|
||||||
|
|
@ -103,7 +113,6 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
|
||||||
singleObj.put("bipCreateBy", bipCreateBy); // 创建人ID
|
singleObj.put("bipCreateBy", bipCreateBy); // 创建人ID
|
||||||
|
|
||||||
// 创建子项数组
|
// 创建子项数组
|
||||||
JSONArray contentArray = new JSONArray();
|
|
||||||
for (PickmItemVO item : itemVOS) {
|
for (PickmItemVO item : itemVOS) {
|
||||||
JSONObject itemObj = new JSONObject();
|
JSONObject itemObj = new JSONObject();
|
||||||
|
|
||||||
|
|
@ -139,12 +148,81 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
|
||||||
|
|
||||||
contentArray.add(itemObj); // 将子项添加到数组
|
contentArray.add(itemObj); // 将子项添加到数组
|
||||||
}
|
}
|
||||||
|
flags = "addOrder";
|
||||||
|
} else {
|
||||||
|
// JSONObject singleObj = new JSONObject();
|
||||||
|
singleObj.put("materialPreparationPlanNumber", pickmHeadVO.getVbillcode());// 备料计划单号
|
||||||
|
singleObj.put("bipId", pickmHeadVO.getCpickmid());// 主键ID
|
||||||
|
// 生产部门
|
||||||
|
String deptsql = " select name from org_dept where pk_dept='" + pickmHeadVO.getCdeptid() + "' and dr=0 ";
|
||||||
|
Map<String, Object> dept = (Map<String, Object>) baseDAO.executeQuery(deptsql, new MapProcessor());
|
||||||
|
singleObj.put("bipDeptName", dept.get("name")); // 生产部门
|
||||||
|
singleObj.put("bipDeptId", pickmHeadVO.getCdeptid()); // 生产部门Id
|
||||||
|
|
||||||
|
singleObj.put("bipProcessProductionOrderId", pickmHeadVO.getVsourcemocode()); // 流程生产订单号
|
||||||
|
singleObj.put("bipProcessProductionOrderRowNum", pickmHeadVO.getVsourcemorowcode()); // 来源单据号行号
|
||||||
|
singleObj.put("bipParentProcessProductionOrderId", pickmHeadVO.getVfirstbillcode()); // 上级来源单据号
|
||||||
|
singleObj.put("bipParentProcessProductionOrderRowNum", pickmHeadVO.getVfirstbillrowno()); // 上级来源单据行号
|
||||||
|
singleObj.put("bipOriginProcessProductionOrderId", pickmHeadVO.getVsalebillcode()); // 顶级来源单据号
|
||||||
|
singleObj.put("bipOriginProcessProductionOrderRowNum", ""); // 顶级来源单据行号
|
||||||
|
singleObj.put("orderQuantity", pickmHeadVO.getNastnum() != null ? pickmHeadVO.getNastnum().doubleValue() : null); // 订单数量(计划数量)
|
||||||
|
singleObj.put("bomVersion", pickmHeadVO.getVbomversionnumber()); // bom版本
|
||||||
|
// 物料信息
|
||||||
|
String cpsql = "select code,name,graphid,pk_measdoc,materialspec from bd_material where pk_material = '" + pickmHeadVO.getCmaterialvid() + "' ";
|
||||||
|
Map<String, Object> mrl = (Map<String, Object>) baseDAO.executeQuery(cpsql, new MapProcessor());
|
||||||
|
singleObj.put("productCode", mrl.get("code")); // 产品编码
|
||||||
|
singleObj.put("productName", mrl.get("name")); // 产品名称
|
||||||
|
|
||||||
|
// singleObj.put("intervalModel", mrl.get("materialspec")); // (物料的自定义字段)
|
||||||
|
singleObj.put("processCode", "(物料的自定义字段)"); // 产品编码的工序(物料的自定义字段)
|
||||||
|
singleObj.put("requiredDate", pickmHeadVO.getDmakedate().toString()); // 需用日期
|
||||||
|
String sql1 = " select user_name from sm_user where cuserid = '" + pickmHeadVO.getModifier() + "' ";
|
||||||
|
String bipCreateBy = (String) baseDAO.executeQuery(sql1, new ColumnProcessor());
|
||||||
|
|
||||||
|
singleObj.put("bipUpdateBy", bipCreateBy); // 创建人ID
|
||||||
|
|
||||||
|
// 创建子项数组
|
||||||
|
// JSONArray contentArray = new JSONArray();
|
||||||
|
for (PickmItemVO item : itemVOS) {
|
||||||
|
JSONObject itemObj = new JSONObject();
|
||||||
|
|
||||||
|
itemObj.put("bipChildId", item.getCpickm_bid()); // 子项主键ID
|
||||||
|
itemObj.put("quantityPerSet", item.getNunituseastnum() != null ? item.getNunituseastnum().doubleValue() : null); // 单套数量(单位用量)
|
||||||
|
itemObj.put("reservedQuantity", item.getNatpastnum() != null ? item.getNatpastnum().doubleValue() : null); // 预留数量
|
||||||
|
itemObj.put("cumulativePendingQuantity", item.getNshouldastnum() != null ? item.getNshouldastnum().doubleValue() : null); // 累计待发数量
|
||||||
|
itemObj.put("cumulativeIssuedQuantity", item.getNaccoutastnum() != null ? item.getNaccoutastnum().doubleValue() : null); // 累计出库数量
|
||||||
|
itemObj.put("totalQuantity", item.getNplanoutnum() != null ? item.getNplanoutnum().doubleValue() : null); // 总数量(计划出库主数量)
|
||||||
|
|
||||||
|
// 物料信息
|
||||||
|
String mrlsql = "select code,name,graphid,pk_measdoc,materialspec from bd_material where pk_material = '" + item.getCbmaterialid() + "' ";
|
||||||
|
Map<String, Object> material = (Map<String, Object>) baseDAO.executeQuery(mrlsql, new MapProcessor());
|
||||||
|
itemObj.put("materialCode", material.get("code")); // 物料编码
|
||||||
|
itemObj.put("materialName", material.get("name")); // 物料名称
|
||||||
|
itemObj.put("drawingNumber", material.get("graphid")); // 图号
|
||||||
|
Object unit = hybo.findColValue("bd_measdoc", "code", " pk_measdoc = '" + material.get("pk_measdoc") + "' ");
|
||||||
|
itemObj.put("unit", unit); // 规格单位
|
||||||
|
// 生产信息
|
||||||
|
// itemObj.put("intervalModel", material.get("materialspec")); // 产品类型
|
||||||
|
itemObj.put("lineNumber", String.valueOf(item.getVrowno())); // 行号
|
||||||
|
// 项目编码
|
||||||
|
String cprojectid = pickmHeadVO.getCprojectid();// 项目id
|
||||||
|
String projectCode = MyHelper.getStrValByCondition(ProjectHeadVO.getDefaultTableName(), ProjectHeadVO.PROJECT_CODE,
|
||||||
|
ProjectHeadVO.PK_PROJECT + " = '" + cprojectid + "'");
|
||||||
|
singleObj.put("cbprojectid", projectCode);
|
||||||
|
// 生产厂商
|
||||||
|
// String productor = item.getCbproductorid();// 生产厂商id
|
||||||
|
String productorCode = getDefCode("Defdoc-BD006_0xx", item.getCbproductorid());
|
||||||
|
singleObj.put("cbproductorid", productorCode);
|
||||||
|
|
||||||
|
contentArray.add(itemObj); // 将子项添加到数组
|
||||||
|
}
|
||||||
|
flags = "updateOrder";
|
||||||
|
}
|
||||||
singleObj.put("itemList", contentArray); // 将子项数组添加到主对象
|
singleObj.put("itemList", contentArray); // 将子项数组添加到主对象
|
||||||
jsonArray.add(singleObj);
|
jsonArray.add(singleObj);
|
||||||
list.put("list", jsonArray);
|
list.put("list", jsonArray);
|
||||||
}
|
}
|
||||||
pushData(list);
|
pushData(list, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -168,7 +246,7 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
|
||||||
/**
|
/**
|
||||||
* 推送同步数据
|
* 推送同步数据
|
||||||
*/
|
*/
|
||||||
private void pushData(JSONObject param) throws BusinessException {
|
private void pushData(JSONObject param, String flags) throws BusinessException {
|
||||||
// 转json字符串的时候保留null值
|
// 转json字符串的时候保留null值
|
||||||
String jsonStr = JSON.toJSONString(param,
|
String jsonStr = JSON.toJSONString(param,
|
||||||
SerializerFeature.WriteMapNullValue,
|
SerializerFeature.WriteMapNullValue,
|
||||||
|
|
@ -176,7 +254,12 @@ public class AfterApproveRuleHighpressureMes implements IRule<AggPickmVO> {
|
||||||
);
|
);
|
||||||
logger.error("gyMes-Pickm-param = " + jsonStr);
|
logger.error("gyMes-Pickm-param = " + jsonStr);
|
||||||
String baseUrl = configParams.get("mesBaseUrl");
|
String baseUrl = configParams.get("mesBaseUrl");
|
||||||
String requestUrl = baseUrl + configParams.get("materialRequirementsAdd");
|
String requestUrl = "";
|
||||||
|
if (flags.equals("addOrder")) {
|
||||||
|
requestUrl = baseUrl + configParams.get("materialRequirementsAdd");
|
||||||
|
} else if (flags.equals("updateOrder")) {//调用修改口
|
||||||
|
requestUrl = baseUrl + configParams.get("materialRequirementsUpdate");
|
||||||
|
}
|
||||||
logger.error("gyMes-Pickm-url = " + requestUrl);
|
logger.error("gyMes-Pickm-url = " + requestUrl);
|
||||||
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
|
String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr);
|
||||||
JSONObject resultObj = JSONObject.parseObject(result);
|
JSONObject resultObj = JSONObject.parseObject(result);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue