Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
d7cb1f7ff9
|
|
@ -102,10 +102,6 @@ public class AfterApproceRuleSyncRZWMSProcess implements IRule<SCOrderVO> {
|
|||
singleObj.put("jhrq", body.getDplanarrvdate().toString());
|
||||
}
|
||||
|
||||
singleObj.put("cgjh_wbid", body.getVsrctrantype()); // 第三方系统采购计划id
|
||||
singleObj.put("cgxh", body.getVsrcrowno()); // 采购计划序号
|
||||
singleObj.put("cgbh", body.getVsrccode()); // 采购计划编号
|
||||
|
||||
singleObj.put("sdck", body.getPk_recvstordoc()); // 送达仓库
|
||||
|
||||
singleObj.put("bzsm", body.getVbmemo()); // 备注说明
|
||||
|
|
|
|||
|
|
@ -0,0 +1,331 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nccloud.web.ic.pub.action;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.itf.scmpub.reference.uap.bd.currency.CurrencyInfo;
|
||||
import nc.pubitf.ic.flowaccount.BillInfo;
|
||||
import nc.pubitf.ic.flowaccount.FlowAccountQuery;
|
||||
import nc.vo.ic.general.define.ICBillBodyVO;
|
||||
import nc.vo.ic.general.define.ICBillVO;
|
||||
import nc.vo.ic.m4a.entity.GeneralInVO;
|
||||
import nc.vo.ic.m4c.entity.SaleOutVO;
|
||||
import nc.vo.ic.m4i.entity.GeneralOutVO;
|
||||
import nc.vo.ic.pub.lang.ResBase;
|
||||
import nc.vo.ic.pub.lang.RuleRes;
|
||||
import nc.vo.ic.pub.util.ValueCheckUtil;
|
||||
import nc.vo.ml.NCLangRes4VoTransl;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.CircularlyAccessibleValueObject;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.pubapp.pattern.model.transfer.bill.ClientBillCombinServer;
|
||||
import nc.vo.pubapp.pattern.pub.MathTool;
|
||||
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||
import nc.vo.scmpub.util.AppInfoContext;
|
||||
import nccloud.commons.lang.StringUtils;
|
||||
import nccloud.framework.core.exception.ExceptionUtils;
|
||||
import nccloud.framework.core.json.IJson;
|
||||
import nccloud.framework.core.util.GridCompareUtils;
|
||||
import nccloud.framework.service.ServiceLocator;
|
||||
import nccloud.framework.web.action.itf.ICommonAction;
|
||||
import nccloud.framework.web.container.IRequest;
|
||||
import nccloud.framework.web.json.JsonFactory;
|
||||
import nccloud.framework.web.ui.config.PageTemplet;
|
||||
import nccloud.framework.web.ui.model.row.Cell;
|
||||
import nccloud.framework.web.ui.pattern.billcard.BillCard;
|
||||
import nccloud.pubitf.ic.inbound.service.IICFilterData;
|
||||
import nccloud.pubitf.riart.pflow.CloudPFlowContext;
|
||||
import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService;
|
||||
import nccloud.web.ic.pub.entity.SrcFlagDTO;
|
||||
import nccloud.web.ic.pub.precision.ICBaseBillcardPrecisionHandler;
|
||||
import nccloud.web.ic.pub.resexp.ICPFResumeExceptionUtil;
|
||||
import nccloud.web.ic.pub.utils.PageUtils;
|
||||
import nccloud.web.ic.ui.pattern.billcard.ICBillCardOperator;
|
||||
|
||||
public class SaveAction implements ICommonAction {
|
||||
public SaveAction() {
|
||||
}
|
||||
|
||||
public Object doAction(IRequest request) {
|
||||
CloudPFlowContext context = ICPFResumeExceptionUtil.processBefore(request);
|
||||
String str = request.read();
|
||||
IJson json = JsonFactory.create();
|
||||
BillCard card = (BillCard)json.fromJson(str, BillCard.class);
|
||||
SrcFlagDTO srcFlag = (SrcFlagDTO)json.fromJson(str, SrcFlagDTO.class);
|
||||
ICBillCardOperator operator = this.getOperator(card);
|
||||
ICBillVO[] vos = new ICBillVO[]{(ICBillVO)operator.toBill(request)};
|
||||
vos = this.fillBill(vos);
|
||||
|
||||
for(ICBillVO vo : vos) {
|
||||
if ((vo instanceof GeneralOutVO || vo instanceof GeneralInVO) && !StringUtils.isNotEmpty(vo.getPrimaryKey()) && srcFlag.getSrcFlag() != null) {
|
||||
if ("assembly".equals(srcFlag.getSrcFlag().get("srcFlag"))) {
|
||||
vo.getParentVO().setAttributeValue("srcflag", "1");
|
||||
}
|
||||
|
||||
if ("teardown".equals(srcFlag.getSrcFlag().get("srcFlag"))) {
|
||||
vo.getParentVO().setAttributeValue("srcflag", "2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
operator.setOriginBillcard(card);
|
||||
if (vos != null && vos.length > 0) {
|
||||
this.checkReferencedBill(vos);
|
||||
this.checkncorrespond(vos);
|
||||
vos = (ICBillVO[])((IICFilterData)ServiceLocator.find(IICFilterData.class)).filterFromFront(this.getBilltype().getCode(), vos);
|
||||
context.setBillType(this.getBilltype().getCode());
|
||||
context.setBillVos(vos);
|
||||
ICloudScriptPFlowService service = (ICloudScriptPFlowService)ServiceLocator.find(ICloudScriptPFlowService.class);
|
||||
context.setActionName("WRITE");
|
||||
ICBillVO[] obj = null;
|
||||
|
||||
try {
|
||||
AppInfoContext.setBtnCode(this.getBtnCode());
|
||||
Object ret = service.exeScriptPFlow(context);
|
||||
if (ret instanceof ICBillVO[]) {
|
||||
obj = (ICBillVO[])ret;
|
||||
} else {
|
||||
obj = (ICBillVO[])((Object[])ret)[0];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return ICPFResumeExceptionUtil.handleICResumeException(e);
|
||||
}
|
||||
|
||||
obj = ((IICFilterData)ServiceLocator.find(IICFilterData.class)).fillLocationVOs(this.getBilltype().getCode(), obj);
|
||||
ClientBillCombinServer<ICBillVO> util = new ClientBillCombinServer();
|
||||
this.processDelBody(vos);
|
||||
util.combine(vos, obj);
|
||||
this.processLocationVOs(vos, obj);
|
||||
this.handlerComputedPropertyField(vos);
|
||||
BillCard retcard = null;
|
||||
try {
|
||||
retcard = this.afterProcess(operator, vos[0]);
|
||||
} catch (DAOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
retcard = GridCompareUtils.compareBillCardGrid(operator.getOriginBillcard(), retcard);
|
||||
operator.translate(retcard);
|
||||
this.dealCarrier(retcard);
|
||||
return retcard;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkncorrespond(ICBillVO[] vos) {
|
||||
ArrayList<String> lbids = new ArrayList();
|
||||
|
||||
for(int i = 0; i < vos.length; ++i) {
|
||||
ICBillBodyVO[] bodys = vos[i].getBodys();
|
||||
|
||||
for(int j = 0; j < bodys.length; ++j) {
|
||||
String cgeneralbid = bodys[j].getCgeneralbid();
|
||||
lbids.add(cgeneralbid);
|
||||
}
|
||||
}
|
||||
|
||||
IICFilterData service = (IICFilterData)ServiceLocator.find(IICFilterData.class);
|
||||
Map<String, UFDouble> extnum = service.getExtnum(vos[0].getParentVO().getBillType(), (String[])lbids.toArray(new String[0]));
|
||||
StringBuilder errs = new StringBuilder();
|
||||
if (!ValueCheckUtil.isNullORZeroLength(extnum)) {
|
||||
for(int i = 0; i < vos.length; ++i) {
|
||||
ICBillBodyVO[] bodys = vos[i].getBodys();
|
||||
|
||||
for(int j = 0; j < bodys.length; ++j) {
|
||||
String cgeneralbid = bodys[j].getCgeneralbid();
|
||||
UFDouble ncorrespondastnum = bodys[j].getNcorrespondastnum();
|
||||
if (!MathTool.equals(ncorrespondastnum, (UFDouble)extnum.get(cgeneralbid))) {
|
||||
errs.append(ResBase.getCrowno()).append(": ").append(bodys[j].getCrowno()).append(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008001_0", "04008001-0975")).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(errs)) {
|
||||
ExceptionUtils.wrapBusinessException(errs.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkReferencedBill(ICBillVO[] vos) {
|
||||
ICBillVO vo = vos[0];
|
||||
if (!StringUtils.isEmpty(vo.getHead().getCgeneralhid())) {
|
||||
List<String> idList = new ArrayList();
|
||||
String vbillcode = vos[0].getHead().getVbillcode();
|
||||
|
||||
for(ICBillBodyVO bodyVO : vo.getBodys()) {
|
||||
if (StringUtils.isNotEmpty(bodyVO.getCgeneralbid())) {
|
||||
idList.add(bodyVO.getCgeneralbid());
|
||||
}
|
||||
}
|
||||
|
||||
if (idList != null && idList.size() > 0) {
|
||||
FlowAccountQuery flow = (FlowAccountQuery)ServiceLocator.find(FlowAccountQuery.class);
|
||||
Map<String, List<BillInfo>> refmap = new HashMap();
|
||||
|
||||
try {
|
||||
refmap = flow.queryBillReferenced((String[])idList.toArray(new String[idList.size()]));
|
||||
} catch (BusinessException e) {
|
||||
ExceptionUtils.wrapException(e);
|
||||
}
|
||||
|
||||
if (ValueCheckUtil.isNullORZeroLength(refmap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vo instanceof SaleOutVO) {
|
||||
List<String> errList = new ArrayList();
|
||||
|
||||
for(ICBillBodyVO bodyVO : vo.getBodys()) {
|
||||
if (bodyVO.getStatus() == 3) {
|
||||
String cgeneralbid = bodyVO.getCgeneralbid();
|
||||
if (StringUtils.isNotEmpty(cgeneralbid) && refmap.containsKey(cgeneralbid)) {
|
||||
errList.add(bodyVO.getCrowno());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ValueCheckUtil.isNullORZeroLength(errList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder errs = new StringBuilder();
|
||||
errs.append(RuleRes.getBillRownReferencedErr(vbillcode)).append("\n");
|
||||
|
||||
for(String row : errList) {
|
||||
errs.append(ResBase.getCrowno()).append(": ").append(row).append(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008001_0", "04008001-0975")).append("\n");
|
||||
}
|
||||
|
||||
ExceptionUtils.wrapBusinessException(errs.toString());
|
||||
}
|
||||
|
||||
ExceptionUtils.wrapBusinessException(RuleRes.getBillReferencedErr(vbillcode));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void handlerComputedPropertyField(ICBillVO[] obj) {
|
||||
}
|
||||
|
||||
public String getBtnCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void processLocationVOs(ICBillVO[] vos, ICBillVO[] obj) {
|
||||
ICBillBodyVO[] clientBodys = vos[0].getChildrenVO();
|
||||
ICBillBodyVO[] serverBodys = obj[0].getChildrenVO();
|
||||
Map<String, ICBillBodyVO> bvomap = new HashMap();
|
||||
|
||||
for(ICBillBodyVO bvo : serverBodys) {
|
||||
bvomap.put(bvo.getCgeneralbid(), bvo);
|
||||
}
|
||||
|
||||
for(int i = 0; i < clientBodys.length; ++i) {
|
||||
if (bvomap.get(clientBodys[i].getCgeneralbid()) != null) {
|
||||
ICBillBodyVO serverBody = (ICBillBodyVO)bvomap.get(clientBodys[i].getCgeneralbid());
|
||||
clientBodys[i].setLocationVOs(serverBody.getLocationVOs());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processDelBody(ICBillVO[] vos) {
|
||||
ICBillBodyVO[] bodys = vos[0].getBodys();
|
||||
List<ICBillBodyVO> realbody = new ArrayList();
|
||||
|
||||
for(ICBillBodyVO body : bodys) {
|
||||
if (body.getStatus() != 3) {
|
||||
realbody.add(body);
|
||||
}
|
||||
}
|
||||
|
||||
vos[0].setChildrenVO((CircularlyAccessibleValueObject[])null);
|
||||
vos[0].setChildrenVO((CircularlyAccessibleValueObject[])realbody.toArray(new ICBillBodyVO[0]));
|
||||
}
|
||||
|
||||
private ICBillCardOperator getOperator(BillCard card) {
|
||||
String[] info = card.getUserjson().split(",");
|
||||
String pagecode = null;
|
||||
String appcode = null;
|
||||
String pagecodecard = null;
|
||||
if (info.length > 1) {
|
||||
pagecode = info[0];
|
||||
appcode = info[1];
|
||||
pagecodecard = info[2];
|
||||
} else {
|
||||
pagecode = info[0];
|
||||
pagecodecard = card.getPageid();
|
||||
}
|
||||
|
||||
ICBillCardOperator operator;
|
||||
if (appcode == null) {
|
||||
operator = new ICBillCardOperator((String)null, pagecodecard, pagecode);
|
||||
} else {
|
||||
PageTemplet pageTemplet = PageUtils.getPageTemplet(appcode, pagecodecard);
|
||||
operator = new ICBillCardOperator(pageTemplet.getOid(), pagecodecard, pagecode);
|
||||
}
|
||||
|
||||
return operator;
|
||||
}
|
||||
|
||||
protected ICBillVO[] fillBill(ICBillVO[] vos) {
|
||||
return vos;
|
||||
}
|
||||
|
||||
private BillCard afterProcess(ICBillCardOperator operator, ICBillVO vo) throws DAOException {
|
||||
BillCard retcard = operator.toCard(vo, false, false);
|
||||
operator.processICBillstatusForWeb(retcard);
|
||||
|
||||
// 获取来源单据号
|
||||
// String sourceBillNo = (String) vo.getHead().getAttributeValue("55A2250500000006");
|
||||
// if (StringUtils.isNotEmpty(sourceBillNo)) {
|
||||
// // 更新来源单据状态为 "已处理"
|
||||
// updateSourceBillStatus(sourceBillNo, "已处理");
|
||||
// }
|
||||
|
||||
// 其他处理逻辑
|
||||
String ccurrencyid = (String) vo.getBody(0).getAttributeValue("ccurrencyid");
|
||||
if (!StringUtils.isEmpty(ccurrencyid)) {
|
||||
String name = CurrencyInfo.getName(ccurrencyid);
|
||||
retcard.getBody().getModel().getListRows().forEach((row) -> {
|
||||
Cell cell = new Cell();
|
||||
cell.setValue(ccurrencyid);
|
||||
cell.setDisplay(name);
|
||||
row.addCell("ccurrencyid", cell);
|
||||
});
|
||||
}
|
||||
|
||||
ICBaseBillcardPrecisionHandler handler = this.getPrecisionHandler(retcard);
|
||||
handler.process();
|
||||
return retcard;
|
||||
}
|
||||
private void updateSourceBillStatus(String sourceBillNo, String status) throws DAOException {
|
||||
|
||||
//1.查询 流程生产订单明细行产品:合格入库数量=数量
|
||||
String sql = "update mm_pickm set cstatus = '" + status + "' where ccode = '" + sourceBillNo + "'";
|
||||
// BaseDAO baseDAO = new BaseDAO();
|
||||
// baseDAO.executeUpdate(sql);
|
||||
//2.更新流程生产订单明细行对应产品的下游单据备料计划状态改为完成态
|
||||
}
|
||||
|
||||
protected ICBillType getBilltype() {
|
||||
throw new RuntimeException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0198"));
|
||||
}
|
||||
|
||||
protected ICBaseBillcardPrecisionHandler getPrecisionHandler(BillCard card) {
|
||||
return new ICBaseBillcardPrecisionHandler(card);
|
||||
}
|
||||
|
||||
protected void dealCarrier(BillCard card) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
package nc.bs.ic.m4c.insert;
|
||||
|
||||
import nc.bs.ic.general.insert.IInsertBP;
|
||||
import nc.bs.ic.general.insert.rule.after.RewriteQCInsertRule;
|
||||
import nc.bs.ic.general.insert.rule.before.CheckCliabilityValue;
|
||||
import nc.bs.ic.general.rule.after.AtpAfterUpdate;
|
||||
import nc.bs.ic.general.rule.before.CtplcustomeridCheck;
|
||||
import nc.bs.ic.general.rule.before.InvAttributeCheck;
|
||||
import nc.bs.ic.m4c.base.BPPlugInPoint;
|
||||
import nc.bs.ic.m4c.base.rule.FillCostOrgRule;
|
||||
import nc.bs.ic.m4c.base.rule.ReturnBarcodeCheck;
|
||||
import nc.bs.ic.m4c.base.rule.ReturnDbizdateCheck;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutCloseBusiLogRule;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutDefaultValueSet;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutFillInvoiceNumRule;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutFromInvoiceCheckRule;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutMarginProcess;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutRetMarginProRule;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutVOScaleCheckRule;
|
||||
import nc.bs.ic.m4c.base.rule.SaleOutValueValidCheck;
|
||||
import nc.bs.ic.m4c.insert.rule.InsertRewriteMMDP;
|
||||
import nc.bs.ic.m4c.insert.rule.ReWrite5720InsertRule;
|
||||
import nc.bs.ic.m4c.insert.rule.ReWrite5730InsertRule;
|
||||
import nc.bs.ic.m4c.insert.rule.ReWrite6020InsertRule;
|
||||
import nc.bs.ic.m4c.insert.rule.ReWrite6030InsertRule;
|
||||
import nc.bs.ic.m4c.insert.rule.ReWriteICInsertRule;
|
||||
import nc.bs.ic.m4c.insert.rule.ReWriteSOInsertForPushSaveRule;
|
||||
import nc.bs.ic.m4c.insert.rule.ReWriteSOInsertRule;
|
||||
import nc.bs.ic.m4c.insert.rule.SaleOutCheckRule;
|
||||
import nc.bs.ic.m4c.insert.rule.credit.RenovateARByHidsBeginRule;
|
||||
import nc.bs.ic.m4c.insert.rule.credit.RenovateARByHidsEndRule;
|
||||
import nc.bs.ic.m4c.sign.rule.AfterSigningSynchronizeRuleRZ;
|
||||
import nc.bs.ic.pub.base.ICAroundProcesser;
|
||||
import nc.bs.ic.pub.base.IInsertRuleProvider;
|
||||
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
|
||||
import nc.vo.credit.engrossmaintain.pub.action.M4CEngrossAction;
|
||||
import nc.vo.ic.general.define.MetaNameConst;
|
||||
import nc.vo.ic.m4c.entity.SaleOutVO;
|
||||
import nccloud.bs.ic.mobile.component.operation.rule.MobAfterSaveMessageRule;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* <b>销售出库单新增BP:</b>
|
||||
* <b>推式保存时调用</b>
|
||||
* <p>
|
||||
*
|
||||
* @author chenlla
|
||||
* @version 6.0
|
||||
* @time 2010-1-26下午04:58:23
|
||||
* @since
|
||||
*/
|
||||
public class InsertBP implements IInsertBP<SaleOutVO>,
|
||||
IInsertRuleProvider<SaleOutVO> {
|
||||
|
||||
private boolean isPush = false;
|
||||
|
||||
public InsertBP(boolean isPush) {
|
||||
this.isPush = isPush;
|
||||
}
|
||||
|
||||
public InsertBP() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAfterRule(SaleOutVO[] vos, AroundProcesser<SaleOutVO> processor) {
|
||||
// 信用
|
||||
processor.addAfterRule(new RenovateARByHidsEndRule(M4CEngrossAction.M4CInsert));
|
||||
processor.addAfterRule(new ReWriteICInsertRule());
|
||||
/*
|
||||
* 放在现存量更新规则之后,因为回写销售订单,发货单时,如果出库数量等于订单数量,
|
||||
* 订单自动行关闭,行关闭会执行预留解除,导致现存量更新时,处理预留业务产生错误
|
||||
*/
|
||||
if (this.isPush) {
|
||||
((ICAroundProcesser<SaleOutVO>) processor).addAfterRuleAt(
|
||||
new ReWriteSOInsertForPushSaveRule(), AtpAfterUpdate.class);
|
||||
// processor.addAfterRule(new ReWriteSOInsertForPushSaveRule());
|
||||
} else {
|
||||
((ICAroundProcesser<SaleOutVO>) processor).addAfterRuleAt(
|
||||
new ReWriteSOInsertRule(), AtpAfterUpdate.class);
|
||||
// processor.addAfterRule(new ReWriteSOInsertRule());
|
||||
}
|
||||
processor.addAfterRule(new RewriteQCInsertRule<SaleOutVO>());
|
||||
processor.addAfterRule(new SaleOutCloseBusiLogRule());
|
||||
processor.addAfterRule(new SaleOutFillInvoiceNumRule());
|
||||
processor.addAfterRule(new InsertRewriteMMDP());
|
||||
// 新增保存回写出口明细
|
||||
processor.addAfterRule(new ReWrite5730InsertRule());
|
||||
// 新增保存回写出口合同
|
||||
processor.addAfterRule(new ReWrite5720InsertRule());
|
||||
// 新增保存回写转口明细
|
||||
processor.addAfterRule(new ReWrite6030InsertRule());
|
||||
// 新增保存回写转口合同
|
||||
processor.addAfterRule(new ReWrite6020InsertRule());
|
||||
// 2020年3月2日 新增保存移动业务消息
|
||||
processor.addAfterRule(new MobAfterSaveMessageRule());
|
||||
|
||||
//2025年5月27日 新增保存推送锐制
|
||||
processor.addAfterFinalRule(new AfterSigningSynchronizeRuleRZ());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBeforeRule(SaleOutVO[] vos,
|
||||
AroundProcesser<SaleOutVO> processor) {
|
||||
processor.addBeforeRule(new FillCostOrgRule());
|
||||
((ICAroundProcesser<SaleOutVO>) processor).addBeforeRuleAt(
|
||||
new SaleOutDefaultValueSet(), InvAttributeCheck.class);
|
||||
processor.addBeforeRule(new SaleOutCheckRule());
|
||||
processor.addBeforeRule(new SaleOutValueValidCheck());
|
||||
processor.addBeforeRule(new SaleOutFromInvoiceCheckRule());
|
||||
processor.addBeforeRule(new CtplcustomeridCheck<SaleOutVO>());
|
||||
processor.addBeforeRule(new SaleOutMarginProcess());
|
||||
// 红字退回倒挤
|
||||
processor.addBeforeRule(new SaleOutRetMarginProRule());
|
||||
// 利润中心校验规则
|
||||
processor.addBeforeRule(new CheckCliabilityValue<SaleOutVO>(MetaNameConst.CIOLIABILITYOID, MetaNameConst.CLIABILITYOID));
|
||||
processor.addBeforeRule(new ReturnBarcodeCheck());
|
||||
processor.addBeforeRule(new ReturnDbizdateCheck());
|
||||
processor.addBeforeRule(new SaleOutVOScaleCheckRule());
|
||||
// 信用
|
||||
processor.addBeforeRule(new RenovateARByHidsBeginRule(M4CEngrossAction.M4CInsert));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] insert(SaleOutVO[] bills) {
|
||||
M4CInsertBPTemplate<SaleOutVO> insertBP =
|
||||
new M4CInsertBPTemplate<SaleOutVO>(BPPlugInPoint.InsertBP, this);
|
||||
SaleOutVO[] insertvo = insertBP.insert(bills);
|
||||
return insertvo;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,8 +56,6 @@ public class SignBP implements ISignBP<SaleOutVO>, ISignRuleProvider<SaleOutVO>
|
|||
processor.addAfterRule(new AfterSigningSynchronizeRuleMES());
|
||||
// 盘点(审批后传MES)
|
||||
|
||||
// 销售出库签字后 同步到锐制
|
||||
processor.addAfterRule(new AfterSigningSynchronizeRuleRZ());
|
||||
}
|
||||
|
||||
public void addBeforeRule(SaleOutVO[] vos, AroundProcesser<SaleOutVO> processor) {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class AfterSigningSynchronizeRuleRZ implements IRule<SaleOutVO> {
|
|||
singleObj.put("wbpid",cgeneralhid);//第三方系统分组id
|
||||
singleObj.put("operate",1);//operate int 操作状态 必填 1新增/修改、2删除(删除时只需上传wbid)
|
||||
singleObj.put("djly",1013);//djly varchar(20) 来源单据
|
||||
singleObj.put("djbh_id",cgeneralhid+"_"+cgeneralbid);//单据id
|
||||
singleObj.put("djbh_id",cgeneralhid);//单据id
|
||||
singleObj.put("djbh",vbillcode);//单据编号
|
||||
singleObj.put("djxh",crowno);//单据序号
|
||||
singleObj.put("djrq",dbizdate.toString());//单据日期--出库日期
|
||||
|
|
|
|||
|
|
@ -0,0 +1,362 @@
|
|||
package nccloud.api.impl.ic.m4c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.scmpub.query.SCMBillQuery;
|
||||
import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil;
|
||||
import nc.pubitf.ic.m4c.api.ISaleOutMaintainAPI;
|
||||
import nc.vo.ic.general.define.ICBillFlag;
|
||||
import nc.vo.ic.general.define.ICBillHeadVO;
|
||||
import nc.vo.ic.general.define.MetaNameConst;
|
||||
import nc.vo.ic.general.util.ICLocationUtil;
|
||||
import nc.vo.ic.location.ICLocationVO;
|
||||
import nc.vo.ic.m4c.entity.SaleOutBodyVO;
|
||||
import nc.vo.ic.m4c.entity.SaleOutHeadVO;
|
||||
import nc.vo.ic.m4c.entity.SaleOutVO;
|
||||
import nc.vo.ic.pub.define.ICPubMetaNameConst;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.VOStatus;
|
||||
import nc.vo.pubapp.util.VORowNoUtils;
|
||||
import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule;
|
||||
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||
import nccloud.api.ic.m4c.IAPISaleOutMaintain;
|
||||
import nccloud.api.impl.ic.m4c.check.CheckSaleOutSaveValidator;
|
||||
import nccloud.api.impl.ic.m4c.fill.SaleOutSaveFillValue;
|
||||
import nccloud.api.impl.ic.m4c.fill.SaleOutSaveFromRefFillValue;
|
||||
import nccloud.api.impl.ic.m4c.fill.SaleOutUpdateFillValue;
|
||||
import nccloud.api.impl.ic.pub.check.CheckProhibitUpdateFields;
|
||||
import nccloud.api.impl.ic.pub.rule.ChooseHeadOrg;
|
||||
import nccloud.commons.lang.ArrayUtils;
|
||||
import nccloud.commons.lang.StringUtils;
|
||||
import nccloud.openapi.ic.util.ICAPILocationVOUtils;
|
||||
import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
|
||||
import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
|
||||
|
||||
/**
|
||||
* @version NCC1909
|
||||
* @Description: 销售出库单维护接口实现类
|
||||
* @author: 曹军
|
||||
* @date: 2019-5-17 上午10:19:25
|
||||
*/
|
||||
|
||||
public class APISaleOutMaintainImpl implements IAPISaleOutMaintain {
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] save(List<Map<String, Object>> paramList) throws BusinessException {
|
||||
// MapList转聚合VOList
|
||||
List<SaleOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, SaleOutVO.class);
|
||||
SaleOutVO[] vos = aggVOList.toArray(new SaleOutVO[aggVOList.size()]);
|
||||
// 设置货位序列号VO
|
||||
ICAPILocationVOUtils.setLocationVO(ICBillType.PurchaseIn.getCode(), vos);
|
||||
// 1、传入数据基本非空校验
|
||||
BillVOsCheckRule checker =
|
||||
new BillVOsCheckRule(new CheckSaleOutSaveValidator());
|
||||
checker.check(vos);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
// 翻译货位
|
||||
ICAPILocationVOUtils.translate(vos);
|
||||
// 其他数据填充
|
||||
new SaleOutSaveFillValue().setDefaultValue(vos);
|
||||
|
||||
return (SaleOutVO[]) PfServiceScmUtil.processBatch("WRITE", "4C", vos, null,
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] update(List<Map<String, Object>> paramList) throws BusinessException {
|
||||
|
||||
// MapList转聚合VOList
|
||||
List<SaleOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, SaleOutVO.class);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
SaleOutVO[] vos =
|
||||
aggVOList.toArray(new SaleOutVO[aggVOList.size()]);
|
||||
// 设置货位序列号VO
|
||||
ICAPILocationVOUtils.setLocationVO(ICBillType.MaterialOut.getCode(), vos);
|
||||
SaleOutHeadVO newVO = vos[0].getHead();
|
||||
String cgeneralhid = newVO.getCgeneralhid();
|
||||
if (StringUtils.isEmpty(cgeneralhid)) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
|
||||
.getStrByID("4008027_0", "04008027-0390")/*
|
||||
* @res
|
||||
* "修改销售出库单请指定表头主键cgeneralhid值。"
|
||||
*/);
|
||||
}
|
||||
SCMBillQuery<SaleOutVO> queryTool =
|
||||
new SCMBillQuery<SaleOutVO>(SaleOutVO.class);
|
||||
SaleOutVO[] saleOutVOs = queryTool.queryVOByIDs(new String[]{
|
||||
cgeneralhid
|
||||
});
|
||||
Map<String, ICLocationVO[]> deleteLoc =
|
||||
new HashMap<String, ICLocationVO[]>();
|
||||
// 加载原始单据和货位信息
|
||||
SaleOutVO[] originBills = queryTool.queryVOByIDs(new String[]{
|
||||
cgeneralhid
|
||||
});
|
||||
ICLocationUtil.loadLocationVOs(originBills);
|
||||
if (ArrayUtils.isEmpty(saleOutVOs)) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
|
||||
.getStrByID("4008027_0", "04008027-0360")/*
|
||||
* @res
|
||||
* "没找到要修改的出库单信息,请检查数据的表头主键cgeneralhid。"
|
||||
*/);
|
||||
} else {
|
||||
List<String> headProFields =
|
||||
CheckProhibitUpdateFields.getHeadProhibitFields("4C");
|
||||
List<String> bodyProFields =
|
||||
CheckProhibitUpdateFields.getBodyProhibitFields("4C");
|
||||
SaleOutHeadVO origVO = saleOutVOs[0].getHead();
|
||||
if (origVO.getFbillflag() == null
|
||||
|| 0 != ((Integer) ICBillFlag.FREE.value())
|
||||
.compareTo((Integer) origVO.getFbillflag())) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0361")/*
|
||||
* @res
|
||||
* "当前出库单编号:"
|
||||
*/
|
||||
+ origVO.getVbillcode()
|
||||
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||
"4008027_0", "04008027-0362")/* @res "不是自由状态,不能修改" */);
|
||||
}
|
||||
origVO.setStatus(VOStatus.UPDATED);
|
||||
for (String attr : newVO.getAttributeNames()) {
|
||||
if (newVO.getAttributeValue(attr) == null) {
|
||||
continue;
|
||||
}
|
||||
if (headProFields.contains(attr)
|
||||
&& !newVO.getAttributeValue(attr).equals(
|
||||
origVO.getAttributeValue(attr))) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0363")/*
|
||||
* @res
|
||||
* "表头字段:"
|
||||
*/
|
||||
+ attr
|
||||
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||
"4008027_0", "04008027-0364")/* @res "不允许修改。" */);
|
||||
}
|
||||
origVO.setAttributeValue(attr, newVO.getAttributeValue(attr));
|
||||
}
|
||||
for (SaleOutVO orivo : originBills) {
|
||||
SaleOutBodyVO[] oribodys = orivo.getBodys();
|
||||
for (SaleOutBodyVO oribody : oribodys) {
|
||||
ICLocationVO[] locationVOs = oribody.getLocationVOs();
|
||||
if (null != locationVOs) {
|
||||
deleteLoc.put(oribody.getCgeneralbid(), locationVOs);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vos[0].getBodys() != null) {
|
||||
Map<String, SaleOutBodyVO> pkbs =
|
||||
new HashMap<String, SaleOutBodyVO>();
|
||||
for (SaleOutBodyVO origBvo : saleOutVOs[0].getBodys()) {
|
||||
origBvo.setStatus(VOStatus.UPDATED);
|
||||
pkbs.put(origBvo.getCgeneralbid(), origBvo);
|
||||
}
|
||||
for (SaleOutBodyVO newBvo : vos[0].getBodys()) {
|
||||
SaleOutBodyVO roigBvo = pkbs.get(newBvo.getCgeneralbid());
|
||||
if (newBvo.getCgeneralbid() == null || roigBvo == null) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0365")/*
|
||||
* @res
|
||||
* "没有匹配到原始出库单表体信息,请检查数据的表体主键cgeneralbid。"
|
||||
*/);
|
||||
}
|
||||
Set<String> bfields = new HashSet<String>();
|
||||
for (String battr : newBvo.getAttributeNames()) {
|
||||
if (newBvo.getAttributeValue(battr) == null) {
|
||||
continue;
|
||||
}
|
||||
if (bodyProFields.contains(battr)
|
||||
&& !newBvo.getAttributeValue(battr).equals(
|
||||
roigBvo.getAttributeValue(battr))) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0366")/*
|
||||
* @res
|
||||
* "表体字段:"
|
||||
*/
|
||||
+ battr
|
||||
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||
"4008027_0", "04008027-0364")/* @res "不允许修改。" */);
|
||||
}
|
||||
roigBvo.setAttributeValue(battr, newBvo.getAttributeValue(battr));
|
||||
bfields.add(battr);
|
||||
}
|
||||
//设置货位序列号孙表,把原来的孙表删除,修改的货位置为新增
|
||||
if (null != newBvo.getLocationVOs()) {
|
||||
List<ICLocationVO> allloc = new ArrayList<ICLocationVO>();
|
||||
if (null != deleteLoc && null != deleteLoc.get(roigBvo.getCgeneralbid())) {
|
||||
for (ICLocationVO delloc : deleteLoc.get(roigBvo.getCgeneralbid())) {
|
||||
delloc.setStatus(VOStatus.DELETED);
|
||||
allloc.add(delloc);
|
||||
}
|
||||
}
|
||||
for (ICLocationVO loc : newBvo.getLocationVOs()) {
|
||||
loc.setStatus(VOStatus.NEW);
|
||||
allloc.add(loc);
|
||||
}
|
||||
roigBvo.setLocationVOs(allloc.toArray(new ICLocationVO[allloc.size()]));
|
||||
}
|
||||
// 翻译货位
|
||||
ICAPILocationVOUtils.translate(saleOutVOs);
|
||||
// 其他数据填充
|
||||
new SaleOutUpdateFillValue().setDefaultValue(saleOutVOs, bfields);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NCLocator.getInstance()
|
||||
.lookup(nc.itf.ic.m4c.self.ISaleOutMaintain.class)
|
||||
.update(saleOutVOs, originBills);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] updateAndSign(List<Map<String, Object>> paramList) throws BusinessException {
|
||||
SaleOutVO[] updateVOs =NCLocator.getInstance().lookup(IAPISaleOutMaintain.class).update(paramList);
|
||||
SaleOutVO[] signVOs =NCLocator.getInstance().lookup(IAPISaleOutMaintain.class).sign(updateVOs);
|
||||
return signVOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] delete(SaleOutVO[] vos) throws BusinessException {
|
||||
if (ArrayUtils.isEmpty(vos)) {
|
||||
return null;
|
||||
}
|
||||
for (SaleOutVO aggvo : vos) {
|
||||
ICBillHeadVO parentVO = aggvo.getParentVO();
|
||||
if (parentVO.getFbillflag() == null
|
||||
|| 0 != ((Integer) ICBillFlag.FREE.value())
|
||||
.compareTo((Integer) parentVO.getFbillflag())) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0361")/*
|
||||
* @res
|
||||
* "当前出库单编号:"
|
||||
*/
|
||||
+ parentVO.getVbillcode()
|
||||
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||
"4008027_0", "04008027-0367")/* @res "不是自由状态,不能删除" */);
|
||||
}
|
||||
}
|
||||
return (SaleOutVO[]) PfServiceScmUtil.processBatch("DELETE", "4C", vos,
|
||||
null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] sign(SaleOutVO[] vos) throws BusinessException {
|
||||
if (ArrayUtils.isEmpty(vos)) {
|
||||
return null;
|
||||
}
|
||||
for (SaleOutVO aggvo : vos) {
|
||||
ICBillHeadVO parentVO = aggvo.getParentVO();
|
||||
if (parentVO.getFbillflag() == null
|
||||
|| 0 != ((Integer) ICBillFlag.FREE.value())
|
||||
.compareTo((Integer) parentVO.getFbillflag())) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0361")/*
|
||||
* @res
|
||||
* "当前出库单编号:"
|
||||
*/
|
||||
+ parentVO.getVbillcode()
|
||||
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||
"4008027_0", "04008027-0330")/* @res "不是自由状态,不能签字" */);
|
||||
}
|
||||
if (aggvo.getChildrenVO() != null && aggvo.getChildrenVO().length > 0) {
|
||||
if (aggvo.getChildrenVO()[0]
|
||||
.getAttributeValue(ICPubMetaNameConst.NNUM) == null) {
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0361")/*
|
||||
* @res
|
||||
* "当前出库单编号:"
|
||||
*/
|
||||
+ parentVO.getVbillcode()
|
||||
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||
"4008027_0", "04008027-0331")/* @res "主数量为空,不能签字" */);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ICLocationUtil.loadLocationVOs(vos);
|
||||
return (SaleOutVO[]) PfServiceScmUtil.processBatch("SIGN", "4C", vos,
|
||||
null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] unSign(SaleOutVO[] vos) throws BusinessException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] saveRefSaleOrder(List<Map<String, Object>> paramList) throws BusinessException {
|
||||
// MapList转聚合VOList
|
||||
List<SaleOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, SaleOutVO.class);
|
||||
SaleOutVO[] vos = aggVOList.toArray(new SaleOutVO[aggVOList.size()]);
|
||||
// 1、传入数据基本非空校验
|
||||
BillVOsCheckRule checker =
|
||||
new BillVOsCheckRule(new CheckSaleOutSaveValidator());
|
||||
checker.check(vos);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
// 其他数据填充
|
||||
new SaleOutSaveFromRefFillValue().setRefValue(vos, "30");
|
||||
|
||||
// 保存销售出库单
|
||||
return (SaleOutVO[]) PfServiceScmUtil.processBatch("WRITE", "4C", vos, null,
|
||||
null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] saveRefDelivery(List<Map<String, Object>> paramList) throws BusinessException {
|
||||
// MapList转聚合VOList
|
||||
List<SaleOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, SaleOutVO.class);
|
||||
SaleOutVO[] vos = aggVOList.toArray(new SaleOutVO[aggVOList.size()]);
|
||||
// 1、传入数据基本非空校验
|
||||
BillVOsCheckRule checker =
|
||||
new BillVOsCheckRule(new CheckSaleOutSaveValidator());
|
||||
checker.check(vos);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
|
||||
// 其他数据填充
|
||||
new SaleOutSaveFromRefFillValue().setRefValue(vos, "4331");
|
||||
// 保存销售出库单
|
||||
return (SaleOutVO[]) PfServiceScmUtil.processBatch("WRITE", "4C", vos, null,
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaleOutVO[] saveFromRef(List<Map<String, Object>> paramList)
|
||||
throws BusinessException {
|
||||
|
||||
// MapList转聚合VOList
|
||||
List<SaleOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, SaleOutVO.class);
|
||||
SaleOutVO[] vos =
|
||||
aggVOList.toArray(new SaleOutVO[aggVOList.size()]);
|
||||
// 1、传入数据基本非空校验
|
||||
BillVOsCheckRule checker =
|
||||
new BillVOsCheckRule(new CheckSaleOutSaveValidator());
|
||||
checker.check(vos);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
|
||||
//设置组织vid
|
||||
new ChooseHeadOrg().process(vos);
|
||||
//设置行号
|
||||
VORowNoUtils.setVOsRowNoByRule(vos, MetaNameConst.CROWNO);
|
||||
ISaleOutMaintainAPI saleOut = NCLocator.getInstance().lookup(ISaleOutMaintainAPI.class);
|
||||
return saleOut.insertBills(vos);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,272 @@
|
|||
package nccloud.api.impl.ic.m4d;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.scmpub.query.SCMBillQuery;
|
||||
import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil;
|
||||
import nc.pubimpl.ic.api.maintain.BillMaintainTool;
|
||||
import nc.pubitf.ic.m4d.api.IMaterialOutMaintainAPI;
|
||||
import nc.vo.ic.general.define.ICBillFlag;
|
||||
import nc.vo.ic.general.define.ICBillHeadVO;
|
||||
import nc.vo.ic.general.util.ICLocationUtil;
|
||||
import nc.vo.ic.location.ICLocationVO;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutBodyVO;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutHeadVO;
|
||||
import nc.vo.ic.m4d.entity.MaterialOutVO;
|
||||
import nc.vo.ic.pub.define.ICPubMetaNameConst;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.VOStatus;
|
||||
import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule;
|
||||
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||
import nccloud.api.ic.m4d.IAPIMaterialOutMaintain;
|
||||
import nccloud.api.impl.ic.m4d.check.CheckMaterialOutSaveValidator;
|
||||
import nccloud.api.impl.ic.m4d.fill.MaterialOutSaveFillValue;
|
||||
import nccloud.api.impl.ic.m4d.fill.MaterialOutUpdateFillValue;
|
||||
import nccloud.api.impl.ic.pub.check.CheckProhibitUpdateFields;
|
||||
import nccloud.openapi.ic.util.ICAPILocationVOUtils;
|
||||
import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
|
||||
import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description: 库存材料出库单维护实现类
|
||||
*
|
||||
* @author: 曹军
|
||||
* @date: 2019-5-17 上午10:49:30
|
||||
* @version NCC1909
|
||||
*/
|
||||
|
||||
public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain{
|
||||
|
||||
@Override
|
||||
public MaterialOutVO[] save(List<Map<String, Object>> paramList) throws BusinessException {
|
||||
// MapList转聚合VOList
|
||||
List<MaterialOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, MaterialOutVO.class);
|
||||
MaterialOutVO[] vos =
|
||||
aggVOList.toArray(new MaterialOutVO[aggVOList.size()]);
|
||||
// 设置货位序列号VO
|
||||
ICAPILocationVOUtils.setLocationVO(ICBillType.MaterialOut.getCode(),vos);
|
||||
// 1、传入数据基本非空校验
|
||||
BillVOsCheckRule checker =
|
||||
new BillVOsCheckRule(new CheckMaterialOutSaveValidator());
|
||||
checker.check(vos);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
// 翻译货位
|
||||
ICAPILocationVOUtils.translate(vos);
|
||||
//其他数据填充
|
||||
new MaterialOutSaveFillValue().setDefaultValue(vos);
|
||||
|
||||
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
|
||||
//设置每行行号
|
||||
setMaterialOutRowNum(vos);
|
||||
return materialOut.insertBills(vos);
|
||||
}
|
||||
|
||||
private void setMaterialOutRowNum(MaterialOutVO[] vos) {
|
||||
for (int i = 0; i < vos.length; i++) {
|
||||
MaterialOutVO vo = vos[i];
|
||||
MaterialOutBodyVO[] bodys = vo.getBodys();
|
||||
if (bodys != null && bodys.length > 0) {
|
||||
for (int j = 0; j < bodys.length; j++) {
|
||||
MaterialOutBodyVO body = bodys[j];
|
||||
body.setCrowno(String.valueOf((j +1)*10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialOutVO[] update(List<Map<String, Object>> paramList) throws BusinessException {
|
||||
// MapList转聚合VOList
|
||||
List<MaterialOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, MaterialOutVO.class);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
MaterialOutVO[] vos =
|
||||
aggVOList.toArray(new MaterialOutVO[aggVOList.size()]);
|
||||
// 设置货位序列号VO
|
||||
ICAPILocationVOUtils.setLocationVO(ICBillType.MaterialOut.getCode(),vos);
|
||||
MaterialOutHeadVO newVO = vos[0].getHead();
|
||||
String cgeneralhid = newVO.getCgeneralhid();
|
||||
if(StringUtils.isEmpty(cgeneralhid)){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0391")/*@res "修改材料出库单请指定表头主键cgeneralhid值。"*/);
|
||||
}
|
||||
SCMBillQuery<MaterialOutVO> queryTool =
|
||||
new SCMBillQuery<MaterialOutVO>(MaterialOutVO.class);
|
||||
MaterialOutVO[] materialOutVOs = queryTool.queryVOByIDs(new String[]{cgeneralhid});
|
||||
Map<String, ICLocationVO[]> deleteLoc =
|
||||
new HashMap<String, ICLocationVO[]>();
|
||||
// 加载原始单据和货位信息
|
||||
MaterialOutVO[] originBills = queryTool.queryVOByIDs(new String[] {
|
||||
cgeneralhid
|
||||
});
|
||||
ICLocationUtil.loadLocationVOs(originBills);
|
||||
if(ArrayUtils.isEmpty(materialOutVOs)){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0360")/*@res "没找到要修改的出库单信息,请检查数据的表头主键cgeneralhid。"*/);
|
||||
}else{
|
||||
List<String> headProFields = CheckProhibitUpdateFields.getHeadProhibitFields("4D");
|
||||
List<String> bodyProFields = CheckProhibitUpdateFields.getBodyProhibitFields("4D");
|
||||
MaterialOutHeadVO origVO = materialOutVOs[0].getHead();
|
||||
if(origVO.getFbillflag() == null ||
|
||||
0 != ((Integer) ICBillFlag.FREE.value())
|
||||
.compareTo((Integer) origVO.getFbillflag())){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0361")/*@res "当前出库单编号:"*/ + origVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0362")/*@res "不是自由状态,不能修改"*/);
|
||||
}
|
||||
origVO.setStatus(VOStatus.UPDATED);
|
||||
for(String attr : newVO.getAttributeNames()){
|
||||
if(newVO.getAttributeValue(attr) == null) {
|
||||
continue;
|
||||
}
|
||||
if(headProFields.contains(attr)
|
||||
&& !newVO.getAttributeValue(attr).equals(origVO.getAttributeValue(attr))){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0363")/*@res "表头字段:"*/ + attr + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0364")/*@res "不允许修改。"*/ );
|
||||
}
|
||||
origVO.setAttributeValue(attr, newVO.getAttributeValue(attr));
|
||||
}
|
||||
for (MaterialOutVO orivo : originBills) {
|
||||
MaterialOutBodyVO[] oribodys = orivo.getBodys();
|
||||
for (MaterialOutBodyVO oribody : oribodys) {
|
||||
ICLocationVO[] locationVOs = oribody.getLocationVOs();
|
||||
if (null != locationVOs) {
|
||||
deleteLoc.put(oribody.getCgeneralbid(), locationVOs);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(vos[0].getBodys() != null){
|
||||
Map<String, MaterialOutBodyVO> pkbs = new HashMap<String, MaterialOutBodyVO>();
|
||||
for(MaterialOutBodyVO origBvo : materialOutVOs[0].getBodys()){
|
||||
origBvo.setStatus(VOStatus.UPDATED);
|
||||
pkbs.put(origBvo.getCgeneralbid(), origBvo);
|
||||
}
|
||||
for(MaterialOutBodyVO newBvo : vos[0].getBodys()){
|
||||
MaterialOutBodyVO roigBvo = pkbs.get(newBvo.getCgeneralbid());
|
||||
if(newBvo.getCgeneralbid() == null || roigBvo == null){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0365")/*@res "没有匹配到原始出库单表体信息,请检查数据的表体主键cgeneralbid。"*/);
|
||||
}
|
||||
Set<String> bfields = new HashSet<String>();
|
||||
for(String battr : newBvo.getAttributeNames()){
|
||||
if(newBvo.getAttributeValue(battr) == null) {
|
||||
continue;
|
||||
}
|
||||
if(bodyProFields.contains(battr)
|
||||
&& !newBvo.getAttributeValue(battr).equals(roigBvo.getAttributeValue(battr))){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0366")/*@res "表体字段:"*/ + battr + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0364")/*@res "不允许修改。"*/ );
|
||||
}
|
||||
roigBvo.setAttributeValue(battr, newBvo.getAttributeValue(battr));
|
||||
bfields.add(battr);
|
||||
}
|
||||
//设置货位序列号孙表,把原来的孙表删除,修改的货位置为新增
|
||||
if(null != newBvo.getLocationVOs()) {
|
||||
List<ICLocationVO> allloc = new ArrayList<ICLocationVO>();
|
||||
if(null != deleteLoc && null != deleteLoc.get(roigBvo.getCgeneralbid())) {
|
||||
for(ICLocationVO delloc : deleteLoc.get(roigBvo.getCgeneralbid())) {
|
||||
delloc.setStatus(VOStatus.DELETED);
|
||||
allloc.add(delloc);
|
||||
}
|
||||
}
|
||||
for(ICLocationVO loc : newBvo.getLocationVOs()) {
|
||||
loc.setStatus(VOStatus.NEW);
|
||||
allloc.add(loc);
|
||||
}
|
||||
roigBvo.setLocationVOs(allloc.toArray(new ICLocationVO[allloc.size()]));
|
||||
}
|
||||
// 翻译货位
|
||||
ICAPILocationVOUtils.translate(materialOutVOs);
|
||||
//其他数据填充
|
||||
new MaterialOutUpdateFillValue().setDefaultValue(materialOutVOs,bfields);
|
||||
}
|
||||
}
|
||||
}
|
||||
BillMaintainTool<MaterialOutVO> tool =
|
||||
new BillMaintainTool<MaterialOutVO>(MaterialOutVO.class,
|
||||
ICBillType.MaterialOut.getCode());
|
||||
tool.doBeforeInsert(materialOutVOs);
|
||||
return NCLocator.getInstance()
|
||||
.lookup(nc.itf.ic.m4d.IMaterialOutMaintain.class).update(materialOutVOs,originBills);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialOutVO[] delete(MaterialOutVO[] vos) throws BusinessException {
|
||||
if(ArrayUtils.isEmpty(vos)){
|
||||
return null;
|
||||
}
|
||||
for(MaterialOutVO aggvo : vos){
|
||||
ICBillHeadVO parentVO = aggvo.getParentVO();
|
||||
if(parentVO.getFbillflag() == null ||
|
||||
0 != ((Integer) ICBillFlag.FREE.value())
|
||||
.compareTo((Integer) parentVO.getFbillflag())){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0361")/*@res "当前出库单编号:"*/ + parentVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0367")/*@res "不是自由状态,不能删除"*/);
|
||||
}
|
||||
}
|
||||
return (MaterialOutVO[]) PfServiceScmUtil.processBatch("DELETE", "4D", vos, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialOutVO[] sign(MaterialOutVO[] vos) throws BusinessException {
|
||||
if(ArrayUtils.isEmpty(vos)){
|
||||
return null;
|
||||
}
|
||||
for(MaterialOutVO aggvo : vos){
|
||||
ICBillHeadVO parentVO = aggvo.getParentVO();
|
||||
if(parentVO.getFbillflag() == null ||
|
||||
0 != ((Integer) ICBillFlag.FREE.value())
|
||||
.compareTo((Integer) parentVO.getFbillflag())){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0361")/*@res "当前出库单编号:"*/ + parentVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0330")/*@res "不是自由状态,不能签字"*/);
|
||||
}
|
||||
if(aggvo.getChildrenVO() != null && aggvo.getChildrenVO().length > 0){
|
||||
if(aggvo.getChildrenVO()[0].getAttributeValue(ICPubMetaNameConst.NNUM) == null){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0361")/*@res "当前出库单编号:"*/ + parentVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0392")/*@res "总数量为空,不能签字"*/);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ICLocationUtil.loadLocationVOs(vos);
|
||||
return (MaterialOutVO[]) PfServiceScmUtil.processBatch("SIGN", "4D", vos, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialOutVO[] unSign(MaterialOutVO[] vos) throws BusinessException {
|
||||
if(ArrayUtils.isEmpty(vos)){
|
||||
return null;
|
||||
}
|
||||
for(MaterialOutVO aggvo : vos){
|
||||
ICBillHeadVO parentVO = aggvo.getParentVO();
|
||||
if(parentVO.getFbillflag() == null ||
|
||||
0 != ((Integer) ICBillFlag.SIGN.value())
|
||||
.compareTo((Integer) parentVO.getFbillflag())){
|
||||
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0361")/*@res "当前出库单编号:"*/ + parentVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0332")/*@res "不是签字状态,不能取消签字"*/);
|
||||
}
|
||||
}
|
||||
return (MaterialOutVO[]) PfServiceScmUtil.processBatch("CANCELSIGN", "4D", vos, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialOutVO[] saveByRef(List<Map<String, Object>> paramList) throws BusinessException{
|
||||
|
||||
// MapList转聚合VOList
|
||||
List<MaterialOutVO> aggVOList =
|
||||
TransferMapToVOTool.transferMapToAggVO(paramList, MaterialOutVO.class);
|
||||
MaterialOutVO[] vos =
|
||||
aggVOList.toArray(new MaterialOutVO[aggVOList.size()]);
|
||||
// 1、传入数据基本非空校验
|
||||
BillVOsCheckRule checker =
|
||||
new BillVOsCheckRule(new CheckMaterialOutSaveValidator());
|
||||
checker.check(vos);
|
||||
// 2、编码翻译成pk
|
||||
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||
IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class);
|
||||
return materialOut.insertBills(vos);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package nccloud.api.ic.m4c;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import nc.vo.ic.m4c.entity.SaleOutVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description: 销售出库单维护接口
|
||||
*
|
||||
* @author: 曹军
|
||||
* @date: 2019-5-17 上午9:23:53
|
||||
* @version NCC1909
|
||||
*/
|
||||
|
||||
public interface IAPISaleOutMaintain {
|
||||
|
||||
/**
|
||||
* 销售出库单新增保存操作
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] save(List<Map<String, Object>> paramList) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 销售出库单修改操作
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] update(List<Map<String, Object>> paramList) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 销售出库单修改签字操作
|
||||
* @param paramList
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] updateAndSign(List<Map<String, Object>> paramList) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 销售出库单删除操作
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] delete(SaleOutVO[] vos) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 销售出库单签字操作
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] sign(SaleOutVO[] vos) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 销售出库单取消签字操作
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] unSign(SaleOutVO[] vos) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 根据销售订单生成销售出库单
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] saveRefSaleOrder(List<Map<String, Object>> paramMapList)
|
||||
throws BusinessException;
|
||||
/**
|
||||
* 根据发货单生成销售出库单
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] saveRefDelivery (List<Map<String, Object>> paramMapList)
|
||||
throws BusinessException;
|
||||
/**
|
||||
* 参照生成销售出库单
|
||||
* @param vos
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public SaleOutVO[] saveFromRef (List<Map<String, Object>> paramList)
|
||||
throws BusinessException;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,272 @@
|
|||
package nccloud.openapi.ic.m4c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import nc.bs.framework.common.InvocationInfoProxy;
|
||||
import org.json.JSONString;
|
||||
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.scmpub.query.SCMBillQuery;
|
||||
import nc.vo.ic.m4c.entity.SaleOutVO;
|
||||
import nc.vo.ic.pub.define.ICPubMetaNameConst;
|
||||
import nc.ws.opm.pub.utils.result.APIErrCodeEnum;
|
||||
import nccloud.api.ic.m4c.IAPISaleOutMaintain;
|
||||
import nccloud.api.ic.m4c.IAPISaleOutQuery;
|
||||
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||
import nccloud.openapi.scmpub.pub.NCCPubRestResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description: 库存销售出库单资源类
|
||||
*
|
||||
* @author: 曹军
|
||||
* @date: 2019-5-17 上午10:21:00
|
||||
* @version NCC1909
|
||||
*/
|
||||
|
||||
@Path("ic/saleout")
|
||||
public class SaleOutResource extends NCCPubRestResource {
|
||||
|
||||
private Integer pageNo = defaultPageIndex;
|
||||
|
||||
private Integer pageSize = defaultPageNum;
|
||||
|
||||
private static String HEADTABLE = "ic_saleout_h";
|
||||
|
||||
private static String BODYTABLE = "ic_saleout_b";
|
||||
|
||||
@POST
|
||||
@Path("commonquery")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString queryVOByCommon(Map<String, Object> paramMap) {
|
||||
if (paramMap == null || !paramMap.containsKey(ICPubMetaNameConst.PK_ORG)
|
||||
|| !paramMap.containsKey(ICPubMetaNameConst.DBILLDATE)) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入参数错误,组织、单据日期条件必输", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
try {
|
||||
// 处理传过来的分页信息
|
||||
if (paramMap.get(PAGE_NO) != null) {
|
||||
Double pageno = (Double) paramMap.get(PAGE_NO);
|
||||
this.pageNo = pageno.intValue();
|
||||
}
|
||||
if (paramMap.get(PAGE_SIZE) != null) {
|
||||
Double pagesize = (Double) paramMap.get(PAGE_SIZE);
|
||||
this.pageSize = pagesize.intValue();
|
||||
}
|
||||
IAPISaleOutQuery iQuery =
|
||||
NCLocator.getInstance().lookup(IAPISaleOutQuery.class);
|
||||
SaleOutVO[] saleoutVOs =
|
||||
iQuery.queryPageVOByScheme(paramMap, this.pageNo,
|
||||
this.pageSize);
|
||||
return ResultMessageUtil.toJSON(saleoutVOs,
|
||||
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||
"4008027_0", "04008027-0460")/* @res "销售出库单查询成功" */);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("schemequery")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString queryVOByScheme(Map<String, Object> paramMap) {
|
||||
if (paramMap == null) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入参数为空,请检查", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
try {
|
||||
// 调用查询接口
|
||||
IAPISaleOutQuery query =
|
||||
NCLocator.getInstance().lookup(IAPISaleOutQuery.class);
|
||||
SaleOutVO[] saleOutVOs = query.queryVOByScheme(paramMap);
|
||||
return ResultMessageUtil.toJSON(saleOutVOs,
|
||||
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
|
||||
"04008027-0460")/* @res "销售出库单查询成功" */);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("save")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString save(List<Map<String, Object>> paramList) {
|
||||
try {
|
||||
for (Map<String, Object> map : paramList) {
|
||||
if (!map.containsKey(HEADTABLE) || !map.containsKey(BODYTABLE)) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
}
|
||||
// 保存
|
||||
SaleOutVO[] saleOutVOs =
|
||||
NCLocator.getInstance().lookup(IAPISaleOutMaintain.class)
|
||||
.save(paramList);
|
||||
return ResultMessageUtil.toJSON(saleOutVOs,
|
||||
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
|
||||
"04008027-0462")/* @res "销售出库单保存成功" */);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("update")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString update(Map<String, Object> paramMap) {
|
||||
try {
|
||||
if (paramMap == null || !paramMap.containsKey(HEADTABLE)) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
List<Map<String, Object>> paramMapList= new ArrayList<>();
|
||||
paramMapList.add(paramMap);
|
||||
//锐制需要修改保存时走签字
|
||||
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
||||
if("gaoning".equals(userCode)){
|
||||
// 修改并签字--事务一致
|
||||
SaleOutVO[] signVOs =NCLocator.getInstance().lookup(IAPISaleOutMaintain.class).updateAndSign(paramMapList);
|
||||
|
||||
|
||||
return ResultMessageUtil.toJSON(signVOs,
|
||||
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
|
||||
"04008027-0464")/* @res "销售出库单修改签字成功" */);
|
||||
}else{
|
||||
// 修改
|
||||
SaleOutVO[] updateVO =
|
||||
NCLocator.getInstance().lookup(IAPISaleOutMaintain.class)
|
||||
.update(paramMapList);
|
||||
return ResultMessageUtil.toJSON(updateVO,
|
||||
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
|
||||
"04008027-0464")/* @res "销售出库单修改成功" */);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("delete")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString delete(String[] hids) {
|
||||
if (hids == null || hids.length == 0) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入参数为空,请检查", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
else {
|
||||
try {
|
||||
SCMBillQuery<SaleOutVO> queryTool =
|
||||
new SCMBillQuery<SaleOutVO>(SaleOutVO.class);
|
||||
SaleOutVO[] saleOutVOs = queryTool.queryVOByIDs(hids);
|
||||
if (saleOutVOs.length == 0) {
|
||||
return ResultMessageUtil.exceptionToJSON("根据传入数据未匹配到相关数据", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
else {
|
||||
NCLocator.getInstance()
|
||||
.lookup(IAPISaleOutMaintain.class).delete(saleOutVOs);
|
||||
return ResultMessageUtil.toJSON(new String[0], nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0466")/*
|
||||
* @res
|
||||
* "销售出库单删除成功"
|
||||
*/);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("sign")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString sign(String[] hids) {
|
||||
if (hids == null || hids.length == 0) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入参数为空,请检查", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
else {
|
||||
try {
|
||||
SCMBillQuery<SaleOutVO> queryTool =
|
||||
new SCMBillQuery<SaleOutVO>(SaleOutVO.class);
|
||||
SaleOutVO[] saleOutVOs = queryTool.queryVOByIDs(hids);
|
||||
if (saleOutVOs.length == 0) {
|
||||
return ResultMessageUtil.exceptionToJSON("根据传入数据未匹配到相关数据", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
else {
|
||||
saleOutVOs =
|
||||
NCLocator.getInstance()
|
||||
.lookup(IAPISaleOutMaintain.class).sign(saleOutVOs);
|
||||
return ResultMessageUtil.toJSON(saleOutVOs, nc.vo.ml.NCLangRes4VoTransl
|
||||
.getNCLangRes().getStrByID("4008027_0", "04008027-0468")/*
|
||||
* @res
|
||||
* "销售出库单签字成功"
|
||||
*/);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("saveRefSaleOrder")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString saveRefSaleOrder(Map<String, Object> paramMap) {
|
||||
try {
|
||||
if (!paramMap.containsKey(HEADTABLE) || !paramMap.containsKey(BODYTABLE)) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
List<Map<String, Object>> paramMapList= new ArrayList<>();
|
||||
paramMapList.add(paramMap);
|
||||
|
||||
IAPISaleOutMaintain service =
|
||||
NCLocator.getInstance().lookup(IAPISaleOutMaintain.class);
|
||||
SaleOutVO[] resultVOs =
|
||||
service.saveRefSaleOrder(paramMapList);
|
||||
// 返回结果
|
||||
return ResultMessageUtil.toJSON(resultVOs, "销售出库单保存成功");
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("saveRefDelivery")
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public JSONString saveRefDelivery(Map<String, Object> paramMap) {
|
||||
try {
|
||||
if (!paramMap.containsKey(HEADTABLE) || !paramMap.containsKey(BODYTABLE)) {
|
||||
return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", APIErrCodeEnum.BUSINESSEXCCODE.getCode());
|
||||
}
|
||||
List<Map<String, Object>> paramMapList= new ArrayList<>();
|
||||
paramMapList.add(paramMap);
|
||||
IAPISaleOutMaintain service =
|
||||
NCLocator.getInstance().lookup(IAPISaleOutMaintain.class);
|
||||
SaleOutVO[] resultVOs =
|
||||
service.saveRefDelivery(paramMapList);
|
||||
return ResultMessageUtil.toJSON(resultVOs, "销售出库单保存成功");
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
package nccloud.resources.ic.ic.saleout;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import nc.bs.businessevent.BdUpdateEvent;
|
||||
import nc.bs.businessevent.BusinessEvent;
|
||||
import nc.bs.businessevent.IBusinessEvent;
|
||||
import nc.bs.businessevent.IBusinessListener;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.ic.general.businessevent.ICGeneralCommonEvent;
|
||||
import nc.bs.trade.business.HYSuperDMO;
|
||||
import nc.itf.uap.IUAPQueryBS;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import nc.vo.bd.defdoc.DefdocVO;
|
||||
import nc.vo.ic.general.define.ICBillBodyVO;
|
||||
import nc.vo.ic.m4c.entity.SaleOutHeadVO;
|
||||
import nc.vo.ic.m4c.entity.SaleOutVO;
|
||||
|
|
@ -20,7 +20,12 @@ import nc.vo.pub.lang.UFDouble;
|
|||
import nc.vo.pubapp.AppContext;
|
||||
import nc.vo.tmpub.util.ModuleEnum;
|
||||
import nc.vo.tmpub.util.ModuleUtil;
|
||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -30,158 +35,182 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
public class saveBeforeCheck implements IBusinessListener {
|
||||
|
||||
@Override
|
||||
public void doAction(IBusinessEvent event) throws BusinessException {
|
||||
@Override
|
||||
public void doAction(IBusinessEvent event) throws BusinessException {
|
||||
|
||||
String pk_group = AppContext.getInstance().getPkGroup();
|
||||
if (ModuleUtil.isEnableByGroup(pk_group, ModuleEnum.SSCRP, false)) {
|
||||
if (event != null) {
|
||||
Map<String, SaleOutVO[]> map = this.getBills(event);
|
||||
SaleOutVO[] obills = map.get("obj");
|
||||
// 判断是否是需要控制的业务单元
|
||||
SaleOutHeadVO parentVO = obills[0].getHead();
|
||||
String pkstockorgStr = getPk_stockorg(parentVO.getPk_org());
|
||||
if (pkstockorgStr == null || pkstockorgStr.equals("")) {
|
||||
return;
|
||||
}
|
||||
ICBillBodyVO[] childrenVO = obills[0].getChildrenVO();
|
||||
for (int i = 0; i < childrenVO.length; ++i) {
|
||||
ICBillBodyVO vo = childrenVO[i];
|
||||
Map<String, Object> valMap = getSaleorderPK(vo.getCsourcebillbid());
|
||||
if (valMap == null || valMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 历史数据不考虑
|
||||
String storedDateStr = (String) valMap.get("creationtime");
|
||||
String targetDateStr = "2024-12-31 00:00:00";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter);
|
||||
LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter);
|
||||
if (storedDate.isBefore(targetDate)) {
|
||||
return;
|
||||
}
|
||||
// 销售发票表头pk_billtypecode=30-Cxx-12
|
||||
if (valMap.get("pk_billtypecode").equals("30-Cxx-12")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-02")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-08")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-13")) {
|
||||
return;
|
||||
}
|
||||
// 销售发票表头vdef21=是
|
||||
if (valMap.get("vdef20") == null || !valMap.get("vdef20").equals("Y")) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",销售发票验证不通过,无法保存!");
|
||||
}
|
||||
if (valMap.get("sqty") == null) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计发货申请数量为0,无法保存!");
|
||||
} else {
|
||||
try {
|
||||
double sQty = Double.parseDouble((String) valMap.get("sqty"));// 累计发货申请数量
|
||||
UFDouble bdnumUF = vo.getNshouldassistnum();// 本单应发数量
|
||||
double bdnum = 0;
|
||||
if (bdnumUF != null) {
|
||||
bdnum = bdnumUF.getDouble();
|
||||
}
|
||||
// 应发数量判断
|
||||
Object ntotaloutnumsObj = valMap.get("ntotaloutnums");
|
||||
String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : "";
|
||||
double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计出库主数量
|
||||
String pk_group = AppContext.getInstance().getPkGroup();
|
||||
if (ModuleUtil.isEnableByGroup(pk_group, ModuleEnum.SSCRP, false)) {
|
||||
if (event != null) {
|
||||
Map<String, SaleOutVO[]> map = this.getBills(event);
|
||||
SaleOutVO[] obills = map.get("obj");
|
||||
// 判断是否是需要控制的业务单元
|
||||
SaleOutHeadVO parentVO = obills[0].getHead();
|
||||
String pkstockorgStr = getPk_stockorg(parentVO.getPk_org());
|
||||
if (pkstockorgStr == null || pkstockorgStr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ICBillBodyVO[] childrenVO = obills[0].getChildrenVO();
|
||||
for (int i = 0; i < childrenVO.length; ++i) {
|
||||
ICBillBodyVO vo = childrenVO[i];
|
||||
Map<String, Object> valMap = getSaleorderPK(vo.getCsourcebillbid());
|
||||
if (valMap == null || valMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 历史数据不考虑
|
||||
String storedDateStr = (String) valMap.get("creationtime");
|
||||
String targetDateStr = "2024-12-31 00:00:00";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter);
|
||||
LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter);
|
||||
if (storedDate.isBefore(targetDate)) {
|
||||
return;
|
||||
}
|
||||
// 销售发票表头pk_billtypecode=30-Cxx-12
|
||||
if (valMap.get("pk_billtypecode").equals("30-Cxx-12")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-02")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-08")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-13")) {
|
||||
return;
|
||||
}
|
||||
// 销售发票表头vdef21=是
|
||||
if (valMap.get("vdef20") == null || !valMap.get("vdef20").equals("Y")) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",销售发票验证不通过,无法保存!");
|
||||
}
|
||||
if (valMap.get("sqty") == null) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计发货申请数量为0,无法保存!");
|
||||
} else {
|
||||
try {
|
||||
double sQty = Double.parseDouble((String) valMap.get("sqty"));// 累计发货申请数量
|
||||
UFDouble bdnumUF = vo.getNshouldassistnum();// 本单应发数量
|
||||
double bdnum = 0;
|
||||
if (bdnumUF != null) {
|
||||
bdnum = bdnumUF.getDouble();
|
||||
}
|
||||
// 应发数量判断
|
||||
Object ntotaloutnumsObj = valMap.get("ntotaloutnums");
|
||||
String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : "";
|
||||
double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计出库主数量
|
||||
|
||||
if (sQty < (ntotaloutnum + bdnum)) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库应发数量'" + (ntotaloutnum + bdnum)
|
||||
+ "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
|
||||
}
|
||||
// 实发数量判断
|
||||
UFDouble bdsfnumUF = vo.getNassistnum();// 本单实发数量
|
||||
double bdsfnum = 0;
|
||||
if (bdsfnumUF != null) {
|
||||
bdsfnum = bdsfnumUF.getDouble();
|
||||
}
|
||||
Object nassistnumObj = valMap.get("nassistnum");
|
||||
String nassistnums = (nassistnumObj != null) ? nassistnumObj.toString() : "";
|
||||
double nassistnum = (nassistnums.isEmpty()) ? 0 : Double.parseDouble(nassistnums);// 累计出库主数量
|
||||
if (sQty < (nassistnum + bdsfnum)) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库实发数量'" + (nassistnum + bdsfnum)
|
||||
+ "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new BusinessException("累计发货申请数量、累计出库数量转化数值失败" + e);
|
||||
}
|
||||
}
|
||||
/*if (sQty < (ntotaloutnum + bdnum)) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库应发数量'" + (ntotaloutnum + bdnum)
|
||||
+ "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
|
||||
}*/
|
||||
// 实发数量判断
|
||||
UFDouble bdsfnumUF = vo.getNassistnum();// 本单实发数量
|
||||
double bdsfnum = 0;
|
||||
if (bdsfnumUF != null) {
|
||||
bdsfnum = bdsfnumUF.getDouble();
|
||||
}
|
||||
Object nassistnumObj = valMap.get("nassistnum");
|
||||
String nassistnums = (nassistnumObj != null) ? nassistnumObj.toString() : "";
|
||||
double nassistnum = (nassistnums.isEmpty()) ? 0 : Double.parseDouble(nassistnums);// 累计出库主数量
|
||||
if (sQty < (nassistnum + bdsfnum)) {
|
||||
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库实发数量'" + (nassistnum + bdsfnum)
|
||||
+ "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new BusinessException("累计发货申请数量、累计出库数量转化数值失败" + e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> getSaleorderPK(String csourcebillbidStr) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " SELECT s.creationtime,bt.pk_billtypecode,sb.csaleorderbid,sb.vbdef2 AS sQty,\n" + "s.vdef11,\n"
|
||||
+ "si.vdef20,\n" + "sbv.nassistnum,\n" + "sbv.ntotaloutnums\n" + "FROM so_saleinvoice_b sib\n"
|
||||
+ "INNER JOIN so_saleinvoice si ON si.csaleinvoiceid = sib.csaleinvoiceid\n"
|
||||
+ "INNER JOIN so_saleorder_b sb ON sb.csaleorderbid = sib.csrcbid\n"
|
||||
+ "left join (SELECT SUM(b.nshouldassistnum) AS ntotaloutnums,sum(nassistnum) as nassistnum,c.csaleorderbid\n"
|
||||
+ "FROM so_saleorder_b c\n" + "INNER JOIN so_saleinvoice_b a ON c.csaleorderbid = a.csrcbid\n"
|
||||
+ "INNER JOIN ic_saleout_b b ON b.csourcebillbid = a.csaleinvoicebid\n" + "where a.dr=0 and b.dr=0 \n"
|
||||
+ "GROUP BY c.csaleorderbid) sbv on sbv.csaleorderbid=sb.csaleorderbid\n"
|
||||
+ "INNER JOIN so_saleorder s ON s.csaleorderid = sb.csaleorderid\n"
|
||||
+ "INNER JOIN bd_billtype bt on bt.pk_billtypeid=s.ctrantypeid\n"
|
||||
+ "INNER JOIN so_saleorder_exe se ON sb.csaleorderbid = se.csaleorderbid\n"
|
||||
+ "WHERE sib.csaleinvoicebid = '" + csourcebillbidStr + "' ";
|
||||
Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
return valList;
|
||||
}
|
||||
private Map<String, Object> getSaleorderPK(String csourcebillbidStr) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " SELECT s.creationtime,bt.pk_billtypecode,sb.csaleorderbid,sb.vbdef2 AS sQty,\n" + "s.vdef11,\n"
|
||||
+ "si.vdef20,\n" + "sbv.nassistnum,\n" + "sbv.ntotaloutnums\n" + "FROM so_saleinvoice_b sib\n"
|
||||
+ "INNER JOIN so_saleinvoice si ON si.csaleinvoiceid = sib.csaleinvoiceid\n"
|
||||
+ "INNER JOIN so_saleorder_b sb ON sb.csaleorderbid = sib.csrcbid\n"
|
||||
+ "left join (SELECT SUM(b.nshouldassistnum) AS ntotaloutnums,sum(nassistnum) as nassistnum,c.csaleorderbid\n"
|
||||
+ "FROM so_saleorder_b c\n" + "INNER JOIN so_saleinvoice_b a ON c.csaleorderbid = a.csrcbid\n"
|
||||
+ "INNER JOIN ic_saleout_b b ON b.csourcebillbid = a.csaleinvoicebid\n" + "where a.dr=0 and b.dr=0 \n"
|
||||
+ "GROUP BY c.csaleorderbid) sbv on sbv.csaleorderbid=sb.csaleorderbid\n"
|
||||
+ "INNER JOIN so_saleorder s ON s.csaleorderid = sb.csaleorderid\n"
|
||||
+ "INNER JOIN bd_billtype bt on bt.pk_billtypeid=s.ctrantypeid\n"
|
||||
+ "INNER JOIN so_saleorder_exe se ON sb.csaleorderbid = se.csaleorderbid\n"
|
||||
+ "WHERE sib.csaleinvoicebid = '" + csourcebillbidStr + "' ";
|
||||
Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
return valList;
|
||||
}
|
||||
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
|
||||
private Map<String, SaleOutVO[]> getBills(IBusinessEvent event) throws BusinessException {
|
||||
Object object = null;
|
||||
Object old = null;
|
||||
Map<String, SaleOutVO[]> retMap = new HashMap<>();
|
||||
// 类型判断和赋值
|
||||
if (event instanceof BusinessEvent) {
|
||||
BusinessEvent bills = (BusinessEvent) event;
|
||||
object = bills.getObject();
|
||||
} else if (event instanceof BdUpdateEvent) {
|
||||
BdUpdateEvent e = (BdUpdateEvent) event;
|
||||
object = e.getNewObject();
|
||||
old = e.getOldObject();
|
||||
} else if (event instanceof ICGeneralCommonEvent) {
|
||||
ICGeneralCommonEvent e = (ICGeneralCommonEvent) event;
|
||||
object = e.getNewObjs();
|
||||
old = e.getOldObjs();
|
||||
} else {
|
||||
throw new BusinessException("未找到单据类型");
|
||||
}
|
||||
// 将 object 和 old 转换为 SaleOutVO[] 并添加到 retMap
|
||||
retMap.put("new", toSaleOutVOArray(object));
|
||||
retMap.put("old", toSaleOutVOArray(old));
|
||||
// 根据 new 或 old 来设置 "obj"
|
||||
retMap.put("obj", retMap.get("new") != null ? retMap.get("new") : retMap.get("old"));
|
||||
return retMap;
|
||||
}
|
||||
private Map<String, SaleOutVO[]> getBills(IBusinessEvent event) throws BusinessException {
|
||||
Object object = null;
|
||||
Object old = null;
|
||||
Map<String, SaleOutVO[]> retMap = new HashMap<>();
|
||||
// 类型判断和赋值
|
||||
if (event instanceof BusinessEvent) {
|
||||
BusinessEvent bills = (BusinessEvent) event;
|
||||
object = bills.getObject();
|
||||
} else if (event instanceof BdUpdateEvent) {
|
||||
BdUpdateEvent e = (BdUpdateEvent) event;
|
||||
object = e.getNewObject();
|
||||
old = e.getOldObject();
|
||||
} else if (event instanceof ICGeneralCommonEvent) {
|
||||
ICGeneralCommonEvent e = (ICGeneralCommonEvent) event;
|
||||
object = e.getNewObjs();
|
||||
old = e.getOldObjs();
|
||||
} else {
|
||||
throw new BusinessException("未找到单据类型");
|
||||
}
|
||||
// 将 object 和 old 转换为 SaleOutVO[] 并添加到 retMap
|
||||
retMap.put("new", toSaleOutVOArray(object));
|
||||
retMap.put("old", toSaleOutVOArray(old));
|
||||
// 根据 new 或 old 来设置 "obj"
|
||||
retMap.put("obj", retMap.get("new") != null ? retMap.get("new") : retMap.get("old"));
|
||||
return retMap;
|
||||
}
|
||||
|
||||
// 辅助方法:将对象转换为 SaleOutVO 数组
|
||||
private SaleOutVO[] toSaleOutVOArray(Object object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
if (object.getClass().isArray()) {
|
||||
return (SaleOutVO[]) object;
|
||||
} else {
|
||||
return new SaleOutVO[] { (SaleOutVO) object };
|
||||
}
|
||||
}
|
||||
// 辅助方法:将对象转换为 SaleOutVO 数组
|
||||
private SaleOutVO[] toSaleOutVOArray(Object object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
if (object.getClass().isArray()) {
|
||||
return (SaleOutVO[]) object;
|
||||
} else {
|
||||
return new SaleOutVO[]{(SaleOutVO) object};
|
||||
}
|
||||
}
|
||||
|
||||
private String getPk_stockorg(String pk_stockorg) throws BusinessException {
|
||||
String sql = " select pk_stockorg from org_stockorg where code in ('C018','C029','C033','C039','C020','C019') and pk_stockorg='"
|
||||
+ pk_stockorg + "' ";
|
||||
String saleorderPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor());
|
||||
return saleorderPK;
|
||||
}
|
||||
private String getPk_stockorg(String pk_stockorg) throws BusinessException {
|
||||
Map<String, String> defMap = checkOrgCtrl();
|
||||
if (defMap.isEmpty() || "".equals(defMap.getOrDefault("so_out", ""))) {
|
||||
return "";
|
||||
}
|
||||
String orgStr = defMap.getOrDefault("so_out", "");
|
||||
// 将数组转换为字符串,并添加单引号
|
||||
String newOrgStr = orgStr.replace(",", "','");
|
||||
String sql = " select pk_stockorg from org_stockorg where code in ('" + newOrgStr + "') and pk_stockorg='"
|
||||
+ pk_stockorg + "' ";
|
||||
NCCForUAPLogger.debug("so_out-getPk_stockorg-sql:" + sql);
|
||||
String saleorderPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor());
|
||||
return saleorderPK;
|
||||
}
|
||||
|
||||
private Map<String, String> checkOrgCtrl() {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='org-ctrl' and dr=0 ) and dr=0";
|
||||
try {
|
||||
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
|
||||
if (defdocVOs != null && defdocVOs.length > 0) {
|
||||
for (DefdocVO defdocVO : defdocVOs) {
|
||||
map.put(defdocVO.getCode().trim(), defdocVO.getMemo());
|
||||
}
|
||||
}
|
||||
} catch (DAOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,12 +83,17 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
|
|||
singleObj.put("djyl", body.getNplanoutastnum().getDouble()); // 单据用量
|
||||
singleObj.put("clyl", body.getNplanoutastnum().getDouble()); // 材料用量
|
||||
|
||||
String rccode = transferCodeByPk(RcVO.getDefaultTableName(), RcVO.VRCCODE, RcVO.CRCID, head.getVstdprocid());
|
||||
singleObj.put("scgx_wbid", rccode); // 第三方系统使用工序id
|
||||
// String rccode = transferCodeByPk(RcVO.getDefaultTableName(), RcVO.VRCCODE, RcVO.CRCID, head.getVstdprocid());
|
||||
singleObj.put("scgx_wbid", body.getVbdef11());
|
||||
// singleObj.put("scgx_wbid", rccode); // 第三方系统使用工序id
|
||||
|
||||
//sdbj int 锁定标记 必填 默认1:正常业务ERP审核后,传输至锐制MOM
|
||||
singleObj.put("sdbj", 1);
|
||||
//shbj int 审核标记 必填 默认1:正常业务ERP审核后,传输至锐制MOM
|
||||
singleObj.put("shbj", 1);
|
||||
|
||||
//jylxbm --
|
||||
singleObj.put("jylxbm", head.getVbusitype());
|
||||
details.add(singleObj);
|
||||
|
||||
}
|
||||
|
|
@ -109,7 +114,6 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
|
|||
private void pushToRZMOM(AggPickmVO[] aggPickmVOS) throws BusinessException {
|
||||
String rzwmsip = SysInitQuery.getParaString("GLOBLE00000000000000", "RZWMSIP");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject dataIn = new JSONObject();
|
||||
JSONObject dataIn2 = new JSONObject();
|
||||
JSONArray details = new JSONArray();
|
||||
|
|
@ -123,8 +127,7 @@ public class AfterApproveRuleSyncRZWMS implements IRule<AggPickmVO> {
|
|||
}
|
||||
dataIn2.put("Details", details);
|
||||
dataIn.put("Data", dataIn2);
|
||||
data.put("data", dataIn);
|
||||
jsonObject.put("data", data);
|
||||
jsonObject.put("data", dataIn);
|
||||
log.error("生产BOW推送锐制请求报文:" + jsonObject.toJSONString());
|
||||
String result = ThirdPartyPostRequestUtil.sendPostRequest(rzwmsip, jsonObject.toJSONString());
|
||||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,263 @@
|
|||
package nc.bs.mmpac.pmo.pac0002.bp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterApprovingSynchronizeRuleRZ;
|
||||
import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOATPUpdateRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOAdjustReserveRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOBatchCodeEditRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOBatchCodeEditSynPickmRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOCffileidInserAndUpdatetRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOCreateVersionRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOMarkWrSNWhenUpdateRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOProcedureSortRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOSyncSNWhenItemDeleteRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOSyncSNWhenUpdateRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOUpdatePickmRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.PMOUpdateSaveApproveRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckApproveOperTypeRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDateLogicRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDispatchNumRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckOutputNumRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPlanDateTimeRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPlanPutNumRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPlanPutNumberRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProcedureDateLogicRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProcedureDupRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProcedureNotNullRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProdurepointRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPutNumRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckSNNumAndUnitRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckSaveNotNullRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckSnBindRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOProcedureChkPntRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOProcedurePutCheckRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMORwkProcCheckRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.check.PMORwkProcOperTypeRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillBatchCodeRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillInsertPlanTimeByProcedureRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillSNPkAndCodeRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.grand.PMOIsCreatPlanOutputRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.grand.PMORecalProcedureRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4INVP;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4MPS;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4PMO;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4PSCRecive;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4PSM;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4Renovate;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4SFC;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4SO;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteUpdateNum4TO;
|
||||
import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule;
|
||||
import nc.bs.pubapp.pub.rule.BillCodeCheckRule;
|
||||
import nc.impl.pubapp.pattern.rule.ICompareRule;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
|
||||
import nc.util.mmf.framework.base.MMArrayUtil;
|
||||
import nc.util.mmf.framework.gc.GCUpdateBPTemplate;
|
||||
import nc.vo.mmpac.pmo.pac0002.constant.PMOConst;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.util.PmoSagaUtil;
|
||||
import nc.vo.pub.VOStatus;
|
||||
|
||||
/**
|
||||
* 订单变更业务处理<br>
|
||||
*
|
||||
* @since 6.31
|
||||
* @version 2013-6-18 上午11:33:58
|
||||
* @author wanghjd
|
||||
*/
|
||||
public class PMOAdjustBP {
|
||||
|
||||
public PMOAggVO[] adjust(PMOAggVO[] fullBills, PMOAggVO[] originBills) {
|
||||
if (MMArrayUtil.isEmpty(fullBills)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (PMOAggVO vo : fullBills) {
|
||||
if (vo.getParent().getStatus() != VOStatus.UPDATED) {
|
||||
vo.getParent().setStatus(VOStatus.UPDATED);
|
||||
}
|
||||
}
|
||||
// sagas冻结并开启saga
|
||||
PmoSagaUtil.frozenAndAddSaga(fullBills);
|
||||
// 调用修改模板
|
||||
GCUpdateBPTemplate<PMOAggVO> bp = new GCUpdateBPTemplate<PMOAggVO>(PMOPluginPoint.ADJUST);
|
||||
// 执行前规则
|
||||
this.addBeforeRule(bp.getAroundProcesser());
|
||||
// 执行后规则
|
||||
this.addAfterRule(bp.getAroundProcesser());
|
||||
PMOAggVO[] rets = bp.update(fullBills, originBills);
|
||||
// 修改保存补偿
|
||||
PmoSagaUtil.compensate4Update(rets.clone(), originBills);
|
||||
return rets;
|
||||
}
|
||||
|
||||
private void addBeforeRule(CompareAroundProcesser<PMOAggVO> processer) {
|
||||
// 校验冻结状态 added by fengjinga
|
||||
IRule<PMOAggVO> checkFrozenRule = new MMVOSagaFrozenValidateRule<PMOAggVO>(false);
|
||||
processer.addBeforeRule(checkFrozenRule);
|
||||
// 校验单据号唯一性
|
||||
IRule<PMOAggVO> checkUniqueRule = new BillCodeCheckRule(PMOConst.PMO_BILLTYPE, PMOHeadVO.VBILLCODE,
|
||||
PMOHeadVO.PK_GROUP, PMOHeadVO.PK_ORG);
|
||||
// 把工序按工序号排序
|
||||
processer.addBeforeRule(new PMOProcedureSortRule());
|
||||
// 表头的交易类型,表体的物料、数量、计划投入数量不能为空
|
||||
IRule<PMOAggVO> checNullRule = new PMOCheckSaveNotNullRule(false);
|
||||
processer.addBeforeRule(checNullRule);
|
||||
// (变更专用)计划开工时间和计划完工时间可空,但是不能同时为空
|
||||
IRule<PMOAggVO> daterule = new PMOCheckPlanDateTimeRule();
|
||||
processer.addBeforeRule(daterule);
|
||||
// (变更专用)工序计划联动规则;
|
||||
ICompareRule<PMOAggVO> recalproc = new PMORecalProcedureRule();
|
||||
processer.addBeforeRule(recalproc);
|
||||
// (变更专用)验证修改计划投入数量后,需满足大于等于已完工数量
|
||||
IRule<PMOAggVO> checkPutNumRule = new PMOCheckPutNumRule();
|
||||
processer.addBeforeRule(checkPutNumRule);
|
||||
// (变更专用)计划产出数量不可小于订单的被预留数量
|
||||
IRule<PMOAggVO> checkOutputNumRule = new PMOCheckOutputNumRule();
|
||||
processer.addBeforeRule(checkOutputNumRule);
|
||||
// (变更专用)校验订单的计划投入数量不能小于该订单对应的所有投放计划的计划投放数量之和
|
||||
IRule<PMOAggVO> checkPlanPutNumRule = new PMOCheckPlanPutNumRule();
|
||||
processer.addBeforeRule(checkPlanPutNumRule);
|
||||
// (变更专用)当计划投入数量改小时,需保证不能小于max(订单各‘正常’类型工序的累计派工数量)
|
||||
IRule<PMOAggVO> checkDispatchNumRule = new PMOCheckDispatchNumRule();
|
||||
processer.addBeforeRule(checkDispatchNumRule);
|
||||
// (变更和修改共用)返工工序不可修改,并且最后一道返工工序必须是报告点;
|
||||
ICompareRule<PMOAggVO> procCheck = new PMORwkProcCheckRule();
|
||||
processer.addBeforeRule(procCheck);
|
||||
// 工序计划编辑性校验(有工序完工报告的工序及其之前的工序不可修改删除,也不可在其中插入工序)
|
||||
ICompareRule<PMOAggVO> putCheckRule = new PMOProcedurePutCheckRule();
|
||||
processer.addBeforeRule(putCheckRule);
|
||||
// 根据工序计划更新产品行计划完工时间
|
||||
IRule<PMOAggVO> filltimeprocedurerule = new PMOFillInsertPlanTimeByProcedureRule();
|
||||
processer.addBeforeRule(filltimeprocedurerule);
|
||||
// 日期是否符合自然逻辑顺序
|
||||
IRule<PMOAggVO> timeRule = new PMOCheckDateLogicRule();
|
||||
processer.addBeforeRule(timeRule);
|
||||
// 工序计划时间先后校验
|
||||
IRule<PMOAggVO> procdatelogicrule = new PMOCheckProcedureDateLogicRule(false);
|
||||
processer.addBeforeRule(procdatelogicrule);
|
||||
// 工序计划工序号重复校验
|
||||
IRule<PMOAggVO> proccoderule = new PMOCheckProcedureDupRule();
|
||||
processer.addBeforeRule(proccoderule);
|
||||
// 当计划投入数量改小时,需保证不能小于Max(生产订单工序计划中返工工序为‘否’的所有工序的累计完工数量【累计完工数量:工序对应的所有完工报告中该工序的完工数量】)
|
||||
IRule<PMOAggVO> planputNumberRule = new PMOCheckPlanPutNumberRule();
|
||||
processer.addBeforeRule(planputNumberRule);
|
||||
|
||||
// (变更和修改共用)最后一条返工工序的工序转移方式不能为‘不转移’;
|
||||
IRule<PMOAggVO> rwkProcOperType = new PMORwkProcOperTypeRule();
|
||||
processer.addBeforeRule(rwkProcOperType);
|
||||
// 校验检测点必须是报告点,且转移方式不能为‘自动转移’
|
||||
IRule<PMOAggVO> chkPntRule = new PMOProcedureChkPntRule();
|
||||
processer.addBeforeRule(chkPntRule);
|
||||
// 增加工序计划必须有一个报告点 add lijjl
|
||||
processer.addBeforeRule(new PMOCheckProdurepointRule());
|
||||
// 非工序返工补单的保存校验,最后报告点的工序的工序转移方式必须为非转移
|
||||
IRule<PMOAggVO> operTypeRule = new PMOCheckApproveOperTypeRule();
|
||||
processer.addBeforeRule(operTypeRule);
|
||||
// 校验工序管理物料,工序计划不能为空
|
||||
IRule<PMOAggVO> approvecheckrule = new PMOCheckProcedureNotNullRule();
|
||||
processer.addBeforeRule(approvecheckrule);
|
||||
// 预计产出规则;
|
||||
ICompareRule<PMOAggVO> createOutput = new PMOIsCreatPlanOutputRule();
|
||||
processer.addBeforeRule(createOutput);
|
||||
|
||||
// 批次号修改同步备料计划规则
|
||||
ICompareRule<PMOAggVO> batchcodeRule = new PMOBatchCodeEditSynPickmRule();
|
||||
processer.addBeforeRule(batchcodeRule);
|
||||
// 批次号修改同步批次档案规则
|
||||
ICompareRule<PMOAggVO> batchcodedocRule = new PMOBatchCodeEditRule();
|
||||
processer.addBeforeRule(batchcodedocRule);
|
||||
// 生成生产批次号
|
||||
IRule<PMOAggVO> fillbatchcodeRule = new PMOFillBatchCodeRule();
|
||||
processer.addBeforeRule(fillbatchcodeRule);
|
||||
// v636 序列号批次关联的不允许进行删除
|
||||
IRule<PMOAggVO> snBindRule = new PMOCheckSnBindRule();
|
||||
processer.addBeforeRule(snBindRule);
|
||||
// 更新前库存可用量规则
|
||||
IRule<PMOAggVO> checkATPUpdateRule = new PMOATPUpdateRule(true, PMOConst.PMO_BILLTYPE);
|
||||
processer.addBeforeRule(checkATPUpdateRule);
|
||||
// 回写生产报告数量
|
||||
ICompareRule<PMOAggVO> rewritewr = new RewriteUpdateNum4Renovate();
|
||||
processer.addBeforeRule(rewritewr);
|
||||
// 回写销售订单的累计补货数量
|
||||
ICompareRule<PMOAggVO> rewriteso = new RewriteUpdateNum4SO();
|
||||
processer.addBeforeRule(rewriteso);
|
||||
// 回写计划订单的排产数量
|
||||
ICompareRule<PMOAggVO> rewritepsm = new RewriteUpdateNum4PSM();
|
||||
processer.addBeforeRule(rewritepsm);
|
||||
// 回写主生产计划订单的已排产数量(根据订单类型)
|
||||
ICompareRule<PMOAggVO> rewritepo = new RewriteUpdateNum4MPS();
|
||||
processer.addBeforeRule(rewritepo);
|
||||
// 回写库存计划订单的已排产数量(根据订单类型)
|
||||
ICompareRule<PMOAggVO> rewriteinvp = new RewriteUpdateNum4INVP();
|
||||
processer.addBeforeRule(rewriteinvp);
|
||||
// 回写调拨订单的已排产数量(根据订单类型)
|
||||
ICompareRule<PMOAggVO> rewriteto = new RewriteUpdateNum4TO();
|
||||
processer.addBeforeRule(rewriteto);
|
||||
// 车间管理的工序完工会写返工数量
|
||||
ICompareRule<PMOAggVO> rewritesfc = new RewriteUpdateNum4SFC();
|
||||
processer.addBeforeRule(rewritesfc);
|
||||
// (变更专用)变更操作,生成新版本
|
||||
ICompareRule<PMOAggVO> verAutoUpRule = new PMOCreateVersionRule();
|
||||
processer.addBeforeRule(verAutoUpRule);
|
||||
|
||||
// 调用库存接口,注册预留供给单据行数据
|
||||
ICompareRule<PMOAggVO> adjustReserveRule = new PMOAdjustReserveRule();
|
||||
processer.addBeforeRule(adjustReserveRule);
|
||||
|
||||
// V65 回写收货单返工处理数量
|
||||
ICompareRule<PMOAggVO> rewritePSCrecive = new RewriteUpdateNum4PSCRecive();
|
||||
processer.addBeforeRule(rewritePSCrecive);
|
||||
// V65回写Wr返工订单的序列号使用标志
|
||||
IRule<PMOAggVO> wrMarkRule = new PMOMarkWrSNWhenUpdateRule();
|
||||
processer.addBeforeRule(wrMarkRule);
|
||||
// 65 特征码新增修改保存
|
||||
PMOCffileidInserAndUpdatetRule cffileidRule = new PMOCffileidInserAndUpdatetRule();
|
||||
processer.addBeforeRule(cffileidRule);
|
||||
// V65 检查数量与单位
|
||||
IRule<PMOAggVO> snCheckRule = new PMOCheckSNNumAndUnitRule();
|
||||
processer.addBeforeRule(snCheckRule);
|
||||
// 65 补充pk
|
||||
IRule<PMOAggVO> snRule = new PMOFillSNPkAndCodeRule();
|
||||
processer.addBeforeRule(snRule);
|
||||
// V65
|
||||
IRule<PMOAggVO> itemDeletesnRule = new PMOSyncSNWhenItemDeleteRule();
|
||||
processer.addBeforeRule(itemDeletesnRule);
|
||||
// V65
|
||||
ICompareRule<PMOAggVO> snSyncRule = new PMOSyncSNWhenUpdateRule();
|
||||
processer.addBeforeRule(snSyncRule);
|
||||
|
||||
}
|
||||
|
||||
private void addAfterRule(CompareAroundProcesser<PMOAggVO> processer) {
|
||||
// 回写返工的原始生产订单(根据来源订单表体id)
|
||||
ICompareRule<PMOAggVO> pmoBills = new RewriteUpdateNum4PMO();
|
||||
processer.addAfterRule(pmoBills);
|
||||
// (变更和修改通用)更新备料计划规则
|
||||
ICompareRule<PMOAggVO> pickmUpdateRule = new PMOUpdatePickmRule(this.checkInfoList);
|
||||
processer.addAfterRule(pickmUpdateRule);
|
||||
// 更新后库存可用量规则
|
||||
IRule<PMOAggVO> atpUpdateRule = new PMOATPUpdateRule(false, PMOConst.PMO_BILLTYPE);
|
||||
processer.addAfterRule(atpUpdateRule);
|
||||
// 修改保存即审核 added by fengjinga
|
||||
IRule<PMOAggVO> saveapproverule = new PMOUpdateSaveApproveRule();
|
||||
processer.addAfterRule(saveapproverule);
|
||||
|
||||
//变更推送生产订单至锐制MES
|
||||
IRule<PMOAggVO> pushRZRule = new AfterApprovingSynchronizeRuleRZ(Boolean.FALSE);
|
||||
processer.addAfterFinalRule(pushRZRule);
|
||||
}
|
||||
|
||||
// 挪退料建议
|
||||
private List<String> checkInfoList = new ArrayList<String>();
|
||||
|
||||
public List<String> getCheckInfoList() {
|
||||
return this.checkInfoList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ public class PMOApproveBP {
|
|||
ICompareRule<PMOAggVO> auditSupplyRule = new PMOApproveAuditSupplyRule();
|
||||
processer.addAfterRule(auditSupplyRule);
|
||||
// 审批后推送到RZ系统
|
||||
processer.addAfterRule(new AfterApprovingSynchronizeRuleRZ());
|
||||
processer.addAfterRule(new AfterApprovingSynchronizeRuleRZ(true));
|
||||
// 审批后推送流程生产订单到MES
|
||||
processer.addAfterRule(new AfterApproveRuleSyncMes());
|
||||
|
||||
|
|
|
|||
|
|
@ -43,13 +43,14 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
|
|||
|
||||
private static final String MES_PMO_SYNC_URL = "/GTHINKING/AjaxService/N_SCSJJSA/102525006.ashx/receive_woinfo_insert";
|
||||
|
||||
private static final String PK_VIOLATION_ERROR_SUBSTRING = "违反了 PRIMARY KEY 约束“PK_WO”";
|
||||
|
||||
@Override
|
||||
public void process(PMOAggVO[] pmoAggVOS) {
|
||||
if (ArrayUtil.isEmpty(pmoAggVOS)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 检查并筛选生产订单
|
||||
List<PMOAggVO> filteredOrders = checkAndFilterBillSrcOrg(pmoAggVOS);
|
||||
if (filteredOrders.isEmpty()) {
|
||||
obmlog.info("没有符合条件的生产订单需要同步到MES系统。");
|
||||
|
|
@ -68,17 +69,100 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
|
|||
}
|
||||
|
||||
for (PMOItemVO item : bodys) {
|
||||
syncOrderItemToMes(head, item);
|
||||
obmlog.debug("处理生产订单行 " + item.getVrowno());
|
||||
obmlog.debug(item);
|
||||
if (item.getVparentbillid() == null || item.getVparentbillid().equals("~")) {
|
||||
syncOrderItemToMes(head, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
obmlog.info("生产订单同步到MES系统处理完成。");
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
obmlog.error("同步生产订单到MES系统失败: " + e.getMessage(), e);
|
||||
ExceptionUtils.wrappException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用MES接口并处理特定错误(如主键冲突)
|
||||
*
|
||||
* @param apiPath MES接口路径
|
||||
* @param requestPayload 请求体
|
||||
* @param orderNo 订单号 (用于日志)
|
||||
* @param itemRow 行号 (用于日志)
|
||||
* @throws BusinessException 如果发生非特定可忽略的错误
|
||||
*/
|
||||
private void callMesWithCustomErrorHandling(String apiPath, JSONObject requestPayload, String orderNo, String itemRow) throws BusinessException {
|
||||
String responseString = null;
|
||||
try {
|
||||
responseString = HTTP_POST_OTHER_SYS.callMes(apiPath, requestPayload);
|
||||
obmlog.info("生产订单 " + orderNo + " 行 " + itemRow + " MES系统原始返回: " + responseString);
|
||||
|
||||
if (responseString == null || responseString.trim().isEmpty()) {
|
||||
obmlog.warn("生产订单 " + orderNo + " 行 " + itemRow + " MES系统返回为空。");
|
||||
// 根据业务需求,空响应可能也算一种错误
|
||||
// throw new BusinessException("MES系统返回为空。");
|
||||
return; // 或者认为空响应不是致命错误,继续执行
|
||||
}
|
||||
|
||||
JSONObject jsonResponse = JSONObject.parseObject(responseString);
|
||||
|
||||
// 检查是否存在 "Data" 数组
|
||||
if (jsonResponse.containsKey("Data") && jsonResponse.get("Data") instanceof JSONArray) {
|
||||
JSONArray dataArray = jsonResponse.getJSONArray("Data");
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JSONObject dataObject = dataArray.getJSONObject(i);
|
||||
String successInData = dataObject.getString("Success");
|
||||
if ("false".equalsIgnoreCase(successInData)) {
|
||||
String errorMessage = dataObject.getString("ErrorMessage");
|
||||
if (StringUtils.isEmpty(errorMessage)) {
|
||||
errorMessage = dataObject.getString("Message");
|
||||
}
|
||||
if (StringUtils.isEmpty(errorMessage)) {
|
||||
errorMessage = "外部系统在Data数组中未提供明确错误消息,但Success为false。";
|
||||
}
|
||||
|
||||
if (errorMessage.contains(PK_VIOLATION_ERROR_SUBSTRING)) {
|
||||
obmlog.warn("生产订单 " + orderNo + " 行 " + itemRow + " MES返回主键冲突错误(Item " + i + "),视为可忽略: " + errorMessage);
|
||||
// 特定错误,记录并继续
|
||||
} else {
|
||||
throw new BusinessException("同步MES系统失败 (Item " + i + "), 错误消息:" + errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 处理顶层Success字段
|
||||
String success = jsonResponse.getString("Success");
|
||||
if ("false".equalsIgnoreCase(success)) {
|
||||
String errorMessage = jsonResponse.getString("ErrorMessage");
|
||||
if (StringUtils.isEmpty(errorMessage)) {
|
||||
errorMessage = jsonResponse.getString("Message");
|
||||
}
|
||||
if (StringUtils.isEmpty(errorMessage)) {
|
||||
errorMessage = "外部系统未提供明确错误消息,但顶层Success为false。";
|
||||
}
|
||||
|
||||
if (errorMessage.contains(PK_VIOLATION_ERROR_SUBSTRING)) {
|
||||
obmlog.warn("生产订单 " + orderNo + " 行 " + itemRow + " MES返回主键冲突错误,视为可忽略: " + errorMessage);
|
||||
// 特定错误,记录并继续
|
||||
} else {
|
||||
throw new BusinessException("同步MES系统失败, 错误消息:" + errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果所有检查通过或特定错误被忽略,则方法正常结束
|
||||
} catch (BusinessException e) {
|
||||
// 直接抛出已捕获的业务异常
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
// 捕获调用callMes或JSON解析等其他异常
|
||||
obmlog.error("生产订单 " + orderNo + " 行 " + itemRow + " 调用MES或处理响应时发生错误。原始响应: " + responseString + " 错误: " + e.getMessage(), e);
|
||||
throw new BusinessException("调用MES或处理响应时发生错误:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查并筛选需要同步的单据
|
||||
*/
|
||||
|
|
@ -87,6 +171,14 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
|
|||
for (PMOAggVO aggvo : pmoAggVOS) {
|
||||
String pkOrg = aggvo.getParentVO().getPk_org();
|
||||
String orgCode = transferCodeByPk(FactoryVO.getDefaultTableName(), FactoryVO.CODE, FactoryVO.PK_FACTORY, pkOrg);
|
||||
// // 防止mes传bip,bip再推送给mes
|
||||
// String billmaker = aggvo.getParentVO().getBillmaker();
|
||||
// String userCode = transferCodeByPk("sm_user", UserVO.USER_CODE, UserVO.CUSERID, billmaker);
|
||||
//
|
||||
// if ("C034".equals(orgCode)&&(!"gaoning".equals(userCode))) {
|
||||
// aggvoList.add(aggvo);
|
||||
// }
|
||||
|
||||
if ("C034".equals(orgCode)) {
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
|
|
@ -214,9 +306,15 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
|
|||
JSONObject SXZF16 = new JSONObject();
|
||||
JSONObject SXZF17 = new JSONObject();
|
||||
JSONObject SXZF18 = new JSONObject();
|
||||
SXZF16.put("propertyFiled", item.getVparentbillcode());
|
||||
SXZF17.put("propertyFiled", item.getVparentmorowno());
|
||||
SXZF18.put("propertyFiled", head.getVtrantypecode());
|
||||
|
||||
SXZF16.put("propertyFiled", "SXZF16");
|
||||
SXZF17.put("propertyFiled", "SXZF17");
|
||||
SXZF18.put("propertyFiled", "SXZF18");
|
||||
|
||||
SXZF16.put("propertyValue", item.getVparentbillcode());
|
||||
SXZF17.put("propertyValue", item.getVparentmorowno());
|
||||
SXZF18.put("propertyValue", head.getVtrantypecode());
|
||||
|
||||
properties.add(SXZF16);
|
||||
properties.add(SXZF17);
|
||||
properties.add(SXZF18);
|
||||
|
|
@ -230,12 +328,13 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
|
|||
|
||||
obmlog.info("生产订单 " + vbillcode + " 行 " + itemRow + " 同步MES请求数据: " + requestPayload.toJSONString());
|
||||
|
||||
// Send to MES
|
||||
// Note: The actual endpoint URL might need to be configured or obtained from a central place.
|
||||
HTTP_POST_OTHER_SYS.sendToExternalSystem(MES_PMO_SYNC_URL, requestPayload);
|
||||
obmlog.info("生产订单 " + vbillcode + " 行 " + itemRow + " 已成功发送到MES系统。");
|
||||
// Send to MES using custom error handling
|
||||
callMesWithCustomErrorHandling(MES_PMO_SYNC_URL, requestPayload, vbillcode, itemRow);
|
||||
|
||||
obmlog.info("生产订单 " + vbillcode + " 行 " + itemRow + " 已成功发送到MES系统或特定错误已被记录。");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键查询编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,12 +2,17 @@ package nc.bs.mmpac.pmo.pac0002.bp.rule;
|
|||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yonyou.iuap.bd.defdoc.dto.DefDoc;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.service.PMOBPService;
|
||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.pubitf.para.SysInitQuery;
|
||||
import nc.util.mmf.framework.base.MMMapUtil;
|
||||
import nc.util.mmf.framework.base.MMValueCheck;
|
||||
import nc.vo.bd.defdoc.DefdocVO;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.bd.stordoc.StordocVO;
|
||||
import nc.vo.cmp.util.StringUtils;
|
||||
|
|
@ -17,13 +22,16 @@ import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
|||
import nc.vo.org.DeptVO;
|
||||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFBoolean;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
||||
import nc.vo.rum.stocks.StocksVO;
|
||||
import nc.vo.scmpub.util.ArrayUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程生产订单审批后推送RZ
|
||||
|
|
@ -32,6 +40,12 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<PMOAggVO> {
|
|||
private static final Log log = Log.getInstance("rzmomlog");
|
||||
private static final BaseDAO dao = new BaseDAO();
|
||||
|
||||
private Boolean flag;
|
||||
|
||||
public AfterApprovingSynchronizeRuleRZ(Boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(PMOAggVO[] pmoAggVOS) {
|
||||
if (ArrayUtil.isEmpty(pmoAggVOS)) {
|
||||
|
|
@ -57,13 +71,35 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<PMOAggVO> {
|
|||
*/
|
||||
private List<PMOAggVO> checkAndFilterBillSrcOrg(PMOAggVO[] pmoAggVOS) throws BusinessException {
|
||||
List<PMOAggVO> aggvoList = new ArrayList<>();
|
||||
List<String> tranidList = new ArrayList<String>();
|
||||
for (PMOAggVO aggvo : pmoAggVOS) {
|
||||
PMOHeadVO headvo = aggvo.getParentVO();
|
||||
String tranid = headvo.getCtrantypeid();
|
||||
if (!MMValueCheck.isEmpty(tranid)) {
|
||||
tranidList.add(tranid);
|
||||
}
|
||||
}
|
||||
Map<String, UFBoolean> bSaveApproveMap =new HashMap<>();
|
||||
if (tranidList.size() > 0) {
|
||||
bSaveApproveMap = PMOBPService.getIPMOTransTypeQueryService()
|
||||
.getBSaveApproveByTranTypeIDs(tranidList.toArray(new String[0]));
|
||||
|
||||
}
|
||||
for (PMOAggVO aggvo : pmoAggVOS) {
|
||||
String pkOrg = aggvo.getParentVO().getPk_org();
|
||||
Integer fbillstatus = aggvo.getParentVO().getFbillstatus();
|
||||
String tranid = aggvo.getParentVO().getCtrantypeid();
|
||||
String orgCode = transferCodeByPk(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||
if ("C022".equals(orgCode) && 1 == fbillstatus&&aggvo.getChildrenVO()!=null && aggvo.getChildrenVO().length>0) {
|
||||
aggvoList.add(aggvo);
|
||||
if(this.flag){
|
||||
if ("C022".equals(orgCode) && 1 == fbillstatus&&aggvo.getChildrenVO()!=null && aggvo.getChildrenVO().length>0) {
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
}else{
|
||||
if ("C022".equals(orgCode)&& 1 == fbillstatus&&aggvo.getChildrenVO()!=null && aggvo.getChildrenVO().length > 0 && !bSaveApproveMap.isEmpty()&&!bSaveApproveMap.getOrDefault(tranid, UFBoolean.FALSE).booleanValue()) {
|
||||
aggvoList.add(aggvo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return aggvoList;
|
||||
}
|
||||
|
|
@ -159,6 +195,7 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<PMOAggVO> {
|
|||
// 工作中心 生产部门ID
|
||||
// detailItem.put("scgc_wbid", transferCodeByPk(DeptVO.getDefaultTableName(), DeptVO.CODE, DeptVO.PK_DEPT, body.getCdeptid()));
|
||||
detailItem.put("scgc_wbid", body.getCdeptid());
|
||||
detailItem.put("cjbz_wbid", body.getCdeptid());
|
||||
|
||||
// 备注说明
|
||||
detailItem.put("bzsm", body.getVnote());
|
||||
|
|
@ -168,7 +205,8 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<PMOAggVO> {
|
|||
detailItem.put("jhbhzdsc", 0);
|
||||
|
||||
// 项目编号
|
||||
detailItem.put("wlzdycs06", body.getVdef1());
|
||||
detailItem.put("wlzdycs06", transferCodeByPk("bd_defdoc", DefdocVO.CODE, DefdocVO.PK_DEFDOC, body.getVdef1()));
|
||||
// detailItem.put("wlzdycs06", body.getVdef1());
|
||||
details.add(detailItem);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,111 +1,141 @@
|
|||
package nc.bs.mmpac.pmo.pac0002.bp.rule;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.trade.business.HYSuperDMO;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.uap.IUAPQueryBS;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import nc.vo.bd.defdoc.DefdocVO;
|
||||
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.pub.BusinessException;
|
||||
import nc.vo.so.m30.entity.SaleOrderBVO;
|
||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程生成订单保存时验证销售订单累计排产状态,并验收首付款比例 zhangxinah 适配2312
|
||||
*/
|
||||
public class saveBeforeCheckRule implements IRule<PMOAggVO> {
|
||||
|
||||
@Override
|
||||
public void process(PMOAggVO[] vos) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
List<SaleOrderBVO> list = new ArrayList<SaleOrderBVO>();
|
||||
for (PMOAggVO vo : vos) {
|
||||
// 判断是否是需要控制的业务单元
|
||||
PMOHeadVO pmoHeadVO = vo.getParentVO();
|
||||
String pkstockorgStr = getPk_stockorg(pmoHeadVO.getPk_org());
|
||||
if (pkstockorgStr == null || pkstockorgStr.equals("")) {
|
||||
return;
|
||||
}
|
||||
PMOItemVO[] iSuperVOs = vo.getChildrenVO();
|
||||
for (int i = 0; i < iSuperVOs.length; i++) {
|
||||
PMOItemVO itemvo = iSuperVOs[i];
|
||||
// 判断是否类型是否为30
|
||||
if (itemvo.getVsrctype() == null || !itemvo.getVsrctype().equals("30")) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void process(PMOAggVO[] vos) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
List<SaleOrderBVO> list = new ArrayList<SaleOrderBVO>();
|
||||
for (PMOAggVO vo : vos) {
|
||||
// 判断是否是需要控制的业务单元
|
||||
PMOHeadVO pmoHeadVO = vo.getParentVO();
|
||||
String pkstockorgStr = getPk_stockorg(pmoHeadVO.getPk_org());
|
||||
if (pkstockorgStr == null || pkstockorgStr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
PMOItemVO[] iSuperVOs = vo.getChildrenVO();
|
||||
for (int i = 0; i < iSuperVOs.length; i++) {
|
||||
PMOItemVO itemvo = iSuperVOs[i];
|
||||
// 判断是否类型是否为30
|
||||
if (itemvo.getVsrctype() == null || !itemvo.getVsrctype().equals("30")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Object> valMap = getVbdef6(itemvo.getVsrcbid());
|
||||
if (valMap == null || valMap.isEmpty()) {
|
||||
throw new BusinessException("无法关联到销售订单,无法保存!");
|
||||
}
|
||||
// 销售发票表头pk_billtypecode=30-Cxx-12
|
||||
if (valMap.get("pk_billtypecode").equals("30-Cxx-12")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-02")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-08")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-13")) {
|
||||
return;
|
||||
}
|
||||
// 历史数据不考虑
|
||||
String storedDateStr = (String) valMap.get("creationtime");
|
||||
String targetDateStr = "2024-12-27 00:00:00";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter);
|
||||
LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter);
|
||||
if (storedDate.isBefore(targetDate)) {
|
||||
return;
|
||||
}
|
||||
if (valMap.get("vbdef12") == null) {
|
||||
throw new BusinessException("生产订单明细" + (i + 1) + ",累计排产申请数量为0,无法保存!");
|
||||
} else {
|
||||
try {
|
||||
double sQty = Double.parseDouble((String) valMap.get("vbdef12"));// 累计排产申请数量
|
||||
Object ntotaloutnumsObj = valMap.get("nastnum");
|
||||
String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : "";
|
||||
double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计生产数量
|
||||
double bdnum = itemvo.getNastnum().getDouble();
|
||||
if (sQty < (ntotaloutnum + bdnum)) {
|
||||
throw new BusinessException("生产订单明细" + (i + 1) + ",累计生产数量'" + (ntotaloutnum + bdnum)
|
||||
+ "'大于销售订单累计排产申请数量'" + sQty + "',无法保存!");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new BusinessException("累计排产申请数量转化数值失败" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
Map<String, Object> valMap = getVbdef6(itemvo.getVsrcbid());
|
||||
if (valMap == null || valMap.isEmpty()) {
|
||||
throw new BusinessException("无法关联到销售订单,无法保存!");
|
||||
}
|
||||
// 销售发票表头pk_billtypecode=30-Cxx-12
|
||||
if (valMap.get("pk_billtypecode").equals("30-Cxx-12")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-02")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-08")
|
||||
|| valMap.get("pk_billtypecode").equals("30-Cxx-13")) {
|
||||
return;
|
||||
}
|
||||
// 历史数据不考虑
|
||||
String storedDateStr = (String) valMap.get("creationtime");
|
||||
String targetDateStr = "2024-12-27 00:00:00";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter);
|
||||
LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter);
|
||||
if (storedDate.isBefore(targetDate)) {
|
||||
return;
|
||||
}
|
||||
if (valMap.get("vbdef12") == null) {
|
||||
throw new BusinessException("生产订单明细" + (i + 1) + ",累计排产申请数量为0,无法保存!");
|
||||
} else {
|
||||
try {
|
||||
double sQty = Double.parseDouble((String) valMap.get("vbdef12"));// 累计排产申请数量
|
||||
Object ntotaloutnumsObj = valMap.get("nastnum");
|
||||
String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : "";
|
||||
double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计生产数量
|
||||
double bdnum = itemvo.getNastnum().getDouble();
|
||||
if (sQty < (ntotaloutnum + bdnum)) {
|
||||
throw new BusinessException("生产订单明细" + (i + 1) + ",累计生产数量'" + (ntotaloutnum + bdnum)
|
||||
+ "'大于销售订单累计排产申请数量'" + sQty + "',无法保存!");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new BusinessException("累计排产申请数量转化数值失败" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> getVbdef6(String vsrcbidStr) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " SELECT bt.pk_billtypecode,s.creationtime,b.vbdef12,d.nastnum FROM so_saleorder_b b\n"
|
||||
+ "INNER JOIN so_saleorder s ON s.csaleorderid = b.csaleorderid\n"
|
||||
+ "left join (select mm_mo.Vsrcbid,sum(nastnum) as nastnum \n" + "from mm_mo\n" + "where mm_mo.dr=0\n"
|
||||
+ "group by mm_mo.Vsrcbid) d on b.csaleorderbid=d.Vsrcbid\n"
|
||||
+ "INNER JOIN bd_billtype bt on bt.pk_billtypeid=s.ctrantypeid\n" + "where b.csaleorderbid='"
|
||||
+ vsrcbidStr + "' ";
|
||||
Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
return valList;
|
||||
}
|
||||
private Map<String, Object> getVbdef6(String vsrcbidStr) throws BusinessException {
|
||||
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
String sql = " SELECT bt.pk_billtypecode,s.creationtime,b.vbdef12,d.nastnum FROM so_saleorder_b b\n"
|
||||
+ "INNER JOIN so_saleorder s ON s.csaleorderid = b.csaleorderid\n"
|
||||
+ "left join (select mm_mo.Vsrcbid,sum(nastnum) as nastnum \n" + "from mm_mo\n" + "where mm_mo.dr=0\n"
|
||||
+ "group by mm_mo.Vsrcbid) d on b.csaleorderbid=d.Vsrcbid\n"
|
||||
+ "INNER JOIN bd_billtype bt on bt.pk_billtypeid=s.ctrantypeid\n" + "where b.csaleorderbid='"
|
||||
+ vsrcbidStr + "' ";
|
||||
Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
|
||||
return valList;
|
||||
}
|
||||
|
||||
private String getPk_stockorg(String pk_stockorg) throws BusinessException {
|
||||
String sql = " select pk_stockorg from org_stockorg where code in ('C018','C029','C033','C039','C020','C019') and pk_stockorg='"
|
||||
+ pk_stockorg + "' ";
|
||||
String saleorderPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor());
|
||||
return saleorderPK;
|
||||
}
|
||||
private String getPk_stockorg(String pk_stockorg) throws BusinessException {
|
||||
Map<String, String> defMap = checkOrgCtrl();
|
||||
if (defMap.isEmpty() || "".equals(defMap.getOrDefault("pmo", ""))) {
|
||||
return "";
|
||||
}
|
||||
String orgStr = defMap.getOrDefault("pmo", "");
|
||||
// 将数组转换为字符串,并添加单引号
|
||||
String newOrgStr = orgStr.replace(",", "','");
|
||||
String sql = " select pk_stockorg from org_stockorg where code in ('" + newOrgStr + "') and pk_stockorg='"
|
||||
+ pk_stockorg + "' ";
|
||||
// NCCForUAPLogger.debug("pmo-getPk_stockorg-sql:" + sql);
|
||||
String saleorderPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor());
|
||||
return saleorderPK;
|
||||
}
|
||||
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
private Map<String, String> checkOrgCtrl() {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='org-ctrl' and dr=0 ) and dr=0";
|
||||
try {
|
||||
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
|
||||
if (defdocVOs != null && defdocVOs.length > 0) {
|
||||
for (DefdocVO defdocVO : defdocVOs) {
|
||||
map.put(defdocVO.getCode().trim(), defdocVO.getMemo());
|
||||
}
|
||||
}
|
||||
} catch (DAOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding='gb2312'?>
|
||||
<module displayname="mmpsc" name="mmpsc">
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package nc.bs.mmpsc.pscsettle.bp;
|
||||
|
||||
import nc.bs.mmpsc.pscsettle.plugin.SettlePluginPoint;
|
||||
import nc.bs.mmpsc.pscsettle.rule.SettleStatusCheckRule;
|
||||
import nc.bs.mmpsc.pscsettle.rule.SettleStatusUpdateRule;
|
||||
import nc.bs.mmpsc.pscsettle.rule.approve.FillAuditInfoRule;
|
||||
import nc.bs.mmpsc.pscsettle.rule.unapprove.FilterAdjustedRule;
|
||||
import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule;
|
||||
import nc.impl.pubapp.pattern.data.bill.template.UpdateBPTemplate;
|
||||
import nc.impl.pubapp.pattern.rule.IFilterRule;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
|
||||
import nc.vo.mmpsc.pscsettle.entity.AggSettleVO;
|
||||
import nc.vo.mmpsc.pscsettle.enumeration.SettleStatusEnum;
|
||||
|
||||
public class SettleApproveBP {
|
||||
public SettleApproveBP() {
|
||||
}
|
||||
|
||||
public AggSettleVO[] approve(AggSettleVO[] clientBills, AggSettleVO[] originBills) {
|
||||
UpdateBPTemplate<AggSettleVO> bp = new UpdateBPTemplate(SettlePluginPoint.APPROVE);
|
||||
this.addBeforeRule(bp.getAroundProcesser());
|
||||
this.addAfterRule(bp.getAroundProcesser(), originBills);
|
||||
return (AggSettleVO[])bp.update(clientBills, originBills);
|
||||
}
|
||||
|
||||
private void addAfterRule(CompareAroundProcesser<AggSettleVO> processer, AggSettleVO[] originBills) {
|
||||
}
|
||||
|
||||
private void addBeforeRule(CompareAroundProcesser<AggSettleVO> processer) {
|
||||
IRule<AggSettleVO> checkFrozenRule = new MMVOSagaFrozenValidateRule(true);
|
||||
processer.addBeforeRule(checkFrozenRule);
|
||||
IRule<AggSettleVO> crule = new SettleStatusCheckRule(SettleStatusEnum.FREE);
|
||||
processer.addBeforeRule(crule);
|
||||
IFilterRule<AggSettleVO> filterRule = new FilterAdjustedRule();
|
||||
processer.addBeforeRule(filterRule);
|
||||
IRule<AggSettleVO> rule = new SettleStatusUpdateRule(SettleStatusEnum.APPROVED);
|
||||
processer.addBeforeRule(rule);
|
||||
IRule<AggSettleVO> auditRule = new FillAuditInfoRule();
|
||||
processer.addBeforeRule(auditRule);
|
||||
}
|
||||
}
|
||||
|
|
@ -169,14 +169,6 @@ public class AfterApprovingSynchronizeRuleRZ implements IRule<OrderVO> {
|
|||
detailItem.put("jhrq", item.getDplanarrvdate().toString());
|
||||
}
|
||||
|
||||
// 设置来源单据信息
|
||||
//第三方系统采购计划id
|
||||
detailItem.put("cgjh_wbid", item.getVsourcetrantype());
|
||||
//采购计划编号
|
||||
detailItem.put("cgbh", item.getVsourcecode());
|
||||
//采购计划序号
|
||||
detailItem.put("cgxh", item.getVsourcerowno());
|
||||
|
||||
// 设置仓库和备注信息
|
||||
detailItem.put("sdck", item.getPk_reqstordoc());
|
||||
detailItem.put("bzsm", item.getVbmemo());
|
||||
|
|
|
|||
|
|
@ -320,24 +320,16 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
if (null == originVos || originVos.length == 0) {
|
||||
ExceptionUtils.wrappBusinessException("根据传入数据未匹配到相关数据");
|
||||
}
|
||||
|
||||
Map<String, String> delMap = new HashMap<>();
|
||||
for (Map<String, Object> objectMap : paramList) {
|
||||
Map<String, Object> headdata = (Map<String, Object>) objectMap.get(HEADTABLE);
|
||||
delMap.put(headdata.get("csaleorderid") + "", headdata.getOrDefault("delId", "") + "");
|
||||
List<Object> bodyArr = (List<Object>) objectMap.get(BODYTABLE);
|
||||
for (Object body : bodyArr) {
|
||||
Map<String, Object> bodydata = (Map<String, Object>) body;
|
||||
if (!(bodydata.getOrDefault("vbdef11", "") + "").isEmpty()) {
|
||||
String vbdef11 = bodydata.get("vbdef11") + "";
|
||||
String dr = bodydata.getOrDefault("dr", "0") + "";
|
||||
String csaleorderid = bodydata.get("csaleorderid") + "";
|
||||
String countSql = "SELECT count(1) FROM so_saleorder_b"
|
||||
+ " WHERE nvl(dr,0) = 0 and csaleorderid = '[csaleorderid]' and vbdef11 = '[vbdef11]' ";
|
||||
countSql = countSql.replace("[csaleorderid]", csaleorderid);
|
||||
countSql = countSql.replace("[vbdef11]", vbdef11);
|
||||
Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor());
|
||||
if ("0".equals(dr) && num <= 0) {
|
||||
bodydata.put("status", "add");
|
||||
}
|
||||
if ((bodydata.getOrDefault("vbdef11", "") + "").isEmpty()) {
|
||||
// 如果vbdef11为空则标记为新增行
|
||||
bodydata.put("status", "add");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -364,20 +356,21 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
SaleOrderVO bipVo = vosMap.get(primaryKey);
|
||||
// 设置单据状态
|
||||
hvo.setStatus(VOStatus.UPDATED);
|
||||
|
||||
Map<String, SaleOrderBVO> bvoMap = new HashMap<>();
|
||||
for (SaleOrderBVO saleOrderBVO : bipVo.getChildrenVO()) {
|
||||
bvoMap.put(saleOrderBVO.getCsaleorderbid(), saleOrderBVO);
|
||||
}
|
||||
String delId = delMap.get(primaryKey);
|
||||
|
||||
// 比较combinBillVOs中的BVO和vos中的BVO
|
||||
for (SaleOrderBVO bvo : vo.getChildrenVO()) {
|
||||
bvo.setStatus(VOStatus.UPDATED);
|
||||
// 设置删除的物料行的状态,在bip传的数据中找不到
|
||||
String csaleorderbid = bvo.getCsaleorderbid();
|
||||
if (bvoMap.get(csaleorderbid) == null) {
|
||||
bvo.setStatus(VOStatus.DELETED);
|
||||
NCCForUAPLogger.debug("findDeletedBids:" + VOStatus.DELETED + ",csaleorderbid = " + csaleorderbid);
|
||||
// 设置删除的物料行的状态,在bip传的数据中找不到
|
||||
if (StringUtils.isNotEmpty(delId)) {
|
||||
String[] delIds = delId.split(",", -1);
|
||||
String vbdef11 = bvo.getVbdef11();
|
||||
// 如果BIP合同销售订单的主键在删除的数组中,则设置为删除状态
|
||||
if (Arrays.asList(delIds).contains(vbdef11)) {
|
||||
bvo.setStatus(VOStatus.DELETED);
|
||||
NCCForUAPLogger.debug("findDeletedBids:" + VOStatus.DELETED + ",csaleorderbid = " + csaleorderbid);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 更新 combinBillVO 中的字段为 vos 中的值
|
||||
|
|
@ -456,7 +449,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
// 订单类型
|
||||
// String ctrantypeid = orderHVO.getAttributeValue("ctrantypeid") + "";
|
||||
String vtrantypecode = orderHVO.getVtrantypecode();
|
||||
NCCForUAPLogger.debug("setOtherId-ccustomerid:" + ccustomerid + ",vtrantypecode:" + vtrantypecode);
|
||||
// NCCForUAPLogger.debug("setOtherId-ccustomerid:" + ccustomerid + ",vtrantypecode:" + vtrantypecode);
|
||||
try {
|
||||
String sql = "";
|
||||
// 部门
|
||||
|
|
@ -464,7 +457,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
sql = " select pk_vid,pk_dept from org_dept where code = '[code]' ";
|
||||
sql = sql.replace("[code]", cdeptvid);
|
||||
Map deptMap = (Map) new BaseDAO().executeQuery(sql, new MapProcessor());
|
||||
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-deptObj:" + deptMap);
|
||||
// NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-deptObj:" + deptMap);
|
||||
if (deptMap != null && !deptMap.isEmpty()) {
|
||||
if (!"".equals(deptMap.getOrDefault("pk_dept", "") + "")) {
|
||||
orderHVO.setCdeptid(deptMap.getOrDefault("pk_dept", "") + "");
|
||||
|
|
@ -479,7 +472,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
sql = " select pk_psndoc from bd_psndoc where code = '[code]' ";
|
||||
sql = sql.replace("[code]", cemployeeid);
|
||||
Object staffObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_psndoc"));
|
||||
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-staffObj:" + staffObj);
|
||||
// NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-staffObj:" + staffObj);
|
||||
if (staffObj != null) {
|
||||
String id = BFPubTools.getString_TrimAsNull(staffObj);
|
||||
if (!id.isEmpty()) {
|
||||
|
|
@ -492,7 +485,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' ";
|
||||
sql = sql.replace("[code]", cinvoicecustid);
|
||||
Object invCustObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer"));
|
||||
NCCForUAPLogger.debug("setOtherId-invCustObj:" + invCustObj);
|
||||
// NCCForUAPLogger.debug("setOtherId-invCustObj:" + invCustObj);
|
||||
if (invCustObj != null) {
|
||||
String id = BFPubTools.getString_TrimAsNull(invCustObj);
|
||||
if (!id.isEmpty()) {
|
||||
|
|
@ -505,7 +498,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' ";
|
||||
sql = sql.replace("[code]", ccustomerid);
|
||||
Object custObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer"));
|
||||
NCCForUAPLogger.debug("setOtherId-custObj:" + custObj);
|
||||
// NCCForUAPLogger.debug("setOtherId-custObj:" + custObj);
|
||||
if (custObj != null) {
|
||||
String id = BFPubTools.getString_TrimAsNull(custObj);
|
||||
if (!id.isEmpty()) {
|
||||
|
|
@ -518,12 +511,12 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
IBilltypeService billtypeService = NCLocator.getInstance().lookup(IBilltypeService.class);
|
||||
BilltypeVO billtype = billtypeService.getBilltype(vtrantypecode);
|
||||
if (billtype != null && billtype.getPk_billtypeid() != null) {
|
||||
NCCForUAPLogger.debug("setOtherId-pk_billtypeid:" + billtype.getPk_billtypeid());
|
||||
// NCCForUAPLogger.debug("setOtherId-pk_billtypeid:" + billtype.getPk_billtypeid());
|
||||
orderHVO.setCtrantypeid(billtype.getPk_billtypeid());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-exp:" + e.getMessage());
|
||||
Logger.error("APISaleOrderMaitainImpl-setOtherId-exp:" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -724,20 +717,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
targetBVO.setVbdef18(sourceBVO.getVbdef18()); // 是否定制
|
||||
targetBVO.setVbdef19(sourceBVO.getVbdef19()); // 计划开工日期
|
||||
targetBVO.setVbdef20(sourceBVO.getVbdef20()); // 计划完工日期
|
||||
targetBVO.setVbdef14(sourceBVO.getVbdef14()); // 合同销售订单变更明细id
|
||||
|
||||
// 更新日志输出(按需添加字段)
|
||||
NCCForUAPLogger.debug(String.format(
|
||||
"cmaterialvid = [%S], vbdef1 = [%S], vbdef5 = [%S], vbdef10 = [%S], vbdef13 = [%S], "
|
||||
+ " vbdef18 = [%S], vbdef19 = [%S], vbdef20 = [%S]",
|
||||
cmaterialvid,
|
||||
targetBVO.getVbdef1(),
|
||||
targetBVO.getVbdef5(),
|
||||
targetBVO.getVbdef10(),
|
||||
targetBVO.getVbdef13(),
|
||||
targetBVO.getVbdef18(), // 是否定制
|
||||
targetBVO.getVbdef19(), // 计划开工日期
|
||||
targetBVO.getVbdef20() // 计划完工日期
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -991,7 +972,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
// 税码
|
||||
bVO.setAttributeValue("ctaxcodeid", o_pk_project);
|
||||
} catch (BusinessException e) {
|
||||
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setMaterl:" + e.getMessage());
|
||||
Logger.error("APISaleOrderMaitainImpl-setMaterl:" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -1249,7 +1230,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
*/
|
||||
|
||||
} catch (Exception e) {
|
||||
NCCForUAPLogger.debug("APISaleOrderMaitainImpl-addBvo:" + e.getMessage());
|
||||
Logger.error("APISaleOrderMaitainImpl-addBvo:" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -1273,6 +1254,10 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
*/
|
||||
@Override
|
||||
public void updateBipFlagSo(Map<String, Object> paramMap) throws Exception {
|
||||
// 如果不包含BOM配置完成时间、工艺配置完成时间,则不同步
|
||||
if (!paramMap.containsKey("vbdef16") && !paramMap.containsKey("vbdef17")) {
|
||||
return;
|
||||
}
|
||||
String csaleorderbid = (String) paramMap.get("csaleorderbid");
|
||||
Map<String, Object> soMap = getSaleOrderInfo(csaleorderbid);
|
||||
// 如果没有存合同销售订单信息则不回写
|
||||
|
|
@ -1309,6 +1294,8 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain {
|
|||
// BIP合同销售订单更新 主表id
|
||||
updateJson.put("id", soMap.get("vdef9"));
|
||||
bodyJson.put("HTXSDD", updateJson);
|
||||
NCCForUAPLogger.debug("updateBipFlagSo-bodyJson:" + bodyJson);
|
||||
Logger.error("updateBipFlagSo-bodyJson:" + bodyJson);
|
||||
String resultString = doSendHttp(updateUrl, "POST", tokenParam, "", headers, bodyJson.toJSONString());
|
||||
NCCForUAPLogger.debug("updateBipFlagSo-resultString:" + resultString);
|
||||
Logger.error("updateBipFlagSo-resultString:" + resultString);
|
||||
|
|
|
|||
|
|
@ -318,7 +318,10 @@ public class IAPISaleInvMaitainImpl {
|
|||
itemDetails.put("ftaxtypeflag", 1);// ¿Û˰Àà±ð
|
||||
itemDetails.put("pk_group", "00");// ¼¯ÍÅ
|
||||
itemDetails.put("pk_org", originalJson.getJSONObject("billhead").getString("pk_org"));// ¿ªÆ±×éÖ¯
|
||||
itemDetails.put("cunitid", item.getString("castunitid"));// 寮데貫
|
||||
// 单位
|
||||
String castunitid = item.getString("castunitid");
|
||||
itemDetails.put("cunitid", castunitid);// 主单位
|
||||
itemDetails.put("cqtunitid", castunitid);// 报价单位
|
||||
String vchangerate = value2.getOrDefault("vchangerate", "1/1") + "";
|
||||
itemDetails.put("vchangerate", vchangerate);// »»ËãÂÊ
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ public class ClosesoUpdateBL extends AbstractNCCRestResource {
|
|||
public JSONString ClosesoUpdateBL(JSONString json) {
|
||||
JSONObject errojson = new JSONObject();
|
||||
Set<String> vbillcodes = new HashSet<>();
|
||||
Set<String> billcodes = new HashSet<>();
|
||||
// 创建map 9-冻结; 10-办结; 11-终止; 8:生效(取消冻结)
|
||||
Map<String, String> operationMap = new HashMap<>();
|
||||
|
||||
|
|
@ -136,9 +137,8 @@ public JSONString ClosesoUpdateBL(JSONString json) {
|
|||
" SET h.vdef1 = '" + operationId + "' "+
|
||||
" WHERE EXISTS (" +
|
||||
" SELECT 1" +
|
||||
" FROM so_saleorder_b b" +
|
||||
" left join bd_defdoc hbd on hbd.pk_defdoc=b.vbdef1 "+
|
||||
" WHERE b.csaleorderid = h.csaleorderid" +
|
||||
" FROM bd_defdoc hbd "+
|
||||
" WHERE hbd.pk_defdoc=h.VDEF6" +
|
||||
" AND hbd.code = '" + vctcode + "' " +
|
||||
" );";
|
||||
|
||||
|
|
@ -153,10 +153,10 @@ public JSONString ClosesoUpdateBL(JSONString json) {
|
|||
return ResultMessageUtil.exceptionToJSON(new NullPointerException("vctcode:null"));
|
||||
}
|
||||
// 根据组织ID和销售订单代码获取销售订单的唯一标识
|
||||
String sql = " select h.csaleorderid,b.csaleorderbid,h.ts,hbd.code as vbillcode,o.code as pk_org from so_saleorder h "
|
||||
String sql = " select h.csaleorderid,b.csaleorderbid,h.ts,hbd.code as vbillcode,o.code as pk_org,h.vbillcode as billcode from so_saleorder h "
|
||||
+ "left join so_saleorder_b b on h.csaleorderid=b.csaleorderid "
|
||||
+ "left join org_salesorg o on h.pk_org=o.pk_salesorg "
|
||||
+" left join bd_defdoc hbd on hbd.pk_defdoc=b.vbdef1 "+
|
||||
+" left join bd_defdoc hbd on hbd.pk_defdoc=h.VDEF6 "+
|
||||
|
||||
"where hbd.code='" + vctcode + "' ";
|
||||
List<Object[]> result = (List<Object[]>) getQueryService().executeQuery(sql, new ArrayListProcessor());
|
||||
|
|
@ -175,9 +175,11 @@ public JSONString ClosesoUpdateBL(JSONString json) {
|
|||
String ts = (String) row[2];
|
||||
bidsList.add(csaleorderbid + "," + ts);
|
||||
String vbillcode = (String) row[3];
|
||||
String billcode = (String) row[5];
|
||||
if (vbillcode != null) {
|
||||
pk_org=(String)row[4];
|
||||
vbillcodes.add(vbillcode);
|
||||
billcodes.add(billcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -239,6 +241,14 @@ public JSONString ClosesoUpdateBL(JSONString json) {
|
|||
|
||||
int succState = updateSaleBSQty(updateSql.toString());
|
||||
|
||||
for (String vbillcode : billcodes){
|
||||
// ¸üÐÂÁ÷³ÌÉú²ú¶©µ¥
|
||||
String updateSql1 = " UPDATE mm_mo h" +
|
||||
" SET h.vdef5 = '" + operationId + "' "+
|
||||
" WHERE h.vsrccode = '" + vbillcode + "' " +
|
||||
" ;";
|
||||
updateSaleBSQty(updateSql1.toString());
|
||||
}
|
||||
// 如果操作成功,设置错误JSON对象的code为0,表示成功
|
||||
errojson.put("status", "1");
|
||||
errojson.put("message", "销售订单状态修改了"+succState+"条,"+ret2);
|
||||
|
|
|
|||
|
|
@ -6,14 +6,15 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.itf.uap.IUAPQueryBS;
|
||||
import nc.jdbc.framework.ConnectionFactory;
|
||||
import nc.jdbc.framework.JdbcSession;
|
||||
import nc.jdbc.framework.PersistenceManager;
|
||||
import nc.jdbc.framework.exception.DbException;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.jdbc.framework.processor.MapListProcessor;
|
||||
import nc.jdbc.framework.processor.MapProcessor;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||
import nccloud.commons.lang.StringUtils;
|
||||
import nccloud.ws.rest.resource.AbstractNCCRestResource;
|
||||
import org.json.JSONString;
|
||||
|
||||
|
|
@ -28,238 +29,255 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 排产申请累计排产数量同步NCC
|
||||
* 2005适配2312
|
||||
*/
|
||||
@Path("so/so/salepc")
|
||||
public class saleUpdateLJpc extends AbstractNCCRestResource {
|
||||
@Override
|
||||
public String getModule() {
|
||||
return "so";
|
||||
}
|
||||
// 用于存储手工维护的必填字段和字段说明
|
||||
private Map<String, String> requiredFields;
|
||||
// 构造方法,初始化必填字段及其说明
|
||||
public saleUpdateLJpc() {
|
||||
// 初始化必填字段列表及字段说明
|
||||
requiredFields = new HashMap<>();
|
||||
requiredFields.put("pk_org", "业务单元");
|
||||
requiredFields.put("array.vbillcode", "单据编号");
|
||||
requiredFields.put("array.crowno", "行号");
|
||||
requiredFields.put("array.sendQty", "发货数量");
|
||||
}
|
||||
@Override
|
||||
public String getModule() {
|
||||
return "so";
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/saleUpdateLJpc")
|
||||
@Consumes({"application/json"})
|
||||
@Produces({"application/json"})
|
||||
public JSONString saleUpdateLJpc(JSONString json) {
|
||||
JSONObject returnJson = new JSONObject();
|
||||
try {
|
||||
JSONObject object = JSON.parseObject(json.toJSONString());
|
||||
if (object == null) {
|
||||
return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null"));
|
||||
}
|
||||
// 校验必填字段
|
||||
String tipsStr = checkRequiredFields(object);
|
||||
if (!tipsStr.equals("")) {
|
||||
return ResultMessageUtil.exceptionToJSON(new NullPointerException(tipsStr));
|
||||
}
|
||||
String pk_org = (String) object.getOrDefault("pk_org", "");
|
||||
Object obj = object.getOrDefault("array", "");
|
||||
ArrayList<?> arrayList = new ArrayList<>();
|
||||
if (obj instanceof JSONArray) {
|
||||
JSONArray jsonArray = (JSONArray) obj;
|
||||
arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class));
|
||||
}
|
||||
// 用于存储手工维护的必填字段和字段说明
|
||||
private Map<String, String> requiredFields;
|
||||
|
||||
// 构造方法,初始化必填字段及其说明
|
||||
public saleUpdateLJpc() {
|
||||
// 初始化必填字段列表及字段说明
|
||||
requiredFields = new HashMap<>();
|
||||
requiredFields.put("pk_org", "业务单元");
|
||||
requiredFields.put("array.vbillcode", "单据编号");
|
||||
requiredFields.put("array.crowno", "行号");
|
||||
requiredFields.put("array.sendQty", "发货数量");
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/saleUpdateLJpc")
|
||||
@Consumes({"application/json"})
|
||||
@Produces({"application/json"})
|
||||
public JSONString saleUpdateLJpc(JSONString json) {
|
||||
JSONObject returnJson = new JSONObject();
|
||||
try {
|
||||
JSONObject object = JSON.parseObject(json.toJSONString());
|
||||
if (object == null) {
|
||||
return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null"));
|
||||
}
|
||||
// 校验必填字段
|
||||
String tipsStr = checkRequiredFields(object);
|
||||
if (!tipsStr.isEmpty()) {
|
||||
return ResultMessageUtil.exceptionToJSON(new NullPointerException(tipsStr));
|
||||
}
|
||||
String pk_org = (String) object.getOrDefault("pk_org", "");
|
||||
Object obj = object.getOrDefault("array", "");
|
||||
ArrayList<?> arrayList = new ArrayList<>();
|
||||
if (obj instanceof JSONArray) {
|
||||
JSONArray jsonArray = (JSONArray) obj;
|
||||
arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class));
|
||||
}
|
||||
|
||||
// StringBuilder sqlStr = new StringBuilder();
|
||||
List sqlStr = new ArrayList();
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
Map dataMap = (Map) arrayList.get(i);
|
||||
List sqlStr = new ArrayList();
|
||||
List<JSONObject> resList = new ArrayList<>();
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
Map dataMap = (Map) arrayList.get(i);
|
||||
|
||||
String sqlser="SELECT b.csaleorderid, b.vbdef6, b.vbdef12 "
|
||||
+ "FROM so_saleorder_b b "
|
||||
+ "LEFT JOIN so_saleorder h ON b.csaleorderid = h.csaleorderid "
|
||||
+ "LEFT JOIN org_salesorg o ON h.pk_org = o.pk_salesorg "
|
||||
+ "WHERE b.dr=0 and h.vbillcode = '" + dataMap.get("vbillcode") + "' "
|
||||
+ "AND o.code = '" + pk_org + "' "
|
||||
+ "AND b.csaleorderbid = '" + dataMap.get("crowno") + "'";
|
||||
List<Map<String, Object>> results = (List<Map<String, Object>>) getQueryService().executeQuery(sqlser, new MapListProcessor());
|
||||
if (results.size()==0){
|
||||
returnJson.put("state", 'N');
|
||||
returnJson.put("msg", "失败,单据"+dataMap.get("vbillcode")+"行号:"+dataMap.get("crowno")+"不存在");
|
||||
return ResultMessageUtil.toJSON(returnJson);
|
||||
}
|
||||
if (dataMap.get("sendQty")!=null){
|
||||
sqlStr.add("UPDATE so_saleorder_b b "
|
||||
+ "SET b.vbdef6 = '1001A11000000C0W6P7S',b.vbdef12 = '"+dataMap.get("sendQty")+"'"
|
||||
+ "WHERE b.csaleorderid IN ("
|
||||
+ " SELECT h.csaleorderid"
|
||||
+ " FROM so_saleorder h"
|
||||
+ " LEFT JOIN org_salesorg o ON h.pk_org = o.pk_salesorg"
|
||||
+ " WHERE h.vbillcode = '" + dataMap.get("vbillcode") + "' "
|
||||
+ " AND o.code = '" + pk_org + "' "
|
||||
+ " AND b.csaleorderbid = '" + dataMap.get("crowno") + "' and b.dr=0 "
|
||||
+ ");");
|
||||
}
|
||||
}
|
||||
String sqlser = "SELECT b.csaleorderid, b.vbdef6, b.vbdef12 "
|
||||
+ "FROM so_saleorder_b b "
|
||||
+ "LEFT JOIN so_saleorder h ON b.csaleorderid = h.csaleorderid "
|
||||
+ "LEFT JOIN org_salesorg o ON h.pk_org = o.pk_salesorg "
|
||||
+ "WHERE b.dr=0 and h.vbillcode = '" + dataMap.get("vbillcode") + "' "
|
||||
+ "AND o.code = '" + pk_org + "' "
|
||||
+ "AND b.csaleorderbid = '" + dataMap.get("crowno") + "'";
|
||||
List<Map<String, Object>> results = (List<Map<String, Object>>) getQueryService().executeQuery(sqlser, new MapListProcessor());
|
||||
if (results.size() == 0) {
|
||||
returnJson.put("state", 'N');
|
||||
returnJson.put("msg", "失败,单据" + dataMap.get("vbillcode") + "行号:" + dataMap.get("crowno") + "不存在");
|
||||
return ResultMessageUtil.toJSON(returnJson);
|
||||
}
|
||||
if (dataMap.get("sendQty") != null) {
|
||||
sqlStr.add("UPDATE so_saleorder_b b "
|
||||
+ "SET b.vbdef6 = '1001A11000000C0W6P7S',b.vbdef12 = '" + dataMap.get("sendQty") + "'"
|
||||
+ "WHERE b.csaleorderid IN ("
|
||||
+ " SELECT h.csaleorderid"
|
||||
+ " FROM so_saleorder h"
|
||||
+ " LEFT JOIN org_salesorg o ON h.pk_org = o.pk_salesorg"
|
||||
+ " WHERE h.vbillcode = '" + dataMap.get("vbillcode") + "' "
|
||||
+ " AND o.code = '" + pk_org + "' "
|
||||
+ " AND b.csaleorderbid = '" + dataMap.get("crowno") + "' and b.dr=0 "
|
||||
+ ");");
|
||||
}
|
||||
JSONObject resJson = new JSONObject(dataMap);
|
||||
String csaleorderbid = dataMap.getOrDefault("csaleorderbid", "") + "";
|
||||
if (StringUtils.isNotEmpty(csaleorderbid)) {
|
||||
String sql = " select sb.csaleorderbid,sb.vbdef19,sb.vbdef20" +
|
||||
" from so_saleorder_b sb" +
|
||||
" where sb.csaleorderbid='" + csaleorderbid + "' ";
|
||||
Map<String, Object> soMap = (Map<String, Object>) getQueryService().executeQuery(sql, new MapProcessor());
|
||||
resJson.put("vbdef19", soMap.getOrDefault("vbdef19", ""));
|
||||
resJson.put("vbdef20", soMap.getOrDefault("vbdef20", ""));
|
||||
}
|
||||
resList.add(resJson);
|
||||
}
|
||||
|
||||
// int succState = updateSaleBSQty(sqlStr.toString());
|
||||
int succState = executeUpdate(sqlStr);
|
||||
int succState = executeUpdate(sqlStr);
|
||||
|
||||
if (succState == arrayList.size()) {
|
||||
returnJson.put("state", 'Y');
|
||||
returnJson.put("msg", "成功,已修改"+succState+"行");
|
||||
if (succState == arrayList.size()) {
|
||||
returnJson.put("state", 'Y');
|
||||
returnJson.put("msg", "成功,已修改" + succState + "行");
|
||||
|
||||
}else {
|
||||
returnJson.put("state", 'N');
|
||||
returnJson.put("msg", "失败,已修改"+succState+"行");
|
||||
}
|
||||
return ResultMessageUtil.toJSON(returnJson);
|
||||
} catch (DbException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
returnJson.put("state", 'N');
|
||||
returnJson.put("msg", "失败,已修改" + succState + "行");
|
||||
}
|
||||
returnJson.put("resList", resList);
|
||||
return ResultMessageUtil.toJSON(returnJson);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updateSqls为要执行的sql语句。返回影响行数量
|
||||
*/
|
||||
public int executeUpdate(List<String> updateSqls) throws DbException {
|
||||
if (updateSqls == null) {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* updateSqls为要执行的sql语句。返回影响行数量
|
||||
*/
|
||||
public int executeUpdate(List<String> updateSqls) throws DbException {
|
||||
if (updateSqls == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
PersistenceManager manager = null;
|
||||
JdbcSession session = null;
|
||||
Connection connection = null;
|
||||
int ret = 0;
|
||||
PersistenceManager manager = null;
|
||||
JdbcSession session = null;
|
||||
Connection connection = null;
|
||||
|
||||
try {
|
||||
manager = PersistenceManager.getInstance();
|
||||
session = manager.getJdbcSession();
|
||||
connection = session.getConnection(); // 获取实际的数据库连接
|
||||
try {
|
||||
manager = PersistenceManager.getInstance();
|
||||
session = manager.getJdbcSession();
|
||||
connection = session.getConnection(); // 获取实际的数据库连接
|
||||
// connection = ConnectionFactory.getConnection();
|
||||
// 开始事务
|
||||
connection.setAutoCommit(false); // 禁用自动提交,手动管理事务
|
||||
// 开始事务
|
||||
connection.setAutoCommit(false); // 禁用自动提交,手动管理事务
|
||||
|
||||
// 执行批量操作
|
||||
for (String sql : updateSqls) {
|
||||
session.addBatch(sql);
|
||||
}
|
||||
// 执行批量操作
|
||||
for (String sql : updateSqls) {
|
||||
session.addBatch(sql);
|
||||
}
|
||||
|
||||
// 执行批处理
|
||||
ret = session.executeBatch();
|
||||
// 执行批处理
|
||||
ret = session.executeBatch();
|
||||
|
||||
// 提交事务
|
||||
connection.commit(); // 批处理成功后提交事务
|
||||
// 提交事务
|
||||
connection.commit(); // 批处理成功后提交事务
|
||||
|
||||
} catch (DbException e) {
|
||||
if (connection != null) {
|
||||
try {
|
||||
// 如果发生异常,回滚事务
|
||||
connection.rollback();
|
||||
} catch (SQLException rollbackEx) {
|
||||
// 记录回滚异常的详细信息
|
||||
throw new DbException("Error during transaction rollback", rollbackEx) {
|
||||
@Override
|
||||
public boolean isDataIntegrityViolation() {
|
||||
return false;
|
||||
}
|
||||
} catch (DbException e) {
|
||||
if (connection != null) {
|
||||
try {
|
||||
// 如果发生异常,回滚事务
|
||||
connection.rollback();
|
||||
} catch (SQLException rollbackEx) {
|
||||
// 记录回滚异常的详细信息
|
||||
throw new DbException("Error during transaction rollback", rollbackEx) {
|
||||
@Override
|
||||
public boolean isDataIntegrityViolation() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBadSQLGrammar() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
throw e; // 将原始异常抛出
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
try {
|
||||
// 恢复自动提交模式,确保不会影响其他操作
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
// 忽略恢复自动提交时的异常
|
||||
}
|
||||
}
|
||||
if (manager != null) {
|
||||
manager.release();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isBadSQLGrammar() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
throw e; // 将原始异常抛出
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
try {
|
||||
// 恢复自动提交模式,确保不会影响其他操作
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
// 忽略恢复自动提交时的异常
|
||||
}
|
||||
}
|
||||
if (manager != null) {
|
||||
manager.release();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 方法:检查必填项并返回转化后的Map
|
||||
public static String checkRequiredFields(JSONObject data) throws Exception {
|
||||
String returnStr = "";
|
||||
// 2. 检查必填字段 pk_org
|
||||
String pkOrg = (String) data.getOrDefault("pk_org", "");
|
||||
if (pkOrg.isEmpty()) {
|
||||
return "字段pk_org缺失或为空!";
|
||||
}
|
||||
// 3. 获取并检查 array 字段
|
||||
Object array = data.getOrDefault("array", null);
|
||||
if (array == null || !(array instanceof JSONArray) || ((JSONArray) array).isEmpty()) {
|
||||
return "array对象为空或不存在!";
|
||||
}
|
||||
ArrayList<?> arrayList = new ArrayList<>();
|
||||
if (array instanceof JSONArray) {
|
||||
JSONArray jsonArray = (JSONArray) array;
|
||||
arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class));
|
||||
}
|
||||
// 5. 遍历每个对象,检查必填字段
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
Map item = (Map) arrayList.get(i);
|
||||
// 检查必填字段 'crowno'
|
||||
if (item.getOrDefault("crowno", "").toString().isEmpty()) {
|
||||
return "第 " + (i + 1) + " 项缺少必填字段crowno!";
|
||||
}
|
||||
// 检查必填字段 'vbillcode'
|
||||
if (item.getOrDefault("vbillcode", "").toString().isEmpty()) {
|
||||
return "第 " + (i + 1) + " 项缺少必填字段vbillcode!";
|
||||
}
|
||||
// 检查必填字段 'sendQty'
|
||||
if (item.getOrDefault("sendQty", "").toString().isEmpty()) {
|
||||
return "第 " + (i + 1) + " 项缺少必填字段sendQty!";
|
||||
}
|
||||
}
|
||||
return returnStr;
|
||||
}
|
||||
// 方法:检查必填项并返回转化后的Map
|
||||
public static String checkRequiredFields(JSONObject data) throws Exception {
|
||||
String returnStr = "";
|
||||
// 2. 检查必填字段 pk_org
|
||||
String pkOrg = (String) data.getOrDefault("pk_org", "");
|
||||
if (pkOrg.isEmpty()) {
|
||||
return "字段pk_org缺失或为空!";
|
||||
}
|
||||
// 3. 获取并检查 array 字段
|
||||
Object array = data.getOrDefault("array", null);
|
||||
if (array == null || !(array instanceof JSONArray) || ((JSONArray) array).isEmpty()) {
|
||||
return "array对象为空或不存在!";
|
||||
}
|
||||
ArrayList<?> arrayList = new ArrayList<>();
|
||||
if (array instanceof JSONArray) {
|
||||
JSONArray jsonArray = (JSONArray) array;
|
||||
arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class));
|
||||
}
|
||||
// 5. 遍历每个对象,检查必填字段
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
Map item = (Map) arrayList.get(i);
|
||||
// 检查必填字段 'crowno'
|
||||
if (item.getOrDefault("crowno", "").toString().isEmpty()) {
|
||||
return "第 " + (i + 1) + " 项缺少必填字段crowno!";
|
||||
}
|
||||
// 检查必填字段 'vbillcode'
|
||||
if (item.getOrDefault("vbillcode", "").toString().isEmpty()) {
|
||||
return "第 " + (i + 1) + " 项缺少必填字段vbillcode!";
|
||||
}
|
||||
// 检查必填字段 'sendQty'
|
||||
if (item.getOrDefault("sendQty", "").toString().isEmpty()) {
|
||||
return "第 " + (i + 1) + " 项缺少必填字段sendQty!";
|
||||
}
|
||||
}
|
||||
return returnStr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*创建时间:2024-11-28
|
||||
*作用:查询
|
||||
*传值:无
|
||||
*返回值:必填项map对象
|
||||
*/
|
||||
private String getSaleorderBPK(String pk_org, String vbillcode, String crowno) throws BusinessException {
|
||||
String sql = " select b.csaleorderbid from so_saleorder h \n"
|
||||
+ "left join so_saleorder_b b on h.csaleorderid=b.csaleorderid\n"
|
||||
+ "left join org_salesorg o on h.pk_org=o.pk_salesorg\n"
|
||||
+ "where h.vbillcode='" + vbillcode + "' and o.code='" + pk_org + "' and b.crowno='" + crowno + "' ";
|
||||
String saleorderBPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor());
|
||||
return saleorderBPK;
|
||||
}
|
||||
/*
|
||||
*创建时间:2024-11-28
|
||||
*作用:查询
|
||||
*传值:无
|
||||
*返回值:必填项map对象
|
||||
*/
|
||||
private String getSaleorderBPK(String pk_org, String vbillcode, String crowno) throws BusinessException {
|
||||
String sql = " select b.csaleorderbid from so_saleorder h \n"
|
||||
+ "left join so_saleorder_b b on h.csaleorderid=b.csaleorderid\n"
|
||||
+ "left join org_salesorg o on h.pk_org=o.pk_salesorg\n"
|
||||
+ "where h.vbillcode='" + vbillcode + "' and o.code='" + pk_org + "' and b.crowno='" + crowno + "' ";
|
||||
String saleorderBPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor());
|
||||
return saleorderBPK;
|
||||
}
|
||||
|
||||
/*
|
||||
*创建时间:2024-11-28
|
||||
*作用:查询
|
||||
*传值:无
|
||||
*返回值:必填项map对象
|
||||
*/
|
||||
private int updateSaleBSQty(String sql) throws BusinessException {
|
||||
BaseDAO baseDAO = new BaseDAO();
|
||||
int succInt = baseDAO.executeUpdate(sql);
|
||||
return succInt;
|
||||
}
|
||||
/*
|
||||
*创建时间:2024-11-28
|
||||
*作用:查询
|
||||
*传值:无
|
||||
*返回值:必填项map对象
|
||||
*/
|
||||
private int updateSaleBSQty(String sql) throws BusinessException {
|
||||
BaseDAO baseDAO = new BaseDAO();
|
||||
int succInt = baseDAO.executeUpdate(sql);
|
||||
return succInt;
|
||||
}
|
||||
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@ import nccloud.api.rest.utils.NCCRestUtils;
|
|||
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||
import nccloud.api.so.m30.IAPISaleOrderMaitain;
|
||||
import nccloud.api.so.m30.IAPISaleOrderQuery;
|
||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
||||
import nccloud.commons.lang.StringUtils;
|
||||
import nccloud.openapi.scmpub.pub.NCCPubRestResource;
|
||||
import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
|
||||
|
|
@ -495,7 +494,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
// 删除最后的", "
|
||||
sql.delete(sql.length() - 2, sql.length());
|
||||
sql.append(" where csaleorderbid = ?");
|
||||
NCCForUAPLogger.debug("updateDef-sql:" + sql);
|
||||
// NCCForUAPLogger.debug("updateDef-sql:" + sql);
|
||||
parameter.addParam(csaleorderbid);
|
||||
BaseDAO baseDAO = new BaseDAO();
|
||||
int num = baseDAO.executeUpdate(sql.toString(), parameter);
|
||||
|
|
@ -503,7 +502,7 @@ public class SaleOrderResource extends NCCPubRestResource {
|
|||
// 回写合同平台的对应字段
|
||||
NCLocator.getInstance().lookup(IAPISaleOrderMaitain.class).updateBipFlagSo(paramMap);
|
||||
}
|
||||
return ResultMessageUtil.toJSON(num, "销售订单修改成功");
|
||||
return ResultMessageUtil.toJSON(num, "销售订单修改成功,共修改" + num + "行");
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ public class InvoiceDownloadAction implements ICommonAction {
|
|||
String ofdData = (String) infoMap.get("taxofd");
|
||||
|
||||
if (MMValueCheck.isEmpty(pdfData) && MMValueCheck.isEmpty(xmlData) && MMValueCheck.isEmpty(ofdData)) {
|
||||
throw new Exception("δ²éѯµ½·¢Æ±ÐÅÏ¢");
|
||||
// throw new Exception("未查询到发票信息");
|
||||
continue;
|
||||
}
|
||||
|
||||
String ctcode = "";
|
||||
|
|
@ -135,13 +136,17 @@ public class InvoiceDownloadAction implements ICommonAction {
|
|||
"AND bd.pk_defdoc = '" + ivApplicationHeadVO.getDef2().toString() + "' ";
|
||||
// List<Map<String,Object>> operationresult = (List<Map<String,Object>>) getQueryService().executeQuery(operationSql, new ArrayListProcessor());
|
||||
Map<String, Object> valList = (Map<String, Object>) getQueryService().executeQuery(operationSql, new MapProcessor());
|
||||
ctcode = (String) valList.get("name");
|
||||
if(valList == null){
|
||||
ctcode = ivApplicationHeadVO.getDef2(); // 合同号
|
||||
}
|
||||
}
|
||||
if(!ctcode.equals("") && !ctcode.equals("/") ){
|
||||
ctcode=ctcode+"_";
|
||||
}
|
||||
|
||||
// 添加 PDF
|
||||
if (!MMValueCheck.isEmpty(pdfData)) {
|
||||
byte[] pdfBytes = DatatypeConverter.parseBase64Binary(pdfData);
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".pdf"));
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".pdf"));
|
||||
zipStream.write(pdfBytes);
|
||||
zipStream.closeEntry();
|
||||
}
|
||||
|
|
@ -149,7 +154,7 @@ public class InvoiceDownloadAction implements ICommonAction {
|
|||
// 添加 XML
|
||||
if (!MMValueCheck.isEmpty(xmlData)) {
|
||||
byte[] xmlBytes = DatatypeConverter.parseBase64Binary(xmlData);
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".xml"));
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".xml"));
|
||||
zipStream.write(xmlBytes);
|
||||
zipStream.closeEntry();
|
||||
}
|
||||
|
|
@ -157,11 +162,11 @@ public class InvoiceDownloadAction implements ICommonAction {
|
|||
// 添加 OFD
|
||||
if (!MMValueCheck.isEmpty(ofdData)) {
|
||||
byte[] ofdBytes = DatatypeConverter.parseBase64Binary(ofdData);
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".ofd"));
|
||||
zipStream.putNextEntry(new ZipEntry(ctcode + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble()) + ".ofd"));
|
||||
zipStream.write(ofdBytes);
|
||||
zipStream.closeEntry();
|
||||
}
|
||||
zipName=ctcode + "_" + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble());
|
||||
zipName=ctcode + headVO.getGmfmc() + "_" + headVO.getFphm() + "_" + String.valueOf(headVO.getJshj().toDouble());
|
||||
} else {
|
||||
throw new Exception("获取发票信息失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,8 @@ public class ErpSaleOrderToBIPBackgroupWorkPlugin implements IBackgroundWorkPlug
|
|||
String flag = map.get("flag");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if("2".equals(flag)){
|
||||
sb.append(" select ic_saleout_b.cgeneralbid as csaleinvoicebid,so_saleorder.vdef9,so_saleorder_b.vbdef11,so_saleorder_exe.ntotalarmny as totalaccrued ,so_saleorder_exe.ntotalinvoicenum as billqty, NVL(so_saleorder_exe.ntotaloutnum, 0) as totaloutqty ");
|
||||
sb.append(" select ic_saleout_b.cgeneralbid as csaleinvoicebid,so_saleorder.vdef9,so_saleorder_b.vbdef11, so_saleorder_b.fretexchange, so_saleorder_b.cexchangesrcretid, so_saleorder_b.narrangemonum, so_saleorder_b.ntotalreturnnum, so_saleorder_b.ntotalrednum," +
|
||||
" so_saleorder_exe.ntotalarmny as totalaccrued ,so_saleorder_exe.ntotalinvoicenum as billqty, NVL(so_saleorder_exe.ntotaloutnum, 0) as totaloutqty ");
|
||||
sb.append(" from so_saleorder_exe,ic_saleout_b,ic_saleout_h,so_saleorder_b,so_saleorder ");
|
||||
sb.append(" where so_saleorder_exe.csaleorderbid=ic_saleout_b.cfirstbillbid ");
|
||||
sb.append(" and ic_saleout_h.cgeneralhid = ic_saleout_b.cgeneralhid ");
|
||||
|
|
@ -162,7 +163,7 @@ public class ErpSaleOrderToBIPBackgroupWorkPlugin implements IBackgroundWorkPlug
|
|||
sb.append(" and nvl(so_saleorder.vdef9,'~') not in ('~') ");
|
||||
sb.append(" and so_saleorder_exe.csaleorderbid='").append(map.get("cfirstbid")).append("'");
|
||||
}else{
|
||||
sb.append(" select so_saleinvoice_b.csaleinvoicebid,so_saleorder.vdef9,so_saleorder_b.vbdef11,so_saleorder_exe.ntotalarmny as totalaccrued ,so_saleorder_exe.ntotalinvoicenum as billqty, NVL(so_saleorder_exe.ntotaloutnum, 0) as totaloutqty ");
|
||||
sb.append(" select so_saleinvoice_b.csaleinvoicebid,so_saleorder.vdef9,so_saleorder_b.vbdef11,so_saleorder_b.fretexchange, so_saleorder_b.cexchangesrcretid, so_saleorder_b.narrangemonum, so_saleorder_b.ntotalreturnnum, so_saleorder_b.ntotalrednum, so_saleorder_exe.ntotalarmny as totalaccrued ,so_saleorder_exe.ntotalinvoicenum as billqty, NVL(so_saleorder_exe.ntotaloutnum, 0) as totaloutqty ");
|
||||
sb.append(" from so_saleorder_exe,so_saleinvoice_b,so_saleinvoice,so_saleorder_b,so_saleorder ");
|
||||
sb.append(" where so_saleorder_exe.csaleorderbid=so_saleinvoice_b.csrcbid ");
|
||||
sb.append(" and so_saleinvoice.csaleinvoiceid=so_saleinvoice_b.csaleinvoiceid and so_saleinvoice.fstatusflag=2 ");
|
||||
|
|
@ -201,6 +202,14 @@ public class ErpSaleOrderToBIPBackgroupWorkPlugin implements IBackgroundWorkPlug
|
|||
b_map.put("totalAccrued", custpkmap.get("totalaccrued"));// 累计确认应收金额
|
||||
b_map.put("totalOutQty", custpkmap.get("totaloutqty"));// 累计出库主数量
|
||||
|
||||
b_map.put("fretexchange", custpkmap.get("fretexchange")); // 退换货标记
|
||||
b_map.put("cexchangesrcretid", custpkmap.get("cexchangesrcretid")); // 换货行对应退货行
|
||||
b_map.put("narrangemonum", custpkmap.get("narrangemonum")); // 累计安排生产订单主数量
|
||||
b_map.put("ntotalreturnnum", custpkmap.get("ntotalreturnnum")); // 累计退货主数量
|
||||
b_map.put("ntotalrednum", custpkmap.get("ntotalrednum")); // 累计回冲主数量
|
||||
|
||||
|
||||
|
||||
l_map_f.add(b_map);
|
||||
|
||||
js_apct.put("contractOrdersList", l_map_f);
|
||||
|
|
|
|||
|
|
@ -66,16 +66,26 @@ public class MaterialAsstFrame1ChangedListener implements IBusinessListener {
|
|||
this.dealMaterialStockAssts(event, true);
|
||||
this.dealMaterialPlanUpdateAssts(event, true);
|
||||
}
|
||||
// else if ("1002".equals(event.getEventType())) {
|
||||
// this.dealMaterialStockAssts1(event, false);
|
||||
// this.dealMaterialPlanUpdateAssts1(event, false);
|
||||
// }
|
||||
}else if("8b7d49ab-7a65-4885-bcf1-7df89b84df4b".equals(event.getSourceID())){
|
||||
//计划信息分配后
|
||||
if ("1009".equals(event.getEventType()) ) {
|
||||
this.dealMaterialStockAssts1(event, false);
|
||||
this.dealMaterialPlanUpdateAssts1(event, false);
|
||||
}
|
||||
}else if("13636fc1-0215-4102-a11e-af4be73a05ab".equals(event.getSourceID())){
|
||||
//库存信息分配后
|
||||
if ("1009".equals(event.getEventType()) ) {
|
||||
this.dealMaterialStockAssts1(event, false);
|
||||
}
|
||||
}else if("a3133495-8c94-47b4-83d4-0d32bd08ac82".equals(event.getSourceID())){
|
||||
//生产信息分配后
|
||||
if ("1009".equals(event.getEventType()) ) {
|
||||
this.dealMaterialProdUpdateAssts1(event, false);
|
||||
}
|
||||
}else if("d0ff92c6-1059-46b4-97fd-ed8b3d0a85d9".equals(event.getSourceID())){
|
||||
//成本信息分配后
|
||||
if ("1009".equals(event.getEventType()) ) {
|
||||
this.dealMaterialCostAssts1(event, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +101,9 @@ public class MaterialAsstFrame1ChangedListener implements IBusinessListener {
|
|||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
if(pk_marasstframe == null){
|
||||
continue;
|
||||
}
|
||||
//库存
|
||||
this.updateMaterialStockUpdateAssts(pk_marasstframe, pk_material);
|
||||
//成本
|
||||
|
|
@ -110,11 +123,48 @@ public class MaterialAsstFrame1ChangedListener implements IBusinessListener {
|
|||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
if(pk_marasstframe == null){
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateMaterialStockUpdateAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
|
||||
}
|
||||
private void dealMaterialProdUpdateAssts1(BDCommonEvent event, boolean isBatchUp) throws BusinessException {
|
||||
for(int i = 0; i < event.getNewObjs().length; ++i) {
|
||||
MaterialProdVO newVO = (MaterialProdVO)event.getNewObjs()[i];
|
||||
String pk_material = newVO.getPk_material();
|
||||
String pk_marasstframe = this.getmarasstframe(pk_material).get(0);
|
||||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
if(pk_marasstframe == null){
|
||||
return;
|
||||
}
|
||||
this.updateMaterialProdAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
|
||||
}
|
||||
private void dealMaterialCostAssts1(BDCommonEvent event, boolean isBatchUp) throws BusinessException {
|
||||
for(int i = 0; i < event.getNewObjs().length; ++i) {
|
||||
MaterialCostVO newVO = (MaterialCostVO)event.getNewObjs()[i];
|
||||
String pk_material = newVO.getPk_material();
|
||||
String pk_marasstframe = this.getmarasstframe(pk_material).get(0);
|
||||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
if(pk_marasstframe == null){
|
||||
return;
|
||||
}
|
||||
//生产信息
|
||||
this.updateMaterialCostUpdateAssts(pk_marasstframe, pk_material);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void updateMaterialStockUpdateAssts(String pk_marasstframe, String materialVID) throws BusinessException {
|
||||
|
|
@ -271,7 +321,9 @@ public class MaterialAsstFrame1ChangedListener implements IBusinessListener {
|
|||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
|
||||
if(pk_marasstframe == null){
|
||||
continue;
|
||||
}
|
||||
this.updateMaterialPlanAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
}
|
||||
|
|
@ -285,7 +337,9 @@ public class MaterialAsstFrame1ChangedListener implements IBusinessListener {
|
|||
if (!isBatchUp) {
|
||||
BDPKLockUtil.lockString(new String[]{pk_material});
|
||||
}
|
||||
|
||||
if(pk_marasstframe == null){
|
||||
return;
|
||||
}
|
||||
this.updateMaterialPlanAssts(pk_marasstframe, pk_material);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue