Преглед изворни кода

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

zhoudw пре 7 година
родитељ
комит
a55044feea

+ 3 - 1
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/ExcelController.java

@@ -3,6 +3,7 @@ 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 com.usoftchina.saas.utils.DateUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
@@ -15,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.net.URLEncoder;
+import java.util.Date;
 import java.util.Map;
 
 /**导入模板下载、解析
@@ -32,7 +34,7 @@ public class ExcelController {
     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 title = map.get("title").toString() + "_" + DateUtils.format(new Date(), "yyyyMMdd");
         String filename = URLEncoder.encode(title + ".xlsx", "UTF-8");
         response.setContentType("application/vnd.ms-excel");
         response.setHeader("Content-Disposition", "attachment;filename=" + filename);

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

@@ -45,6 +45,9 @@ public class ExcelServiceImpl implements ExcelService{
         Map<String, Object> map = new HashMap<>();
         SXSSFWorkbook workbook = new SXSSFWorkbook();
         DataTemplet dataTemplet = dataTempletMapper.selectByCaller(caller, companyId);
+        if (null == dataTemplet) {
+            throw new BizException(9876, "没有查询到对应的excel配置");
+        }
         //列
         String cols = dataTemplet.getDt_columns();
         JSONArray array = (JSONArray) JSONArray.parse(cols);
@@ -70,7 +73,6 @@ public class ExcelServiceImpl implements ExcelService{
     }
 
     @Override
-    @Transactional
     public Integer parseTemplet(Workbook wb, String caller) {
         if (wb == null || StringUtils.isEmpty(caller)) {
             throw new BizException(BizExceptionCode.NULL_DATA);
@@ -182,7 +184,7 @@ public class ExcelServiceImpl implements ExcelService{
                                }
                            }
                            //检测日期类型是否规范
-                           if ("date".equals(set.getType())) {
+                           if ("date".equals(set.getType()) && !StringUtils.isEmpty(value)) {
                                flag = validateDateFormat(value);
                                if (!flag) {
                                    err.append("第" + (i + 2) + "行 " + set.getDescription() + " 日期格式不正确! ");
@@ -257,7 +259,7 @@ public class ExcelServiceImpl implements ExcelService{
         if (StringUtils.isEmpty(date)) {
             return false;
         }
-        String regEx1 = "[0-9]{8}";
+        String regEx1 = "[0-9]{4}/[0-9]{2}/[0-9]{2}";
         String regEX2 = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
         // 编译正则表达式
         Pattern pattern1 = Pattern.compile(regEx1);
@@ -290,6 +292,10 @@ public class ExcelServiceImpl implements ExcelService{
             switch(cell.getCellType()){
                 case Cell.CELL_TYPE_NUMERIC:{
                     cellValue = String.valueOf(cell.getNumericCellValue());
+                    //判断是否为INT类型
+                    if (Double.valueOf(cellValue.toString()).intValue() - Double.valueOf(cellValue.toString()) == 0) {
+                        return Double.valueOf(cellValue.toString()).intValue();
+                    }
                     break;
                 }
                 case Cell.CELL_TYPE_FORMULA:{
@@ -336,9 +342,10 @@ public class ExcelServiceImpl implements ExcelService{
      */
     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);// 固定列
+        CellStyle style = getCellStyle(workbook, true);
+        CellStyle detailStyle = getCellStyle(workbook, false);
+        //sheet.autoSizeColumn(2);
+       // sheet.createFreezePane(0, 1);// 固定列
         Cell cell = null;
         int rIdx = 0;
         int cIdx = 0;
@@ -347,8 +354,8 @@ public class ExcelServiceImpl implements ExcelService{
         Row row = null;
         if (remark != null) {
             row = sheet.createRow(rIdx);
-            row.setHeightInPoints((short) 100);
-            sheet.setColumnWidth(cIdx, 1000);
+            row.setHeightInPoints((short) 50);
+            sheet.setColumnWidth(cIdx, 500);
             cell = getCell(sheet, rIdx, cIdx);
             cell.setCellValue(remark);
             sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, cols.size() - 1));
@@ -365,19 +372,23 @@ public class ExcelServiceImpl implements ExcelService{
                 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);
+               // 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);
+                if ("main".equals(obj.get("position"))) {
+                    cell.setCellStyle(style);
+                } else {
+                    cell.setCellStyle(detailStyle);
+                }
+                cell.setCellValue(value);
+                keys.add(String.valueOf(obj.get("description")));
                 cIdx++;
                 value = "";
             }
@@ -410,7 +421,7 @@ public class ExcelServiceImpl implements ExcelService{
         }
     }
 
-    private CellStyle getCellStyle(SXSSFWorkbook workbook) {
+    private CellStyle getCellStyle(SXSSFWorkbook workbook, boolean main) {
         CellStyle style = workbook.createCellStyle();
         style.setFillBackgroundColor((short) 18);
         style.setFillPattern(FillPatternType.LEAST_DOTS);
@@ -421,7 +432,7 @@ public class ExcelServiceImpl implements ExcelService{
         style.setFont(font);
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setFillForegroundColor(HSSFColor.GREEN.index);
-        style.setFillBackgroundColor(HSSFColor.PALE_BLUE.index);
+        style.setFillBackgroundColor(main ? HSSFColor.LIGHT_YELLOW.index : HSSFColor.PALE_BLUE.index);
         style.setBorderBottom(BorderStyle.MEDIUM);
         style.setBorderLeft(BorderStyle.MEDIUM);
         style.setBorderRight(BorderStyle.MEDIUM);

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

@@ -15,7 +15,7 @@
   </resultMap>
 
   <delete id="deleteByIds">
-    delete from data_importdetail where dd_diid in (${ids})
+    delete from data_importdetail where dd_diid in (${value})
   </delete>
 
   <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImportDetail" >

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

@@ -6,7 +6,7 @@
   il_toformal=0 and il_result is not null
 </delete>
   <delete id="deleteByIds">
-    delete from data_import where di_id in (${ids});
+    delete from data_import where di_id in (${value});
   </delete>
 
   <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImport" >
@@ -72,7 +72,7 @@
     update data_import
     set
     di_result = #{err},
-    di_success = 0,
+    di_success = 0
     where di_id = #{id}
   </update>
 

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

@@ -12,6 +12,6 @@
   </resultMap>
 
   <select id="selectByCaller" resultMap="BaseResultMap">
-    select * from data_Templet where dt_caller=#{caller} and companyid = #{companyid}
+    select * from data_Templet where dt_caller=#{caller}
   </select>
 </mapper>

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

@@ -32,4 +32,6 @@ public interface EmployeeMapper extends CommonBaseMapper<Employee> {
     int validateNameAndCodeWhenInsert(@Param("code") String code,@Param("name") String em_name,@Param("companyId") Long companyId);
 
     int validateNameAndCodeWhenUpdate(@Param("code") String code,@Param("name") String em_name,@Param("id") Long id,@Param("companyId") Long companyId);
+
+    List<Employee> selectByName(@Param("name") String name, @Param("companyId") Long companyId);
 }

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

@@ -491,6 +491,8 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         return getMapper().getCombo(id,BaseContextHolder.getCompanyId());
     }
 
+    @Autowired
+    private EmployeeMapper employeeMapper;
     @Override
     public void saveToFormal(Integer id, boolean update) {
         if (null == id || "0".equals(id)) {
@@ -511,6 +513,17 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
                 List<DataImportDetail> data = datas.get(code);
                 DataImportDetail main = dataImportMapper.selectMainBycode(code, id, companyId);
                 CustomerDTO customerDTO = JSONObject.parseObject(main.getDd_maindata(), CustomerDTO.class);
+                //验证业务员
+                if (!StringUtils.isEmpty(customerDTO.getCu_sellername())) {
+                    List<Employee> employees = employeeMapper.selectByName(customerDTO.getCu_sellername(), companyId);
+                    if (null == employees || StringUtils.isEmpty(employees.get(0))) {
+                        err.append("客户编号为: " + customerDTO.getCu_code() + " 的业务员: "+ customerDTO.getCu_sellername() +" 在系统中不存在,请确认数据是否正确");
+                        break;
+                    }
+                    customerDTO.setCu_sellerid(Integer.valueOf(employees.get(0).getId().toString()));
+                    customerDTO.setCu_sellercode(employees.get(0).getEm_code());
+                    customerDTO.setCu_sellername(employees.get(0).getEm_name());
+                }
                 customerDTO.setCu_status(Status.OPEN.getDisplay());
                 customerDTO.setCu_statuscode(Status.OPEN.name());
                 //编号不存在

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

@@ -244,5 +244,8 @@
     select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and em_id !=#{id}  and companyId =#{companyId}
   </select>
 
+  <select id="selectByName" resultMap="BaseResultMap">
+    select * from employee where em_name = #{name} and companyId=#{companyId}
+  </select>
 
 </mapper>

+ 1 - 1
applications/sale/sale-server/src/main/resources/config/application-docker-test.yml

@@ -4,7 +4,7 @@ eureka:
     prefer-ip-address: false
   client:
     serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-dev:8515/eureka/
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-test:8515/eureka/
 spring:
   rabbitmq:
     virtual-host: test

+ 37 - 64
frontend/saas-web/app.json

@@ -275,6 +275,39 @@
         "cacheParam": "_dc"
     },
 
+    "builds": {
+        "dev": {
+            "server": {
+                "accountCenter":"http://192.168.0.181:8000",
+                "accountEnterprise":"http://192.168.0.181:8000/#/enterprise",
+                "basePath": {
+                    "https": "https://saas-api-dev.usoftchina.com:5443",
+                    "http": "http://192.168.0.181:8560"
+                },
+                "urlPattern": "^\/api\/"
+            }
+        },
+        "test": {
+            "server": {
+                "accountCenter": "https://saas-test.usoftchina.com:5443",
+                "accountEnterprise": "https://saas-test.usoftchina.com:5443/#/enterprise",
+                "basePath": {
+                    "https": "https://saas-api-test.usoftchina.com:5443",
+                    "http": "http://192.168.0.181:8575"
+                },
+                "urlPattern": "^\/api\/"
+            }
+        },
+        "prod": {
+            "server": {
+                "accountCenter":"https://saas.usoftchina.com",
+                "accountEnterprise":"https://saas.usoftchina.com/#/enterprise",
+                "basePath": "https://saas-api.usoftchina.com",
+                "urlPattern": "^\/api\/"
+            }
+        }
+    },
+
     /**
      * Settings specific to production builds.
      */
@@ -293,12 +326,6 @@
         },
         "compressor": {
             "type": "yui"
-        },
-        "server": {
-            "accountCenter":"https://saas.usoftchina.com",
-            "accountEnterprise":"https://saas.usoftchina.com/#/enterprise",
-            "basePath": "https://saas-api.usoftchina.com",
-            "urlPattern": "^\/api\/"
         }
     },
 
@@ -306,68 +333,14 @@
      * Settings specific to testing builds.
      */
     "testing": {
-        "output": {
-            "appCache": {
-                "enable": true,
-                "path": "cache.appcache"
-            }
-        },
-        "loader": {
-            "cache": "${build.timestamp}"
-        },
-        "cache": {
-            "enable": true
-        },
-        "compressor": {
-            "type": "yui"
-        },
-        "server": {
-            /** 暂时更改
-            "accountCenter": "https://saas-test.usoftchina.com:5443",
-            "accountEnterprise": "https://saas-test.usoftchina.com:5443/#/enterprise",
-            "basePath": {
-                "https": "https://saas-api-test.usoftchina.com:5443",
-                "http": "http://192.168.0.181:8575"
-            },
-            "urlPattern": "^\/api\/"
-            **/
-            "accountCenter":"http://192.168.0.181:8000",
-            "accountEnterprise":"http://192.168.0.181:8000/#/enterprise",
-            "basePath": {
-                "https": "https://saas-api-dev.usoftchina.com:5443",
-                "http": "http://192.168.0.181:8560"
-            },
-            "urlPattern": "^\/api\/"
-        }
     },
 
     /**
      * Settings specific to development builds.
      */
     "development": {
-        "output": {
-            "appCache": {
-                "enable": true,
-                "path": "cache.appcache"
-            }
-        },
-        "loader": {
-            "cache": "${build.timestamp}"
-        },
-        "cache": {
-            "enable": true
-        },
-        "compressor": {
-            "type": "yui"
-        },
-        "server": {
-            "accountCenter":"http://192.168.0.181:8000",
-            "accountEnterprise":"http://192.168.0.181:8000/#/enterprise",
-            "basePath": {
-                "https": "https://saas-api-dev.usoftchina.com:5443",
-                "http": "http://192.168.0.181:8560"
-            },
-            "urlPattern": "^\/api\/"
+        "watch": {
+            "delay": 250
         }
     },
 
@@ -422,7 +395,7 @@
      *          "css": "${app.output.resources}/${app.name}-all.css",
      *          "js": {
      *              "path": "app.js",
-     *              // This setting constrols the output language level.  Set to 'ES6' to 
+     *              // This setting constrols the output language level.  Set to 'ES6' to
      *              // disable the transpiler
      *              "version": "ES5"
      *          },
@@ -563,4 +536,4 @@
      * Normally you should never change this value.
      */
     "id": "a20e1670-7932-41f6-8e9c-55b77cba3f26"
-}
+}

+ 3 - 3
frontend/saas-web/package.json

@@ -6,9 +6,9 @@
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1",
     "dev": "sencha app watch",
-    "build-dev": "sencha app build --development",
-    "build-test": "sencha app build --testing",
-    "build": "sencha app build --production"
+    "build-dev": "sencha app build --build dev --testing",
+    "build-test": "sencha app build --build test --production",
+    "build": "sencha app build --build prod --production"
   },
   "keywords": [
     "saas"