guq 7 лет назад
Родитель
Сommit
1270314be5

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

@@ -84,10 +84,11 @@ public class ExcelServiceImpl implements ExcelService{
         di.setDi_toformal(0);
         di.setDi_toformal(0);
         di.setDi_success(0);
         di.setDi_success(0);
         List<Map<String,String>> datas = new ArrayList<Map<String,String>>();
         List<Map<String,String>> datas = new ArrayList<Map<String,String>>();
-        String cols = "[{\"description\":\"物料编号\",\"necessary\":\"true\",\"position\":\"main\",\"field\":\"pr_code\",\"codefield\":true}," +
-                "{\"description\":\"物料名称\",\"necessary\":\"true\",\"position\":\"main\",\"field\":\"pr_detail\",\"codefield\":false},{\"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}]";
+        DataTemplet dataTemplet = dataTempletMapper.selectByCaller(caller, companyId);
+        String cols = dataTemplet.getDt_columns();
+        if (StringUtils.isEmpty(cols)) {
+            throw new BizException(12135, "没有查询到对应的excel配置");
+        }
         //前端列表信息
         //前端列表信息
         List<TempletSet> templetSets = JSONArray.parseArray(cols, TempletSet.class);
         List<TempletSet> templetSets = JSONArray.parseArray(cols, TempletSet.class);
         Map<String, List<TempletSet>> columns = CollectionUtils.groupBy(templetSets, TempletSet::getPosition);
         Map<String, List<TempletSet>> columns = CollectionUtils.groupBy(templetSets, TempletSet::getPosition);

+ 6 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerController.java

@@ -174,4 +174,10 @@ public class CustomerController {
         return Result.success();
         return Result.success();
     }
     }
 
 
+    //导入保存至列表
+    @RequestMapping("/saveToFormal")
+    public Result saveToFormal(Integer id, boolean update) {
+        customerService.saveToFormal(id, update);
+        return Result.success();
+    }
 }
 }

+ 7 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/VendorController.java

@@ -134,4 +134,11 @@ public class VendorController {
         return Result.success();
         return Result.success();
     }
     }
 
 
+    //导入保存至列表
+    @RequestMapping("/saveToFormal")
+    public Result saveToFormal(Integer id, boolean update) {
+        vendorService.saveToFormal(id, update);
+        return Result.success();
+    }
+
 }
 }

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

@@ -37,4 +37,6 @@ public interface CustomerMapper extends CommonBaseMapper<Customer> {
     int validNameAndCodeWhenRelated(Customer customer);
     int validNameAndCodeWhenRelated(Customer customer);
 
 
     List<ComboDTO> getCombo(@Param("id") Long id,@Param("companyId") Long companyId);
     List<ComboDTO> getCombo(@Param("id") Long id,@Param("companyId") Long companyId);
+
+    Long selectIdByCode(@Param("code") String code, @Param("companyId") Long companyId);
 }
 }

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

@@ -31,4 +31,6 @@ public interface VendorMapper extends CommonBaseMapper<Vendor> {
     int validFinish(@Param("id") Long id,@Param("companyId") Long companyId);
     int validFinish(@Param("id") Long id,@Param("companyId") Long companyId);
 
 
     void check(Map<String, Object> map);
     void check(Map<String, Object> map);
+
+    Long selectIdByCode(@Param("code") String code, @Param("companyId") Long companyId);
 }
 }

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

@@ -44,4 +44,6 @@ public interface CustomerService extends CommonBaseService<CustomerMapper, Custo
     PageInfo<CustomerList> getDbfind(PageRequest page, ListReqDTO listReqDTO);
     PageInfo<CustomerList> getDbfind(PageRequest page, ListReqDTO listReqDTO);
 
 
     List<ComboDTO> getAddressCombo(Long id);
     List<ComboDTO> getAddressCombo(Long id);
+
+    void saveToFormal(Integer id, boolean update);
 }
 }

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

@@ -95,4 +95,6 @@ public interface VendorService extends CommonBaseService<VendorMapper, Vendor>{
      * @return
      * @return
      */
      */
     boolean batchDelete(BatchDealBaseDTO baseDTOs);
     boolean batchDelete(BatchDealBaseDTO baseDTOs);
+
+    void saveToFormal(Integer id, boolean update);
 }
 }

+ 69 - 4
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.document.service.impl;
 package com.usoftchina.saas.document.service.impl;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
@@ -11,25 +12,25 @@ import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
+import com.usoftchina.saas.commons.po.DataImportDetail;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.context.BaseContextHolder;
-import com.usoftchina.saas.document.dto.CustomerDTO;
-import com.usoftchina.saas.document.dto.CustomerFormDTO;
-import com.usoftchina.saas.document.dto.CustomeraddressDTO;
-import com.usoftchina.saas.document.dto.CustomercontactDTO;
+import com.usoftchina.saas.document.dto.*;
 import com.usoftchina.saas.document.entities.*;
 import com.usoftchina.saas.document.entities.*;
 import com.usoftchina.saas.document.mapper.*;
 import com.usoftchina.saas.document.mapper.*;
 import com.usoftchina.saas.document.service.CustomerService;
 import com.usoftchina.saas.document.service.CustomerService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.BeanMapper;
+import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.DateUtils;
 import com.usoftchina.saas.utils.DateUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
+import sun.reflect.generics.tree.LongSignature;
 
 
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
@@ -59,6 +60,8 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
     private SubledgerMapper subledgerMapper;
     private SubledgerMapper subledgerMapper;
     @Autowired
     @Autowired
     private CustomerMapper customerMapper;
     private CustomerMapper customerMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
 
 
 
 
     @Override
     @Override
@@ -485,6 +488,68 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         return getMapper().getCombo(id,BaseContextHolder.getCompanyId());
         return getMapper().getCombo(id,BaseContextHolder.getCompanyId());
     }
     }
 
 
+    @Override
+    public void saveToFormal(Integer id, boolean update) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        StringBuilder err = new StringBuilder();
+        List<CustomerFormDTO> list = new ArrayList<>();
+        CustomerFormDTO listDTO = null;
+        List<DataImportDetail> details = dataImportMapper.selectDataById(id);
+        if (!CollectionUtils.isEmpty(details)) {
+            Map<String, List<DataImportDetail>> datas = CollectionUtils.groupBy(details, DataImportDetail::getDd_codevalue);
+            Integer detno = null;
+            for (String code : datas.keySet()) {
+                listDTO = new CustomerFormDTO();
+                List<CustomercontactDTO> details_ = new ArrayList<>();
+                int i = getMapper().validateCodeWhenInsert(code, companyId);
+                List<DataImportDetail> data = datas.get(code);
+                DataImportDetail main = dataImportMapper.selectMainBycode(code, id, companyId);
+                CustomerDTO customerDTO = JSONObject.parseObject(main.getDd_maindata(), CustomerDTO.class);
+                customerDTO.setCu_status(Status.OPEN.getDisplay());
+                customerDTO.setCu_statuscode(Status.OPEN.name());
+                //编号不存在
+                if (i == 0) {
+                    customerDTO.setId(0l);
+                    //编号存在、需要更新
+                } else if (update){
+                    Long cu_id = getMapper().selectIdByCode(code, companyId);
+                    customerDTO.setId(cu_id);
+                    //编号存在、不需要处理
+                } else {
+                    continue;
+                }
+                //添加从表
+                if (data.size() > 0) {
+                    detno = 1;
+                    for (DataImportDetail vendorDetail : data) {
+                        CustomercontactDTO detail = JSONObject.parseObject(vendorDetail.getDd_detaildata(), CustomercontactDTO.class);
+                        if (null != detail) {
+                            detail.setCc_cuid(customerDTO.getId());
+                            detail.setCc_detno(detno);
+                            detno++;
+                            details_.add(detail);
+                        }
+                    }
+                }
+                listDTO.setMain(customerDTO);
+                listDTO.setItems1(details_);
+                listDTO.setItems2(new ArrayList<CustomeraddressDTO>());
+                list.add(listDTO);
+            }
+            if (err.length() > 0) {
+                dataImportMapper.updateDataImportError(err.toString(), id);
+                throw new BizException(12345, err.toString());
+            }
+            for (CustomerFormDTO  dto : list) {
+                saveFormData(dto);
+            }
+            dataImportMapper.updateDataImport(id);
+        }
+    }
+
 
 
     private List<CustomerList> getListByMode(ListReqDTO req) {
     private List<CustomerList> getListByMode(ListReqDTO req) {
         List<CustomerList> list = null;
         List<CustomerList> list = null;

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

@@ -1,8 +1,8 @@
 package com.usoftchina.saas.document.service.impl;
 package com.usoftchina.saas.document.service.impl;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
-import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.api.MessageLogService;
@@ -11,21 +11,22 @@ import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
+import com.usoftchina.saas.commons.po.DataImportDetail;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.dto.ProductListDTO;
 import com.usoftchina.saas.document.dto.VendorDTO;
 import com.usoftchina.saas.document.dto.VendorDTO;
 import com.usoftchina.saas.document.dto.VendorListDTO;
 import com.usoftchina.saas.document.dto.VendorListDTO;
-import com.usoftchina.saas.document.entities.Subledger;
-import com.usoftchina.saas.document.entities.Vendor;
-import com.usoftchina.saas.document.entities.VendorList;
-import com.usoftchina.saas.document.entities.Vendorcontact;
+import com.usoftchina.saas.document.entities.*;
+import com.usoftchina.saas.document.mapper.DataImportMapper;
 import com.usoftchina.saas.document.mapper.SubledgerMapper;
 import com.usoftchina.saas.document.mapper.SubledgerMapper;
 import com.usoftchina.saas.document.mapper.VendorMapper;
 import com.usoftchina.saas.document.mapper.VendorMapper;
 import com.usoftchina.saas.document.mapper.VendorcontactMapper;
 import com.usoftchina.saas.document.mapper.VendorcontactMapper;
 import com.usoftchina.saas.document.service.VendorService;
 import com.usoftchina.saas.document.service.VendorService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.page.PageRequest;
+import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.DateUtils;
 import com.usoftchina.saas.utils.DateUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,6 +54,8 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
     private SubledgerMapper subledgerMapper;
     private SubledgerMapper subledgerMapper;
     @Autowired
     @Autowired
     private VendorMapper vendorMapper;
     private VendorMapper vendorMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
 
 
     @Override
     @Override
     public PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, ListReqDTO listReqDTO) {
     public PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, ListReqDTO listReqDTO) {
@@ -427,6 +430,67 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
         return true;
         return true;
     }
     }
 
 
+    @Override
+    public void saveToFormal(Integer id, boolean update) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        StringBuilder err = new StringBuilder();
+        List<VendorListDTO> list = new ArrayList<>();
+        VendorListDTO listDTO = null;
+        List<DataImportDetail> details = dataImportMapper.selectDataById(id);
+        if (!CollectionUtils.isEmpty(details)) {
+            Map<String, List<DataImportDetail>> datas = CollectionUtils.groupBy(details, DataImportDetail::getDd_codevalue);
+            Integer detno = null;
+            for (String code : datas.keySet()) {
+                listDTO = new VendorListDTO();
+                List<Vendorcontact> details_ = new ArrayList<>();
+                int i = getMapper().validateCodeWhenInsert(code, companyId);
+                List<DataImportDetail> data = datas.get(code);
+                DataImportDetail main = dataImportMapper.selectMainBycode(code, id, companyId);
+                Vendor vendor = JSONObject.parseObject(main.getDd_maindata(), Vendor.class);
+                vendor.setVe_status(Status.OPEN.getDisplay());
+                vendor.setVe_statuscode(Status.OPEN.name());
+                //编号不存在
+                if (i == 0) {
+                    vendor.setId(0l);
+                    //编号存在、需要更新
+                } else if (update){
+                    Long pr_id = getMapper().selectIdByCode(code, companyId);
+                    vendor.setId(pr_id);
+                    //编号存在、不需要处理
+                } else {
+                    continue;
+                }
+                //添加从表
+                if (data.size() > 0) {
+                    detno = 1;
+                    for (DataImportDetail productDetail : data) {
+                        Vendorcontact detail = JSONObject.parseObject(productDetail.getDd_detaildata(), Vendorcontact.class);
+                        if (null != detail) {
+                            detail.setVc_veid(vendor.getId());
+                            detail.setVc_detno(detno);
+                            detno++;
+                            details_.add(detail);
+                        }
+                    }
+                }
+                listDTO.setMain(vendor);
+                listDTO.setItems(details_);
+                list.add(listDTO);
+            }
+            if (err.length() > 0) {
+                dataImportMapper.updateDataImportError(err.toString(), id);
+                throw new BizException(12345, err.toString());
+            }
+            for (VendorListDTO  dto : list) {
+                saveFormData(dto);
+            }
+            dataImportMapper.updateDataImport(id);
+        }
+    }
+
     private List<VendorDTO> getList(ListReqDTO listReqDTO){
     private List<VendorDTO> getList(ListReqDTO listReqDTO){
         Long companyId = BaseContextHolder.getCompanyId();
         Long companyId = BaseContextHolder.getCompanyId();
         String condition = listReqDTO.getFinalCondition();
         String condition = listReqDTO.getFinalCondition();

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

@@ -397,5 +397,8 @@
     SELECT ca_address display,ca_address value FROM customeraddress WHERE ca_cuid=#{id} and COMPANYID=#{companyId} order by ca_id desc
     SELECT ca_address display,ca_address value FROM customeraddress WHERE ca_cuid=#{id} and COMPANYID=#{companyId} order by ca_id desc
   </select>
   </select>
 
 
+  <select id="selectIdByCode" resultType="long">
+    select ve_id from VENDOR where ve_code=#{code} and companyId=#{companyId}
+  </select>
 
 
 </mapper>
 </mapper>

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

@@ -469,5 +469,9 @@
         <parameter property="v_companyid" jdbcType="INTEGER" mode="IN" />
         <parameter property="v_companyid" jdbcType="INTEGER" mode="IN" />
         <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
         <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
     </parameterMap>
     </parameterMap>
+
+    <select id="selectIdByCode" resultType="long">
+        select ve_id from VENDOR where ve_code=#{code} and companyId=#{companyId}
+    </select>
 </mapper>
 </mapper>