bom接口解决物料翻译错误问题-张鑫0505
This commit is contained in:
parent
c58d29bee8
commit
2b73616ff0
|
@ -15,6 +15,7 @@ import nc.itf.bd.bom.bom0202.IBomBillMaintainService;
|
|||
import nc.itf.bd.bom.bom0202.IBomBillQueryService;
|
||||
import nc.itf.bd.bom.bom0202.IBomBusinessService;
|
||||
import nc.itf.mmf.busi.measure.IMeasesureService;
|
||||
import nc.itf.uif.pub.IUifService;
|
||||
import nc.mmbd.utils.factoryparam.MMBDFactoryParameter;
|
||||
import nc.pubitf.uapbd.IMaterialPubService;
|
||||
import nc.pubitf.uapbd.IMaterialPubService_C;
|
||||
|
@ -113,6 +114,15 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
AggBomVO[] aggVOs = (AggBomVO[]) list.toArray(new AggBomVO[list.size()]);
|
||||
|
||||
BillFieldsCodeToPkUtil.doTranslateVOFields(aggVOs);
|
||||
IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class);
|
||||
for (AggBomVO aggtwo : aggVOs) {
|
||||
BomItemVO[] items = aggtwo.getChildrenVO();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
MaterialVO bankAccSub = (MaterialVO) iUifService.queryByPrimaryKey(MaterialVO.class,
|
||||
items[i].getAttributeValue("cmaterialid").toString());
|
||||
items[i].setAttributeValue("cmaterialvid", bankAccSub.getAttributeValue("pk_source"));
|
||||
}
|
||||
}
|
||||
List<AggBomVO> commitAggvoList = new ArrayList<>();
|
||||
List<AggBomVO> addAggvoList = new ArrayList<>();
|
||||
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
||||
|
@ -138,7 +148,7 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
}
|
||||
|
||||
mapClear();
|
||||
//请求参数状态为审批通过时,自动提交--不设审批流 start
|
||||
// 请求参数状态为审批通过时,自动提交--不设审批流 start
|
||||
AggBomVO[] result = null;
|
||||
if (commitAggvoList.isEmpty() && addAggvoList.isEmpty()) {
|
||||
return ResultMessageUtil.exceptionToJSON("BOM保存失败,不存在单据状态不为【空/自由/审批通过】的数据", "999");
|
||||
|
@ -146,38 +156,40 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
result = service.insertBom((AggBomVO[]) addAggvoList.toArray(new AggBomVO[0]));
|
||||
} else if (!commitAggvoList.isEmpty() && addAggvoList.isEmpty()) {
|
||||
List<AggBomVO> newAggVOList = new ArrayList<>();
|
||||
if("gaoning".equals(userCode)){
|
||||
for(AggBomVO aggvo:commitAggvoList){
|
||||
result = service.insertCommitBomWithParam(new AggBomVO[]{aggvo}, true, true);
|
||||
if ("gaoning".equals(userCode)) {
|
||||
for (AggBomVO aggvo : commitAggvoList) {
|
||||
result = service.insertCommitBomWithParam(new AggBomVO[] { aggvo }, true, true);
|
||||
newAggVOList.add(result[0]);
|
||||
}
|
||||
return ResultMessageUtil.toJSON(newAggVOList.toArray(new AggBomVO[0]), "BOM保存成功");
|
||||
}else if("dlkght".equals(userCode)){
|
||||
for(AggBomVO aggvo:commitAggvoList){
|
||||
} else if ("dlkght".equals(userCode)) {
|
||||
for (AggBomVO aggvo : commitAggvoList) {
|
||||
try {
|
||||
result = service.insertCommitBomWithParam_RequiresNew(new AggBomVO[]{aggvo}, true, true);
|
||||
result = service.insertCommitBomWithParam_RequiresNew(new AggBomVO[] { aggvo }, true, true);
|
||||
newAggVOList.add(result[0]);
|
||||
}catch (Exception e){
|
||||
if(e.getMessage()!=null){
|
||||
if(e.getMessage().length()>100){
|
||||
aggvo.getParent().setAttributeValue("hvdef2",e.getMessage().substring(0,100));
|
||||
}else{
|
||||
aggvo.getParent().setAttributeValue("hvdef2",e.getMessage().substring(0,e.getMessage().length()-1));
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage() != null) {
|
||||
if (e.getMessage().length() > 100) {
|
||||
aggvo.getParent().setAttributeValue("hvdef2", e.getMessage().substring(0, 100));
|
||||
} else {
|
||||
aggvo.getParent().setAttributeValue("hvdef2",
|
||||
e.getMessage().substring(0, e.getMessage().length() - 1));
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Throwable unmarsh = ExceptionUtils.unmarsh(e);
|
||||
aggvo.getParent().setAttributeValue("hvdef2", "异常"+unmarsh.getMessage());
|
||||
aggvo.getParent().setAttributeValue("hvdef2", "异常" + unmarsh.getMessage());
|
||||
}
|
||||
|
||||
newAggVOList.add(aggvo);
|
||||
}
|
||||
}
|
||||
return ResultMessageUtil.toJSON(newAggVOList.toArray(new AggBomVO[0]), "100999","BOM保存提交成功部分成功部分失败",true);
|
||||
return ResultMessageUtil.toJSON(newAggVOList.toArray(new AggBomVO[0]), "100999",
|
||||
"BOM保存提交成功部分成功部分失败", true);
|
||||
}
|
||||
} else {
|
||||
return ResultMessageUtil.exceptionToJSON("BOM保存失败,新增不允许单据状态自由或者空和审批通过同时存在", "999");
|
||||
}
|
||||
//请求参数状态为审批通过时,自动提交--不设审批流 end
|
||||
// 请求参数状态为审批通过时,自动提交--不设审批流 end
|
||||
return ResultMessageUtil.toJSON(result, "BOM保存成功");
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
|
@ -186,10 +198,15 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
|
||||
private void dealWithMaterial(AggBomVO agg) {
|
||||
String hcmaterialvid = (String) agg.getParentVO().getAttributeValue("hcmaterialvid");
|
||||
//物料没启用版本,直接赋值
|
||||
String hcmaterialid = (String) agg.getParentVO().getAttributeValue("hcmaterialid");
|
||||
// 物料没启用版本,直接赋值
|
||||
if (hcmaterialvid.length() == 20) {
|
||||
agg.getParentVO().setAttributeValue("hcmaterialid", hcmaterialvid);
|
||||
}
|
||||
// 物料没启用版本,直接赋值
|
||||
if (hcmaterialid.length() == 20) {
|
||||
agg.getParentVO().setAttributeValue("hcmaterialvid", hcmaterialid);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONString update(List<Map<String, Object>> paramList) {
|
||||
|
@ -223,13 +240,14 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
mapInit(original);
|
||||
|
||||
AggBomVO agg = aggInit(paramMap);
|
||||
//2025年4月11日14点35分 --重新赋值上制单人创建人+默认 --start
|
||||
// 2025年4月11日14点35分 --重新赋值上制单人创建人+默认 --start
|
||||
agg.getParentVO().setAttributeValue("billmaker", original.getParent().getAttributeValue("billmaker"));
|
||||
agg.getParentVO().setAttributeValue("creator", original.getParent().getAttributeValue("creator"));
|
||||
if(bom.get("hbdefault")==null){
|
||||
agg.getParentVO().setAttributeValue("hbdefault", original.getParent().getAttributeValue("hbdefault"));
|
||||
if (bom.get("hbdefault") == null) {
|
||||
agg.getParentVO().setAttributeValue("hbdefault",
|
||||
original.getParent().getAttributeValue("hbdefault"));
|
||||
}
|
||||
//2025年4月11日14点35分 --重新赋值上制单人创建人+默认 --end
|
||||
// 2025年4月11日14点35分 --重新赋值上制单人创建人+默认 --end
|
||||
JSONString checkInfo = requiredCheck(agg);
|
||||
if (checkInfo != null) {
|
||||
return checkInfo;
|
||||
|
@ -240,9 +258,19 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
AggBomVO[] aggVOs = (AggBomVO[]) list.toArray(new AggBomVO[list.size()]);
|
||||
|
||||
BillFieldsCodeToPkUtil.doTranslateVOFields(aggVOs);
|
||||
IUifService iUifService = NCLocator.getInstance().lookup(IUifService.class);
|
||||
for (AggBomVO aggtwo : aggVOs) {
|
||||
BomItemVO[] items = aggtwo.getChildrenVO();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
MaterialVO bankAccSub = (MaterialVO) iUifService.queryByPrimaryKey(MaterialVO.class,
|
||||
items[i].getAttributeValue("cmaterialid").toString());
|
||||
items[i].setAttributeValue("cmaterialvid", bankAccSub.getAttributeValue("pk_source"));
|
||||
}
|
||||
}
|
||||
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
||||
for (AggBomVO agg : aggVOs) {
|
||||
|
||||
// zhangxinah 对物料主键进行翻译
|
||||
dealWithMaterial(agg);
|
||||
dataSupplement(agg, userCode);
|
||||
|
||||
UFBoolean flag = (UFBoolean) agg.getParent().getAttributeValue("hbdefault");
|
||||
|
@ -675,13 +703,13 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
BomVO head = (BomVO) aggBomVO.getParent();
|
||||
if (VersionTypeEnum.AVAILABLE.equalsValue(head.getHfversiontype())
|
||||
&& !head.getCbomid().equals(headvo.getCbomid())) {
|
||||
//sdlizheng --添加独立判断--plm三方越过此校验
|
||||
if ("gaoning".equals(userCode)||"dlkght".equals(userCode)) {
|
||||
// sdlizheng --添加独立判断--plm三方越过此校验
|
||||
if ("gaoning".equals(userCode) || "dlkght".equals(userCode)) {
|
||||
// AggBomVO afterVO = service.canceldefault(aggBomVO);
|
||||
} else {
|
||||
return UFBoolean.TRUE;
|
||||
}
|
||||
//sdlizheng --添加独立判断--plm三方越过此校验
|
||||
// sdlizheng --添加独立判断--plm三方越过此校验
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -730,17 +758,17 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
agg.getParent().setAttributeValue("fbillstatus", Integer.valueOf(-1));
|
||||
agg.getParent().setAttributeValue("hfbomsource", Integer.valueOf(1));
|
||||
agg.getParent().setAttributeValue("hfbomcategory", Integer.valueOf(1));
|
||||
if ("gaoning".equals(userCode)||"dlkght".equals(userCode)) {
|
||||
//sdlizheng 1、对于之前不存在的BOM,新增时:如果是传自由态,不默认且无效,走标准逻辑,如果传的是审批态默认且有效。2025年4月11日16点28分 start
|
||||
if ("gaoning".equals(userCode) || "dlkght".equals(userCode)) {
|
||||
// sdlizheng
|
||||
// 1、对于之前不存在的BOM,新增时:如果是传自由态,不默认且无效,走标准逻辑,如果传的是审批态默认且有效。2025年4月11日16点28分 start
|
||||
if (fbillstatus != null && "1".equals(fbillstatus.toString())) {
|
||||
agg.getParent().setAttributeValue("hfversiontype", Integer.valueOf(1));
|
||||
agg.getParent().setAttributeValue("hbdefault", UFBoolean.TRUE);
|
||||
}
|
||||
//sdlizheng 1、对于之前不存在的BOM,新增时:如果是传自由态,不默认且无效,如果传的是审批态默认且有效。2025年4月11日16点28分 end
|
||||
// sdlizheng 1、对于之前不存在的BOM,新增时:如果是传自由态,不默认且无效,如果传的是审批态默认且有效。2025年4月11日16点28分 end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void materialidSupplement(AggBomVO agg) {
|
||||
|
@ -931,11 +959,11 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
|
||||
hcmaterialvid = ((MaterialVersionVO) ((IMaterialPubService_C) NCLocator.getInstance()
|
||||
.lookup(IMaterialPubService_C.class))
|
||||
.queryMaterialBaseInfoByOidPks(new String[]{hcmaterialoid}, new String[]{"pk_material"})
|
||||
.queryMaterialBaseInfoByOidPks(new String[] { hcmaterialoid }, new String[] { "pk_material" })
|
||||
.get(hcmaterialoid)).toString();
|
||||
}
|
||||
Map<String, MaterialPlanVO> map = queryMaterialPlanInfoByPks(new String[]{hcmaterialvid}, pkorg,
|
||||
new String[]{"fixedahead"});
|
||||
Map<String, MaterialPlanVO> map = queryMaterialPlanInfoByPks(new String[] { hcmaterialvid }, pkorg,
|
||||
new String[] { "fixedahead" });
|
||||
|
||||
UFDouble fixedahead = UFDouble.ZERO_DBL;
|
||||
if (MMValueCheck.isNotEmpty(map) && MMValueCheck.isNotEmpty((SuperVO) map.get(hcmaterialvid))
|
||||
|
@ -1334,11 +1362,11 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
for (BomOutputsVO item : items) {
|
||||
try {
|
||||
materialMap = ((IBomBillQueryService) NCLocator.getInstance().lookup(IBomBillQueryService.class))
|
||||
.queryMaterialInfo(item.getPk_org(), new String[]{item.getCmaterialvid()});
|
||||
.queryMaterialInfo(item.getPk_org(), new String[] { item.getCmaterialvid() });
|
||||
|
||||
Map<String, MeasureVO> measurevoMap = new HashMap<String, MeasureVO>();
|
||||
IMeasesureService service = (IMeasesureService) NCLocator.getInstance().lookup(IMeasesureService.class);
|
||||
measurevoMap.putAll(service.getMeasureInfoMap(new String[]{item.getCmaterialvid()}));
|
||||
measurevoMap.putAll(service.getMeasureInfoMap(new String[] { item.getCmaterialvid() }));
|
||||
if (measurevoMap.containsKey(item.getCmaterialvid())) {
|
||||
item.setVchangerate(((MeasureVO) measurevoMap.get(item.getCmaterialvid())).getVchangeRate());
|
||||
item.setCastunitid(((MeasureVO) measurevoMap.get(item.getCmaterialvid())).getCassMeasures());
|
||||
|
@ -1436,8 +1464,8 @@ public class APIBomBusinessServiceImpl implements IAPIBomBusinessService {
|
|||
Map<String, MaterialVO> materialSourceMap = new HashMap<String, MaterialVO>();
|
||||
try {
|
||||
materialSourceMap = ((IMaterialPubService_C) NCLocator.getInstance().lookup(IMaterialPubService_C.class))
|
||||
.queryMaterialBaseInfoByPks(new String[]{materialVid},
|
||||
new String[]{"pk_source", "graphid", "materialspec", "materialtype"});
|
||||
.queryMaterialBaseInfoByPks(new String[] { materialVid },
|
||||
new String[] { "pk_source", "graphid", "materialspec", "materialtype" });
|
||||
|
||||
} catch (BusinessException e1) {
|
||||
ResultMessageUtil.exceptionToJSON(e1);
|
||||
|
|
Loading…
Reference in New Issue