Browse Source

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

hy 7 years ago
parent
commit
68a1da039b

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

@@ -2,6 +2,7 @@ package com.usoftchina.saas.commons.service.impl;
 
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
 import com.usoftchina.saas.commons.dto.ProductBaseDTO;
 import com.usoftchina.saas.commons.dto.ProductBaseDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.mapper.DataImportDetailMapper;
 import com.usoftchina.saas.commons.mapper.DataImportDetailMapper;
@@ -25,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * @author: guq
  * @author: guq
@@ -74,6 +76,7 @@ public class ExcelServiceImpl implements ExcelService{
     }
     }
 
 
     @Override
     @Override
+    @Transactional
     public Integer parseTemplet(Workbook wb, String caller) {
     public Integer parseTemplet(Workbook wb, String caller) {
         if (wb == null || StringUtils.isEmpty(caller)) {
         if (wb == null || StringUtils.isEmpty(caller)) {
             throw new BizException(BizExceptionCode.NULL_DATA);
             throw new BizException(BizExceptionCode.NULL_DATA);
@@ -112,19 +115,19 @@ public class ExcelServiceImpl implements ExcelService{
         //获取最大列数
         //获取最大列数
         int colnum = row.getPhysicalNumberOfCells();
         int colnum = row.getPhysicalNumberOfCells();
         String key = null;
         String key = null;
+        Map<String,String> map = null;
         //添加keys
         //添加keys
-        for (int j = 0;j < colnum; j++){
+        for (int j = 0; j < colnum; j++){
             key = (String) getCellFormatValue(row.getCell(j));
             key = (String) getCellFormatValue(row.getCell(j));
             keys.add(key);
             keys.add(key);
         }
         }
         //存储数据
         //存储数据
         for (int i = 2; i < rownum; i++) {
         for (int i = 2; i < rownum; i++) {
-            Map<String,String> map = new LinkedHashMap<String,String>();
+            map = new LinkedHashMap<String,String>();
             row = sheet.getRow(i);
             row = sheet.getRow(i);
             if(row !=null){
             if(row !=null){
                 for (int j = 0;j < colnum; j++){
                 for (int j = 0;j < colnum; j++){
                     cellData = (String) getCellFormatValue(row.getCell(j));
                     cellData = (String) getCellFormatValue(row.getCell(j));
-                    //检测字段必填与否
                     map.put(keys.get(j), cellData);
                     map.put(keys.get(j), cellData);
                 }
                 }
             }else{
             }else{
@@ -134,6 +137,7 @@ public class ExcelServiceImpl implements ExcelService{
         }
         }
         dataImportMapper.insertSelective(di);
         dataImportMapper.insertSelective(di);
         Integer keyvalue = di.getDi_id();
         Integer keyvalue = di.getDi_id();
+        List<String> validateCode = Lists.newArrayList();
         //数据转换成字段
         //数据转换成字段
         if (!CollectionUtils.isEmpty(datas)) {
         if (!CollectionUtils.isEmpty(datas)) {
             StringBuilder err = new StringBuilder();
             StringBuilder err = new StringBuilder();
@@ -169,6 +173,7 @@ public class ExcelServiceImpl implements ExcelService{
                                mainData = new JSONObject();
                                mainData = new JSONObject();
                                codeValue = value;
                                codeValue = value;
                                difference = true;
                                difference = true;
+                               validateCode.add(codeValue);
                            }
                            }
                            //检查是否是同一单
                            //检查是否是同一单
                            if (set.isCodefield() && data.get("*" + set.getDescription()).equals("")) {
                            if (set.isCodefield() && data.get("*" + set.getDescription()).equals("")) {
@@ -213,7 +218,8 @@ public class ExcelServiceImpl implements ExcelService{
                                value = data.get(set.getDescription());
                                value = data.get(set.getDescription());
                            }
                            }
                            if ("true".equals(set.getNecessary()) && value.equals("")) {
                            if ("true".equals(set.getNecessary()) && value.equals("")) {
-                               err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
+                               detailData = null;
+                               //err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
                                break;
                                break;
                            }
                            }
                            //检测日期类型是否规范
                            //检测日期类型是否规范
@@ -227,7 +233,7 @@ public class ExcelServiceImpl implements ExcelService{
                            //拼从表数据
                            //拼从表数据
                            detailData.put(set.getField(), value);
                            detailData.put(set.getField(), value);
                        }
                        }
-                       if (detailData.size() > 0) {
+                       if (null != detailData && detailData.size() > 0) {
                            dd.setDd_codevalue(codeValue);
                            dd.setDd_codevalue(codeValue);
                            dd.setDd_detaildata(detailData.toJSONString());
                            dd.setDd_detaildata(detailData.toJSONString());
                        }
                        }
@@ -235,6 +241,11 @@ public class ExcelServiceImpl implements ExcelService{
                 }
                 }
                 dataImportDetailMapper.insertSelective(dd);
                 dataImportDetailMapper.insertSelective(dd);
             }
             }
+            //重复编号检测
+            List<String> samecode = getDuplicateElements(validateCode);
+            if (null != samecode && samecode.size() > 0) {
+                err.append("下列编号重复: " + printList(samecode) + " 请确认无误后再上传!");
+            }
             //必填项检查
             //必填项检查
             if (err.length() > 0) {
             if (err.length() > 0) {
                 dataImportMapper.updateErr(err.toString(), keyvalue);
                 dataImportMapper.updateErr(err.toString(), keyvalue);
@@ -244,6 +255,24 @@ public class ExcelServiceImpl implements ExcelService{
         return keyvalue;
         return keyvalue;
     }
     }
 
 
+    private  <E> List<E> getDuplicateElements(List<E> list) {
+        return list.stream() // list 对应的 Stream
+                .collect(Collectors.toMap(e -> e, e -> 1, (a, b) -> a + b)) // 获得元素出现频率的 Map,键为元素,值为元素出现的次数
+                .entrySet().stream() // 所有 entry 对应的 Stream
+                .filter(entry -> entry.getValue() > 1) // 过滤出元素出现次数大于 1 的 entry
+                .map(entry -> entry.getKey()) // 获得 entry 的键(重复元素)对应的 Stream
+                .collect(Collectors.toList());  // 转化为 List
+    }
+
+    private String printList(List list) {
+        String result = null;
+        if (!StringUtils.isEmpty(list)) {
+            result = list.toString().substring(1, list.toString().length() - 1);
+        }
+        return result;
+    }
+
+
 
 
 
 
     private boolean validateDateFormat(String date) {
     private boolean validateDateFormat(String date) {

+ 1 - 1
frontend/saas-web/app/view/main/Main.js

@@ -31,7 +31,7 @@ Ext.define('saas.view.main.Main', {
                     reference: 'mainLogo',
                     reference: 'mainLogo',
                     width: 180,
                     width: 180,
                     cls: 'main-logo-wrap',
                     cls: 'main-logo-wrap',
-                    html: '<div class="main-logo"><img src="resources/images/default/logo-default.png"/><div class="logo-text">U企云服</div></div>',
+                    html: '<div class="main-logo"><img src="resources/images/default/logo-default.png"/><div class="logo-text">企云服</div></div>',
                     bind: {
                     bind: {
                         width: '{navWidth}'
                         width: '{navWidth}'
                     }
                     }

+ 1 - 0
frontend/saas-web/app/view/main/Navigation.scss

@@ -146,6 +146,7 @@ $nav-font-color-over: #fff;
                     height: 40px;
                     height: 40px;
                     line-height: 40px;
                     line-height: 40px;
                     font-size: 16px;
                     font-size: 16px;
+                    font-weight: bold;
                     color: #4F5170;
                     color: #4F5170;
                     letter-spacing: 0.64px;
                     letter-spacing: 0.64px;
                     text-align: left;
                     text-align: left;

+ 1 - 1
frontend/saas-web/index.html

@@ -5,7 +5,7 @@
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes">
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes">
 
 
-    <title>云进销存 - U企云服</title>
+    <title>云进销存 - 企云服</title>
     <link rel="icon" href="/resources/images/favicon.png" type="image/x-icon">
     <link rel="icon" href="/resources/images/favicon.png" type="image/x-icon">
     <!-- 图片动画效果样式导入 -->
     <!-- 图片动画效果样式导入 -->
     <link type="text/css" rel="stylesheet" href="/resources/othcss/imagehover.css" />
     <link type="text/css" rel="stylesheet" href="/resources/othcss/imagehover.css" />