guozhuang 3 лет назад
Родитель
Сommit
403f1a8335
23 измененных файлов с 519 добавлено и 6 удалено
  1. 2 2
      .gitignore
  2. 7 1
      business-common/pom.xml
  3. 16 0
      business-common/src/main/java/com/rongwei/business/dao/CompanyBaseInfoDetailDao.java
  4. 15 0
      business-common/src/main/java/com/rongwei/business/dao/SysFileFolderDao.java
  5. 10 0
      business-common/src/main/java/com/rongwei/business/service/CompanyBaseInfoDetailService.java
  6. 20 0
      business-common/src/main/java/com/rongwei/business/service/SysFileFolderService.java
  7. 20 0
      business-common/src/main/java/com/rongwei/business/service/impl/CompanyBaseInfoDetailServiceImpl.java
  8. 32 0
      business-common/src/main/java/com/rongwei/business/service/impl/SysFileFolderServiceImpl.java
  9. BIN
      business-common/target/classes/com/rongwei/business/dao/CompanyBaseInfoDetailDao.class
  10. BIN
      business-common/target/classes/com/rongwei/business/service/CompanyBaseInfoDetailService.class
  11. BIN
      business-common/target/classes/com/rongwei/business/service/impl/CompanyBaseInfoDetailServiceImpl.class
  12. 8 2
      business-entity/pom.xml
  13. 21 0
      business-entity/src/main/java/com/rongwei/business/domain/CompanyProductDo.java
  14. 84 0
      business-entity/src/main/java/com/rongwei/business/domain/SysFileFolderDo.java
  15. 12 1
      business-server/pom.xml
  16. 128 0
      business-server/src/main/java/com/rongwei/business/common/utils/QrCodeGeneratorUtils.java
  17. 68 0
      business-server/src/main/java/com/rongwei/business/controller/InitCodeController.java
  18. 13 0
      business-server/target/classes/bootstrap-dev.yml
  19. 10 0
      business-server/target/classes/bootstrap-pro.yml
  20. 53 0
      business-server/target/classes/bootstrap.yml
  21. BIN
      business-server/target/classes/com/rongwei/BusinessServerApplication.class
  22. BIN
      business-server/target/classes/com/rongwei/business/common/utils/QrCodeGeneratorUtils.class
  23. BIN
      business-server/target/classes/com/rongwei/business/controller/InitCodeController.class

+ 2 - 2
.gitignore

@@ -7,9 +7,9 @@
 .idea/modules.xml
 .idea/vcs.xml
 business-common/business-common.iml
-business-common/src/
+#business-common/src/
 business-entity/business-entity.iml
-business-entity/src/
+#business-entity/src/
 business-server/business-server.iml
 business-server/src/test/
 rw-business.iml

+ 7 - 1
business-common/pom.xml

@@ -16,6 +16,12 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>com.rongwei</groupId>
+            <artifactId>business-entity</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
         <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-generator</artifactId>
@@ -46,4 +52,4 @@
             <version>1.1-SNAPSHOT</version>
         </dependency>
     </dependencies>
-</project>
+</project>

+ 16 - 0
business-common/src/main/java/com/rongwei/business/dao/CompanyBaseInfoDetailDao.java

@@ -0,0 +1,16 @@
+package com.rongwei.business.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+/**
+ * @author shangmi
+ */
+@Mapper
+public interface CompanyBaseInfoDetailDao {
+
+    @Select("select SECRETKEY from fl_company_base_info_detail " +
+            "where TENANTID = #{tenantId} ORDER BY CREATEDATE desc limit 1 ")
+    String getSecret(@Param("tenantId") String tenantId);
+}

+ 15 - 0
business-common/src/main/java/com/rongwei/business/dao/SysFileFolderDao.java

@@ -0,0 +1,15 @@
+package com.rongwei.business.dao;
+
+import com.rongwei.rwcommon.base.BaseDao;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileFolderDo;
+
+/**
+ * 文件目录表
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2019-10-08 14:53:10
+ */
+public interface SysFileFolderDao extends BaseDao<SysFileFolderDo> {
+
+}

+ 10 - 0
business-common/src/main/java/com/rongwei/business/service/CompanyBaseInfoDetailService.java

@@ -0,0 +1,10 @@
+package com.rongwei.business.service;
+
+
+/**
+ * @author shangmi
+ */
+public interface CompanyBaseInfoDetailService {
+
+    String getSecret(String tenantId);
+}

+ 20 - 0
business-common/src/main/java/com/rongwei/business/service/SysFileFolderService.java

@@ -0,0 +1,20 @@
+package com.rongwei.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileFolderDo;
+
+
+/**
+ * 文件目录表
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2019-10-08 14:53:10
+ */
+public interface SysFileFolderService extends IService<SysFileFolderDo> {
+
+
+    SysFileFolderDo getFolderByFoldercode(String foldercode);
+
+}
+

+ 20 - 0
business-common/src/main/java/com/rongwei/business/service/impl/CompanyBaseInfoDetailServiceImpl.java

@@ -0,0 +1,20 @@
+package com.rongwei.business.service.impl;
+
+import com.rongwei.business.dao.CompanyBaseInfoDetailDao;
+import com.rongwei.business.service.CompanyBaseInfoDetailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service("CompanyBaseInfoDetailService")
+public class CompanyBaseInfoDetailServiceImpl implements CompanyBaseInfoDetailService {
+
+    @Autowired
+    private CompanyBaseInfoDetailDao companyBaseInfoDetailDao;
+
+    @Override
+    public String getSecret(String tenantId) {
+
+        String secret = companyBaseInfoDetailDao.getSecret(tenantId);
+        return secret;
+    }
+}

+ 32 - 0
business-common/src/main/java/com/rongwei/business/service/impl/SysFileFolderServiceImpl.java

@@ -0,0 +1,32 @@
+package com.rongwei.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.business.dao.SysFileFolderDao;
+import com.rongwei.business.service.SysFileFolderService;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileFolderDo;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service("sysFileFolderService")
+public class SysFileFolderServiceImpl extends ServiceImpl<SysFileFolderDao, SysFileFolderDo> implements SysFileFolderService {
+
+    /**
+     * 根据文件夹编号获取文件夹对象
+     * @param foldercode
+     * @return
+     */
+    @Override
+    public SysFileFolderDo getFolderByFoldercode(String foldercode){
+        Map<String,Object> map = new HashMap<>();
+        map.put("foldercode", foldercode);
+        List<SysFileFolderDo> lists = (List<SysFileFolderDo>) this.listByMap(map);
+        if(lists != null && lists.size()>0){
+            return lists.get(0);
+        }
+        return null;
+    }
+
+}

BIN
business-common/target/classes/com/rongwei/business/dao/CompanyBaseInfoDetailDao.class


BIN
business-common/target/classes/com/rongwei/business/service/CompanyBaseInfoDetailService.class


BIN
business-common/target/classes/com/rongwei/business/service/impl/CompanyBaseInfoDetailServiceImpl.class


+ 8 - 2
business-entity/pom.xml

@@ -11,5 +11,11 @@
 
     <artifactId>business-entity</artifactId>
 
-
-</project>
+    <dependencies>
+        <dependency>
+            <groupId>com.rongwei</groupId>
+            <artifactId>rw-common-utils</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>

+ 21 - 0
business-entity/src/main/java/com/rongwei/business/domain/CompanyProductDo.java

@@ -0,0 +1,21 @@
+package com.rongwei.business.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * @author shangmi
+ */
+@Data
+@TableName(value= "fl_company_product")
+public class CompanyProductDo {
+
+    @TableId
+    private String id;
+
+    /**
+     * 产品编码
+     */
+    private String productcode;
+}

+ 84 - 0
business-entity/src/main/java/com/rongwei/business/domain/SysFileFolderDo.java

@@ -0,0 +1,84 @@
+package com.rongwei.business.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 文件目录表
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2019-10-08 14:53:10
+ */
+@Data
+@TableName(value= "sys_file_folder")
+public class SysFileFolderDo extends BaseDo implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键ID
+	 */
+	@TableId
+	private String id;
+	/**
+	 * 文件夹编号
+	 */
+	private String foldercode;
+	/**
+	 * 文件夹名称
+	 */
+	private String foldername;
+	/**
+	 * 父级ID
+	 */
+	private String pid;
+	/**
+	 * 父级ID全路径
+	 */
+	private String fullpid;
+	/**
+	 * 是否叶子节点
+	 */
+	private String isleaf;
+	/**
+	 * 树结构编号
+	 */
+	private String treecode;
+	/**
+	 * 树结构等级
+	 */
+	private Integer level;
+	/**
+	 * 文件夹路径
+	 */
+	private String folderpath;
+	/**
+	 * 文件夹全路径
+	 */
+	private String fullfolderpath;
+	/**
+	 * 扩展字段1
+	 */
+	private String extends1;
+	/**
+	 * 扩展字段2
+	 */
+	private String extends2;
+	/**
+	 * 扩展字段3
+	 */
+	private String extends3;
+	/**
+	 * 租户ID
+	 */
+	private String tenantid;
+	/**
+	 * 扩展json格式配置
+	 */
+	private String roption;
+
+}

+ 12 - 1
business-server/pom.xml

@@ -12,6 +12,17 @@
     <artifactId>business-server</artifactId>
 
     <dependencies>
+        <!-- 二维码 -->
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>core</artifactId>
+            <version>3.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.zxing</groupId>
+            <artifactId>javase</artifactId>
+            <version>3.3.0</version>
+        </dependency>
         <dependency>
             <groupId>com.rongwei</groupId>
             <artifactId>business-common</artifactId>
@@ -84,4 +95,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
+</project>

+ 128 - 0
business-server/src/main/java/com/rongwei/business/common/utils/QrCodeGeneratorUtils.java

@@ -0,0 +1,128 @@
+package com.rongwei.business.common.utils;
+
+import cn.hutool.core.date.DateUtil;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import com.rongwei.rwcommon.utils.Constants;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileFolderDo;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESKeySpec;
+import javax.crypto.spec.IvParameterSpec;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.UUID;
+
+/**
+ * @author shangmi
+ */
+public class QrCodeGeneratorUtils {
+    /**
+     * 文件上传的保存路径
+     */
+    public static String UPLOAD_PATH = System.getProperty("user.dir") + File.separator + "upload" + File.separator;
+
+    /**
+     * 生成二维码,返回相对路径
+     *
+     * @param text
+     * @return
+     */
+    public static String generateQRCodeImage(String text) {
+        HashMap hashMap = new HashMap(16);
+        // 设置二维码字符编码
+        hashMap.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+        // 设置二维码纠错等级
+        hashMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
+        // 设置二维码边距
+        hashMap.put(EncodeHintType.MARGIN, 1);
+        try {
+            // 开始生成二维码
+            BitMatrix bitMatrix = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, 300, 300, hashMap);
+            SysFileItemDo sysFileItem = new SysFileItemDo();
+            String fileId = SecurityUtil.getUUID();
+            String fileUrl = "/files/";;
+            String filePath = sysConfigService.getContentByConfigCode(Constants.CONFIG_FILE_ROOT_PATH);
+            sysFileItem.setExtends1("files");
+            SysFileFolderDo sysFileFolderDo = sysFileFolderService.getFolderByFoldercode(foldercode);
+            String moduleName = sysFileFolderDo.getFullfolderpath();
+            sysFileItem.setFilefolderid(sysFileFolderDo.getId());
+            String fileName = UUID.randomUUID() + ".png";
+            fileUrl = fileUrl + fileName.substring(fileName.lastIndexOf(".") + 1);
+
+            sysFileItem.setFilename(fileName);
+
+            sysFileItem.setFiletype(fileName.substring(fileName.lastIndexOf(".") + 1));
+            sysFileItem.setStoragetype("1");
+            sysFileItem.setFullpath(filePath + fileName);
+            sysFileItem.setUrlpath(fileUrl);
+            sysFileItem.setRelationid("0");
+            sysFileItem.setId(fileId);
+            sysFileItem.setCreatedate(new Date());
+            sysFileItem.setModifydate(new Date());
+
+            File targetFile = new File(filePath);
+            if (!targetFile.exists()) {
+                targetFile.mkdirs();
+            }
+            File file = new File(filePath + fileName);
+            sysFileItem.setFilesize(file.length());
+            // 导出到指定目录
+            MatrixToImageWriter.writeToPath(bitMatrix, "png", file.toPath());
+
+            return sysFileItem.getUrlpath();
+        } catch (WriterException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    public static byte[] DES_CBC_Encrypt(byte[] content, byte[] keyBytes) {
+        try {
+            DESKeySpec keySpec = new DESKeySpec(keyBytes);
+            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
+            SecretKey key = keyFactory.generateSecret(keySpec);
+            Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
+            cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(keySpec.getKey()));
+            byte[] result = cipher.doFinal(content);
+            return result;
+        } catch (Exception e) {
+            System.out.println("exception:" + e.toString());
+        }
+        return null;
+    }
+
+    public static String byteToHexString(byte[] bytes) {
+        StringBuffer sb = new StringBuffer(bytes.length);
+        String sTemp;
+        for (int i = 0; i < bytes.length; i++) {
+            sTemp = Integer.toHexString(0xFF & bytes[i]);
+            if (sTemp.length() < 2) {
+                sb.append(0);
+            }
+            sb.append(sTemp.toUpperCase());
+        }
+        return sb.toString();
+    }
+
+    public static void main(String[] args) {
+        String text = "https://www.baidu.com";
+        String s = generateQRCodeImage(text);
+        System.out.println(s);
+    }
+}

+ 68 - 0
business-server/src/main/java/com/rongwei/business/controller/InitCodeController.java

@@ -0,0 +1,68 @@
+package com.rongwei.business.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.rongwei.business.common.utils.QrCodeGeneratorUtils;
+import com.rongwei.business.domain.CompanyProductDo;
+import com.rongwei.business.service.CompanyBaseInfoDetailService;
+import com.rongwei.business.service.SysFileFolderService;
+import com.rongwei.commonservice.service.RedisService;
+import com.rongwei.commonservice.service.SysConfigService;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.utils.Constants;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileFolderDo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author shangmi
+ * 生成二维码及防伪码
+ */
+@RestController
+@RequestMapping("/initCode")
+@Slf4j
+public class InitCodeController {
+
+    @Autowired
+    private CompanyBaseInfoDetailService companyBaseInfoDetailService;
+    @Autowired
+    private SysConfigService sysConfigService;
+    @Autowired
+    private SysFileFolderService sysFileFolderService;
+    @Autowired
+    private RedisService redisService;
+
+    private static final String FOLDER_CODE = "product_management";
+
+    @RequestMapping("saveCode")
+    public R saveCode(@RequestBody List<CompanyProductDo> companyProductDos){
+        //获取当前登录用户
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = attributes.getRequest();
+        String token = request.getHeader("token");
+        SysUserVo currUser = redisService.getLoginUser(token);
+        //获取最新密钥
+        String secret = companyBaseInfoDetailService.getSecret(currUser.getTenantid());
+        // 文件存储路径目录
+        String filePath = sysConfigService.getContentByConfigCode(Constants.CONFIG_FILE_ROOT_PATH);
+        //指定文件夹
+        SysFileFolderDo sysFileFolderDo = sysFileFolderService.getFolderByFoldercode(FOLDER_CODE);
+        companyProductDos.parallelStream().forEach(ev ->{
+            String productcode = ev.getProductcode();
+            byte[] bytes = QrCodeGeneratorUtils.DES_CBC_Encrypt(productcode.getBytes(), secret.getBytes());
+            String s = QrCodeGeneratorUtils.byteToHexString(bytes);
+
+        });
+        return null;
+    }
+
+}

+ 13 - 0
business-server/target/classes/bootstrap-dev.yml

@@ -0,0 +1,13 @@
+spring:
+  cloud:
+    nacos:
+      config:
+        file-extension: yaml
+        server-addr: 127.0.0.1:8848
+        namespace: cd047569-9470-4dfb-8663-b113d01cd30f
+        ext-config[0]:
+          data-id: common-config.yaml
+      discovery:
+        server-addr: 127.0.0.1:8848
+        namespace: cd047569-9470-4dfb-8663-b113d01cd30f
+

+ 10 - 0
business-server/target/classes/bootstrap-pro.yml

@@ -0,0 +1,10 @@
+spring:
+  cloud:
+    nacos:
+      config:
+        file-extension: yaml
+        server-addr: 127.0.0.1:8848
+        namespace: 75f91d9a-0dd2-4dd9-98f6-61a221d396f1
+      discovery:
+        server-addr: 127.0.0.1:8848
+        namespace: 75f91d9a-0dd2-4dd9-98f6-61a221d396f1

+ 53 - 0
business-server/target/classes/bootstrap.yml

@@ -0,0 +1,53 @@
+spring:
+  profiles:
+    active: dev
+  application:
+    name: rw-business-server
+  jta:
+    atomikos:
+      properties:
+        log-base-name: rwbusinesslog
+  servlet:
+    multipart:
+      max-file-size: 100MB
+      max-request-size: 1000MB
+server:
+  port: 9689
+
+management:
+  endpoints:
+    web:
+      exposure:
+        include: "*"
+feign:
+  client:
+    config:
+      default:
+        connectTimeout: 5000
+        readTimeout: 5000
+  sentinel:
+    enabled: true
+jwt:
+  token-header: Authorization
+  expire: 14400
+  rsa-secret: xx1WET12^%3^(WE45
+client:
+  id: ace-auth
+  secret: 123456
+  token-header: x-client-token
+  expire: 14400
+  rsa-secret: x2318^^(*WRYQWR(QW&T
+mybatis-plus:
+  configuration:
+    #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
+    map-underscore-to-camel-case: false
+  #basepackage: com.rongwei.rwadmin.system.dao
+  xmlLocation: classpath:mybatis/**/*Dao.xml
+  mapperLocations: "classpath:mybatis/**/*Dao.xml"
+  typeAliasesPackage: com.rongwei.bsentity.domain
+  global-config:
+    db-config:
+      logic-delete-value: 1
+      logic-not-delete-value: 0
+      column-like: true

BIN
business-server/target/classes/com/rongwei/BusinessServerApplication.class


BIN
business-server/target/classes/com/rongwei/business/common/utils/QrCodeGeneratorUtils.class


BIN
business-server/target/classes/com/rongwei/business/controller/InitCodeController.class