Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
983cc1ecb8
|
@ -134,7 +134,7 @@ public class SaleOutResource extends NCCPubRestResource {
|
||||||
paramMapList.add(paramMap);
|
paramMapList.add(paramMap);
|
||||||
//锐制需要修改保存时走签字
|
//锐制需要修改保存时走签字
|
||||||
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
||||||
if("gaoning".equals(userCode)){
|
if("rzmes".equals(userCode)){
|
||||||
// 修改并签字--事务一致
|
// 修改并签字--事务一致
|
||||||
SaleOutVO[] signVOs =NCLocator.getInstance().lookup(IAPISaleOutMaintain.class).updateAndSign(paramMapList);
|
SaleOutVO[] signVOs =NCLocator.getInstance().lookup(IAPISaleOutMaintain.class).updateAndSign(paramMapList);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
package nc.bs.mmpac.wr.bp;
|
||||||
|
|
||||||
|
//import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import nc.bs.framework.common.InvocationInfoProxy;
|
||||||
|
import nc.bs.mmpac.wr.rule.prodin.WrProdInSetInStockOrgRule;
|
||||||
|
import nc.bs.mmpac.wr.rule.prodin.WrProdInSetWarehouseRule;
|
||||||
|
import nc.bs.uif2.validation.ValidationException;
|
||||||
|
import nc.bs.uif2.validation.ValidationFailure;
|
||||||
|
import nc.impl.pubapp.pattern.data.vo.VOQuery;
|
||||||
|
import nc.impl.pubapp.pattern.rule.IRule;
|
||||||
|
import nc.util.mmf.framework.base.MMNumberUtil;
|
||||||
|
import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
|
import nc.vo.mmpac.wr.consts.WrptLangConst;
|
||||||
|
import nc.vo.mmpac.wr.entity.AggWrVO;
|
||||||
|
import nc.vo.mmpac.wr.entity.WrItemVO;
|
||||||
|
import nc.vo.mmpac.wr.entity.WrQualityVO;
|
||||||
|
import nc.vo.mmpac.wr.entity.WrTransTypeVO;
|
||||||
|
import nc.vo.mmpac.wr.enumeration.WrBillStatusEnum;
|
||||||
|
import nc.vo.mmpac.wr.enumeration.WrQualityProcessMethodEnum;
|
||||||
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
|
import nc.vo.pubapp.pattern.pub.SqlBuilder;
|
||||||
|
|
||||||
|
public class WrAutoProdInFilterBP {
|
||||||
|
|
||||||
|
|
||||||
|
public AggWrVO[] filter(AggWrVO[] aggWrVOs) {
|
||||||
|
// 过滤交易类型是否勾选了自动入库
|
||||||
|
List<String> transIDs = new ArrayList<String>();
|
||||||
|
for (AggWrVO aggvo : aggWrVOs) {
|
||||||
|
if (!WrBillStatusEnum.COMMITE.equalsValue(aggvo.getParentVO().getFbillstatus())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (MMValueCheck.isEmpty(transIDs) || !transIDs.contains(aggvo.getParentVO().getVtrantypeid())) {
|
||||||
|
transIDs.add(aggvo.getParentVO().getVtrantypeid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, Boolean> isAutoInMap = this.getIsAutoProdIn(transIDs);
|
||||||
|
if (MMValueCheck.isEmpty(isAutoInMap)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 入库过滤规则
|
||||||
|
List<AggWrVO> inVOs = new ArrayList<AggWrVO>();
|
||||||
|
for (AggWrVO aggvo : aggWrVOs) {
|
||||||
|
//审批通过
|
||||||
|
if (!WrBillStatusEnum.COMMITE.equalsValue(aggvo.getParentVO().getFbillstatus())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//交易类型:自动入库
|
||||||
|
String transID = aggvo.getParentVO().getVtrantypeid();
|
||||||
|
if (!isAutoInMap.containsKey(transID) ||! MMValueCheck.isTrue(isAutoInMap.get(transID))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//过滤类型为合格入库的
|
||||||
|
if(MMValueCheck.isEmpty(aggvo.getChildrenVO())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<WrItemVO> initems=new ArrayList<WrItemVO>();
|
||||||
|
for(WrItemVO item:aggvo.getChildrenVO()) {
|
||||||
|
if(MMValueCheck.isEmpty(item.getQualityvos())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<WrQualityVO> inqvos=new ArrayList<WrQualityVO>();
|
||||||
|
for(WrQualityVO qvo:item.getQualityvos()) {
|
||||||
|
if(WrQualityProcessMethodEnum.PRODIN.equalsValue( qvo.getFgprocessmethod())&&MMNumberUtil.isGtZero(qvo.getNgnum())) {
|
||||||
|
WrQualityVO inqvo=(WrQualityVO)qvo.clone();
|
||||||
|
inqvo.setNgtoinnum(inqvo.getNgnum());
|
||||||
|
inqvo.setNgtoinastnum(inqvo.getNgastnum());
|
||||||
|
inqvos.add(inqvo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(MMValueCheck.isEmpty(inqvos)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
WrItemVO initem=(WrItemVO)item.clone();
|
||||||
|
initem.setQualityvos(inqvos.toArray(new WrQualityVO[0]));
|
||||||
|
initems.add(initem);
|
||||||
|
}
|
||||||
|
if(MMValueCheck.isEmpty(initems)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
AggWrVO agg=(AggWrVO)aggvo.clone();
|
||||||
|
agg.setChildren(WrItemVO.class, initems.toArray(new WrItemVO[0]));
|
||||||
|
inVOs.add(agg);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (MMValueCheck.isEmpty(inVOs)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
AggWrVO[] filterVOs = inVOs.toArray(new AggWrVO[0]);
|
||||||
|
// 设置库存组织和仓库
|
||||||
|
IRule<AggWrVO> wrProdInSetInStockOrgRule = new WrProdInSetInStockOrgRule();
|
||||||
|
wrProdInSetInStockOrgRule.process(filterVOs);
|
||||||
|
//2025年5月30日08点45分 --外部系统推送接口时填了仓库,此处不清空
|
||||||
|
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
||||||
|
if("rzmes".equals(userCode)||"MES".equals(userCode)){
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// 设置入库仓库规则
|
||||||
|
IRule<AggWrVO> wrProdInSetWarehouseRule = new WrProdInSetWarehouseRule();
|
||||||
|
wrProdInSetWarehouseRule.process(filterVOs);
|
||||||
|
}
|
||||||
|
//过滤掉入库仓库为空的数据
|
||||||
|
List<AggWrVO>result=new ArrayList<AggWrVO>();
|
||||||
|
for(AggWrVO agg:filterVOs) {
|
||||||
|
List<WrItemVO> items=new ArrayList<WrItemVO>();
|
||||||
|
for(WrItemVO item:agg.getChildrenVO()) {
|
||||||
|
List<WrQualityVO> qvos=new ArrayList<WrQualityVO>();
|
||||||
|
for(WrQualityVO qvo:item.getQualityvos()) {
|
||||||
|
if(MMValueCheck.isNotEmpty(qvo.getCgwarehouseid())) {
|
||||||
|
qvos.add(qvo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(MMValueCheck.isNotEmpty(qvos)) {
|
||||||
|
item.setQualityvos(qvos.toArray(new WrQualityVO[0]));
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(MMValueCheck.isNotEmpty(items)) {
|
||||||
|
agg.setChildren(WrItemVO.class, items.toArray(new WrItemVO[0]));
|
||||||
|
result.add(agg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(MMValueCheck.isEmpty(result)) {
|
||||||
|
/** 生产报告审批成功,倒冲成功,自动入库失败!**/
|
||||||
|
ValidationFailure validationFailure = new ValidationFailure(WrptLangConst.ERR_Audit_ProdIn());
|
||||||
|
ExceptionUtils.wrappException(new ValidationException(Arrays.asList(validationFailure)));
|
||||||
|
}
|
||||||
|
return result.toArray(new AggWrVO[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<String, Boolean> getIsAutoProdIn(List<String> ctrantypeids) {
|
||||||
|
if (MMValueCheck.isEmpty(ctrantypeids)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
SqlBuilder whereSql = new SqlBuilder();
|
||||||
|
whereSql.append(" and ");
|
||||||
|
whereSql.append(WrTransTypeVO.CTRANTYPEID, ctrantypeids.toArray(new String[0]));
|
||||||
|
VOQuery<WrTransTypeVO> voQuery = new VOQuery<WrTransTypeVO>(WrTransTypeVO.class,
|
||||||
|
new String[] { WrTransTypeVO.CTRANTYPEID, WrTransTypeVO.BCREATEPRODIN });
|
||||||
|
WrTransTypeVO[] queryResults = voQuery.query(whereSql.toString(), null);
|
||||||
|
if (MMValueCheck.isEmpty(queryResults)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Map<String, Boolean> result = new HashMap<String, Boolean>();
|
||||||
|
for (WrTransTypeVO queryResult : queryResults) {
|
||||||
|
result.put(queryResult.getCtrantypeid(), MMValueCheck.isTrue(queryResult.getBcreateprodin()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
package nc.bs.mmpac.wr.rule.prodin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import nc.bs.framework.common.InvocationInfoProxy;
|
||||||
|
import nc.bs.mmpac.wr.adapter.WrptServiceAdapter;
|
||||||
|
import nc.impl.pubapp.pattern.rule.IRule;
|
||||||
|
import nc.util.mmf.busi.service.OrgUnitPubService;
|
||||||
|
import nc.util.mmf.framework.base.MMValueCheck;
|
||||||
|
import nc.vo.mmpac.wr.entity.AggWrVO;
|
||||||
|
import nc.vo.mmpac.wr.entity.WrItemVO;
|
||||||
|
import nc.vo.mmpac.wr.entity.WrQualityVO;
|
||||||
|
import nc.vo.org.StockConsignVO;
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
|
|
||||||
|
public class WrProdInSetInStockOrgRule implements IRule<AggWrVO> {
|
||||||
|
@Override
|
||||||
|
public void process(AggWrVO[] vos) {
|
||||||
|
|
||||||
|
// 判空
|
||||||
|
if (MMValueCheck.isEmpty(vos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取得完工入库委托关系
|
||||||
|
Map<String, String> inStockMap = new HashMap<String, String>();
|
||||||
|
try {
|
||||||
|
inStockMap = this.getInStockOrg(vos);
|
||||||
|
}
|
||||||
|
catch (BusinessException e) {
|
||||||
|
ExceptionUtils.wrappException(e);
|
||||||
|
}
|
||||||
|
List<String> orgIds = new ArrayList<String>();
|
||||||
|
for (AggWrVO aggVO : vos) {
|
||||||
|
for (WrItemVO wrItemVO : (WrItemVO[]) aggVO.getChildren(WrItemVO.class)) {
|
||||||
|
String org = inStockMap.get(wrItemVO.getPk_org() + wrItemVO.getCbmaterialvid());
|
||||||
|
orgIds.add(org);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, String> map = new HashMap<String,String>();
|
||||||
|
if(MMValueCheck.isNotEmpty(orgIds)) {
|
||||||
|
try {
|
||||||
|
map = OrgUnitPubService.getNewVIDSByOrgIDS(orgIds.toArray(new String[0]));
|
||||||
|
}catch (BusinessException e) {
|
||||||
|
ExceptionUtils.wrappException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (AggWrVO aggVO : vos) {
|
||||||
|
|
||||||
|
for (WrItemVO wrItemVO : (WrItemVO[]) aggVO.getChildren(WrItemVO.class)) {
|
||||||
|
|
||||||
|
String org = inStockMap.get(wrItemVO.getPk_org() + wrItemVO.getCbmaterialvid());
|
||||||
|
|
||||||
|
if (MMValueCheck.isEmpty(org)) {
|
||||||
|
|
||||||
|
this.setInStockOrg(wrItemVO, wrItemVO.getPk_org(), wrItemVO.getPk_org_v());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String orgV = map.get(org);
|
||||||
|
this.setInStockOrg(wrItemVO, org, orgV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取完工入库委托关系
|
||||||
|
*
|
||||||
|
* @param vos
|
||||||
|
* @return
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
private Map<String, String> getInStockOrg(AggWrVO[] vos) throws BusinessException {
|
||||||
|
|
||||||
|
List<StockConsignVO> scvos = new ArrayList<StockConsignVO>();
|
||||||
|
StockConsignVO scvo = null;
|
||||||
|
|
||||||
|
for (AggWrVO aggVO : vos) {
|
||||||
|
|
||||||
|
for (WrItemVO itemVO : (WrItemVO[]) aggVO.getChildren(WrItemVO.class)) {
|
||||||
|
|
||||||
|
scvo = new StockConsignVO();
|
||||||
|
scvo.setPk_factory(itemVO.getPk_org());
|
||||||
|
scvo.setPk_material(itemVO.getCbmaterialvid());
|
||||||
|
scvos.add(scvo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return WrptServiceAdapter.getInStockConsignPubService().queryStockPkByFactoryPKsAndMaterialPKs(
|
||||||
|
scvos.toArray(new StockConsignVO[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设定入库库存组织
|
||||||
|
*
|
||||||
|
* @param wrItem
|
||||||
|
* @param rOrg
|
||||||
|
* @param rOrgVid
|
||||||
|
*/
|
||||||
|
private void setInStockOrg(WrItemVO wrItemVO, String rOrg, String rOrgVid) {
|
||||||
|
|
||||||
|
// 判空
|
||||||
|
if (MMValueCheck.isEmpty(wrItemVO)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
||||||
|
for (WrQualityVO wrQualityVO : wrItemVO.getQualityvos()) {
|
||||||
|
|
||||||
|
// 设定委外关系库存组织
|
||||||
|
if (!MMValueCheck.isEmpty(rOrg) && !MMValueCheck.isEmpty(rOrgVid)) {
|
||||||
|
|
||||||
|
wrQualityVO.setCgdepositorgid(rOrg);
|
||||||
|
wrQualityVO.setCgdepositorgvid(rOrgVid);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wrQualityVO.setCgdepositorgid(wrItemVO.getPk_org());
|
||||||
|
wrQualityVO.setCgdepositorgvid(wrItemVO.getPk_org_v());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//2025年5月30日08点45分 --外部系统推送接口时填了仓库,此处不清空
|
||||||
|
if("rzmes".equals(userCode)||"MES".equals(userCode)){
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// 清空入库仓库
|
||||||
|
wrQualityVO.setCgwarehouseid(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue