精密铸造-根据采购入库进行手工领料
This commit is contained in:
parent
030dcc1f09
commit
a710e54379
|
|
@ -6,14 +6,7 @@ import nc.bs.ic.general.insert.rule.before.CheckCliabilityValue;
|
||||||
import nc.bs.ic.general.rule.after.AtpAfterUpdate;
|
import nc.bs.ic.general.rule.after.AtpAfterUpdate;
|
||||||
import nc.bs.ic.general.rule.before.CtplcustomeridCheck;
|
import nc.bs.ic.general.rule.before.CtplcustomeridCheck;
|
||||||
import nc.bs.ic.m45.base.BPPlugInPoint;
|
import nc.bs.ic.m45.base.BPPlugInPoint;
|
||||||
import nc.bs.ic.m45.base.rule.FillCostOrgRule;
|
import nc.bs.ic.m45.base.rule.*;
|
||||||
import nc.bs.ic.m45.base.rule.PurchaseBillCheckRule;
|
|
||||||
import nc.bs.ic.m45.base.rule.PurchaseInAssetWarehouseCheck;
|
|
||||||
import nc.bs.ic.m45.base.rule.PurchaseInVOScaleCheckRule;
|
|
||||||
import nc.bs.ic.m45.base.rule.PurchaseinRetMarginProcess;
|
|
||||||
import nc.bs.ic.m45.base.rule.PurchaseinRetMarginProcessFor5805;
|
|
||||||
import nc.bs.ic.m45.base.rule.ReturnSnIsExistInEquipcardCheck;
|
|
||||||
import nc.bs.ic.m45.base.rule.VmiCheckRule;
|
|
||||||
import nc.bs.ic.m45.insert.rule.*;
|
import nc.bs.ic.m45.insert.rule.*;
|
||||||
import nc.bs.ic.pub.base.ICAroundProcesser;
|
import nc.bs.ic.pub.base.ICAroundProcesser;
|
||||||
import nc.bs.ic.pub.base.IInsertRuleProvider;
|
import nc.bs.ic.pub.base.IInsertRuleProvider;
|
||||||
|
|
@ -58,8 +51,8 @@ public class InsertBP implements IInsertBP<PurchaseInVO>,
|
||||||
processor.addAfterRule(new InsertOrSignRewritePayPlanInvoiceRule(IPaymentUtil.STORE_RECEIPT_DATE));
|
processor.addAfterRule(new InsertOrSignRewritePayPlanInvoiceRule(IPaymentUtil.STORE_RECEIPT_DATE));
|
||||||
// 흙욋데괏닸쀼畇꽃뭔북谿마운셕뺍
|
// 흙욋데괏닸쀼畇꽃뭔북谿마운셕뺍
|
||||||
processor.addAfterRule(new M45SaveAndRewriteCTPayPlan());
|
processor.addAfterRule(new M45SaveAndRewriteCTPayPlan());
|
||||||
// žŤĂÜÖýÔě-ÎŢą¸ÁĎÁěÁĎ
|
// žŤĂÜÖýÔě-ÁěÁĎ
|
||||||
processor.addAfterRule(new NoItemsDeliverMaterialRule());
|
processor.addAfterRule(new ManualMaterialPickupRule());
|
||||||
|
|
||||||
// processor.addAfterRule(new InsertRewritePORule());
|
// processor.addAfterRule(new InsertRewritePORule());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,248 @@
|
||||||
|
package nc.bs.ic.m45.insert.rule;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import nc.bs.dao.BaseDAO;
|
||||||
|
import nc.bs.framework.common.InvocationInfoProxy;
|
||||||
|
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.impl.pubapp.pattern.rule.IRule;
|
||||||
|
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
|
||||||
|
import nc.itf.uap.IUAPQueryBS;
|
||||||
|
import nc.util.mmf.framework.base.MMArrayUtil;
|
||||||
|
import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
|
import nc.vo.bd.material.MaterialVO;
|
||||||
|
import nc.vo.ic.m45.entity.PurchaseInBodyVO;
|
||||||
|
import nc.vo.ic.m45.entity.PurchaseInHeadVO;
|
||||||
|
import nc.vo.ic.m45.entity.PurchaseInVO;
|
||||||
|
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFBillstatusEnum;
|
||||||
|
import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFItemStatusEnum;
|
||||||
|
import nc.vo.org.DeptVO;
|
||||||
|
import nc.vo.org.OrgVO;
|
||||||
|
import nc.vo.pmpub.common.utils.ArrayUtils;
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.pub.lang.UFDate;
|
||||||
|
import nc.vo.pub.lang.UFDouble;
|
||||||
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
|
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
||||||
|
import nc.vo.scmf.ic.mbatchcode.BatchcodeVO;
|
||||||
|
import nccloud.api.ic.m4d.IAPIMaterialOutMaintain;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精密铸造-根据采购入库进行手工领料
|
||||||
|
*
|
||||||
|
* @author mzr
|
||||||
|
* @date 2025/10/31
|
||||||
|
*/
|
||||||
|
public class ManualMaterialPickupRule implements IRule<PurchaseInVO> {
|
||||||
|
private static final String LOG_INFO_NAME = "jmqylog";
|
||||||
|
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
||||||
|
public BaseDAO dao;
|
||||||
|
|
||||||
|
public BaseDAO getDao() {
|
||||||
|
if (dao == null) {
|
||||||
|
dao = new BaseDAO();
|
||||||
|
}
|
||||||
|
return dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IUAPQueryBS queryBS = null;
|
||||||
|
|
||||||
|
public final IUAPQueryBS getQueryBS() {
|
||||||
|
if (null == queryBS) {
|
||||||
|
queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||||
|
}
|
||||||
|
return queryBS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(PurchaseInVO[] vos) {
|
||||||
|
if (ArrayUtils.isEmpty(vos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
handelMaterial(vos);
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
logger.error("ManualMaterialPickupRule-exp:" + e.getMessage(), e);
|
||||||
|
ExceptionUtils.wrappException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handelMaterial(PurchaseInVO[] inVOS) throws BusinessException {
|
||||||
|
String orgCondition = "code = 'C038' and enablestate = '2' and isbusinessunit='Y'";
|
||||||
|
HYPubBO hyPub = new HYPubBO();
|
||||||
|
String orgId = hyPub.findColValue(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, orgCondition) + "";
|
||||||
|
// 精密铸造,生成采购入库成功后再进行领料
|
||||||
|
for (PurchaseInVO inVO : inVOS) {
|
||||||
|
PurchaseInHeadVO head = inVO.getHead();
|
||||||
|
PurchaseInBodyVO[] bodys = inVO.getBodys();
|
||||||
|
String pkOrg = head.getPk_org();
|
||||||
|
String vbillcode = head.getVbillcode();
|
||||||
|
UFDate dbilldate = head.getDbilldate();
|
||||||
|
// 判断是否是精密铸造(C038)
|
||||||
|
if (!"null".equals(orgId) && orgId.equals(pkOrg)) {
|
||||||
|
Map<String, String> configParams = MyHelper.getConfigParams("jm-config", null);
|
||||||
|
if (configParams.isEmpty()) {
|
||||||
|
ExceptionUtils.wrappBusinessException("自定义档案中的jm-config参数未配置");
|
||||||
|
}
|
||||||
|
String warehouseCode = configParams.get("warehouseCode");
|
||||||
|
if (MMValueCheck.isEmpty(warehouseCode) || "~".equals(warehouseCode)) {
|
||||||
|
ExceptionUtils.wrappBusinessException("请检查仓库编码是否配置正确");
|
||||||
|
}
|
||||||
|
String configMaterialCode = configParams.get("noItemCode");
|
||||||
|
if (configMaterialCode == null || configMaterialCode.isEmpty()) {
|
||||||
|
ExceptionUtils.wrappBusinessException("自定义档案中的物料参数未配置");
|
||||||
|
}
|
||||||
|
String trantypecode = configParams.get("in-trantypecode");
|
||||||
|
if (trantypecode == null || trantypecode.isEmpty()) {
|
||||||
|
ExceptionUtils.wrappBusinessException("自定义档案中的单据类型参数未配置");
|
||||||
|
}
|
||||||
|
Set<String> rowIds = new HashSet<>();
|
||||||
|
for (PurchaseInBodyVO body : bodys) {
|
||||||
|
String cmaterialvid = body.getCmaterialvid();
|
||||||
|
String condition = "pk_material = '" + cmaterialvid + "'";
|
||||||
|
String materialCode = hyPub.findColValue(MaterialVO.getDefaultTableName(), MaterialVO.CODE, condition) + "";
|
||||||
|
if (configMaterialCode.equals(materialCode)) {
|
||||||
|
// 批次号=流程生产订单明细id
|
||||||
|
String vbatchcode = body.getVbatchcode();
|
||||||
|
if (vbatchcode == null || vbatchcode.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
rowIds.add(vbatchcode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rowIds.isEmpty()) {
|
||||||
|
ExceptionUtils.wrappBusinessException("没有符合条件的流程生产订单信息,无法进行领料");
|
||||||
|
}
|
||||||
|
// 根据流程生产订单明细id分单生成材料出库
|
||||||
|
for (String mobid : rowIds) {
|
||||||
|
// 流程生产订单明细id
|
||||||
|
// ====领料前校验流程生产订单-start====
|
||||||
|
IPMOQueryService pmoQuery = NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||||
|
PMOAggVO[] pmoAggVOS = pmoQuery.queryPMOAggVOByBid(new String[]{mobid});
|
||||||
|
if (MMValueCheck.isEmpty(pmoAggVOS)) {
|
||||||
|
ExceptionUtils.wrappBusinessException("查询不到对应的流程生产订单,无法进行领料");
|
||||||
|
}
|
||||||
|
PMOAggVO aggvo = pmoAggVOS[0];
|
||||||
|
PMOHeadVO pmoHeadvo = aggvo.getParentVO();
|
||||||
|
if (!PMOFBillstatusEnum.AUDIT.equalsValue(pmoHeadvo.getFbillstatus())) {
|
||||||
|
ExceptionUtils.wrappBusinessException("流程生产订单未审核通过,无法进行领料");
|
||||||
|
}
|
||||||
|
PMOItemVO[] items = aggvo.getChildrenVO();
|
||||||
|
PMOItemVO pmoItemVO = null;
|
||||||
|
if (!MMArrayUtil.isEmpty(items)) {
|
||||||
|
for (PMOItemVO item : items) {
|
||||||
|
String cmoid = item.getCmoid();
|
||||||
|
if (mobid.equals(cmoid)) {
|
||||||
|
if (!PMOFItemStatusEnum.PUT.equalsValue(item.getFitemstatus()) &&
|
||||||
|
!PMOFItemStatusEnum.AUDIT.equalsValue(item.getFitemstatus())
|
||||||
|
) {
|
||||||
|
ExceptionUtils.wrappBusinessException("流程生产订单明细未完成,无法进行领料");
|
||||||
|
}
|
||||||
|
pmoItemVO = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pmoItemVO == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ====领料前校验流程生产订单-end====
|
||||||
|
// 查询领料部门
|
||||||
|
String cdeptid = pmoItemVO.getCdeptid();
|
||||||
|
Object deptCode = hyPub.findColValue(DeptVO.getDefaultTableName(), DeptVO.CODE,
|
||||||
|
"pk_dept = '" + cdeptid + "'");
|
||||||
|
if (deptCode == null) {
|
||||||
|
ExceptionUtils.wrappBusinessException("查询不到领料部门,无法进行领料");
|
||||||
|
}
|
||||||
|
String cmaterialvidPmo = pmoItemVO.getCmaterialvid();
|
||||||
|
Object materialCodePmo = hyPub.findColValue(MaterialVO.getDefaultTableName(), MaterialVO.CODE, "pk_material = '" + cmaterialvidPmo + "'");
|
||||||
|
if (materialCodePmo == null) {
|
||||||
|
ExceptionUtils.wrappBusinessException("查询不到产成品信息,无法进行领料");
|
||||||
|
}
|
||||||
|
JSONObject headOutJson = new JSONObject();
|
||||||
|
headOutJson.put("pk_org", "C038");
|
||||||
|
headOutJson.put("pk_org_v", "C038");
|
||||||
|
headOutJson.put("cdptvid", deptCode + "");
|
||||||
|
headOutJson.put("cwarehouseid", warehouseCode);
|
||||||
|
headOutJson.put("vtrantypecode", trantypecode);
|
||||||
|
headOutJson.put("dbilldate", dbilldate);// 单据日期
|
||||||
|
headOutJson.put("vnote", vbillcode);
|
||||||
|
headOutJson.put("billmaker", "BIP");
|
||||||
|
JSONArray bodyOutArr = new JSONArray();
|
||||||
|
for (PurchaseInBodyVO body : bodys) {
|
||||||
|
JSONObject bodyJson = new JSONObject();
|
||||||
|
String cmaterialvid = body.getCmaterialvid();
|
||||||
|
String condition = "pk_material = '" + cmaterialvid + "'";
|
||||||
|
String materialCode = hyPub.findColValue(MaterialVO.getDefaultTableName(), MaterialVO.CODE, condition) + "";
|
||||||
|
// 根据该费用物料进行领料
|
||||||
|
if (configMaterialCode.equals(materialCode) && mobid.equals(body.getVbatchcode())) {
|
||||||
|
// 批次号=流程生产订单明细id
|
||||||
|
String vbatchcode = body.getVbatchcode();
|
||||||
|
if (vbatchcode == null || vbatchcode.isEmpty()) {
|
||||||
|
ExceptionUtils.wrappBusinessException("未存储流程生产明细id,无法进行领料");
|
||||||
|
}
|
||||||
|
// 获取采购入库表体的应收主数量 nshouldnum
|
||||||
|
UFDouble nshouldnum = body.getNshouldnum();
|
||||||
|
bodyJson.put("cmaterialvid", cmaterialvid);
|
||||||
|
bodyJson.put("nshouldnum", nshouldnum);// 应发主数量
|
||||||
|
bodyJson.put("nshouldassistnum", nshouldnum);// 应发数量
|
||||||
|
bodyJson.put("nnum", nshouldnum);// 实发主数量
|
||||||
|
bodyJson.put("nassistnum", nshouldnum);// 实发数量
|
||||||
|
bodyJson.put("dbizdate", dbilldate);// 出库日期
|
||||||
|
bodyJson.put("vchangerate", "1/1");
|
||||||
|
// 批次号赋值
|
||||||
|
bodyJson.put("vbatchcode", mobid);// 批次号
|
||||||
|
Map<String, String> batchMap = getBatchCodeVO(cmaterialvid, mobid);
|
||||||
|
String pkBatchcode = batchMap.get(mobid);
|
||||||
|
bodyJson.put("pk_batchcode", pkBatchcode);// 批次档案id
|
||||||
|
bodyJson.put("vproductbatch", pmoHeadvo.getVbillcode());// 生产订单号
|
||||||
|
bodyJson.put("ccostobject", materialCodePmo + "");// 产成品
|
||||||
|
bodyOutArr.add(bodyJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bodyOutArr.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("ic_material_h", headOutJson);
|
||||||
|
params.put("ic_material_b", bodyOutArr);
|
||||||
|
List<Map<String, Object>> paramList = new ArrayList<>();
|
||||||
|
paramList.add(params);
|
||||||
|
IAPIMaterialOutMaintain materialOut =
|
||||||
|
NCLocator.getInstance().lookup(IAPIMaterialOutMaintain.class);
|
||||||
|
MaterialOutVO[] materialOutVOs = materialOut.save(paramList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getBatchCodeVO(String cbmaterialvid, String vbatchcode)
|
||||||
|
throws BusinessException {
|
||||||
|
Map<String, String> resMap = new HashMap<>();
|
||||||
|
SqlBuilder sb = new SqlBuilder();
|
||||||
|
sb.append("pk_group", InvocationInfoProxy.getInstance().getGroupId());
|
||||||
|
sb.append(" and ");
|
||||||
|
sb.append("nvl(dr,0)", 0);
|
||||||
|
sb.append(" and ");
|
||||||
|
sb.append("cmaterialvid", cbmaterialvid);
|
||||||
|
sb.append(" and ");
|
||||||
|
sb.append("vbatchcode", vbatchcode);
|
||||||
|
Collection<BatchcodeVO> vos = this.getQueryBS().retrieveByClause(BatchcodeVO.class, sb.toString());
|
||||||
|
for (BatchcodeVO vo : vos) {
|
||||||
|
String pk_batchcode = vo.getPk_batchcode();
|
||||||
|
String vbatchcode1 = vo.getVbatchcode();
|
||||||
|
resMap.put(vbatchcode1, pk_batchcode);
|
||||||
|
}
|
||||||
|
return resMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue