Commit f3aebddc by liuyang

2024-09-06 物料清单构件重复校验,零件重复覆盖

parent 1c4509c0
......@@ -393,39 +393,63 @@ public class HGSCTools {
}
public static void add(List<HGSC004A> arrayList, String materialId) {
List<HGSC004> results = DaoBase.getInstance().query(HGSC004.QUERY, new HashMap<String,Object>(){
{put("id",materialId);}
});
AssertUtils.isEmpty(results, "物料清单不存在!");
HGSC004 hgsc004 = Hgsc004.getId(materialId);
List<HGSC004A> hgsc004aList = Optional.ofNullable(
list(new HashMap<String,Object>(){{put(HGSC004A.FIELD_material_id,materialId);}})).orElse(new ArrayList<>());
AssertUtils.isEmpty(Collections.singleton(hgsc004), "物料清单不存在,添加失败!");
AssertUtils.isTrue(hgsc004.getMaterialStatus()==2 || hgsc004.getApprovalStatus()==2, "物料清单已提交或已审核,无法添加!");
for (HGSC004A hgsc004a : arrayList){
//HGSC004A hgsc004a = new HGSC004A();
//hgsc004a.fromMap(resultRow);
hgsc004a.setCompanyCode(results.get(0).getCompanyCode());
hgsc004a.setCompanyName(results.get(0).getCompanyName());
hgsc004a.setDepCode(results.get(0).getDepCode());
hgsc004a.setDepName(results.get(0).getDepName());
hgsc004a.setCompanyCode(hgsc004.getCompanyCode());
hgsc004a.setCompanyName(hgsc004.getCompanyName());
hgsc004a.setDepCode(hgsc004.getDepCode());
hgsc004a.setDepName(hgsc004.getDepName());
hgsc004a.setProductCode(hgsc004a.getProjCodePrefix().trim().concat(hgsc004a.getProductCode()));
hgsc004a.setProductName(hgsc004a.getProjNamePrefix().trim().concat(hgsc004a.getProductName()));
if (hgsc004a.getParentProdCode().trim().isEmpty()){
hgsc004a.setParentProdCode(results.get(0).getProjCode());
hgsc004a.setParentProdName(results.get(0).getProjName());
hgsc004a.setMaterialId(results.get(0).getId());
hgsc004a.setParentProdCode(hgsc004.getProjCode());
hgsc004a.setParentProdName(hgsc004.getProjName());
hgsc004a.setMaterialId(hgsc004.getId());
hgsc004a.setLv(3);
}else{
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("companyCode", hgsc004a.getCompanyCode());
paramMap.put("projCode", hgsc004a.getProjCode());
paramMap.put("lv", 3);
paramMap.put("productCode", hgsc004a.getProjCodePrefix().trim().concat(hgsc004a.getParentProdCode()));
List<HGSC004A> hgsc004aList = list(paramMap);
AssertUtils.isEmpty(hgsc004aList, String.format("父节点-产品编号[%s]数据不存在,导入失败!",hgsc004a.getProjCodePrefix().trim().concat(hgsc004a.getParentProdCode())));
hgsc004a.setMaterialId(results.get(0).getId());
/*Map<String,Object> paramMap = new HashMap<>();
paramMap.put(HGSC004A.FIELD_company_code, hgsc004a.getCompanyCode());
paramMap.put(HGSC004A.FIELD_proj_code, hgsc004a.getProjCode());
paramMap.put(HGSC004A.FIELD_lv, 3);
paramMap.put(HGSC004A.FIELD_product_code, hgsc004a.getProjCodePrefix().trim().concat(hgsc004a.getParentProdCode()));*/
/*List<HGSC004A> hgsc004as = hgsc004aList.stream().filter(o ->
o.getProductCode().equals(hgsc004a.getProjCodePrefix().trim().concat(hgsc004a.getParentProdCode()))
&& o.getLv() == 3
&& o.getProjCode().equals(hgsc004a.getProjCode())
&& o.getCompanyCode().equals(hgsc004a.getCompanyCode())
).collect(Collectors.toList());*/
AssertUtils.isEmpty(hgsc004a.getParentProdCode(), String.format("父节点-产品编号[%s]数据不存在,导入失败!",hgsc004a.getProjCodePrefix().trim().concat(hgsc004a.getParentProdCode())));
hgsc004a.setMaterialId(hgsc004.getId());
hgsc004a.setLv(4);
hgsc004a.setParentProdCode(hgsc004a.getProjCodePrefix().trim().concat(hgsc004a.getParentProdCode()));
hgsc004a.setParentProdName(hgsc004a.getProjNamePrefix().trim().concat(hgsc004a.getParentProdName()));
}
checkSaveData(hgsc004a);
addEntity(hgsc004a);
if (hgsc004a.getLv() == 3){
DaoUtils.insert(HGSC004A.INSERT, hgsc004a);
}else {
List<HGSC004A> hgsc004AS= hgsc004aList.stream()
.filter(o -> o.getLv() == 4
&& o.getCompanyCode().equals(hgsc004a.getCompanyCode())
&& o.getProjCode().equals(hgsc004a.getProjCode())
&& o.getParentProdCode().equals(hgsc004a.getParentProdCode())
&& o.getProductId().equals(hgsc004a.getProductId())
&& o.getProductCode().equals(hgsc004a.getProductCode())
).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(hgsc004AS)){
hgsc004AS.get(0).setQuantity(hgsc004a.getQuantity());
hgsc004AS.get(0).setSingleWeight(hgsc004a.getSingleWeight());
hgsc004AS.get(0).setTotalWeight(hgsc004a.getTotalWeight());
DaoUtils.update(HGSC004A.UPDATE, hgsc004a);
}else {
DaoUtils.insert(HGSC004A.INSERT, hgsc004a);
}
}
}
}
......@@ -435,15 +459,12 @@ public class HGSCTools {
/*if(hgsc004a.getLv().intValue() < 4){
hgsc004a.setLv(hgsc004a.getLv() + 1);
}*/
if(hgsc004a.getLv().intValue() == 3){
hgsc004a.setLeaf(2);
}else{
hgsc004a.setLeaf(1);
}
hgsc004a.setProductStatus(HGConstant.ProductStatus.WTJ);
if(hgsc004a.getLv().intValue() == 3){
if(hgsc004a.getLv() == 3){
hgsc004a.setLeaf(2);
hgsc004a.setProductType(ProductTypeEnum.STRUCT.getCode().toString());
}else{
hgsc004a.setLeaf(1);
hgsc004a.setProductType(ProductTypeEnum.PART.getCode().toString());
}
if (hgsc004a.getQuantity().compareTo(BigDecimal.ZERO) == 0){
......@@ -480,7 +501,7 @@ public class HGSCTools {
hgsc004a.setLength(pz005.getLength());
hgsc004a.setWidth(pz005.getWidth());
hgsc004a.setThick(pz005.getThick());
DaoUtils.insert(HGSC004A.INSERT, hgsc004a);
//DaoUtils.insert(HGSC004A.INSERT, hgsc004a);
//主表全部提交时需要有改变状态
/*if(hgsc004.getMaterialStatus().intValue() == HGConstant.MaterialStatus.QBTJ){
hgsc004a.setChangeType(HGConstant.ChangeType.ZJ);
......@@ -504,14 +525,14 @@ public class HGSCTools {
AssertUtils.isTrue(hgsc003.getBlueprintStatus().compareTo(HGConstant.EnablingStatus.TY) == 0,"蓝图已停用不可修改!");
}*/
//为构件的需要验证是否已经存在了,不能重复添加
if(hgsc004a.getLv().intValue() == 3){
if(hgsc004a.getLv() == 3){
Map<String,Object> mapA = new HashMap<>();
mapA.put("materialId",hgsc004a.getMaterialId());
mapA.put("productId",hgsc004a.getProductId());
mapA.put("parentProdCode",hgsc004a.getParentProdCode());
mapA.put("notId",hgsc004a.getId());
List<HGSC004A> hgsc004AList = DaoBase.getInstance().query(HGSC004A.QUERY,mapA);
AssertUtils.isTrue(!org.springframework.util.CollectionUtils.isEmpty(hgsc004AList), "已存在构建"+hgsc004a.getProductCode()+"-"+hgsc004a.getProductName());
mapA.put(HGSC004A.FIELD_material_id,hgsc004a.getMaterialId());
//mapA.put(HGSC004A.FIELD_product_id,hgsc004a.getProductId());
mapA.put(HGSC004A.FIELD_parent_prod_code,hgsc004a.getParentProdCode());
mapA.put(HGSC004A.FIELD_product_code,hgsc004a.getProductCode());
List<HGSC004A> hgsc004AList = list(mapA);
AssertUtils.isTrue(!CollectionUtils.isEmpty(hgsc004AList), String.format("已存在构建%s-%s",hgsc004a.getProductCode(),hgsc004a.getProductName()));
}
AssertUtils.isEmpty(UserSessionUtils.getAccountCode(), "当前用户未绑定公司,无法操作数据,请联系管理员!");
//AssertUtils.isEmpty(UserSessionUtils.getOrgId(), "当前用户未绑定部门,无法操作数据,请联系管理员!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment