Bläddra i källkod

导入物料增加限制

guq 7 år sedan
förälder
incheckning
71a3423398
16 ändrade filer med 101 tillägg och 11 borttagningar
  1. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductbrandMapper.java
  2. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProducttypeMapper.java
  3. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductunitMapper.java
  4. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductbrandService.java
  5. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProducttypeService.java
  6. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductunitService.java
  7. 42 5
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java
  8. 10 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductbrandServiceImpl.java
  9. 10 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProducttypeServiceImpl.java
  10. 10 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductunitServiceImpl.java
  11. 4 0
      applications/document/document-server/src/main/resources/mapper/ProductbrandMapper.xml
  12. 3 0
      applications/document/document-server/src/main/resources/mapper/ProducttypeMapper.xml
  13. 3 0
      applications/document/document-server/src/main/resources/mapper/ProductunitMapper.xml
  14. 2 2
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/ProdInOutMapper.java
  15. 3 2
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java
  16. 2 2
      applications/sale/sale-server/src/main/resources/mapper/ProdInOutMapper.xml

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductbrandMapper.java

@@ -28,4 +28,6 @@ public interface ProductbrandMapper extends CommonBaseMapper<Productbrand> {
     List<Productbrand> selectAll(@Param("companyId") Long companyId);
 
     int getCountFromProduct(@Param("id") Long id, @Param("companyId") Long companyId);
+
+    Productbrand getComboByName(@Param("name") String name, @Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProducttypeMapper.java

@@ -27,4 +27,6 @@ public interface ProducttypeMapper extends CommonBaseMapper<Producttype> {
     List<Producttype> selectAll(@Param("companyId") Long companyId);
 
     int getCountFromProduct(@Param("id") Long id, @Param("companyId") Long companyId);
+
+    Producttype getTypeByName(@Param("name") String name, @Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductunitMapper.java

@@ -27,4 +27,6 @@ public interface ProductunitMapper extends CommonBaseMapper<Productunit> {
     List<Productunit> selectAll(@Param("companyId") Long companyId);
 
     int getCountFromProduct(@Param("id") Long id, @Param("companyId") Long companyId);
+
+    Productunit getComboByName(@Param("name") String name, @Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductbrandService.java

@@ -15,4 +15,6 @@ public interface ProductbrandService extends CommonBaseService<ProductbrandMappe
     List<Productbrand> selectAll();
 
     DocBaseDTO saveData(Productbrand productbrand);
+
+    Productbrand getComboByName(String name);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProducttypeService.java

@@ -15,4 +15,6 @@ public interface ProducttypeService extends CommonBaseService<ProducttypeMapper,
     List<Producttype> selectAll();
 
     DocBaseDTO saveData(Producttype producttype);
+
+    Producttype getTypeByName(String name);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductunitService.java

@@ -15,4 +15,6 @@ public interface ProductunitService extends CommonBaseService<ProductunitMapper,
     List<Productunit> selectAll();
 
     DocBaseDTO saveData(Productunit productunit);
+
+    Productunit getComboByName(String name);
 }

+ 42 - 5
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java

@@ -26,8 +26,7 @@ import com.usoftchina.saas.document.mapper.DataImportMapper;
 import com.usoftchina.saas.document.mapper.ProductDetailMapper;
 import com.usoftchina.saas.document.mapper.ProductMapper;
 import com.usoftchina.saas.document.mapper.WarehouseMapper;
-import com.usoftchina.saas.document.service.ProductService;
-import com.usoftchina.saas.document.service.WarehouseService;
+import com.usoftchina.saas.document.service.*;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.CollectionUtils;
@@ -55,6 +54,12 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     private DataImportMapper dataImportMapper;
     @Autowired
     private WarehouseMapper warehouseMapper;
+    @Autowired
+    private ProductbrandService productbrandService;
+    @Autowired
+    private ProductunitService productunitService;
+    @Autowired
+    private ProducttypeService producttypeService;
 
     @Override
     public PageInfo<ProductDTO> getProductsByCondition(PageRequest page, ListReqDTO listReqDTO) {
@@ -604,6 +609,9 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
         if (!CollectionUtils.isEmpty(details)) {
             Map<String, List<DataImportDetail>> datas = CollectionUtils.groupBy(details, DataImportDetail::getDd_codevalue);
             Integer detno = null;
+            String brand = null;
+            String unit = null;
+            String kind = null;
             for (String code : datas.keySet()) {
                 listDTO = new ProductListDTO();
                 List<ProductDetail> productDetails = new ArrayList<>();
@@ -616,13 +624,42 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
                 if (!StringUtils.isEmpty(product.getPr_whcode())) {
                     warehouse = warehouseMapper.selectWareHouse(product.getPr_whcode(), companyId);
                     if (null == warehouse) {
-                        err.append("物料编号为: " + product.getPr_code() + " 的物料仓库: "+ product.getPr_whname() +" 在系统中不存在,请确认数据是否正确");
+                        err.append("物料编号为: " + product.getPr_code() + " 的物料仓库: "+ product.getPr_whname() +" 在系统中不存在");
                         break;
                     }
                     product.setPr_whid(warehouse.getId());
-                    product.setPr_status(Status.ENABLE.getDisplay());
-                    product.setPr_statuscode(Status.ENABLE.name());
+                    product.setPr_whname(warehouse.getWh_description());
+                }
+                //验证品牌
+                brand = product.getPr_brand();
+                if (!StringUtils.isEmpty(brand)) {
+                    Productbrand pr_brand = productbrandService.getComboByName(brand);
+                    if (null == pr_brand) {
+                        err.append("物料编号为: " + product.getPr_code() + " 的品牌: "+ product.getPr_brand() +" 在系统中不存在");
+                        break;
+                    }
                 }
+                //验证单位
+                unit = product.getPr_unit();
+                if (!StringUtils.isEmpty(unit)) {
+                    Productunit pr_unit = productunitService.getComboByName(unit);
+                    if (null == pr_unit) {
+                        err.append("物料编号为: " + product.getPr_code() + " 的单位: "+ product.getPr_unit() +" 在系统中不存在");
+                        break;
+                    }
+                }
+                //验证类型
+                kind = product.getPr_kind();
+                if (!StringUtils.isEmpty(kind)) {
+                    Producttype pr_kind = producttypeService.getTypeByName(kind);
+                    if (null == pr_kind) {
+                        err.append("物料编号为: " + product.getPr_code() + " 的类型: "+ product.getPr_kind() +" 在系统中不存在");
+                        break;
+                    }
+                }
+                product.setPr_status(Status.ENABLE.getDisplay());
+                product.setPr_statuscode(Status.ENABLE.name());
+
                 //编号不存在
                 if (i == 0) {
                     product.setId(0l);

+ 10 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductbrandServiceImpl.java

@@ -10,6 +10,7 @@ import com.usoftchina.saas.document.entities.Productbrand;
 import com.usoftchina.saas.document.mapper.ProductbrandMapper;
 import com.usoftchina.saas.document.service.ProductbrandService;
 import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -55,6 +56,15 @@ public class ProductbrandServiceImpl extends CommonBaseServiceImpl<ProductbrandM
         return docBaseDTO;
     }
 
+    @Override
+    public Productbrand getComboByName(String name) {
+        if (StringUtils.isEmpty(name)) {
+            return null;
+        }
+        Productbrand brand = productbrandMapper.getComboByName(name, BaseContextHolder.getCompanyId());
+        return brand;
+    }
+
     @Override
     public boolean removeByPrimaryKey(Long id){
         if (id == null || id < 0){

+ 10 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProducttypeServiceImpl.java

@@ -10,6 +10,7 @@ import com.usoftchina.saas.document.entities.Producttype;
 import com.usoftchina.saas.document.mapper.ProducttypeMapper;
 import com.usoftchina.saas.document.service.ProducttypeService;
 import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -57,6 +58,15 @@ public class ProducttypeServiceImpl extends CommonBaseServiceImpl<ProducttypeMap
         return docBaseDTO;
     }
 
+    @Override
+    public Producttype getTypeByName(String name) {
+        if (StringUtils.isEmpty(name)) {
+            return null;
+        }
+        Producttype type = producttypeMapper.getTypeByName(name, BaseContextHolder.getCompanyId());
+        return type;
+    }
+
     /**
      * 删除
      * @param id

+ 10 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductunitServiceImpl.java

@@ -10,6 +10,7 @@ import com.usoftchina.saas.document.entities.Productunit;
 import com.usoftchina.saas.document.mapper.ProductunitMapper;
 import com.usoftchina.saas.document.service.ProductunitService;
 import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -50,6 +51,15 @@ public class ProductunitServiceImpl extends CommonBaseServiceImpl<ProductunitMap
         return docBaseDTO;
     }
 
+    @Override
+    public Productunit getComboByName(String name) {
+        if (StringUtils.isEmpty(name)) {
+            return null;
+        }
+        Productunit unit = getMapper().getComboByName(name, BaseContextHolder.getCompanyId());
+        return unit;
+    }
+
     @Override
     public boolean removeByPrimaryKey(Long id){
         if(id != null && id > 0){

+ 4 - 0
applications/document/document-server/src/main/resources/mapper/ProductbrandMapper.xml

@@ -134,4 +134,8 @@
     <select id="getCountFromProduct" resultType="int">
         SELECT COUNT(*) FROM PRODUCT WHERE PR_BRAND = (SELECT PB_NAME FROM PRODUCTBRAND WHERE PB_ID = #{id}) AND companyId = #{companyId}
     </select>
+
+  <select id="getComboByName" resultMap="BaseResultMap">
+    select * from PRODUCTBRAND where pb_name = #{name} and companyId = #{companyId}
+  </select>
 </mapper>

+ 3 - 0
applications/document/document-server/src/main/resources/mapper/ProducttypeMapper.xml

@@ -133,4 +133,7 @@
     <select id="getCountFromProduct" resultType="int">
         SELECT COUNT(*) FROM PRODUCT WHERE PR_KIND = (SELECT PT_NAME FROM PRODUCTTYPE WHERE PT_ID = #{id}) AND companyId=#{companyId}
     </select>
+  <select id="getTypeByName" resultMap="BaseResultMap">
+    select * from PRODUCTTYPE where pt_name=#{name} and companyId=#{companyId}
+  </select>
 </mapper>

+ 3 - 0
applications/document/document-server/src/main/resources/mapper/ProductunitMapper.xml

@@ -125,4 +125,7 @@
     <select id="getCountFromProduct" resultType="int">
         SELECT COUNT(*) FROM PRODUCT WHERE PR_UNIT = (SELECT PU_NAME FROM PRODUCTUNIT WHERE PU_ID = #{id}) AND companyId = #{companyId}
     </select>
+  <select id="getComboByName" resultMap="BaseResultMap">
+    select * from PRODUCTUNIT where pu_name=#{name} and companyId = #{companyId}
+  </select>
 </mapper>

+ 2 - 2
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/ProdInOutMapper.java

@@ -26,9 +26,9 @@ public interface ProdInOutMapper extends CommonBaseMapper<ProdInOut> {
 
     String selectCodeById(Long pi_id);
 
-    int validateCodeWhenInsert(@Param("code") String code,@Param("pi_class") String pi_class );
+    int validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
 
-    int validateCodeWhenUpdate(@Param("code") String code,@Param("id") Long id );
+    int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long companyId);
 
     String validateUnAudit(Long id);
 

+ 3 - 2
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java

@@ -629,13 +629,14 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         String code = baseDTO.getCode();
         Long id = baseDTO.getId();
         String pi_class = baseDTO.getName();
+        Long companyId = BaseContextHolder.getCompanyId();
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         String billCode = null;
         synchronized (ProdInOutServiceImpl.class) {
-            Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(code,pi_class) :
-                    prodInOutMapper.validateCodeWhenUpdate(code, id);
+            Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(code, companyId) :
+                    prodInOutMapper.validateCodeWhenUpdate(code, id, companyId);
             String caller = "出货单".equals(pi_class) ? BillCodeSeq.SALEOUT.getCaller() : BillCodeSeq.SALEIN.getCaller();
            /* if(pi_class.equals("出货单")){
                 caller = BillCodeSeq.SALEOUT.getCaller();

+ 2 - 2
applications/sale/sale-server/src/main/resources/mapper/ProdInOutMapper.xml

@@ -512,10 +512,10 @@
     select pi_inoutno from prodinout where pi_id=#{id}
   </select>
   <select id="validateCodeWhenInsert"  resultType="int">
-    select count(1) from prodinout where pi_inoutno = #{code} and pi_class = #{pi_class}
+    select count(1) from prodinout where pi_inoutno = #{code} and companyId = #{companyId}
   </select>
   <select id="validateCodeWhenUpdate" resultType="int" >
-    select count(1) from prodinout where pi_inoutno = #{code} and pi_id != #{id}
+    select count(1) from prodinout where pi_inoutno = #{code} and pi_id != #{id} and companyId = #{companyId}
   </select>
   <select id="validateUnAudit" parameterType="long" resultType="java.lang.String">
     select pi_inoutno from prodinout where pi_id = #{id} and IFNULL(pi_statuscode,' ')!='AUDITED'