箱变-质检报告推启源MES-调整为发送到货单下的所有质检报告
This commit is contained in:
parent
24796e96da
commit
c2ab1bd31b
|
|
@ -6,23 +6,32 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
||||
import nc.impl.pubapp.pattern.data.bill.BillQuery;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.bd.supplier.baseinfo.ISupplierBaseInfoQryService;
|
||||
import nc.vo.am.common.util.StringUtils;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.bd.material.measdoc.MeasdocVO;
|
||||
import nc.vo.bd.psn.PsndocVO;
|
||||
import nc.vo.bd.supplier.SupplierVersionVO;
|
||||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pu.m23.entity.ArriveHeaderVO;
|
||||
import nc.vo.pu.m23.entity.ArriveItemVO;
|
||||
import nc.vo.pu.m23.entity.ArriveVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.qc.c003.entity.ReportHeaderVO;
|
||||
import nc.vo.qc.c003.entity.ReportItemVO;
|
||||
import nc.vo.qc.c003.entity.ReportVO;
|
||||
import nc.vo.sm.UserVO;
|
||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 箱变-质检报告推启源MES
|
||||
|
|
@ -47,7 +56,25 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
|
|||
if (configParams.isEmpty()) {
|
||||
throw new BusinessException("箱变的QMS接口缺少配置");
|
||||
}
|
||||
buildSyncData(reportVOS);
|
||||
Set<String> firstIds = new HashSet<>();
|
||||
// 查询上游到货单的数据
|
||||
for (ReportVO vo : reportVOS) {
|
||||
ReportItemVO[] bvo = vo.getBVO();
|
||||
if (bvo == null) {
|
||||
continue;
|
||||
}
|
||||
for (ReportItemVO itemVO : bvo) {
|
||||
firstIds.add(itemVO.getCfirstid());
|
||||
}
|
||||
}
|
||||
if (!firstIds.isEmpty()) {
|
||||
// 上游到货单
|
||||
BillQuery<ArriveVO> billquery = new BillQuery(ArriveVO.class);
|
||||
ArriveVO[] arriveVOS = billquery.query(firstIds.toArray(new String[0]));
|
||||
buildSyncData(arriveVOS);
|
||||
}
|
||||
// 组织数据
|
||||
// buildSyncData(reportVOS);
|
||||
} catch (Exception e) {
|
||||
ExceptionUtils.wrappException(e);
|
||||
}
|
||||
|
|
@ -55,8 +82,75 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
|
|||
|
||||
/**
|
||||
* 构建同步数据
|
||||
*
|
||||
* @param arriveVOS 到货单VO
|
||||
*/
|
||||
private void buildSyncData(ReportVO[] useVOs) throws BusinessException {
|
||||
private void buildSyncData(ArriveVO[] arriveVOS) throws BusinessException {
|
||||
for (ArriveVO arriveVO : arriveVOS) {
|
||||
ArriveHeaderVO hvo = arriveVO.getHVO();
|
||||
ArriveItemVO[] bvo = arriveVO.getBVO();
|
||||
String pk_arriveorder = hvo.getPk_arriveorder();
|
||||
String pkOrg = hvo.getPk_org();
|
||||
// 判断物料的业务单元是否是箱变公司,不是则跳过
|
||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
// 查询供应商信息
|
||||
String pk_supplier_v = hvo.getPk_supplier_v();
|
||||
SupplierVersionVO supplierVersionVO = new SupplierVersionVO();
|
||||
if (pk_supplier_v != null && !pk_supplier_v.isEmpty() && !"~".equals(pk_supplier_v)) {
|
||||
ISupplierBaseInfoQryService baseQryService = NCLocator.getInstance().lookup(ISupplierBaseInfoQryService.class);
|
||||
supplierVersionVO = baseQryService.querySupplierVersionByVID(pk_supplier_v);
|
||||
}
|
||||
// 制单人名称
|
||||
String creatorName = MyHelper.getStrValByCondition("sm_user", UserVO.USER_NAME,
|
||||
UserVO.CUSERID + " = '" + hvo.getBillmaker() + "'");
|
||||
JSONObject singleObj = new JSONObject();
|
||||
String cghth = "";
|
||||
if (bvo != null && bvo.length > 0) {
|
||||
cghth = bvo[0].getVsourcecode();
|
||||
}
|
||||
// 启源送检单主表
|
||||
long cts = System.currentTimeMillis();
|
||||
singleObj.put("batchid", cts);
|
||||
singleObj.put("csdh", hvo.getVbillcode());// 送检单号,BIP到货单号
|
||||
singleObj.put("sjrq", hvo.getDmakedate().toString());// 送检日期,格式建议为 yyyy-MM-dd
|
||||
singleObj.put("wlgysid", supplierVersionVO.getCode());// 供应商编码
|
||||
singleObj.put("wlgysmc", supplierVersionVO.getName());// 供应商名称
|
||||
singleObj.put("sjr", creatorName);// 送检人,BIP制单人
|
||||
singleObj.put("cghth", cghth);// 采购合同号,关联对应的采购合同
|
||||
singleObj.put("bz", hvo.getVmemo());// 摘要备注,用于填写送检单的补充说明信息
|
||||
// 查询关联的质检报告-传入启源送检单的明细
|
||||
HYPubBO hybo = new HYPubBO();
|
||||
ReportItemVO[] reportItemVOS = (ReportItemVO[]) hybo.queryByCondition(ReportItemVO.class, " and cfirstid = '" + pk_arriveorder + "'");
|
||||
JSONArray contentArray = new JSONArray();
|
||||
for (ReportItemVO reportItemVO : reportItemVOS) {
|
||||
String pkReportbill = reportItemVO.getPk_reportbill();
|
||||
ReportHeaderVO reportHeaderVO = (ReportHeaderVO) hybo.queryByPrimaryKey(ReportHeaderVO.class, pkReportbill);
|
||||
String pkMaterial = reportHeaderVO.getPk_material();
|
||||
Map<String, Object> materialMap = MyHelper.getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,materialspec,materialtype",
|
||||
"pk_material = '" + pkMaterial + "'");
|
||||
String cunitid = reportHeaderVO.getCunitid();// 主单位
|
||||
String cunitname = MyHelper.getStrValByCondition(MeasdocVO.getDefaultTableName(), MeasdocVO.NAME,
|
||||
MeasdocVO.PK_MEASDOC + " = '" + cunitid + "'");
|
||||
JSONObject itemObj = new JSONObject();
|
||||
itemObj.put("wlbh", materialMap.getOrDefault("code", "")); // 物料编码
|
||||
itemObj.put("wlmc", materialMap.getOrDefault("name", "")); // 物料名称
|
||||
String materialtype = skipNull(materialMap.get("materialtype"));
|
||||
String materialspec = skipNull(materialMap.get("materialspec"));
|
||||
itemObj.put("wlxhgg", materialtype + materialspec); // 物料型号规格
|
||||
itemObj.put("sjsl", reportHeaderVO.getNapplynum().toString()); // 送检数量(设计单位),按设计计量单位统计的送检数量
|
||||
itemObj.put("jldw", cunitname); // 计量单位
|
||||
itemObj.put("bz", reportItemVO.getVbdef1()); // 明细备注,用于填写该送检物料的补充说明
|
||||
contentArray.add(itemObj);
|
||||
}
|
||||
singleObj.put("Content", contentArray);
|
||||
pushData(singleObj);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildSyncData1(ReportVO[] useVOs) throws BusinessException {
|
||||
for (ReportVO vo : useVOs) {
|
||||
ReportHeaderVO hvo = vo.getHVO();
|
||||
ReportItemVO[] bvo = vo.getBVO();
|
||||
|
|
@ -68,8 +162,11 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
|
|||
}
|
||||
// 查询供应商信息
|
||||
String pk_supplier_v = hvo.getPk_supplier_v();
|
||||
SupplierVersionVO supplierVersionVO = new SupplierVersionVO();
|
||||
if (pk_supplier_v != null && !pk_supplier_v.isEmpty() && !"~".equals(pk_supplier_v)) {
|
||||
ISupplierBaseInfoQryService baseQryService = NCLocator.getInstance().lookup(ISupplierBaseInfoQryService.class);
|
||||
SupplierVersionVO supplierVersionVO = baseQryService.querySupplierVersionByVID(pk_supplier_v);
|
||||
supplierVersionVO = baseQryService.querySupplierVersionByVID(pk_supplier_v);
|
||||
}
|
||||
// 查询人员信息
|
||||
String pkApplyer = hvo.getPk_applyer();
|
||||
String applyerName = MyHelper.getStrValByCondition(PsndocVO.getDefaultTableName(), PsndocVO.NAME,
|
||||
|
|
@ -102,8 +199,8 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
|
|||
JSONObject itemObj = new JSONObject();
|
||||
itemObj.put("wlbh", materialMap.getOrDefault("code", "")); // 物料编码
|
||||
itemObj.put("wlmc", materialMap.getOrDefault("name", "")); // 物料名称
|
||||
String materialtype = materialMap.getOrDefault("materialtype", "") + "";
|
||||
String materialspec = materialMap.getOrDefault("materialspec", "") + "";
|
||||
String materialtype = skipNull(materialMap.get("materialtype"));
|
||||
String materialspec = skipNull(materialMap.get("materialspec"));
|
||||
itemObj.put("wlxhgg", materialtype + materialspec); // 物料型号规格
|
||||
itemObj.put("sjsl", hvo.getNapplynum().toString()); // 送检数量(设计单位),按设计计量单位统计的送检数量
|
||||
itemObj.put("jldw", cunitname); // 计量单位
|
||||
|
|
@ -163,7 +260,7 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
|
|||
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("xbOrg");
|
||||
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
|
||||
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(",");
|
||||
|
|
@ -175,4 +272,11 @@ public class SyncQcQmsRule implements IRule<ReportVO> {
|
|||
return true;
|
||||
}
|
||||
|
||||
public String skipNull(Object value) {
|
||||
if ((value == null) || (value.toString().trim().length() == 0)) {
|
||||
return "";
|
||||
}
|
||||
return value.toString().trim();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue