Kaynağa Gözat

导入代码

guq 7 yıl önce
ebeveyn
işleme
a4784bc8fe
17 değiştirilmiş dosya ile 1638 ekleme ve 0 silme
  1. 101 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImport.java
  2. 110 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImportDetail.java
  3. 80 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataTemplet.java
  4. 72 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/TempletSet.java
  5. 81 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/ExcelController.java
  6. 10 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportDetailMapper.java
  7. 17 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportMapper.java
  8. 9 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataTempletMapper.java
  9. 14 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/ExcelService.java
  10. 484 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/ExcelServiceImpl.java
  11. 83 0
      applications/commons/commons-server/src/main/resources/mapper/DataImportDetailMapper.xml
  12. 83 0
      applications/commons/commons-server/src/main/resources/mapper/DataImportMapper.xml
  13. 17 0
      applications/commons/commons-server/src/main/resources/mapper/DataTempletMapper.xml
  14. 22 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/DataImportMapper.java
  15. 105 0
      applications/document/document-server/src/main/resources/mapper/DataImportMapper.xml
  16. 175 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/ProdHomePageList.java
  17. 175 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/ProdHomePageList.java

+ 101 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImport.java

@@ -0,0 +1,101 @@
+package com.usoftchina.saas.commons.po;
+
+import java.util.Date;
+
+/**
+ * @author: guq
+ * @create: 2018-11-29 15:15
+ **/
+public class DataImport {
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    private Integer di_id;
+
+    private String di_caller;
+
+    private Long companyid;
+
+    private Date di_date;
+
+    private Integer di_count;
+
+    private String di_result;
+
+    private Integer di_success;
+
+    private String di_man;
+
+    private Integer di_toformal;
+
+    public Integer getDi_id() {
+        return di_id;
+    }
+
+    public void setDi_id(Integer di_id) {
+        this.di_id = di_id;
+    }
+
+    public String getDi_caller() {
+        return di_caller;
+    }
+
+    public void setDi_caller(String di_caller) {
+        this.di_caller = di_caller == null ? null : di_caller.trim();
+    }
+
+
+
+    public Date getDi_date() {
+        return di_date;
+    }
+
+    public void setDi_date(Date di_date) {
+        this.di_date = di_date;
+    }
+
+    public Integer getDi_count() {
+        return di_count;
+    }
+
+    public void setDi_count(Integer di_count) {
+        this.di_count = di_count;
+    }
+
+    public String getDi_result() {
+        return di_result;
+    }
+
+    public void setDi_result(String di_result) {
+        this.di_result = di_result == null ? null : di_result.trim();
+    }
+
+    public Integer getDi_success() {
+        return di_success;
+    }
+
+    public void setDi_success(Integer di_success) {
+        this.di_success = di_success;
+    }
+
+    public String getDi_man() {
+        return di_man;
+    }
+
+    public void setDi_man(String di_man) {
+        this.di_man = di_man == null ? null : di_man.trim();
+    }
+
+    public Integer getDi_toformal() {
+        return di_toformal;
+    }
+
+    public void setDi_toformal(Integer di_toformal) {
+        this.di_toformal = di_toformal;
+    }
+}

+ 110 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImportDetail.java

@@ -0,0 +1,110 @@
+package com.usoftchina.saas.commons.po;
+
+/**
+ * @author: guq
+ * @create: 2018-11-29 15:16
+ **/
+public class DataImportDetail {
+
+    private Integer dd_id;
+
+    private String dd_maindata;
+
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    private Integer dd_detno;
+
+    private Integer dd_diid;
+
+    private Integer dd_checked;
+
+    private Integer dd_success;
+
+    private Integer dd_toformal;
+
+    private Long companyid;
+
+    private String dd_detaildata;
+
+    private String dd_codevalue;
+
+    public Integer getDd_id() {
+        return dd_id;
+    }
+
+    public void setDd_id(Integer dd_id) {
+        this.dd_id = dd_id;
+    }
+
+    public String getDd_maindata() {
+        return dd_maindata;
+    }
+
+    public void setDd_maindata(String dd_maindata) {
+        this.dd_maindata = dd_maindata == null ? null : dd_maindata.trim();
+    }
+
+    public Integer getDd_detno() {
+        return dd_detno;
+    }
+
+    public void setDd_detno(Integer dd_detno) {
+        this.dd_detno = dd_detno;
+    }
+
+    public Integer getDd_diid() {
+        return dd_diid;
+    }
+
+    public void setDd_diid(Integer dd_diid) {
+        this.dd_diid = dd_diid;
+    }
+
+    public Integer getDd_checked() {
+        return dd_checked;
+    }
+
+    public void setDd_checked(Integer dd_checked) {
+        this.dd_checked = dd_checked;
+    }
+
+    public Integer getDd_success() {
+        return dd_success;
+    }
+
+    public void setDd_success(Integer dd_success) {
+        this.dd_success = dd_success;
+    }
+
+    public Integer getDd_toformal() {
+        return dd_toformal;
+    }
+
+    public void setDd_toformal(Integer dd_toformal) {
+        this.dd_toformal = dd_toformal;
+    }
+
+
+    public String getDd_detaildata() {
+        return dd_detaildata;
+    }
+
+    public void setDd_detaildata(String dd_detaildata) {
+        this.dd_detaildata = dd_detaildata == null ? null : dd_detaildata.trim();
+    }
+
+    public String getDd_codevalue() {
+        return dd_codevalue;
+    }
+
+    public void setDd_codevalue(String dd_codevalue) {
+        this.dd_codevalue = dd_codevalue == null ? null : dd_codevalue.trim();
+    }
+
+}

+ 80 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataTemplet.java

@@ -0,0 +1,80 @@
+package com.usoftchina.saas.commons.po;
+
+/**
+ * @author: guq
+ * @create: 2018-11-27 16:20
+ **/
+public class DataTemplet {
+
+    private Integer dt_id;
+
+    private String dt_caller;
+
+    private String dt_description;
+
+    public String getDt_columns() {
+        return dt_columns;
+    }
+
+    public void setDt_columns(String dt_columns) {
+        this.dt_columns = dt_columns;
+    }
+
+    private String dt_title;
+
+    private String dt_columns;
+
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    private String dt_exampledata;
+
+    private Long companyid;
+
+    public Integer getDt_id() {
+        return dt_id;
+    }
+
+    public void setDt_id(Integer dt_id) {
+        this.dt_id = dt_id;
+    }
+
+    public String getDt_caller() {
+        return dt_caller;
+    }
+
+    public void setDt_caller(String dt_caller) {
+        this.dt_caller = dt_caller == null ? null : dt_caller.trim();
+    }
+
+    public String getDt_description() {
+        return dt_description;
+    }
+
+    public void setDt_description(String dt_description) {
+        this.dt_description = dt_description == null ? null : dt_description.trim();
+    }
+
+    public String getDt_title() {
+        return dt_title;
+    }
+
+    public void setDt_title(String dt_title) {
+        this.dt_title = dt_title == null ? null : dt_title.trim();
+    }
+
+    public String getDt_exampledata() {
+        return dt_exampledata;
+    }
+
+    public void setDt_exampledata(String dt_exampledata) {
+        this.dt_exampledata = dt_exampledata == null ? null : dt_exampledata.trim();
+    }
+
+
+}

+ 72 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/TempletSet.java

@@ -0,0 +1,72 @@
+package com.usoftchina.saas.commons.po;
+
+/**
+ * @author: guq
+ * @create: 2018-11-27 20:52
+ **/
+public class TempletSet {
+    private String description;
+    private int width;
+    private String field;
+    private String necessary;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    private String position;
+    private boolean codefield;
+    private String type;
+
+    public boolean isCodefield() {
+        return codefield;
+    }
+
+    public void setCodefield(boolean codefield) {
+        this.codefield = codefield;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public String getField() {
+        return field;
+    }
+
+    public void setField(String field) {
+        this.field = field;
+    }
+
+    public String getNecessary() {
+        return necessary;
+    }
+
+    public void setNecessary(String necessary) {
+        this.necessary = necessary;
+    }
+
+    public String getPosition() {
+        return position;
+    }
+
+    public void setPosition(String position) {
+        this.position = position;
+    }
+}

+ 81 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/ExcelController.java

@@ -0,0 +1,81 @@
+package com.usoftchina.saas.commons.controller;
+
+import com.usoftchina.saas.auth.client.annotation.IgnoreAuth;
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.service.ExcelService;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.util.Map;
+
+/**导入模板下载、解析
+ * @author: guq
+ * @create: 2018-11-26 11:43
+ **/
+@RestController
+@RequestMapping("/excel")
+public class ExcelController {
+
+    @Autowired
+    private ExcelService excelService;
+
+    @RequestMapping("/import/templet")
+    public void CreateTemplet(@RequestParam("caller") String caller, HttpServletResponse response) throws IOException {
+        Map<String, Object> map = excelService.CreateTemplet(caller);
+        SXSSFWorkbook workbook = (SXSSFWorkbook)map.get("workbook");
+        String title = map.get("title").toString();
+        String filename = URLEncoder.encode(title + ".xlsx", "UTF-8");
+        response.setContentType("application/vnd.ms-excel");
+        response.setHeader("Content-Disposition", "attachment;filename=" + filename);
+        OutputStream out;
+        out = response.getOutputStream();
+        workbook.write(out);
+        out.close();
+    }
+
+    @PostMapping(value = "/import/parse", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    public Result ParseTemplet(@RequestParam("caller") String caller, @RequestPart(value = "file") MultipartFile file) throws IOException {
+        InputStream is = null;
+        Workbook wb = null;
+        Integer keyvalue = null;
+        long size = file.getSize();
+        if (size > 104857600) {
+            return Result.error(new String(("{error: '文件过大', size:" + size + "}").getBytes("utf-8"), "iso8859-1"));
+        } else {
+            excelService.clearBefore(caller);
+            String ft = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
+            is = file.getInputStream();
+            if (ft.equals("xlsx")) {
+                wb = new XSSFWorkbook(is);
+            } else if(ft.equals("xls")){
+                wb = new HSSFWorkbook(is);
+            } else {
+                return Result.error(new String("{error: 'excel文件的格式不太规范,导入失败<hr>可以尝试将文件另存为.xls文件,或将数据选择性粘贴到excel模板,然后导入'}".getBytes("utf-8"),
+                        "iso8859-1"));
+            }
+            keyvalue = excelService.parseTemplet(wb, caller);
+        }
+        return Result.success(keyvalue);
+    }
+
+    @RequestMapping(value = "/test")
+    public Result ParseTemplet(String caller) throws IOException {
+        InputStream is = null;
+        Workbook wb = null;
+        File file = new File("C:\\Users\\guh-pc\\Desktop\\import.xlsx");
+        is = new FileInputStream(file);
+        wb = new XSSFWorkbook(is);
+        excelService.parseTemplet(wb, caller);
+        return Result.success();
+    }
+
+}

+ 10 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportDetailMapper.java

@@ -0,0 +1,10 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.commons.po.DataImportDetail;
+
+public interface DataImportDetailMapper {
+
+    int insertSelective(DataImportDetail record);
+
+    void deleteByIds(String ids);
+}

+ 17 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportMapper.java

@@ -0,0 +1,17 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.commons.po.DataImport;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface DataImportMapper {
+    void deleteByCaller(@Param("caller") String caller, @Param("companyid") Long companyid);
+    int insertSelective(DataImport record);
+
+    void updateErr(@Param("err") String err, @Param("id") Integer id);
+
+    String selectByCaller(@Param("caller") String caller, @Param("companyId") Long companyId);
+
+    void deleteByIds(String ids);
+}

+ 9 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataTempletMapper.java

@@ -0,0 +1,9 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.commons.po.DataTemplet;
+import org.apache.ibatis.annotations.Param;
+
+public interface DataTempletMapper {
+
+    DataTemplet selectByCaller(@Param("caller") String caller, @Param("companyid") Long companyid);
+}

+ 14 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/ExcelService.java

@@ -0,0 +1,14 @@
+package com.usoftchina.saas.commons.service;
+
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+
+import java.util.Map;
+
+public interface ExcelService {
+    Map<String, Object> CreateTemplet(String caller);
+
+    void clearBefore(String caller);
+
+    Integer parseTemplet(Workbook wb, String caller);
+}

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

@@ -0,0 +1,484 @@
+package com.usoftchina.saas.commons.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.usoftchina.saas.commons.dto.ProductBaseDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.mapper.DataImportDetailMapper;
+import com.usoftchina.saas.commons.mapper.DataImportMapper;
+import com.usoftchina.saas.commons.mapper.DataTempletMapper;
+import com.usoftchina.saas.commons.po.*;
+import com.usoftchina.saas.commons.service.ExcelService;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.utils.CollectionUtils;
+import com.usoftchina.saas.utils.StringUtils;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author: guq
+ * @create: 2018-11-26 15:19
+ **/
+@Service
+public class ExcelServiceImpl implements ExcelService{
+
+    @Autowired
+    private DataTempletMapper dataTempletMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
+    @Autowired
+    private DataImportDetailMapper dataImportDetailMapper;
+
+    @Override
+    public Map<String, Object> CreateTemplet(String caller) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        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());
+        createWorkbook(workbook, 1, array, datas, remark);
+        map.put("workbook", workbook);
+        map.put("title", dataTemplet.getDt_title());
+        return map;
+    }
+
+    @Override
+    public void clearBefore(String caller) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        String ids = dataImportMapper.selectByCaller(caller, companyId);
+        if (!StringUtils.isEmpty(ids)) {
+            dataImportDetailMapper.deleteByIds(ids);
+            dataImportMapper.deleteByIds(ids);
+        };
+
+    }
+
+    @Override
+    @Transactional
+    public Integer parseTemplet(Workbook wb, String caller) {
+        if (wb == null || StringUtils.isEmpty(caller)) {
+            throw new BizException(BizExceptionCode.NULL_DATA);
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        DataImport di = new DataImport();
+        di.setCompanyid(companyId);
+        di.setDi_caller(caller);
+        di.setDi_date(new Date());
+        di.setDi_man(BaseContextHolder.getUserName());
+        di.setDi_toformal(0);
+        di.setDi_success(0);
+        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}]";
+        //前端列表信息
+        List<TempletSet> templetSets = JSONArray.parseArray(cols, TempletSet.class);
+        Map<String, List<TempletSet>> columns = CollectionUtils.groupBy(templetSets, TempletSet::getPosition);
+        List<String> positions = SetToList(columns.keySet());
+        String cellData = null;
+        String codeValue = null;
+        //读取默认从第2行开始读取
+        List<String> keys = new ArrayList<>();
+        //获取第一个sheet
+        Sheet sheet = wb.getSheetAt(0);
+        //获取最大行数
+        int rownum = sheet.getPhysicalNumberOfRows();
+        if (rownum < 3) {
+            throw new BizException(12324, "请先填写数据");
+        }
+        //获取第2行
+        Row row = sheet.getRow(1);
+        //获取最大列数
+        int colnum = row.getPhysicalNumberOfCells();
+        String key = null;
+        //添加keys
+        for (int j = 0;j < colnum; j++){
+            key = (String) getCellFormatValue(row.getCell(j));
+            keys.add(key);
+        }
+        //存储数据
+        for (int i = 2; i < rownum; i++) {
+            Map<String,String> map = new LinkedHashMap<String,String>();
+            row = sheet.getRow(i);
+            if(row !=null){
+                for (int j = 0;j < colnum; j++){
+                    cellData = (String) getCellFormatValue(row.getCell(j));
+                    //检测字段必填与否
+                    map.put(keys.get(j), cellData);
+                }
+            }else{
+                break;
+            }
+            datas.add(map);
+        }
+        dataImportMapper.insertSelective(di);
+        Integer keyvalue = di.getDi_id();
+        //数据转换成字段
+        if (!CollectionUtils.isEmpty(datas)) {
+            StringBuilder err = new StringBuilder();
+            JSONArray mains = new JSONArray();
+            JSONArray details = new JSONArray();
+            boolean flag = false;
+            //数据行循环
+            for (int i = 0; i < datas.size(); i++) {
+                Map<String,String> data = datas.get(i);
+                DataImportDetail dd = new DataImportDetail();
+                //界面值
+                String value = null;
+                JSONObject mainData = null;
+                JSONObject detailData = null;
+                dd.setCompanyid(companyId);
+                dd.setDd_diid(keyvalue);
+                //主从表循环
+                for (int j = 0; j < positions.size(); j++) {
+                   String position = positions.get(j);
+                    //标识是否一个主表的数据
+                   boolean difference = true;
+                    //依据主从表分类
+                   if ("main".equals(position)) {
+                       List<TempletSet> main = columns.get(position);
+                       for (TempletSet set : main) {
+                           //取excel值
+                           if ("true".equals(set.getNecessary())) {
+                               value = data.get("*" + set.getDescription());
+                           } else {
+                               value = data.get(set.getDescription());
+                           }
+                           //取编号字段
+                           if (set.isCodefield() && !data.get("*" + set.getDescription()).equals("")) {
+                               mainData = new JSONObject();
+                               codeValue = value;
+                               difference = true;
+                           }
+                           //检查是否是同一单
+                           if (set.isCodefield() && data.get("*" + set.getDescription()).equals("")) {
+                               difference = false;
+                               break;
+                           }
+                           //检查主表必填字段是否完整
+                           if (difference) {
+                               dd.setDd_codevalue(codeValue);
+                               if ("true".equals(set.getNecessary()) && data.get("*" + set.getDescription()).equals("")) {
+                                   err.append("第" + (i + 2) + "行 " + set.getDescription() + " 必填字段未填写! ");
+                                   break;
+                               }
+                           }
+                           //检测日期类型是否规范
+                           if ("date".equals(set.getType())) {
+                               flag = validateDateFormat(value);
+                               if (!flag) {
+                                   err.append("第" + (i + 2) + "行 " + set.getDescription() + " 日期格式不正确! ");
+                                   break;
+                               }
+                           }
+                           //插入主表数据
+                           if (null != mainData) {
+                               if ("true".equals(set.getNecessary())) {
+                                   mainData.put(set.getField(), value);
+                               } else {
+                                   mainData.put(set.getField(), value);
+                               }
+                           }
+                       }
+                       //所有主表数据进行分类
+                       if (null != mainData) {
+                           //mains.add(mainData);
+                           dd.setDd_maindata(mainData.toJSONString());
+                       }
+                   } else {
+                       //从表字段
+                       List<TempletSet> detail = columns.get(position);
+                       detailData = new JSONObject();
+                       for (TempletSet set : detail) {
+                           //取excel值
+                           if ("true".equals(set.getNecessary())) {
+                               value = data.get("*" + set.getDescription());
+                           } else {
+                               value = data.get(set.getDescription());
+                           }
+                           //拼从表数据
+                           if ("true".equals(set.getNecessary())) {
+                               detailData.put(set.getField(), data.get("*" + set.getDescription()));
+                           } else {
+                               detailData.put(set.getField(), data.get(set.getDescription()));
+                           }
+                           if ("true".equals(set.getNecessary()) && data.get("*" + set.getDescription()).equals("")) {
+                               err.append("第" + (i + 2) + "行 " + set.getDescription() + " 必填字段未填写! ");
+                               break;
+                           }
+                           //检测日期类型是否规范
+                           if ("date".equals(set.getType())) {
+                               flag = validateDateFormat(value);
+                               if (!flag) {
+                                   err.append("第" + (i + 2) + "行 " + set.getDescription() + " 日期格式不正确! ");
+                                   break;
+                               }
+                           }
+                       }
+                       if (detailData.size() > 0) {
+                           dd.setDd_codevalue(codeValue);
+                           dd.setDd_detaildata(detailData.toJSONString());
+                       }
+                   }
+                }
+                dataImportDetailMapper.insertSelective(dd);
+            }
+            //必填项检查
+            if (err.length() > 0) {
+                dataImportMapper.updateErr(err.toString(), keyvalue);
+                throw new BizException(123456789, err.toString());
+            }
+        }
+        return keyvalue;
+    }
+
+
+
+    private boolean validateDateFormat(String date) {
+        boolean flag = false;
+        if (StringUtils.isEmpty(date)) {
+            return false;
+        }
+        String regEx1 = "[0-9]{8}";
+        String regEX2 = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
+        // 编译正则表达式
+        Pattern pattern1 = Pattern.compile(regEx1);
+        Pattern pattern2 = Pattern.compile(regEX2);
+        Matcher matcher = pattern1.matcher(date);
+        // 字符串是否与正则表达式相匹配
+        flag = matcher.matches();
+        if (!flag) {
+            flag = pattern2.matcher(date).matches();
+        }
+        return flag;
+    }
+
+    //保证先遍历主表
+    private List<String> SetToList(Set<String> sets) {
+        List<String> list = new ArrayList<>();
+        list.add("main");
+        for (String str : sets) {
+            if (!"main".equals(str)) {
+                list.add(str);
+            }
+        }
+        return list;
+    }
+
+    public static Object getCellFormatValue(Cell cell){
+        Object cellValue = null;
+        if(cell!=null){
+            //判断cell类型
+            switch(cell.getCellType()){
+                case Cell.CELL_TYPE_NUMERIC:{
+                    cellValue = String.valueOf(cell.getNumericCellValue());
+                    break;
+                }
+                case Cell.CELL_TYPE_FORMULA:{
+                    //判断cell是否为日期格式
+                    if(DateUtil.isCellDateFormatted(cell)){
+                        //转换为日期格式YYYY-mm-dd
+                        cellValue = cell.getDateCellValue();
+                    }else{
+                        //数字
+                        cellValue = String.valueOf(cell.getNumericCellValue());
+                    }
+                    break;
+                }
+                case Cell.CELL_TYPE_STRING:{
+                    cellValue = cell.getRichStringCellValue().getString();
+                    break;
+                }
+                default:
+                    cellValue = "";
+            }
+        }else{
+            cellValue = "";
+        }
+        return cellValue;
+    }
+
+
+    protected Cell getCell(Sheet sheet, int row, int col) {
+        Row sheetRow = sheet.getRow(row);
+        if (sheetRow == null) {
+            sheetRow = sheet.createRow(row);
+        }
+        Cell cell = sheetRow.getCell(col);
+        if (cell == null) {
+            cell = sheetRow.createCell(col);
+        }
+        return cell;
+    }
+
+    /**
+     * 生成excel工作表
+     *
+     * 数据
+     */
+    private void createWorkbook(SXSSFWorkbook workbook, int sheetIdx, JSONArray cols, JSONArray datas, String remark){
+        Sheet sheet = workbook.createSheet("sheet" + sheetIdx);
+        CellStyle style = getCellStyle(workbook);
+        //sheet.autoSizeColumn((short) 2);
+        sheet.createFreezePane(0, 1);// 固定列
+        Cell cell = null;
+        int rIdx = 0;
+        int cIdx = 0;
+        short width = 0;
+        DataFormat format = workbook.createDataFormat();
+        Row row = null;
+        if (remark != null) {
+            row = sheet.createRow(rIdx);
+            row.setHeightInPoints((short) 100);
+            sheet.setColumnWidth(cIdx, 1000);
+            cell = getCell(sheet, rIdx, cIdx);
+            cell.setCellValue(remark);
+            sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, cols.size() - 1));
+            rIdx++;
+        }
+        row = sheet.createRow(rIdx);
+        row.setHeightInPoints((short) 22);
+        List<String> keys = new ArrayList<String>();
+        if (!CollectionUtils.isEmpty(cols)) {
+            String value = "";
+            //列出主表的列
+            for (int i = 0; i < cols.size(); i++) {
+                JSONObject obj = (JSONObject) cols.get(i);
+                width = (short) (obj.get("width") == null ? 0 : (int)obj.get("width")*35.7);
+                width = width == 0 ? 4000 : width;
+                sheet.setColumnWidth(cIdx, width);
+                sheet.createFreezePane(cols.size() + 1, 2);
+                cell = getCell(sheet, rIdx, cIdx);
+                value = obj.get("description") == null ? value : obj.get("description").toString();
+                if ("true".equals(obj.get("necessary"))) {
+                    value = "*" + value;
+                }
+                cell.setCellValue(value);
+                keys.add(String.valueOf(obj.get("description")));
+                if ("date".equals(obj.get("type"))) {
+                    short df= workbook.createDataFormat().getFormat("yyyy-MM-dd");
+                    style.setDataFormat(df);
+                }
+                cell.setCellStyle(style);
+                cIdx++;
+                value = "";
+            }
+            rIdx++;
+            if (!CollectionUtils.isEmpty(datas)) {
+                for(Object d :datas) {
+                    JSONObject data = (JSONObject)d;
+                    cIdx = 0;
+                    row = sheet.createRow(rIdx);
+                    row.setHeightInPoints((short) 20);
+                    for (String key : keys) {
+                        Cell c = getCell(sheet, rIdx, cIdx);
+                        if (data.get(key) != null) {
+                            String v = String.valueOf(data.get(key));
+                            if ("".equals(v) || "null".equals(v)) {
+                                c.setCellValue(0);
+                            } else if (!v.matches("^-?[0-9]+(.[0-9]+)?")) {
+                                c.setCellValue(v);
+                            } else {
+                                c.setCellValue(Double.parseDouble(v.replace(",", "")));
+                            }
+                        } else {
+                            c.setCellValue("");
+                        }
+                        cIdx++;
+                    }
+                    rIdx++;
+                }
+            }
+        }
+    }
+
+    private CellStyle getCellStyle(SXSSFWorkbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+        style.setFillBackgroundColor((short) 18);
+        style.setFillPattern(FillPatternType.LEAST_DOTS);
+        Font font = workbook.createFont();
+        font.setFontName("仿宋_GB2312");// 字体
+        font.setFontHeightInPoints((short) 12);// 字号
+        font.setColor((short)64);// 颜色
+        style.setFont(font);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setFillForegroundColor(HSSFColor.GREEN.index);
+        style.setFillBackgroundColor(HSSFColor.PALE_BLUE.index);
+        style.setBorderBottom(BorderStyle.MEDIUM);
+        style.setBorderLeft(BorderStyle.MEDIUM);
+        style.setBorderRight(BorderStyle.MEDIUM);
+        style.setBorderTop(BorderStyle.MEDIUM);
+        return style;
+    }
+
+}

+ 83 - 0
applications/commons/commons-server/src/main/resources/mapper/DataImportDetailMapper.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.DataImportDetailMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.commons.po.DataImportDetail" >
+    <id column="dd_id" property="dd_id" jdbcType="INTEGER" />
+    <result column="dd_maindata" property="dd_maindata" jdbcType="VARCHAR" />
+    <result column="dd_detno" property="dd_detno" jdbcType="INTEGER" />
+    <result column="dd_diid" property="dd_diid" jdbcType="INTEGER" />
+    <result column="dd_checked" property="dd_checked" jdbcType="INTEGER" />
+    <result column="dd_success" property="dd_success" jdbcType="INTEGER" />
+    <result column="dd_toformal" property="dd_toformal" jdbcType="INTEGER" />
+    <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="dd_detaildata" property="dd_detaildata" jdbcType="VARCHAR" />
+    <result column="dd_codevalue" property="dd_codevalue" jdbcType="VARCHAR" />
+  </resultMap>
+
+  <delete id="deleteByIds">
+    delete from data_importdetail where dd_diid in (${ids})
+  </delete>
+
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImportDetail" >
+    insert into data_importdetail
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="dd_maindata != null" >
+        dd_maindata,
+      </if>
+      <if test="dd_detno != null" >
+        dd_detno,
+      </if>
+      <if test="dd_diid != null" >
+        dd_diid,
+      </if>
+      <if test="dd_checked != null" >
+        dd_checked,
+      </if>
+      <if test="dd_success != null" >
+        dd_success,
+      </if>
+      <if test="dd_toformal != null" >
+        dd_toformal,
+      </if>
+      <if test="companyid != null" >
+        companyid,
+      </if>
+      <if test="dd_detaildata != null" >
+        dd_detaildata,
+      </if>
+      <if test="dd_codevalue != null" >
+        dd_codevalue,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="dd_maindata != null" >
+        #{dd_maindata,jdbcType=VARCHAR},
+      </if>
+      <if test="dd_detno != null" >
+        #{dd_detno,jdbcType=INTEGER},
+      </if>
+      <if test="dd_diid != null" >
+        #{dd_diid,jdbcType=INTEGER},
+      </if>
+      <if test="dd_checked != null" >
+        #{dd_checked,jdbcType=INTEGER},
+      </if>
+      <if test="dd_success != null" >
+        #{dd_success,jdbcType=INTEGER},
+      </if>
+      <if test="dd_toformal != null" >
+        #{dd_toformal,jdbcType=INTEGER},
+      </if>
+      <if test="companyid != null" >
+        #{companyid,jdbcType=INTEGER},
+      </if>
+      <if test="dd_detaildata != null" >
+        #{dd_detaildata,jdbcType=VARCHAR},
+      </if>
+      <if test="dd_codevalue != null" >
+        #{dd_codevalue,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+
+ </mapper>

+ 83 - 0
applications/commons/commons-server/src/main/resources/mapper/DataImportMapper.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.DataImportMapper" >
+<delete id="deleteByCaller">
+  delete from data_import where di_caller=#{caller} and companyid=#{companyid} and
+  il_toformal=0 and il_result is not null
+</delete>
+  <delete id="deleteByIds">
+    delete from data_import where di_id in (${ids});
+  </delete>
+
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImport" >
+    <selectKey  resultType="java.lang.Integer" keyProperty="di_id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
+    insert into data_import
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        di_caller,
+      </if>
+      <if test="companyid != null" >
+        companyid,
+      </if>
+      <if test="di_date != null" >
+        di_date,
+      </if>
+      <if test="di_count != null" >
+        di_count,
+      </if>
+      <if test="di_result != null" >
+        di_result,
+      </if>
+      <if test="di_success != null" >
+        di_success,
+      </if>
+      <if test="di_man != null" >
+        di_man,
+      </if>
+      <if test="di_toformal != null" >
+        di_toformal,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        #{di_caller,jdbcType=VARCHAR},
+      </if>
+      <if test="companyid != null" >
+        #{companyid,jdbcType=INTEGER},
+      </if>
+      <if test="di_date != null" >
+        #{di_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="di_count != null" >
+        #{di_count,jdbcType=INTEGER},
+      </if>
+      <if test="di_result != null" >
+        #{di_result,jdbcType=VARCHAR},
+      </if>
+      <if test="di_success != null" >
+        #{di_success,jdbcType=INTEGER},
+      </if>
+      <if test="di_man != null" >
+        #{di_man,jdbcType=VARCHAR},
+      </if>
+      <if test="di_toformal != null" >
+        #{di_toformal,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+
+  <update id="updateErr" >
+    update data_import
+    set
+    di_result = #{err},
+    di_success = 0,
+    where di_id = #{id}
+  </update>
+
+
+  <select id="selectByCaller" resultType="string">
+    select group_concat(di_id) from data_import where di_caller=#{caller} and di_toformal=0 and di_result is not null
+  </select>
+</mapper>

+ 17 - 0
applications/commons/commons-server/src/main/resources/mapper/DataTempletMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.DataTempletMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.commons.po.DataTemplet" >
+    <id column="dt_id" property="dt_id" jdbcType="INTEGER" />
+    <result column="dt_caller" property="dt_caller" jdbcType="VARCHAR" />
+    <result column="dt_description" property="dt_description" jdbcType="VARCHAR" />
+    <result column="dt_title" property="dt_title" jdbcType="VARCHAR" />
+    <result column="dt_exampledata" property="dt_exampledata" jdbcType="VARCHAR" />
+    <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="dt_columns" property="dt_columns" jdbcType="VARCHAR"/>
+  </resultMap>
+
+  <select id="selectByCaller" resultMap="BaseResultMap">
+    select * from data_Templet where dt_caller=#{caller} and companyid = #{companyid}
+  </select>
+</mapper>

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

@@ -0,0 +1,22 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.commons.po.DataImport;
+import com.usoftchina.saas.commons.po.DataImportDetail;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface DataImportMapper {
+    void deleteByCaller(@Param("caller") String caller, @Param("companyid") Long companyid);
+    int insertSelective(DataImport record);
+
+    void updateErr(@Param("err") String err, @Param("id") Integer id);
+
+    List<DataImportDetail> selectDataById(Integer id);
+
+    DataImportDetail selectProductBycode(@Param("code") String code, @Param("companyid") Long companyId);
+
+    void updateDataImport(Integer id);
+
+    void updateDataImportError(@Param("err") String err,@Param("id") int id);
+}

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

@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.document.mapper.DataImportMapper" >
+  <resultMap id="DetailMap" type="com.usoftchina.saas.commons.po.DataImportDetail" >
+    <id column="dd_id" property="dd_id" jdbcType="INTEGER" />
+    <result column="dd_maindata" property="dd_maindata" jdbcType="VARCHAR" />
+    <result column="dd_detno" property="dd_detno" jdbcType="INTEGER" />
+    <result column="dd_diid" property="dd_diid" jdbcType="INTEGER" />
+    <result column="dd_checked" property="dd_checked" jdbcType="INTEGER" />
+    <result column="dd_success" property="dd_success" jdbcType="INTEGER" />
+    <result column="dd_toformal" property="dd_toformal" jdbcType="INTEGER" />
+    <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="dd_detaildata" property="dd_detaildata" jdbcType="VARCHAR" />
+    <result column="dd_codevalue" property="dd_codevalue" jdbcType="VARCHAR" />
+  </resultMap>
+
+  <delete id="deleteByCaller">
+  delete from data_import where di_caller=#{caller} and companyid=#{companyid} and
+  il_toformal=0 and il_result is not null
+</delete>
+
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImport" >
+    <selectKey  resultType="java.lang.Integer" keyProperty="di_id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
+    insert into data_import
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        di_caller,
+      </if>
+      <if test="companyid != null" >
+        companyid,
+      </if>
+      <if test="di_date != null" >
+        di_date,
+      </if>
+      <if test="di_count != null" >
+        di_count,
+      </if>
+      <if test="di_result != null" >
+        di_result,
+      </if>
+      <if test="di_success != null" >
+        di_success,
+      </if>
+      <if test="di_man != null" >
+        di_man,
+      </if>
+      <if test="di_toformal != null" >
+        di_toformal,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        #{di_caller,jdbcType=VARCHAR},
+      </if>
+      <if test="companyid != null" >
+        #{companyid,jdbcType=INTEGER},
+      </if>
+      <if test="di_date != null" >
+        #{di_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="di_count != null" >
+        #{di_count,jdbcType=INTEGER},
+      </if>
+      <if test="di_result != null" >
+        #{di_result,jdbcType=VARCHAR},
+      </if>
+      <if test="di_success != null" >
+        #{di_success,jdbcType=INTEGER},
+      </if>
+      <if test="di_man != null" >
+        #{di_man,jdbcType=VARCHAR},
+      </if>
+      <if test="di_toformal != null" >
+        #{di_toformal,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+
+  <update id="updateErr" >
+  update data_import
+  set
+  di_result = #{err},
+  di_success = 0,
+  where di_id = #{id}
+</update>
+
+<select id="selectDataById" resultMap="DetailMap">
+  select * from  data_importdetail
+  where dd_diid = #{id}
+</select>
+
+  <select id="selectProductBycode" resultMap="DetailMap">
+    select * from  data_importdetail
+    where dd_codevalue = #{code} and ifnull(dd_toformal,0) = 0 and ifnull(dd_success,0)=0 and dd_maindata is not null and companyid=#{companyid}
+  </select>
+
+  <update id="updateDataImport" parameterType="integer">
+    update data_import set di_toformal=1,di_success=1  where di_id=#{id}
+  </update>
+  <update id="updateDataImportError">
+    update data_import set di_toformal=1,di_result=#{err} where di_id=#{id}
+  </update>
+</mapper>

+ 175 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/ProdHomePageList.java

@@ -0,0 +1,175 @@
+package com.usoftchina.saas.purchase.po;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author: guq
+ * @create: 2018-12-03 15:40
+ **/
+@Data
+public class ProdHomePageList extends CommonBaseEntity {
+    private String pi_inoutno;
+
+    private String pi_class;
+
+    private Date pi_date;
+
+    private Integer pi_vendid;
+
+    private String pi_vendcode;
+
+    private String pi_vendname;
+
+    private Integer pi_custid;
+
+    private String pi_custcode;
+
+    private String pi_custname;
+
+    private Integer pi_puid;
+
+    private String pi_pucode;
+
+    private Integer pi_said;
+
+    private String pi_sacode;
+
+    private Double pi_total;
+
+    private String pi_status;
+
+    private String pi_statuscode;
+
+    private String pi_printstatus;
+
+    private String pi_printstatuscode;
+
+    private String pi_text1;
+
+    private String pi_text2;
+
+    private String pi_text3;
+
+    private String pi_text4;
+
+    private String pi_text5;
+
+    private String pi_address;
+
+    private Date pi_auditdate;
+
+    private String pi_auditman;
+
+    private String pi_remark;
+
+    private Long pd_piid;
+
+    private String pd_inoutno;
+
+    private String pd_piclass;
+
+    private Integer pd_pdno;
+
+    private String pd_ordercode;
+
+    private Integer pd_orderdetno;
+
+    private Integer pd_prodid;
+
+    private String pd_prodcode;
+
+    private String pd_unit;
+
+    private Double pd_inqty;
+
+    private Double pd_outqty;
+
+    private Double pd_orderprice;
+
+    private Double pd_sendprice;
+
+    private Double pd_price;
+
+    private Double pd_total;
+
+    private Double pd_taxrate;
+
+    private Double pd_netprice;
+
+    private Double pd_nettotal;
+
+    private Integer pd_whid;
+
+    private String pd_whcode;
+
+    private String pd_whname;
+
+    private Integer pd_inwhid;
+
+    private String pd_inwhcode;
+
+    private String pd_inwhname;
+
+    private Integer pd_orderid;
+
+    private Integer pd_sdid;
+
+    private Integer pd_status;
+
+    private String pd_text1;
+
+    private String pd_text2;
+
+    private String pd_text3;
+
+    private String pd_text4;
+
+    private String pd_text5;
+
+    private Integer pd_ym;
+
+    private Double pd_yqty;
+
+    private String pd_remark;
+
+    private Long pd_ioid;
+
+    private String pi_iocode;
+
+    private String pi_prstatus;
+
+    private String pi_prstatuscode;
+
+    //数量字段一致
+    private Double qty;
+
+    //private ProductDTO productDTO;
+    private Long pr_id;
+    private String pr_code;
+    private String pr_detail;
+    private String pr_spec;
+    private String pr_unit;
+    private String pr_kind;
+    private String pr_orispeccode;
+    private long pr_whid;
+    private String pr_whcode;
+    private String pr_whname;
+    private long pr_zxbzs;
+    private long pr_leadtime;
+    private String pr_brand;
+    private String pr_standardprice;
+    private String pr_purcprice;
+    private String pr_saleprice;
+    private long pr_vendid;
+    private String pr_vendname;
+    private String pr_vendcode;
+    private String pr_status;
+    private String pr_statuscode;
+    private String pr_text1;
+    private String pr_text2;
+    private String pr_text3;
+    private String pr_text4;
+}

+ 175 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/ProdHomePageList.java

@@ -0,0 +1,175 @@
+package com.usoftchina.saas.sale.po;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author: guq
+ * @create: 2018-12-03 15:40
+ **/
+@Data
+public class ProdHomePageList extends CommonBaseEntity {
+    private String pi_inoutno;
+
+    private String pi_class;
+
+    private Date pi_date;
+
+    private Integer pi_vendid;
+
+    private String pi_vendcode;
+
+    private String pi_vendname;
+
+    private Integer pi_custid;
+
+    private String pi_custcode;
+
+    private String pi_custname;
+
+    private Integer pi_puid;
+
+    private String pi_pucode;
+
+    private Integer pi_said;
+
+    private String pi_sacode;
+
+    private Double pi_total;
+
+    private String pi_status;
+
+    private String pi_statuscode;
+
+    private String pi_printstatus;
+
+    private String pi_printstatuscode;
+
+    private String pi_text1;
+
+    private String pi_text2;
+
+    private String pi_text3;
+
+    private String pi_text4;
+
+    private String pi_text5;
+
+    private String pi_address;
+
+    private Date pi_auditdate;
+
+    private String pi_auditman;
+
+    private String pi_remark;
+
+    private Long pd_piid;
+
+    private String pd_inoutno;
+
+    private String pd_piclass;
+
+    private Integer pd_pdno;
+
+    private String pd_ordercode;
+
+    private Integer pd_orderdetno;
+
+    private Integer pd_prodid;
+
+    private String pd_prodcode;
+
+    private String pd_unit;
+
+    private Double pd_inqty;
+
+    private Double pd_outqty;
+
+    private Double pd_orderprice;
+
+    private Double pd_sendprice;
+
+    private Double pd_price;
+
+    private Double pd_total;
+
+    private Double pd_taxrate;
+
+    private Double pd_netprice;
+
+    private Double pd_nettotal;
+
+    private Integer pd_whid;
+
+    private String pd_whcode;
+
+    private String pd_whname;
+
+    private Integer pd_inwhid;
+
+    private String pd_inwhcode;
+
+    private String pd_inwhname;
+
+    private Integer pd_orderid;
+
+    private Integer pd_sdid;
+
+    private Integer pd_status;
+
+    private String pd_text1;
+
+    private String pd_text2;
+
+    private String pd_text3;
+
+    private String pd_text4;
+
+    private String pd_text5;
+
+    private Integer pd_ym;
+
+    private Double pd_yqty;
+
+    private String pd_remark;
+
+    private Long pd_ioid;
+
+    private String pi_iocode;
+
+    private String pi_prstatus;
+
+    private String pi_prstatuscode;
+
+    //数量字段一致
+    private Double qty;
+
+    //private ProductDTO productDTO;
+    private Long pr_id;
+    private String pr_code;
+    private String pr_detail;
+    private String pr_spec;
+    private String pr_unit;
+    private String pr_kind;
+    private String pr_orispeccode;
+    private long pr_whid;
+    private String pr_whcode;
+    private String pr_whname;
+    private long pr_zxbzs;
+    private long pr_leadtime;
+    private String pr_brand;
+    private String pr_standardprice;
+    private String pr_purcprice;
+    private String pr_saleprice;
+    private long pr_vendid;
+    private String pr_vendname;
+    private String pr_vendcode;
+    private String pr_status;
+    private String pr_statuscode;
+    private String pr_text1;
+    private String pr_text2;
+    private String pr_text3;
+    private String pr_text4;
+}