适配2312流程生产订单同步自定义项信息导备料计划-张鑫0326
This commit is contained in:
parent
39a1da1f55
commit
70f234684f
|
@ -0,0 +1,51 @@
|
|||
package nc.bs.mmpac.pickm.bp.rule;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.itf.mmpac.pmo.pac0002.IPMOQueryService;
|
||||
import nc.util.mmf.framework.base.MMValueCheck;
|
||||
import nc.vo.mmpac.pickm.entity.AggPickmVO;
|
||||
import nc.vo.mmpac.pickm.entity.PickmItemVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
|
||||
public class PickmFillInfoFormMORule implements IRule<AggPickmVO> {
|
||||
|
||||
@Override
|
||||
public void process(AggPickmVO[] vos) {
|
||||
|
||||
if (MMValueCheck.isEmpty(vos)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
//流程生产订单表体主键
|
||||
Set<String> bmopksSet = new HashSet<>();
|
||||
Arrays.stream(vos).forEach(aggPickmVO -> bmopksSet.add(aggPickmVO.getParentVO().getVsourcemorowid()));
|
||||
IPMOQueryService ipmoQueryService = NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||
Map<String, PMOItemVO> pMOItemVOMap = ipmoQueryService.queryItemBybid(bmopksSet.toArray(new String[0]));
|
||||
|
||||
Arrays.stream(vos).forEach(aggPickmVO -> {
|
||||
//生产订单行主键
|
||||
String vsourcemorowid = aggPickmVO.getParentVO().getVsourcemorowid();
|
||||
PickmItemVO[] children = (PickmItemVO[])aggPickmVO.getChildren(PickmItemVO.class);
|
||||
if(!MMValueCheck.isNotEmpty(children)){
|
||||
return;
|
||||
}
|
||||
for (PickmItemVO pickmItemVO : children) {
|
||||
PMOItemVO pmoItemVO = pMOItemVOMap.get(vsourcemorowid);
|
||||
pickmItemVO.setVbdef5(pmoItemVO.getVdef1());//合同编号
|
||||
pickmItemVO.setVbdef6(pmoItemVO.getVdef2());//合同销售订单号
|
||||
pickmItemVO.setVbdef7(pmoItemVO.getVdef7());//标前项目号
|
||||
}
|
||||
});
|
||||
} catch (BusinessException e) {
|
||||
ExceptionUtils.wrappException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
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.framework.common.NCLocator;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* 流程生成订单保存时验证销售订单累计排产状态,并验收首付款比例
|
||||
* 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;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
public IUAPQueryBS getQueryService() {
|
||||
return NCLocator.getInstance().lookup(IUAPQueryBS.class);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue