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

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

zhuth пре 7 година
родитељ
комит
d382886b0d

+ 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);

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

@@ -12,6 +12,7 @@ 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.DateUtils;
 import com.usoftchina.saas.utils.StringUtils;
 import org.apache.poi.hssf.util.HSSFColor;
 import org.apache.poi.ss.usermodel.*;
@@ -45,6 +46,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 +74,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);
@@ -136,7 +139,6 @@ public class ExcelServiceImpl implements ExcelService{
             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);
@@ -177,25 +179,21 @@ public class ExcelServiceImpl implements ExcelService{
                            if (difference) {
                                dd.setDd_codevalue(codeValue);
                                if ("true".equals(set.getNecessary()) && data.get("*" + set.getDescription()).equals("")) {
-                                   err.append("第" + (i + 2) + "行 " + set.getDescription() + " 必填字段未填写! ");
+                                   err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
                                    break;
                                }
                            }
                            //检测日期类型是否规范
-                           if ("date".equals(set.getType())) {
-                               flag = validateDateFormat(value);
-                               if (!flag) {
-                                   err.append("第" + (i + 2) + "行 " + set.getDescription() + " 日期格式不正确! ");
+                           if ("date".equals(set.getType()) && !StringUtils.isEmpty(value)) {
+                               value = praseDate(value);
+                               if (null == value) {
+                                   err.append("第" + (i + 3) + "行 " + set.getDescription() + " 日期格式不正确!<br/> ");
                                    break;
                                }
                            }
                            //插入主表数据
                            if (null != mainData) {
-                               if ("true".equals(set.getNecessary())) {
-                                   mainData.put(set.getField(), value);
-                               } else {
-                                   mainData.put(set.getField(), value);
-                               }
+                               mainData.put(set.getField(), value);
                            }
                        }
                        //所有主表数据进行分类
@@ -214,24 +212,20 @@ public class ExcelServiceImpl implements ExcelService{
                            } 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() + " 必填字段未填写! ");
+                           if ("true".equals(set.getNecessary()) && value.equals("")) {
+                               err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
                                break;
                            }
                            //检测日期类型是否规范
-                           if ("date".equals(set.getType())) {
-                               flag = validateDateFormat(value);
-                               if (!flag) {
-                                   err.append("第" + (i + 2) + "行 " + set.getDescription() + " 日期格式不正确! ");
+                           if ("date".equals(set.getType()) && !StringUtils.isEmpty(value)) {
+                               value = praseDate(value);
+                               if (null == value) {
+                                   err.append("第" + (i + 3) + "行 " + set.getDescription() + " 日期格式不正确!<br/> ");
                                    break;
                                }
                            }
+                           //拼从表数据
+                           detailData.put(set.getField(), value);
                        }
                        if (detailData.size() > 0) {
                            dd.setDd_codevalue(codeValue);
@@ -257,7 +251,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);
@@ -271,6 +265,15 @@ public class ExcelServiceImpl implements ExcelService{
         return flag;
     }
 
+    private String praseDate(String num) {
+        try {
+            Integer days = Integer.valueOf(num);
+            return DateUtils.plusDay(days, "1899-12-30");
+        }catch (Exception e) {
+            return null;
+        }
+    }
+
     //保证先遍历主表
     private List<String> SetToList(Set<String> sets) {
         List<String> list = new ArrayList<>();
@@ -290,6 +293,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 cellValue.toString().substring(0, cellValue.toString().indexOf("."));
+                    }
                     break;
                 }
                 case Cell.CELL_TYPE_FORMULA:{
@@ -336,9 +343,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 +355,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 +373,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 +422,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 +433,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 || employees.size() == 0 || 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

+ 11 - 1
framework/core/src/main/java/com/usoftchina/saas/utils/DateUtils.java

@@ -543,9 +543,19 @@ public class DateUtils {
     //获取期间
     public static int getYm(Date date){
         String dates = date2String(date, "yyyyMM");
-//        dates = dates + "01";
         int d = Integer.parseInt(dates);
         return d;
     }
 
+    public static String plusDay(int num,String newDate) throws ParseException{
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Date currdate = format.parse(newDate);
+        Calendar ca = Calendar.getInstance();
+        ca.setTime(currdate);
+        ca.add(Calendar.DATE, num);// num为增加的天数,可以改变的
+        Date next = ca.getTime();
+        String enddate = format.format(next);
+        return enddate;
+    }
+
 }

+ 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"
-}
+}

+ 7 - 1
frontend/saas-web/app/view/stock/appropriationInOut/QueryPanel.js

@@ -199,7 +199,13 @@ Ext.define('saas.view.stock.appropriationInOut.QueryPanel', {
                 text: '数量',
                 dataIndex: 'pd_outqty',
                 xtype:'numbercolumn',
-                width: 110
+                width: 110,
+                renderer : function(v) {
+                    var arr = (v + '.').split('.');
+                    var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
+                    var format = '0,000.' + xr.join();
+                    return Ext.util.Format.number(v, format);
+                }
             },{
                 text: '拨出仓',
                 dataIndex: 'pd_whname',

+ 6 - 0
frontend/saas-web/app/view/stock/make/QueryPanel.js

@@ -136,6 +136,12 @@ Ext.define('saas.view.stock.make.QueryPanel', {
             dataIndex: 'ma_qty',
             xtype: 'numbercolumn',
             width: 110,
+            renderer : function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            },
         },{
             text: '单位',
             dataIndex: 'ma_produnit',

+ 7 - 1
frontend/saas-web/app/view/stock/otherIn/QueryPanel.js

@@ -188,7 +188,13 @@ Ext.define('saas.view.stock.otherIn.QueryPanel', {
             text: '数量',
             dataIndex: 'pd_inqty',
             xtype:'numbercolumn',
-            width: 10
+            width: 10,
+            renderer : function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            },
         },{
             text: '仓库',
             dataIndex: 'pd_whname',

+ 7 - 1
frontend/saas-web/app/view/stock/otherOut/QueryPanel.js

@@ -188,7 +188,13 @@ Ext.define('saas.view.stock.otherOut.QueryPanel', {
             text: '数量',
             dataIndex: 'pd_inqty',
             xtype:'numbercolumn',
-            width: 10
+            width: 10,
+            renderer : function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            }
         },{
             text: '仓库',
             dataIndex: 'pd_whname',

+ 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"