1 år sedan
förälder
incheckning
9cb9606bb7

+ 72 - 0
platform-service/src/main/java/com/platform/service/merge/impl/LongYanPurchaseOrderMergeServiceImpl.java

@@ -3,6 +3,7 @@ import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.bean.DictVO;
 import com.platform.common.cache.DictCache;
 import com.platform.common.exception.BusinessException;
+import com.platform.common.util.BeanConverterUtil;
 import com.platform.dao.bean.MyPage;
 import com.github.pagehelper.PageHelper;
 import com.platform.dao.dto.longyanpurchaseorder.LongYanPurchaseOrderDTO;
@@ -38,6 +39,77 @@ public class LongYanPurchaseOrderMergeServiceImpl extends BaseServiceImpl<LongYa
 
     @Override
     public void modModelByDTO(LongYanPurchaseOrderMergeDTO model) {
+        List<LongYanPurchaseOrderVO> longYanPurchaseOrders = model.getLongYanPurchaseOrderVOS();
+        List<DictVO> dictVOS = DictCache.getChildren("MERGE_PARAM_JUGMENT");
+        if (longYanPurchaseOrders==null||longYanPurchaseOrders.size()<2){
+            throw new BusinessException("请选择至少两个请购单进行合并!");
+        }
+        LongYanPurchaseOrder first = BeanConverterUtil.copyListProperties(longYanPurchaseOrders,LongYanPurchaseOrder.class).get(0);
+        //计划类型
+        if ("1".equals(dictVOS.get(0).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(first.getType()!=(item.getType())){
+                    throw new BusinessException("您勾选的采购单存在计划类型不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(1).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(!first.getCptcode().equals(item.getCptcode())){
+                    throw new BusinessException("您勾选的采购单存在采购类型不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(2).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(first.getOldOrNew()!=item.getOldOrNew()){
+                    throw new BusinessException("您勾选的采购单存在采购厂区不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(3).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(!first.getPlanGetDate().equals(item.getPlanGetDate())){
+                    throw new BusinessException("您勾选的采购单存在计划到货日期不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(4).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(!first.getRemark().equals(item.getRemark())){
+                    throw new BusinessException("您勾选的采购单存在请购原因不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(5).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(!first.getCbustype().equals(item.getCbustype())){
+                    throw new BusinessException("您勾选的采购单存在业务类型不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(6).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(!first.getCdepcode().equals(item.getCdepcode())){
+                    throw new BusinessException("您勾选的采购单存在申请部门不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(7).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(!first.getNeedDate().equals(item.getNeedDate())){
+                    throw new BusinessException("您勾选的采购单存在需求日期不匹配,请重新选择!");
+                }
+            });
+        }
+        if ("1".equals(dictVOS.get(8).getValue().toString())){
+            longYanPurchaseOrders.forEach(item->{
+                if(!first.getProjectId().equals(item.getProjectId())){
+                    throw new BusinessException("您勾选的采购单存在关联项目不匹配,请重新选择!");
+                }
+            });
+        }
+
         LongYanPurchaseOrder order = new LongYanPurchaseOrder();
         order.setMergeId("");
         Weekend<LongYanPurchaseOrder> weekend = new Weekend<>(LongYanPurchaseOrder.class);