销售出库和流程生产订单的公司控制调整

This commit is contained in:
mzr 2025-05-26 15:09:32 +08:00
parent 2fffd8820a
commit 5f4d39777d
2 changed files with 291 additions and 232 deletions

View File

@ -1,17 +1,17 @@
package nccloud.resources.ic.ic.saleout; 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.BdUpdateEvent;
import nc.bs.businessevent.BusinessEvent; import nc.bs.businessevent.BusinessEvent;
import nc.bs.businessevent.IBusinessEvent; import nc.bs.businessevent.IBusinessEvent;
import nc.bs.businessevent.IBusinessListener; import nc.bs.businessevent.IBusinessListener;
import nc.bs.dao.DAOException;
import nc.bs.framework.common.NCLocator; import nc.bs.framework.common.NCLocator;
import nc.bs.ic.general.businessevent.ICGeneralCommonEvent; import nc.bs.ic.general.businessevent.ICGeneralCommonEvent;
import nc.bs.trade.business.HYSuperDMO;
import nc.itf.uap.IUAPQueryBS; import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ColumnProcessor; import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor; import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.bd.defdoc.DefdocVO;
import nc.vo.ic.general.define.ICBillBodyVO; import nc.vo.ic.general.define.ICBillBodyVO;
import nc.vo.ic.m4c.entity.SaleOutHeadVO; import nc.vo.ic.m4c.entity.SaleOutHeadVO;
import nc.vo.ic.m4c.entity.SaleOutVO; 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.pubapp.AppContext;
import nc.vo.tmpub.util.ModuleEnum; import nc.vo.tmpub.util.ModuleEnum;
import nc.vo.tmpub.util.ModuleUtil; import nc.vo.tmpub.util.ModuleUtil;
import nccloud.baseapp.core.log.NCCForUAPLogger;
import java.time.LocalDateTime; 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 { public class saveBeforeCheck implements IBusinessListener {
@Override @Override
public void doAction(IBusinessEvent event) throws BusinessException { public void doAction(IBusinessEvent event) throws BusinessException {
String pk_group = AppContext.getInstance().getPkGroup(); String pk_group = AppContext.getInstance().getPkGroup();
if (ModuleUtil.isEnableByGroup(pk_group, ModuleEnum.SSCRP, false)) { if (ModuleUtil.isEnableByGroup(pk_group, ModuleEnum.SSCRP, false)) {
if (event != null) { if (event != null) {
Map<String, SaleOutVO[]> map = this.getBills(event); Map<String, SaleOutVO[]> map = this.getBills(event);
SaleOutVO[] obills = map.get("obj"); SaleOutVO[] obills = map.get("obj");
// 判断是否是需要控制的业务单元 // 判断是否是需要控制的业务单元
SaleOutHeadVO parentVO = obills[0].getHead(); SaleOutHeadVO parentVO = obills[0].getHead();
String pkstockorgStr = getPk_stockorg(parentVO.getPk_org()); String pkstockorgStr = getPk_stockorg(parentVO.getPk_org());
if (pkstockorgStr == null || pkstockorgStr.equals("")) { if (pkstockorgStr == null || pkstockorgStr.isEmpty()) {
return; return;
} }
ICBillBodyVO[] childrenVO = obills[0].getChildrenVO(); ICBillBodyVO[] childrenVO = obills[0].getChildrenVO();
for (int i = 0; i < childrenVO.length; ++i) { for (int i = 0; i < childrenVO.length; ++i) {
ICBillBodyVO vo = childrenVO[i]; ICBillBodyVO vo = childrenVO[i];
Map<String, Object> valMap = getSaleorderPK(vo.getCsourcebillbid()); Map<String, Object> valMap = getSaleorderPK(vo.getCsourcebillbid());
if (valMap == null || valMap.isEmpty()) { if (valMap == null || valMap.isEmpty()) {
return; return;
} }
// 历史数据不考虑 // 历史数据不考虑
String storedDateStr = (String) valMap.get("creationtime"); String storedDateStr = (String) valMap.get("creationtime");
String targetDateStr = "2024-12-31 00:00:00"; String targetDateStr = "2024-12-31 00:00:00";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter); LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter);
LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter); LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter);
if (storedDate.isBefore(targetDate)) { if (storedDate.isBefore(targetDate)) {
return; return;
} }
// 销售发票表头pk_billtypecode=30-Cxx-12 // 销售发票表头pk_billtypecode=30-Cxx-12
if (valMap.get("pk_billtypecode").equals("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-02")
|| valMap.get("pk_billtypecode").equals("30-Cxx-08") || valMap.get("pk_billtypecode").equals("30-Cxx-08")
|| valMap.get("pk_billtypecode").equals("30-Cxx-13")) { || valMap.get("pk_billtypecode").equals("30-Cxx-13")) {
return; return;
} }
// 销售发票表头vdef21= // 销售发票表头vdef21=
if (valMap.get("vdef20") == null || !valMap.get("vdef20").equals("Y")) { if (valMap.get("vdef20") == null || !valMap.get("vdef20").equals("Y")) {
throw new BusinessException("销售出库单明细" + (i + 1) + ",销售发票验证不通过,无法保存!"); throw new BusinessException("销售出库单明细" + (i + 1) + ",销售发票验证不通过,无法保存!");
} }
if (valMap.get("sqty") == null) { if (valMap.get("sqty") == null) {
throw new BusinessException("销售出库单明细" + (i + 1) + "累计发货申请数量为0无法保存"); throw new BusinessException("销售出库单明细" + (i + 1) + "累计发货申请数量为0无法保存");
} else { } else {
try { try {
double sQty = Double.parseDouble((String) valMap.get("sqty"));// 累计发货申请数量 double sQty = Double.parseDouble((String) valMap.get("sqty"));// 累计发货申请数量
UFDouble bdnumUF = vo.getNshouldassistnum();// 本单应发数量 UFDouble bdnumUF = vo.getNshouldassistnum();// 本单应发数量
double bdnum = 0; double bdnum = 0;
if (bdnumUF != null) { if (bdnumUF != null) {
bdnum = bdnumUF.getDouble(); bdnum = bdnumUF.getDouble();
} }
// 应发数量判断 // 应发数量判断
Object ntotaloutnumsObj = valMap.get("ntotaloutnums"); Object ntotaloutnumsObj = valMap.get("ntotaloutnums");
String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : ""; String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : "";
double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计出库主数量 double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计出库主数量
if (sQty < (ntotaloutnum + bdnum)) { if (sQty < (ntotaloutnum + bdnum)) {
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库应发数量'" + (ntotaloutnum + bdnum) throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库应发数量'" + (ntotaloutnum + bdnum)
+ "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!"); + "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
} }
// 实发数量判断 // 实发数量判断
UFDouble bdsfnumUF = vo.getNassistnum();// 本单实发数量 UFDouble bdsfnumUF = vo.getNassistnum();// 本单实发数量
double bdsfnum = 0; double bdsfnum = 0;
if (bdsfnumUF != null) { if (bdsfnumUF != null) {
bdsfnum = bdsfnumUF.getDouble(); bdsfnum = bdsfnumUF.getDouble();
} }
Object nassistnumObj = valMap.get("nassistnum"); Object nassistnumObj = valMap.get("nassistnum");
String nassistnums = (nassistnumObj != null) ? nassistnumObj.toString() : ""; String nassistnums = (nassistnumObj != null) ? nassistnumObj.toString() : "";
double nassistnum = (nassistnums.isEmpty()) ? 0 : Double.parseDouble(nassistnums);// 累计出库主数量 double nassistnum = (nassistnums.isEmpty()) ? 0 : Double.parseDouble(nassistnums);// 累计出库主数量
if (sQty < (nassistnum + bdsfnum)) { if (sQty < (nassistnum + bdsfnum)) {
throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库实发数量'" + (nassistnum + bdsfnum) throw new BusinessException("销售出库单明细" + (i + 1) + ",累计出库实发数量'" + (nassistnum + bdsfnum)
+ "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!"); + "'大于销售订单累计发货申请数量'" + sQty + "',无法保存!");
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new BusinessException("累计发货申请数量、累计出库数量转化数值失败" + e); throw new BusinessException("累计发货申请数量、累计出库数量转化数值失败" + e);
} }
} }
} }
} }
} }
} }
private Map<String, Object> getSaleorderPK(String csourcebillbidStr) throws BusinessException { private Map<String, Object> getSaleorderPK(String csourcebillbidStr) throws BusinessException {
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); 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" 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" + "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_saleinvoice si ON si.csaleinvoiceid = sib.csaleinvoiceid\n"
+ "INNER JOIN so_saleorder_b sb ON sb.csaleorderbid = sib.csrcbid\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" + "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" + "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" + "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" + "GROUP BY c.csaleorderbid) sbv on sbv.csaleorderbid=sb.csaleorderbid\n"
+ "INNER JOIN so_saleorder s ON s.csaleorderid = sb.csaleorderid\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 bd_billtype bt on bt.pk_billtypeid=s.ctrantypeid\n"
+ "INNER JOIN so_saleorder_exe se ON sb.csaleorderbid = se.csaleorderbid\n" + "INNER JOIN so_saleorder_exe se ON sb.csaleorderbid = se.csaleorderbid\n"
+ "WHERE sib.csaleinvoicebid = '" + csourcebillbidStr + "' "; + "WHERE sib.csaleinvoicebid = '" + csourcebillbidStr + "' ";
Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor()); Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
return valList; return valList;
} }
public IUAPQueryBS getQueryService() { public IUAPQueryBS getQueryService() {
return NCLocator.getInstance().lookup(IUAPQueryBS.class); return NCLocator.getInstance().lookup(IUAPQueryBS.class);
} }
private Map<String, SaleOutVO[]> getBills(IBusinessEvent event) throws BusinessException { private Map<String, SaleOutVO[]> getBills(IBusinessEvent event) throws BusinessException {
Object object = null; Object object = null;
Object old = null; Object old = null;
Map<String, SaleOutVO[]> retMap = new HashMap<>(); Map<String, SaleOutVO[]> retMap = new HashMap<>();
// 类型判断和赋值 // 类型判断和赋值
if (event instanceof BusinessEvent) { if (event instanceof BusinessEvent) {
BusinessEvent bills = (BusinessEvent) event; BusinessEvent bills = (BusinessEvent) event;
object = bills.getObject(); object = bills.getObject();
} else if (event instanceof BdUpdateEvent) { } else if (event instanceof BdUpdateEvent) {
BdUpdateEvent e = (BdUpdateEvent) event; BdUpdateEvent e = (BdUpdateEvent) event;
object = e.getNewObject(); object = e.getNewObject();
old = e.getOldObject(); old = e.getOldObject();
} else if (event instanceof ICGeneralCommonEvent) { } else if (event instanceof ICGeneralCommonEvent) {
ICGeneralCommonEvent e = (ICGeneralCommonEvent) event; ICGeneralCommonEvent e = (ICGeneralCommonEvent) event;
object = e.getNewObjs(); object = e.getNewObjs();
old = e.getOldObjs(); old = e.getOldObjs();
} else { } else {
throw new BusinessException("未找到单据类型"); throw new BusinessException("未找到单据类型");
} }
// object old 转换为 SaleOutVO[] 并添加到 retMap // object old 转换为 SaleOutVO[] 并添加到 retMap
retMap.put("new", toSaleOutVOArray(object)); retMap.put("new", toSaleOutVOArray(object));
retMap.put("old", toSaleOutVOArray(old)); retMap.put("old", toSaleOutVOArray(old));
// 根据 new old 来设置 "obj" // 根据 new old 来设置 "obj"
retMap.put("obj", retMap.get("new") != null ? retMap.get("new") : retMap.get("old")); retMap.put("obj", retMap.get("new") != null ? retMap.get("new") : retMap.get("old"));
return retMap; return retMap;
} }
// 辅助方法将对象转换为 SaleOutVO 数组 // 辅助方法将对象转换为 SaleOutVO 数组
private SaleOutVO[] toSaleOutVOArray(Object object) { private SaleOutVO[] toSaleOutVOArray(Object object) {
if (object == null) { if (object == null) {
return null; return null;
} }
if (object.getClass().isArray()) { if (object.getClass().isArray()) {
return (SaleOutVO[]) object; return (SaleOutVO[]) object;
} else { } else {
return new SaleOutVO[] { (SaleOutVO) object }; return new SaleOutVO[]{(SaleOutVO) object};
} }
} }
private String getPk_stockorg(String pk_stockorg) throws BusinessException { 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='" Map<String, String> defMap = checkOrgCtrl();
+ pk_stockorg + "' "; if (defMap.isEmpty() || "".equals(defMap.getOrDefault("so_out", ""))) {
String saleorderPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor()); return "";
return saleorderPK; }
} 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;
}
} }

View File

@ -1,111 +1,141 @@
package nc.bs.mmpac.pmo.pac0002.bp.rule; package nc.bs.mmpac.pmo.pac0002.bp.rule;
import java.time.LocalDateTime; import nc.bs.dao.DAOException;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import nc.bs.framework.common.NCLocator; import nc.bs.framework.common.NCLocator;
import nc.bs.trade.business.HYSuperDMO;
import nc.impl.pubapp.pattern.rule.IRule; import nc.impl.pubapp.pattern.rule.IRule;
import nc.itf.uap.IUAPQueryBS; import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ColumnProcessor; import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor; 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.PMOAggVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO; import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
import nc.vo.pub.BusinessException; import nc.vo.pub.BusinessException;
import nc.vo.so.m30.entity.SaleOrderBVO; 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 * 流程生成订单保存时验证销售订单累计排产状态并验收首付款比例 zhangxinah 适配2312
*/ */
public class saveBeforeCheckRule implements IRule<PMOAggVO> { public class saveBeforeCheckRule implements IRule<PMOAggVO> {
@Override @Override
public void process(PMOAggVO[] vos) { public void process(PMOAggVO[] vos) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
try { try {
List<SaleOrderBVO> list = new ArrayList<SaleOrderBVO>(); List<SaleOrderBVO> list = new ArrayList<SaleOrderBVO>();
for (PMOAggVO vo : vos) { for (PMOAggVO vo : vos) {
// 判断是否是需要控制的业务单元 // 判断是否是需要控制的业务单元
PMOHeadVO pmoHeadVO = vo.getParentVO(); PMOHeadVO pmoHeadVO = vo.getParentVO();
String pkstockorgStr = getPk_stockorg(pmoHeadVO.getPk_org()); String pkstockorgStr = getPk_stockorg(pmoHeadVO.getPk_org());
if (pkstockorgStr == null || pkstockorgStr.equals("")) { if (pkstockorgStr == null || pkstockorgStr.isEmpty()) {
return; return;
} }
PMOItemVO[] iSuperVOs = vo.getChildrenVO(); PMOItemVO[] iSuperVOs = vo.getChildrenVO();
for (int i = 0; i < iSuperVOs.length; i++) { for (int i = 0; i < iSuperVOs.length; i++) {
PMOItemVO itemvo = iSuperVOs[i]; PMOItemVO itemvo = iSuperVOs[i];
// 判断是否类型是否为30 // 判断是否类型是否为30
if (itemvo.getVsrctype() == null || !itemvo.getVsrctype().equals("30")) { if (itemvo.getVsrctype() == null || !itemvo.getVsrctype().equals("30")) {
return; return;
} }
Map<String, Object> valMap = getVbdef6(itemvo.getVsrcbid()); Map<String, Object> valMap = getVbdef6(itemvo.getVsrcbid());
if (valMap == null || valMap.isEmpty()) { if (valMap == null || valMap.isEmpty()) {
throw new BusinessException("无法关联到销售订单,无法保存!"); throw new BusinessException("无法关联到销售订单,无法保存!");
} }
// 销售发票表头pk_billtypecode=30-Cxx-12 // 销售发票表头pk_billtypecode=30-Cxx-12
if (valMap.get("pk_billtypecode").equals("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-02")
|| valMap.get("pk_billtypecode").equals("30-Cxx-08") || valMap.get("pk_billtypecode").equals("30-Cxx-08")
|| valMap.get("pk_billtypecode").equals("30-Cxx-13")) { || valMap.get("pk_billtypecode").equals("30-Cxx-13")) {
return; return;
} }
// 历史数据不考虑 // 历史数据不考虑
String storedDateStr = (String) valMap.get("creationtime"); String storedDateStr = (String) valMap.get("creationtime");
String targetDateStr = "2024-12-27 00:00:00"; String targetDateStr = "2024-12-27 00:00:00";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter); LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter);
LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter); LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter);
if (storedDate.isBefore(targetDate)) { if (storedDate.isBefore(targetDate)) {
return; return;
} }
if (valMap.get("vbdef12") == null) { if (valMap.get("vbdef12") == null) {
throw new BusinessException("生产订单明细" + (i + 1) + "累计排产申请数量为0无法保存"); throw new BusinessException("生产订单明细" + (i + 1) + "累计排产申请数量为0无法保存");
} else { } else {
try { try {
double sQty = Double.parseDouble((String) valMap.get("vbdef12"));// 累计排产申请数量 double sQty = Double.parseDouble((String) valMap.get("vbdef12"));// 累计排产申请数量
Object ntotaloutnumsObj = valMap.get("nastnum"); Object ntotaloutnumsObj = valMap.get("nastnum");
String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : ""; String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : "";
double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计生产数量 double ntotaloutnum = (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);// 累计生产数量
double bdnum = itemvo.getNastnum().getDouble(); double bdnum = itemvo.getNastnum().getDouble();
if (sQty < (ntotaloutnum + bdnum)) { if (sQty < (ntotaloutnum + bdnum)) {
throw new BusinessException("生产订单明细" + (i + 1) + ",累计生产数量'" + (ntotaloutnum + bdnum) throw new BusinessException("生产订单明细" + (i + 1) + ",累计生产数量'" + (ntotaloutnum + bdnum)
+ "'大于销售订单累计排产申请数量'" + sQty + "',无法保存!"); + "'大于销售订单累计排产申请数量'" + sQty + "',无法保存!");
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new BusinessException("累计排产申请数量转化数值失败" + e); throw new BusinessException("累计排产申请数量转化数值失败" + e);
} }
} }
} }
} }
} catch (BusinessException e) { } catch (BusinessException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
private Map<String, Object> getVbdef6(String vsrcbidStr) throws BusinessException { private Map<String, Object> getVbdef6(String vsrcbidStr) throws BusinessException {
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); 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" 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" + "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" + "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" + "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='" + "INNER JOIN bd_billtype bt on bt.pk_billtypeid=s.ctrantypeid\n" + "where b.csaleorderbid='"
+ vsrcbidStr + "' "; + vsrcbidStr + "' ";
Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor()); Map<String, Object> valList = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
return valList; return valList;
} }
private String getPk_stockorg(String pk_stockorg) throws BusinessException { 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='" Map<String, String> defMap = checkOrgCtrl();
+ pk_stockorg + "' "; if (defMap.isEmpty() || "".equals(defMap.getOrDefault("pmo", ""))) {
String saleorderPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor()); return "";
return saleorderPK; }
} 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() { private Map<String, String> checkOrgCtrl() {
return NCLocator.getInstance().lookup(IUAPQueryBS.class); 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);
}
} }