Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
bd306422db
|
|
@ -1,14 +1,16 @@
|
|||
package nc.bs.mmpac.pmo.pac0002.bp.rule;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.util.SyncSrmPrayBillUtil;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.pu.m20.IPraybillMaintain;
|
||||
import nc.jdbc.framework.processor.MapListProcessor;
|
||||
import nc.vo.bd.material.stock.MaterialStockVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pu.m20.entity.PraybillItemVO;
|
||||
|
|
@ -16,7 +18,6 @@ import nc.vo.pu.m20.entity.PraybillVO;
|
|||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.pubapp.pattern.model.transfer.bill.ClientBillToServer;
|
||||
import nccloud.framework.service.ServiceLocator;
|
||||
import nccloud.pubitf.pu.buyingreq.service.IBuyingReqQueryCardInfoService;
|
||||
import nccloud.web.pu.buyingreq.util.PublicUtil;
|
||||
|
||||
|
|
@ -36,89 +37,97 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
|||
public void process(PMOAggVO[] pmoAggVOS) {
|
||||
BaseDAO dao = new BaseDAO();
|
||||
try {
|
||||
for (PMOAggVO pmoAggVO : pmoAggVOS) {
|
||||
for (PMOItemVO pmoItemVO : pmoAggVO.getChildrenVO()) {
|
||||
configParams = MyHelper.getConfigParams("xb-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
throw new BusinessException("箱变的QMS接口缺少配置");
|
||||
}
|
||||
String pkOrg = pmoAggVO.getParentVO().getPk_org();
|
||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
for (PMOAggVO pmoAggVO : pmoAggVOS) {
|
||||
for (PMOItemVO pmoItemVO : pmoAggVO.getChildrenVO()) {
|
||||
configParams = MyHelper.getConfigParams("xb-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
throw new BusinessException("箱变的QMS接口缺少配置");
|
||||
}
|
||||
String pkOrg = pmoAggVO.getParentVO().getPk_org();
|
||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
String pmoid = pmoItemVO.getCmoid();
|
||||
UFDouble nastnum = pmoItemVO.getNastnum();
|
||||
// 查询备料计划
|
||||
String pickmsql = "select cpickm_bid,cbmaterialvid,nplanoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + pmoid + "' and dr=0) and dr = 0";
|
||||
List<Map<String, Object>> hmateral = (List<Map<String, Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
|
||||
try {
|
||||
String pmoid = pmoItemVO.getCmoid();
|
||||
UFDouble nastnum = pmoItemVO.getNastnum();
|
||||
// 查询备料计划
|
||||
String pickmsql = "select cpickm_bid,cbmaterialvid,nplanoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + pmoid + "' and dr=0) and dr = 0";
|
||||
List<Map<String, Object>> hmateral = (List<Map<String, Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
|
||||
|
||||
List<String> pmobids = new ArrayList<String>();
|
||||
List<String> pmoids = new ArrayList<String>();
|
||||
// 根据 生产订单-备料计划-计划订单-请购单-采购订单-到货单-采购入库 依次更新下游单据
|
||||
for (Map<String, Object> map : hmateral) {
|
||||
if (null == map.get("cbmaterialvid")) {
|
||||
List<String> pmobids = new ArrayList<String>();
|
||||
List<String> pmoids = new ArrayList<String>();
|
||||
// 根据 生产订单-备料计划-计划订单-请购单-采购订单-到货单-采购入库 依次更新下游单据
|
||||
for (Map<String, Object> map : hmateral) {
|
||||
if (null == map.get("cbmaterialvid")) {
|
||||
continue;
|
||||
}
|
||||
String material = map.get("cbmaterialvid").toString();
|
||||
if (!checkProdect(material, pkOrg)) {
|
||||
continue;
|
||||
}
|
||||
String material = map.get("cbmaterialvid").toString();
|
||||
if (!checkProdect(material, pkOrg)) {
|
||||
continue;
|
||||
}
|
||||
// 查询计划订单
|
||||
String plosql = "select cpoid from mm_plo where vsrcbid ='" + map.get("cpickm_bid") + "' and dr = 0";
|
||||
List<Map<String, Object>> ploList = (List<Map<String, Object>>) dao.executeQuery(plosql, new MapListProcessor());
|
||||
for (Map<String, Object> plo : ploList) {
|
||||
// 查询请购单
|
||||
String buyingreqsql = "select pk_praybill,pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0";
|
||||
List<Map<String, Object>> buyingreq = (List<Map<String, Object>>) dao.executeQuery(buyingreqsql, new MapListProcessor());
|
||||
for (Map<String, Object> map2 : buyingreq) {
|
||||
}
|
||||
// 查询计划订单
|
||||
String plosql = "select cpoid from mm_plo where vsrcbid ='" + map.get("cpickm_bid") + "' and dr = 0";
|
||||
List<Map<String, Object>> ploList = (List<Map<String, Object>>) dao.executeQuery(plosql, new MapListProcessor());
|
||||
for (Map<String, Object> plo : ploList) {
|
||||
// 查询请购单
|
||||
String buyingreqsql = "select pk_praybill,pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0";
|
||||
List<Map<String, Object>> buyingreq = (List<Map<String, Object>>) dao.executeQuery(buyingreqsql, new MapListProcessor());
|
||||
for (Map<String, Object> map2 : buyingreq) {
|
||||
|
||||
if (UFDouble.ZERO_DBL.compareTo(new UFDouble(map.get("nplanoutnum").toString())) == 0) {
|
||||
pmobids.add(map2.get("pk_praybill_b").toString());
|
||||
pmoids.add(map2.get("pk_praybill").toString());
|
||||
}
|
||||
if (new UFDouble((BigDecimal) map2.get("nnum")).compareTo(new UFDouble((BigDecimal) map.get("nplanoutnum"))) > 0) {
|
||||
// 更新请购单
|
||||
String sql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='"
|
||||
+ map2.get("pk_praybill_b") + "'";
|
||||
dao.executeUpdate(sql);
|
||||
// 查询采购订单
|
||||
String ordersql = "select pk_order_b from po_order_b where csourcebid ='" + map2.get("pk_praybill_b") + "' and dr = 0";
|
||||
List<Map<String, Object>> orders = (List<Map<String, Object>>) dao.executeQuery(ordersql, new MapListProcessor());
|
||||
for (Map<String, Object> order : orders) {
|
||||
// 更新采购订单
|
||||
String updateOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='"
|
||||
+ order.get("pk_order_b") + "'";
|
||||
dao.executeUpdate(updateOrderSql);
|
||||
// 查询到货单
|
||||
String arriveordersql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + order.get("pk_order_b") + "' and dr = 0";
|
||||
List<Map<String, Object>> arriveorders = (List<Map<String, Object>>) dao.executeQuery(arriveordersql, new MapListProcessor());
|
||||
for (Map<String, Object> arriveorder : arriveorders) {
|
||||
// 更新到货单
|
||||
String updatearriveorderSql = "update po_arriveorder_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_arriveorder_b='"
|
||||
+ arriveorder.get("pk_arriveorder_b") + "'";
|
||||
dao.executeUpdate(updatearriveorderSql);
|
||||
// 已经采购入库的数据不处理
|
||||
if (UFDouble.ZERO_DBL.compareTo(new UFDouble(map.get("nplanoutnum").toString())) == 0) {
|
||||
pmobids.add(map2.get("pk_praybill_b").toString());
|
||||
pmoids.add(map2.get("pk_praybill").toString());
|
||||
}
|
||||
if (new UFDouble((BigDecimal) map2.get("nnum")).compareTo(new UFDouble((BigDecimal) map.get("nplanoutnum"))) > 0) {
|
||||
// 更新请购单
|
||||
String sql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='"
|
||||
+ map2.get("pk_praybill_b") + "'";
|
||||
int num = dao.executeUpdate(sql);
|
||||
if (num > 0 && "C030".equals(orgCode)) {
|
||||
SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil();
|
||||
JSONObject reqData = new JSONObject();
|
||||
reqData.put("org", "C030");// 组织编码
|
||||
reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键
|
||||
reqData.put("mainNum", map.get("nplanoutnum"));// 主数量
|
||||
billUtil.reqBIPBill(reqData);
|
||||
}
|
||||
// 查询采购订单
|
||||
String ordersql = "select pk_order_b from po_order_b where csourcebid ='" + map2.get("pk_praybill_b") + "' and dr = 0";
|
||||
List<Map<String, Object>> orders = (List<Map<String, Object>>) dao.executeQuery(ordersql, new MapListProcessor());
|
||||
for (Map<String, Object> order : orders) {
|
||||
// 更新采购订单
|
||||
String updateOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='"
|
||||
+ order.get("pk_order_b") + "'";
|
||||
dao.executeUpdate(updateOrderSql);
|
||||
// 查询到货单
|
||||
String arriveordersql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + order.get("pk_order_b") + "' and dr = 0";
|
||||
List<Map<String, Object>> arriveorders = (List<Map<String, Object>>) dao.executeQuery(arriveordersql, new MapListProcessor());
|
||||
for (Map<String, Object> arriveorder : arriveorders) {
|
||||
// 更新到货单
|
||||
String updatearriveorderSql = "update po_arriveorder_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_arriveorder_b='"
|
||||
+ arriveorder.get("pk_arriveorder_b") + "'";
|
||||
dao.executeUpdate(updatearriveorderSql);
|
||||
// 已经采购入库的数据不处理
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pmobids.size() > 0) {
|
||||
buyingreqRowClose(pmobids, pmoids);
|
||||
}
|
||||
}
|
||||
if (pmobids.size() > 0) {
|
||||
buyingreqRowClose(pmobids,pmoids);
|
||||
}
|
||||
|
||||
|
||||
} catch (DAOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (BusinessException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
|
||||
} catch (DAOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (BusinessException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
@ -134,14 +143,14 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
for (PraybillVO vo : rvo) {
|
||||
ClientBillToServer<PraybillVO> tool = new ClientBillToServer<PraybillVO>();
|
||||
PraybillVO[] lightVOs = (PraybillVO[])tool.construct(new PraybillVO[]{vo}, new PraybillVO[]{vo});
|
||||
PraybillVO[] lightVOs = (PraybillVO[]) tool.construct(new PraybillVO[]{vo}, new PraybillVO[]{vo});
|
||||
// 过滤需要关闭的请购单行
|
||||
for(PraybillVO storeReqAppVO : lightVOs) {
|
||||
for (PraybillVO storeReqAppVO : lightVOs) {
|
||||
PraybillItemVO[] bvos = storeReqAppVO.getBVO();
|
||||
List<PraybillItemVO> newItemVo = new ArrayList<>(lightVOs.length);
|
||||
if (bvos != null && bvos.length > 0) {
|
||||
for(int i = 0; i < bvos.length; ++i) {
|
||||
if (pmobids.contains(bvos[i].getPk_praybill_b()) ) {
|
||||
for (int i = 0; i < bvos.length; ++i) {
|
||||
if (pmobids.contains(bvos[i].getPk_praybill_b())) {
|
||||
bvos[i].setAttributeValue("vclosereason", reason);
|
||||
newItemVo.add(bvos[i]);
|
||||
}
|
||||
|
|
@ -149,12 +158,11 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
storeReqAppVO.setBVO(newItemVo.toArray(new PraybillItemVO[0]));
|
||||
}
|
||||
IPraybillMaintain orderCloseService =NCLocator.getInstance().lookup(IPraybillMaintain.class);
|
||||
IPraybillMaintain orderCloseService = NCLocator.getInstance().lookup(IPraybillMaintain.class);
|
||||
orderCloseService.closeBillRow(lightVOs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -173,10 +181,11 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
|||
e.printStackTrace();
|
||||
}
|
||||
if (list != null && list.size() > 0) {
|
||||
return list.get(0).getFixasst2()==null?false:list.get(0).getFixasst2().booleanValue();
|
||||
return list.get(0).getFixasst2() == null ? false : list.get(0).getFixasst2().booleanValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
|
|
|||
|
|
@ -45,13 +45,16 @@ public class BeforePmoBomRule implements IRule<PMOAggVO> {
|
|||
// vsrctype 来源单据类型 来源销售订单的需要赋值
|
||||
if ("30".equals(pmoItemVO.getVsrctype())) {
|
||||
// BOM状态 (FBomBillstatusEnum) 是否需要判断BOM的状态
|
||||
String cmaterialvid = pmoItemVO.getCmaterialvid();
|
||||
// 根据bom版本号查询BOM(销售订单号+行号)
|
||||
String bomVersion = pmoItemVO.getVsrccode() + "-" + pmoItemVO.getVsrcrowno();
|
||||
String whereSql = BomVO.PK_ORG + " = '" + pkOrg + "' AND " + BomVO.HVERSION + " = '" + bomVersion + "'";
|
||||
String whereSql = BomVO.PK_ORG + " = '" + pkOrg + "'" +
|
||||
" AND " + BomVO.HVERSION + " = '" + bomVersion + "'" +
|
||||
" AND " + BomVO.HCMATERIALID + " = '" + cmaterialvid + "'";
|
||||
// NCCForUAPLogger.debug("whereSql:" + whereSql);
|
||||
String bomId = MyHelper.getStrValByCondition(BomVO.TABLE_NAME, BomVO.CBOMID, whereSql);
|
||||
if (StringUtils.isEmpty(bomId)) {
|
||||
throw new BusinessException("未找到版本号(" + bomVersion + ")对应的BOM");
|
||||
throw new BusinessException("未找到版本号(" + bomVersion + ")对应的BOM,whereSql = " + whereSql);
|
||||
}
|
||||
pmoItemVO.setVbomversion(bomVersion); // 生产BOM版本号
|
||||
pmoItemVO.setCbomversionid(bomId); // 生产BOM版本
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import nc.bs.dao.BaseDAO;
|
|||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.trade.business.HYPubBO;
|
||||
import nc.itf.mmpac.pmo.pac0002.IPMOBusinessService;
|
||||
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
|
||||
import nc.jdbc.framework.SQLParameter;
|
||||
|
|
@ -335,11 +336,14 @@ public class PmoResource extends AbstractNCCRestResource {
|
|||
if (MMCollectionUtil.isEmpty(bidList)) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含pmobids信息", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
} else {
|
||||
HYPubBO hy = new HYPubBO();
|
||||
try {
|
||||
String[] pmobids = bidList.toArray(new String[0]);
|
||||
IPMOQueryService pmoQuery = NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||
PMOAggVO[] pmoAggVOS = pmoQuery.queryPMOAggVOByBid(pmobids);
|
||||
return ResultMessageUtil.toJSON(pmoAggVOS, "流程生产订单查询成功");
|
||||
List<PMOItemVO> pmoItemVOS = new ArrayList<>();
|
||||
for (String bid : bidList) {
|
||||
PMOItemVO pmoItemVO = (PMOItemVO) hy.queryByPrimaryKey(PMOItemVO.class, bid);
|
||||
pmoItemVOS.add(pmoItemVO);
|
||||
}
|
||||
return ResultMessageUtil.toJSON(pmoItemVOS, "流程生产订单查询成功");
|
||||
} catch (BusinessException e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -552,4 +552,61 @@ public class MaterialManageMaterial extends AbstractNCCRestResource {
|
|||
return (IOpenApiJsonConvertToExChangeXmlService) NCLocator.getInstance()
|
||||
.lookup(IOpenApiJsonConvertToExChangeXmlService.class);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("queryMaterialView")
|
||||
@Consumes({ "application/json" })
|
||||
@Produces({ "application/json" })
|
||||
public JSONString queryMaterialView(JSONString json) {
|
||||
JSONObject jObject = JSON.parseObject(json.toJSONString());
|
||||
if (jObject == null) {
|
||||
return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null"));
|
||||
}
|
||||
|
||||
JSONObject data = jObject.getJSONObject("data");
|
||||
String createdate = data.getString("createdate");
|
||||
String ts_mts = data.getString("ts_mts");
|
||||
String ts_mtp = data.getString("ts_mtp");
|
||||
String ts_mt = data.getString("ts_mt");
|
||||
String createdate_mtp = data.getString("createdate_mtp");
|
||||
String createdate_mt = data.getString("createdate_mt");
|
||||
String enablestate = data.getString("enablestate");
|
||||
Map<String, Object> param = new HashMap<String, Object>();
|
||||
|
||||
if (StringUtils.isNotBlank(createdate)) {
|
||||
param.put("CREATEDATE", createdate);
|
||||
}
|
||||
if (StringUtils.isNotBlank(ts_mts)) {
|
||||
param.put("TS_MTS", ts_mts);
|
||||
}
|
||||
if (StringUtils.isNotBlank(ts_mtp)) {
|
||||
param.put("TS_MTP", ts_mtp);
|
||||
}
|
||||
if (StringUtils.isNotBlank(ts_mt)) {
|
||||
param.put("TS_MT", ts_mt);
|
||||
}
|
||||
if (StringUtils.isNotBlank(createdate_mtp)) {
|
||||
param.put("CREATEDATE_MTP", createdate_mtp);
|
||||
}
|
||||
if (StringUtils.isNotBlank(createdate_mt)) {
|
||||
param.put("CREATEDATE_MT", createdate_mt);
|
||||
}
|
||||
if (StringUtils.isNotBlank(enablestate)) {
|
||||
param.put("ENABLESTATE", enablestate);
|
||||
}
|
||||
|
||||
try {
|
||||
ApiResourceParamUtils ApiResourceParamUtils = new ApiResourceParamUtils();
|
||||
String condition = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param);
|
||||
String condition1 = condition.replace("=", ">=");
|
||||
String condition2 = condition1.replaceFirst("ENABLESTATE .", "ENABLESTATE ");
|
||||
String sql = "select * from BD_MATERIAL_C047 where " + condition2;
|
||||
List<Map<String, Object>> rows = (List<Map<String, Object>>) (new BaseDAO()).executeQuery(sql, new MapListProcessor());
|
||||
return ResultMessageUtil.toJSON(rows, "²éѯÎïÁÏÊÓͼÐÅÏ¢³É¹¦");
|
||||
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue