Browse Source

代码完善

guq 7 years ago
parent
commit
b55286430f

+ 4 - 57
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/ExcelServiceImpl.java

@@ -45,66 +45,13 @@ public class ExcelServiceImpl implements ExcelService{
         Map<String, Object> map = new HashMap<>();
         SXSSFWorkbook workbook = new SXSSFWorkbook();
         DataTemplet dataTemplet = dataTempletMapper.selectByCaller(caller, companyId);
+        //列
         String cols = dataTemplet.getDt_columns();
-      /*  String cols = "[{\"description\":\"物料编号\",\"necessary\":\"true\"},{\"description\":\"物料名称\",\"necessary\":\"true\"},{\"description\":\"物料类型\",\"necessary\":\"true\"},{\"description\":\"仓库编号\",\"necessary\":\"true\"},{\"description\":\"仓库名称\",\"necessary\":\"true\"}]";
-        cols = "[{\"description\":\"物料编号\",\"necessary\":\"true\",\"position\":\"main\",\"field\":\"pr_code\",\"codefield\":true}," +
-                "{\"description\":\"物料名称\",\"necessary\":\"true\",\"position\":\"main\",\"field\":\"pr_detail\",\"codefield\":false}," +
-                "{\"description\":\"更新时间\",\"necessary\":\"false\",\"position\":\"main\",\"field\":\"updateTime\",\"codefield\":false,\"type\":\"date\"}," +
-                "{\"description\":\"规格\",\"necessary\":\"true\",\"position\":\"main\",\"field\":\"pr_spec\",\"codefield\":false}," +
-                "{\"description\":\"类型\",\"necessary\":\"true\",\"position\":\"main\",\"field\":\"pr_kind\",\"codefield\":false}," +
-                "{\"description\":\"型号\",\"necessary\":\"false\",\"position\":\"main\",\"field\":\"pr_orispeccode\",\"codefield\":false}" +
-                ",{\"description\":\"品牌\",\"necessary\":\"false\",\"position\":\"main\",\"field\":\"pr_brand\",\"codefield\":false}," +
-                "{\"description\":\"单位\",\"necessary\":\"true\",\"position\":\"main\",\"field\":\"pr_unit\",\"codefield\":false}," +
-                "{\"description\":\"仓库编号\",\"necessary\":\"false\",\"position\":\"main\",\"field\":\"pr_whcode\",\"codefield\":false}," +
-                "{\"description\":\"仓库名称\",\"necessary\":\"false\",\"position\":\"main\",\"field\":\"pr_whname\",\"codefield\":false}," +
-                "{\"description\":\"最新采购单价\",\"necessary\":\"false\",\"position\":\"main\",\"field\":\"pr_purcprice\",\"codefield\":false}" +
-                ",{\"description\":\"最新出货单价\",\"necessary\":\"false\",\"position\":\"main\",\"field\":\"pr_saleprice\",\"codefield\":false}," +
-                "{\"description\":\"替代料仓库编号\",\"necessary\":\"true\",\"position\":\"detail\",\"field\":\"pd_whcode\",\"codefield\":false}," +
-                "{\"description\":\"替代料仓库名称\",\"necessary\":\"false\",\"position\":\"detail\",\"field\":\"pd_whname\",\"codefield\":false}," +
-                "{\"description\":\"期初数量\",\"necessary\":\"true\",\"position\":\"detail\",\"field\":\"pd_num\",\"codefield\":false}," +
-                "{\"description\":\"单位成本\",\"necessary\":\"true\",\"position\":\"detail\",\"field\":\"pd_price\",\"codefield\":false}]";
-      */
         JSONArray array = (JSONArray) JSONArray.parse(cols);
+        //模板数据
         String remark = dataTemplet.getDt_description();
-        //String exampledata = dataTemplet.getDt_exampledata();
-        //JSONArray datas = (JSONArray) JSONArray.parse(exampledata);
-        JSONArray datas = new JSONArray();
-        JSONObject data = new JSONObject();
-        data.put("物料编号", "code1");
-        data.put("物料名称", "name1");
-        data.put("规格", "spec1");
-        data.put("型号", "kind1");
-        data.put("品牌", "brand1");
-        data.put("更新时间", "2018-09-08");
-        data.put("单位", "nuit1");
-        data.put("类型", "leixin1");
-        data.put("仓库编号", "whcode1");
-        data.put("仓库名称", "whname1");
-        data.put("最新采购单价", "100");
-        data.put("最新出货单价", "22");
-        data.put("替代料仓库编号", "tcode1");
-        data.put("替代料仓库名称", "tname1");
-        data.put("期初数量", "22");
-        data.put("单位成本", "22");
-        datas.add(data);
-        JSONObject data2 = new JSONObject();
-        data2.put("物料编号", "code2");
-        data2.put("物料名称", "name2");
-        data2.put("规格", "spec2");
-        data2.put("型号", "kind2");
-        data2.put("品牌", "brand2");
-        data2.put("单位", "nuit2");
-        data2.put("类型", "leixin2");
-        data2.put("仓库编号", "whcode2");
-        data2.put("仓库名称", "whname2");
-        data2.put("最新采购单价", "100");
-        data2.put("最新出货单价", "22");
-        data2.put("替代料仓库编号", "tcode2");
-        data2.put("替代料仓库名称", "tname2");
-        data2.put("期初数量", "22");
-        data2.put("单位成本", "22");
-        datas.add(data2);
-        System.out.println(datas.toJSONString());
+        String exampledata = dataTemplet.getDt_exampledata();
+        JSONArray datas = (JSONArray) JSONArray.parse(exampledata);
         createWorkbook(workbook, 1, array, datas, remark);
         map.put("workbook", workbook);
         map.put("title", dataTemplet.getDt_title());

+ 1 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/DataImportMapper.java

@@ -14,7 +14,7 @@ public interface DataImportMapper {
 
     List<DataImportDetail> selectDataById(Integer id);
 
-    DataImportDetail selectProductBycode(@Param("code") String code, @Param("id") int id, @Param("companyid") Long companyId);
+    DataImportDetail selectMainBycode(@Param("code") String code, @Param("id") int id, @Param("companyid") Long companyId);
 
     void updateDataImport(Integer id);
 

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

@@ -549,7 +549,7 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
                 List<ProductDetail> productDetails = new ArrayList<>();
                 int i = getMapper().validateCodeWhenInsert(code, companyId);
                 List<DataImportDetail> data = datas.get(code);
-                DataImportDetail main = dataImportMapper.selectProductBycode(code, id, companyId);
+                DataImportDetail main = dataImportMapper.selectMainBycode(code, id, companyId);
                 Product product = JSONObject.parseObject(main.getDd_maindata(), Product.class);
                 Warehouse warehouse = null;
                 //验证仓库
@@ -563,6 +563,17 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
                     product.setPr_status(Status.OPEN.getDisplay());
                     product.setPr_statuscode(Status.OPEN.name());
                 }
+                //编号不存在
+                if (i == 0) {
+                    product.setId(0l);
+                    //编号存在、需要更新
+                } else if (update){
+                    Long pr_id = getMapper().selectIdByCode(code, companyId);
+                    product.setId(pr_id);
+                    //编号存在、不需要处理
+                } else {
+                    continue;
+                }
                 //添加从表
                 if (data.size() > 0) {
                     detno = 1;
@@ -584,17 +595,7 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
                         }
                     }
                 }
-                //编号不存在
-                if (i == 0) {
-                    product.setId(0l);
-                //编号存在、需要更新
-                } else if (update){
-                    Long pr_id = getMapper().selectIdByCode(code, companyId);
-                    product.setId(pr_id);
-                //编号存在、不需要处理
-                } else {
-                    continue;
-                }
+
                 listDTO.setMain(product);
                 listDTO.setItems(productDetails);
                 list.add(listDTO);

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/DataImportMapper.xml

@@ -91,7 +91,7 @@
   where dd_diid = #{id}
 </select>
 
-  <select id="selectProductBycode" resultMap="DetailMap">
+  <select id="selectMainBycode" resultMap="DetailMap">
     select * from  data_importdetail
     where dd_codevalue = #{code} and dd_diid=#{id} and ifnull(dd_success,0)=0 and dd_maindata is not null and companyid=#{companyid}
   </select>

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/ProductMapper.xml

@@ -902,7 +902,7 @@
         DELETE FROM PRODIODETAIL WHERE PD_PIID IN (SELECT PI_ID FROM PRODINOUT WHERE PI_INOUTNO=#{code} AND PRODINOUT.COMPANYID = #{companyId}) AND PRODIODETAIL.COMPANYID = #{companyId}
     </delete>
 
-    <select id="selectIdByCode" parameterType="long">
+    <select id="selectIdByCode" resultType="long">
         select pr_id from product where pr_code=#{code} and companyId=#{companyId}
     </select>
 </mapper>