Parcourir la source

【CHG】安全工具生成二维码图片,消息提醒

ZhaoMn il y a 3 ans
Parent
commit
926b296d51
30 fichiers modifiés avec 1637 ajouts et 752 suppressions
  1. 9 0
      pom.xml
  2. 55 55
      railway-admin/src/main/java/com/railway/web/controller/business/safetool/BaseSafetyToolController.java
  3. 61 0
      railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecQcodeController.java
  4. 0 65
      railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecTestRecordController.java
  5. 3 2
      railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebGjsfxServiceImpl.java
  6. 3 2
      railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebJddzServiceImpl.java
  7. 3 2
      railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebJyzqsjlServiceImpl.java
  8. 3 2
      railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebLbjghjlServiceImpl.java
  9. 3 2
      railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebQmjcjlServiceImpl.java
  10. 8 1
      railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebServiceImpl.java
  11. 3 2
      railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebXsjcjlServiceImpl.java
  12. 5 0
      railway-business/src/main/java/com/railway/business/push/service/IBusPushMsgService.java
  13. 247 237
      railway-business/src/main/java/com/railway/business/push/service/impl/BusPushMsgServiceImpl.java
  14. 4 0
      railway-business/src/main/java/com/railway/business/safetool/domain/BaseSafetyTool.java
  15. 7 2
      railway-business/src/main/java/com/railway/business/safetool/mapper/BaseSafetyToolMapper.java
  16. 7 2
      railway-business/src/main/java/com/railway/business/safetool/service/IBaseSafetyToolService.java
  17. 20 4
      railway-business/src/main/java/com/railway/business/safetool/service/impl/BaseSafetyToolServiceImpl.java
  18. 376 358
      railway-business/src/main/resources/mapper/safetool/BaseSafetyToolMapper.xml
  19. 21 0
      railway-common/pom.xml
  20. 18 16
      railway-common/src/main/java/com/railway/common/enums/DelFlagEnum.java
  21. 32 0
      railway-common/src/main/java/com/railway/common/enums/QcodeEnum.java
  22. 43 0
      railway-common/src/main/java/com/railway/common/qrcode/factory/AbstractSnowflake.java
  23. 31 0
      railway-common/src/main/java/com/railway/common/qrcode/factory/AbstractWorkerIdGeneratorFactory.java
  24. 118 0
      railway-common/src/main/java/com/railway/common/qrcode/factory/BitsAllocator.java
  25. 108 0
      railway-common/src/main/java/com/railway/common/qrcode/impl/DefaultSnowflakeGenerator.java
  26. 139 0
      railway-common/src/main/java/com/railway/common/qrcode/impl/SnowflakeClient.java
  27. 256 0
      railway-common/src/main/java/com/railway/common/utils/QRCodeUtilEx.java
  28. 54 0
      railway-common/src/main/java/com/railway/common/utils/snowflake/SnowflakeIdUtils.java
  29. BIN
      railway-common/src/main/resources/lib/core-3.4.1.jar
  30. BIN
      railway-common/src/main/resources/lib/javase-3.4.1.jar

+ 9 - 0
pom.xml

@@ -53,6 +53,8 @@
     <log4j.version>2.15.0</log4j.version>
     <maven-plugin.version>2.6.1</maven-plugin.version>
     <guava.version>30.0-jre</guava.version>
+    <hutool.version>5.7.6</hutool.version>
+    <zxing.version>3.4.1</zxing.version>
   </properties>
 
   <!-- 依赖声明 -->
@@ -230,6 +232,13 @@
         <version>${log4j.version}</version>
       </dependency>
 
+      <!-- 工具 -->
+      <dependency>
+        <groupId>cn.hutool</groupId>
+        <artifactId>hutool-all</artifactId>
+        <version>${hutool.version}</version>
+      </dependency>
+
       <!-- 核心模块-->
       <dependency>
         <groupId>com.railway</groupId>

+ 55 - 55
railway-admin/src/main/java/com/railway/web/controller/business/safetool/BaseSafetyToolController.java

@@ -28,70 +28,70 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping(value = "business/safetool/base/safety/tool")
 public class BaseSafetyToolController extends BaseController {
 
-    private final IBaseSafetyToolService baseSafetyToolService;
+  private final IBaseSafetyToolService baseSafetyToolService;
 
-    public BaseSafetyToolController(IBaseSafetyToolService baseSafetyToolService) {
-        this.baseSafetyToolService = baseSafetyToolService;
-    }
+  public BaseSafetyToolController(IBaseSafetyToolService baseSafetyToolService) {
+    this.baseSafetyToolService = baseSafetyToolService;
+  }
 
-    @ApiOperation(value = "新增")
-    @PostMapping("/add")
-    public AjaxResult add(@Validated @RequestBody BaseSafetyTool baseSafetyTool) {
-        //校验安全工具有效编码唯一
-        BaseSafetyTool validate = new BaseSafetyTool();
-        validate.setToolCode(baseSafetyTool.getToolCode());
-        validate.setState("1");
-        List<BaseSafetyTool> list = baseSafetyToolService.getList(validate);
-        if(list.size()==1){
-            return new AjaxResult(AjaxResult.Type.WARN,"工具编号已存在");
-        }else{
-            return toAjax(baseSafetyToolService.create(baseSafetyTool));
-        }
+  @ApiOperation(value = "新增")
+  @PostMapping("/add")
+  public AjaxResult add(@Validated @RequestBody BaseSafetyTool baseSafetyTool) {
+    //校验安全工具有效编码唯一
+    BaseSafetyTool validate = new BaseSafetyTool();
+    validate.setToolCode(baseSafetyTool.getToolCode());
+    validate.setState("1");
+    List<BaseSafetyTool> list = baseSafetyToolService.getList(validate);
+    if (list.size() == 1) {
+      return new AjaxResult(AjaxResult.Type.WARN, "工具编号已存在");
+    } else {
+      return toAjax(baseSafetyToolService.create(baseSafetyTool));
     }
+  }
 
-    @ApiOperation(value = "删除")
-    @DeleteMapping("/{toolIds}")
-    public AjaxResult delete(@PathVariable String[] toolIds) {
-        return toAjax(baseSafetyToolService.delete(toolIds));
-    }
+  @ApiOperation(value = "删除")
+  @DeleteMapping("/{toolIds}")
+  public AjaxResult delete(@PathVariable Long[] toolIds) {
+    return toAjax(baseSafetyToolService.delete(toolIds));
+  }
 
-    @ApiOperation(value = "更新")
-    @PutMapping("/update")
-    public AjaxResult update(@RequestBody @Valid BaseSafetyTool baseSafetyTool) {
-        return toAjax(baseSafetyToolService.update(baseSafetyTool));
-    }
+  @ApiOperation(value = "更新")
+  @PutMapping("/update")
+  public AjaxResult update(@RequestBody @Valid BaseSafetyTool baseSafetyTool) {
+    return toAjax(baseSafetyToolService.update(baseSafetyTool));
+  }
 
-    @ApiOperation(value = "单个")
-    @GetMapping(value = {"/", "/{toolId}"})
-    public AjaxResult getInfo(String toolId) {
-        BaseSafetyTool info = baseSafetyToolService.getInfo(toolId);
-        AjaxResult ajax = AjaxResult.success();
-        ajax.put("info",info);
-        return ajax;
-    }
+  @ApiOperation(value = "单个")
+  @GetMapping(value = {"/", "/{toolId}"})
+  public AjaxResult getInfo(Long toolId) {
+    BaseSafetyTool info = baseSafetyToolService.getInfo(toolId);
+    AjaxResult ajax = AjaxResult.success();
+    ajax.put("info", info);
+    return ajax;
+  }
 
-    @ApiOperation(value = "列表")
-    @GetMapping(value = "list")
-    public TableDataInfo getList(BaseSafetyTool baseSafetyTool) {
-        startPage();
-        List<BaseSafetyTool> list = baseSafetyToolService.getList(baseSafetyTool);
-        return getDataTable(list);
-    }
+  @ApiOperation(value = "列表")
+  @GetMapping(value = "list")
+  public TableDataInfo getList(BaseSafetyTool baseSafetyTool) {
+    startPage();
+    List<BaseSafetyTool> list = baseSafetyToolService.getList(baseSafetyTool);
+    return getDataTable(list);
+  }
 
-    @ApiOperation(value = "替换安全工具")
-    @PostMapping("/replaceTool")
-    public AjaxResult replaceTool(@Validated @RequestBody BaseSafetyTool baseSafetyTool) {
-        //校验安全工具有效编码唯一
-        BaseSafetyTool validate = new BaseSafetyTool();
-        validate.setToolCode(baseSafetyTool.getToolCode());
-        validate.setState("1");
-        List<BaseSafetyTool> list = baseSafetyToolService.getList(validate);
-        if(list.size()==1&&list.get(0).getToolId().equals(baseSafetyTool.getToolId())){
-            return toAjax(baseSafetyToolService.replaceTool(baseSafetyTool));
-        }else{
-            return new AjaxResult(AjaxResult.Type.WARN,"工具编号已存在");
-        }
+  @ApiOperation(value = "替换安全工具")
+  @PostMapping("/replaceTool")
+  public AjaxResult replaceTool(@Validated @RequestBody BaseSafetyTool baseSafetyTool) {
+    //校验安全工具有效编码唯一
+    BaseSafetyTool validate = new BaseSafetyTool();
+    validate.setToolCode(baseSafetyTool.getToolCode());
+    validate.setState("1");
+    List<BaseSafetyTool> list = baseSafetyToolService.getList(validate);
+    if (list.size() == 1 && list.get(0).getToolId().equals(baseSafetyTool.getToolId())) {
+      return toAjax(baseSafetyToolService.replaceTool(baseSafetyTool));
+    } else {
+      return new AjaxResult(AjaxResult.Type.WARN, "工具编号已存在");
     }
+  }
 
 
 }

+ 61 - 0
railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecQcodeController.java

@@ -0,0 +1,61 @@
+package com.railway.web.controller.business.safetool;
+
+import com.railway.business.safetool.domain.BaseSafetyTool;
+import com.railway.business.safetool.service.IBaseSafetyToolService;
+import com.railway.common.core.controller.BaseController;
+import com.railway.common.core.domain.AjaxResult;
+import com.railway.common.utils.QRCodeUtilEx;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * @author ZhaoMn
+ */
+@Api(value = "rest/safetool/base/safety/tool", tags = "安全工具 - 二维码")
+@RestController
+@Validated
+@RequestMapping(value = "st")
+public class SecQcodeController extends BaseController {
+
+  private final IBaseSafetyToolService baseSafetyToolService;
+
+  public SecQcodeController(IBaseSafetyToolService baseSafetyToolService) {
+    this.baseSafetyToolService = baseSafetyToolService;
+  }
+
+  @ApiOperation(value = "单个")
+  @GetMapping(value = {"/", "/{qcode}"})
+  public AjaxResult getInfo(String qcode) {
+    BaseSafetyTool info = baseSafetyToolService.getInfoByQcode(qcode);
+    AjaxResult ajax = AjaxResult.success();
+    ajax.put("info", info);
+    return ajax;
+  }
+
+  /**
+   * 生成二维码
+   */
+  @ApiOperation(value = "二维码生成", notes = "二维码生成", response = ModelAndView.class)
+  @GetMapping("/captchaImage")
+  public AjaxResult getCode(Long toolId) {
+    AjaxResult ajax = AjaxResult.success();
+    BaseSafetyTool info = baseSafetyToolService.getInfo(toolId);
+    if (null == info) {
+      return ajax;
+    }
+    String base64Code;
+    try {
+      base64Code = QRCodeUtilEx.encodeStr(info.getToolQcode(), info.getToolName());
+    } catch (Exception e) {
+      return AjaxResult.error(e.getMessage());
+    }
+    ajax.put("img", base64Code);
+    return ajax;
+  }
+
+}

+ 0 - 65
railway-admin/src/main/java/com/railway/web/controller/business/safetool/SecTestRecordController.java

@@ -1,65 +0,0 @@
-package com.railway.web.controller.business.safetool;
-
-import com.railway.business.safetool.domain.SecTestRecord;
-import com.railway.business.safetool.service.ISecTestRecordService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-import com.railway.common.core.controller.BaseController;
-import com.railway.common.core.domain.AjaxResult;
-import com.railway.common.core.page.TableDataInfo;
-import javax.validation.Valid;
-import java.util.List;
-
-/**
- * @author ZhaoMn
- */
-@Api(value = "rest/business/safetool/test/record", tags = "安全工具 - 检验记录")
-@RestController
-@Validated
-@RequestMapping(value = "business/safetool/test/record")
-public class SecTestRecordController extends BaseController {
-
-  private final ISecTestRecordService secTestRecordService;
-
-  public SecTestRecordController(ISecTestRecordService secTestRecordService) {
-    this.secTestRecordService = secTestRecordService;
-  }
-
-  @ApiOperation(value = "新增")
-  @PostMapping("/add")
-  public AjaxResult add(@Validated @RequestBody SecTestRecord secTestRecord) {
-    return toAjax(secTestRecordService.create(secTestRecord));
-  }
-
-  @ApiOperation(value = "删除")
-  @DeleteMapping("/{ids}")
-  public AjaxResult delete(@RequestParam String[] ids) {
-    return toAjax(secTestRecordService.delete(ids));
-  }
-
-  @ApiOperation(value = "更新")
-  @PutMapping("/update")
-  public AjaxResult update(@RequestBody @Valid SecTestRecord secTestRecord) {
-    return toAjax(secTestRecordService.update(secTestRecord));
-  }
-
-  @ApiOperation(value = "单个")
-  @GetMapping(value = {"/", "/{id}"})
-  public AjaxResult getInfo(String id) {
-    SecTestRecord info = secTestRecordService.getInfo(id);
-    AjaxResult ajax = AjaxResult.success();
-    ajax.put("info", info);
-    return ajax;
-  }
-
-  @ApiOperation(value = "列表")
-  @GetMapping(value = "list")
-  public TableDataInfo getList(SecTestRecord secTestRecord) {
-    startPage();
-    List<SecTestRecord> list = secTestRecordService.getList(secTestRecord);
-    return getDataTable(list);
-  }
-
-}

+ 3 - 2
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebGjsfxServiceImpl.java

@@ -5,6 +5,7 @@ import com.railway.business.catenary.domain.BusJcebGjsfx;
 import com.railway.business.catenary.domain.vo.JcebQueryVo;
 import com.railway.business.catenary.mapper.BusJcebGjsfxMapper;
 import com.railway.business.catenary.service.IBusJcebGjsfxService;
+import com.railway.business.push.service.IBusPushMsgService;
 import com.railway.common.utils.StringUtils;
 import com.railway.common.utils.poi.EasyExcelUtil;
 import java.util.HashMap;
@@ -26,8 +27,8 @@ public class BusJcebGjsfxServiceImpl extends BusJcebServiceImpl<BusJcebGjsfx>
   private final BusJcebGjsfxMapper busJcebGjsfxMapper;
 
   public BusJcebGjsfxServiceImpl(BusJcebGjsfxMapper busJcebGjsfxMapper,
-      IBaseStationService stationService) {
-    super(busJcebGjsfxMapper, stationService);
+      IBaseStationService stationService, IBusPushMsgService busPushMsgService) {
+    super(busJcebGjsfxMapper, stationService, busPushMsgService);
     this.busJcebGjsfxMapper = busJcebGjsfxMapper;
   }
 

+ 3 - 2
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebJddzServiceImpl.java

@@ -6,6 +6,7 @@ import com.railway.business.catenary.domain.vo.JcebQueryVo;
 import com.railway.business.catenary.enums.JcebStatusEnum;
 import com.railway.business.catenary.mapper.BusJcebJddzMapper;
 import com.railway.business.catenary.service.IBusJcebJddzService;
+import com.railway.business.push.service.IBusPushMsgService;
 import com.railway.common.utils.StringUtils;
 import com.railway.common.utils.poi.EasyExcelUtil;
 import java.util.HashMap;
@@ -27,8 +28,8 @@ public class BusJcebJddzServiceImpl extends BusJcebServiceImpl<BusJcebJddz>
   private final BusJcebJddzMapper busJcebJddzMapper;
 
   public BusJcebJddzServiceImpl(BusJcebJddzMapper busJcebJddzMapper,
-      IBaseStationService stationService) {
-    super(busJcebJddzMapper, stationService);
+      IBaseStationService stationService, IBusPushMsgService busPushMsgService) {
+    super(busJcebJddzMapper, stationService, busPushMsgService);
     this.busJcebJddzMapper = busJcebJddzMapper;
   }
 

+ 3 - 2
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebJyzqsjlServiceImpl.java

@@ -5,6 +5,7 @@ import com.railway.business.catenary.domain.BusJcebJyzqsjl;
 import com.railway.business.catenary.domain.vo.JcebQueryVo;
 import com.railway.business.catenary.mapper.BusJcebJyzqsjlMapper;
 import com.railway.business.catenary.service.IBusJcebJyzqsjlService;
+import com.railway.business.push.service.IBusPushMsgService;
 import com.railway.common.utils.StringUtils;
 import com.railway.common.utils.poi.EasyExcelUtil;
 
@@ -28,8 +29,8 @@ public class BusJcebJyzqsjlServiceImpl extends BusJcebServiceImpl<BusJcebJyzqsjl
   private final BusJcebJyzqsjlMapper busJcebJyzqsjlMapper;
 
   public BusJcebJyzqsjlServiceImpl(BusJcebJyzqsjlMapper busJcebJyzqsjlMapper,
-      IBaseStationService stationService) {
-    super(busJcebJyzqsjlMapper, stationService);
+      IBaseStationService stationService, IBusPushMsgService busPushMsgService) {
+    super(busJcebJyzqsjlMapper, stationService, busPushMsgService);
     this.busJcebJyzqsjlMapper = busJcebJyzqsjlMapper;
   }
 

+ 3 - 2
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebLbjghjlServiceImpl.java

@@ -6,6 +6,7 @@ import com.railway.business.catenary.domain.vo.JcebQueryVo;
 import com.railway.business.catenary.mapper.BusJcebLbjghjlMapper;
 import com.railway.business.catenary.service.IBusJcebLbjghjlService;
 import com.railway.business.catenary.util.JcebQueryUtil;
+import com.railway.business.push.service.IBusPushMsgService;
 import com.railway.common.utils.StringUtils;
 import com.railway.common.utils.poi.EasyExcelUtil;
 import org.springframework.stereotype.Service;
@@ -26,8 +27,8 @@ public class BusJcebLbjghjlServiceImpl extends BusJcebServiceImpl<BusJcebLbjghjl
   private final BusJcebLbjghjlMapper busJcebLbjghjlMapper;
 
   public BusJcebLbjghjlServiceImpl(BusJcebLbjghjlMapper busJcebLbjghjlMapper,
-      IBaseStationService stationService) {
-    super(busJcebLbjghjlMapper, stationService);
+      IBaseStationService stationService, IBusPushMsgService busPushMsgService) {
+    super(busJcebLbjghjlMapper, stationService, busPushMsgService);
     this.busJcebLbjghjlMapper = busJcebLbjghjlMapper;
   }
 

+ 3 - 2
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebQmjcjlServiceImpl.java

@@ -6,6 +6,7 @@ import com.railway.business.catenary.domain.vo.JcebQueryVo;
 import com.railway.business.catenary.mapper.BusJcebQmjcjlMapper;
 import com.railway.business.catenary.service.IBusJcebQmjcjlService;
 import com.railway.business.catenary.util.JcebQueryUtil;
+import com.railway.business.push.service.IBusPushMsgService;
 import com.railway.common.utils.StringUtils;
 import com.railway.common.utils.poi.EasyExcelUtil;
 import java.util.List;
@@ -25,8 +26,8 @@ public class BusJcebQmjcjlServiceImpl extends BusJcebServiceImpl<BusJcebQmjcjl>
   private final BusJcebQmjcjlMapper busJcebQmjcjlMapper;
 
   public BusJcebQmjcjlServiceImpl(BusJcebQmjcjlMapper busJcebQmjcjlMapper,
-      IBaseStationService stationService) {
-    super(busJcebQmjcjlMapper, stationService);
+      IBaseStationService stationService, IBusPushMsgService busPushMsgService) {
+    super(busJcebQmjcjlMapper, stationService, busPushMsgService);
     this.busJcebQmjcjlMapper = busJcebQmjcjlMapper;
   }
 

+ 8 - 1
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebServiceImpl.java

@@ -12,6 +12,7 @@ import com.railway.business.catenary.enums.JcebStatusEnum;
 import com.railway.business.catenary.mapper.BusJcebMapper;
 import com.railway.business.catenary.service.IBusJcebService;
 import com.railway.business.catenary.util.JcebQueryUtil;
+import com.railway.business.push.service.IBusPushMsgService;
 import com.railway.common.enums.DelFlagEnum;
 import com.railway.common.utils.SecurityUtils;
 import com.railway.common.utils.StringUtils;
@@ -36,10 +37,13 @@ public abstract class BusJcebServiceImpl<T extends BusJceb> implements IBusJcebS
 
   private final BusJcebMapper<T> busJcebMapper;
   private final IBaseStationService stationService;
+  private final IBusPushMsgService busPushMsgService;
 
-  public BusJcebServiceImpl(BusJcebMapper<T> busJcebMapper, IBaseStationService stationService) {
+  public BusJcebServiceImpl(BusJcebMapper<T> busJcebMapper, IBaseStationService stationService,
+      IBusPushMsgService busPushMsgService) {
     this.busJcebMapper = busJcebMapper;
     this.stationService = stationService;
+    this.busPushMsgService = busPushMsgService;
   }
 
   /**
@@ -138,6 +142,7 @@ public abstract class BusJcebServiceImpl<T extends BusJceb> implements IBusJcebS
    */
   protected void setSubmit(BusJceb jceb) {
     jceb.setSubmitState(JcebStatusEnum.REPORTED.getCode());
+    busPushMsgService.create(jceb.getCreateBy(), "检测表提交", "检测表提交");
   }
 
   /**
@@ -145,6 +150,7 @@ public abstract class BusJcebServiceImpl<T extends BusJceb> implements IBusJcebS
    */
   protected void setReject(BusJceb jceb) {
     jceb.setSubmitState(JcebStatusEnum.RETURNED.getCode());
+    busPushMsgService.create(jceb.getCreateBy(), "检测表退回", "检测表退回");
   }
 
   /**
@@ -152,6 +158,7 @@ public abstract class BusJcebServiceImpl<T extends BusJceb> implements IBusJcebS
    */
   protected void setConfirm(BusJceb jceb) {
     jceb.setSubmitState(JcebStatusEnum.COMPLETED.getCode());
+    busPushMsgService.create(jceb.getCreateBy(), "检测表确认", "检测表确认");
   }
 
 }

+ 3 - 2
railway-business/src/main/java/com/railway/business/catenary/service/impl/BusJcebXsjcjlServiceImpl.java

@@ -6,6 +6,7 @@ import com.railway.business.catenary.domain.vo.JcebQueryVo;
 import com.railway.business.catenary.mapper.BusJcebXsjcjlMapper;
 import com.railway.business.catenary.service.IBusJcebXsjcjlService;
 import com.railway.business.catenary.util.JcebQueryUtil;
+import com.railway.business.push.service.IBusPushMsgService;
 import com.railway.common.utils.SecurityUtils;
 import com.railway.common.utils.StringUtils;
 import com.railway.common.utils.poi.EasyExcelUtil;
@@ -27,8 +28,8 @@ public class BusJcebXsjcjlServiceImpl extends BusJcebServiceImpl<BusJcebXsjcjl>
   private final BusJcebXsjcjlMapper busJcebXsjcjlMapper;
 
   public BusJcebXsjcjlServiceImpl(BusJcebXsjcjlMapper busJcebXsjcjlMapper,
-      IBaseStationService stationService) {
-    super(busJcebXsjcjlMapper, stationService);
+      IBaseStationService stationService, IBusPushMsgService busPushMsgService) {
+    super(busJcebXsjcjlMapper, stationService, busPushMsgService);
     this.busJcebXsjcjlMapper = busJcebXsjcjlMapper;
   }
 

+ 5 - 0
railway-business/src/main/java/com/railway/business/push/service/IBusPushMsgService.java

@@ -9,6 +9,11 @@ import java.util.List;
 */
 public interface IBusPushMsgService{
 
+    /**
+     * 消息推送
+     */
+    void create(String userName, String title, String content);
+
     /**
     * 新增
     */

+ 247 - 237
railway-business/src/main/java/com/railway/business/push/service/impl/BusPushMsgServiceImpl.java

@@ -15,279 +15,289 @@ import com.railway.business.push.domain.BusPushMsg;
 import com.railway.business.push.enums.PushEnum;
 import com.railway.business.push.mapper.BusPushMsgMapper;
 import com.railway.business.push.service.IBusPushMsgService;
+import com.railway.common.core.domain.entity.SysUser;
 import com.railway.common.utils.SecurityUtils;
 import com.railway.system.service.ISysConfigService;
+import com.railway.system.service.ISysUserService;
 import java.io.IOException;
 import java.util.Date;
 import java.util.List;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+
 /**
-* 个推消息表
-* @author author
-* @date 2021/11/16
-*/
+ * 个推消息表
+ *
+ * @author author
+ * @date 2021/11/16
+ */
 @Slf4j
 @Service
 @Transactional(readOnly = true)
-public class BusPushMsgServiceImpl implements IBusPushMsgService{
+public class BusPushMsgServiceImpl implements IBusPushMsgService {
+
+  private final BusPushMsgMapper busPushMsgMapper;
+  private final ISysUserService sysUserService;
 
-	private final ISysConfigService configService;
-	private BusPushMsgMapper busPushMsgMapper;
+  /**
+   * 每个应用都对应一个唯一的AppID
+   */
+  private String appId;
+  /**
+   * SDK 与服务器端通过 Appkey 互相识别
+   */
+  private String appKey;
+  /**
+   * 服务端API鉴权码
+   */
+  private String masterSecret;
 
-	/**
-	 * 每个应用都对应一个唯一的AppID
-	 */
-	private String appId;
-	/**
-	 * SDK 与服务器端通过 Appkey 互相识别
-	 */
-	private  String appKey;
-	/**
-	 * 服务端API鉴权码
-	 */
-	private String masterSecret;
+  /**
+   * 批量单传使用
+   */
+  private IGtPush push;
 
-	/**
-	 * 批量单传使用
-	 */
-	private IGtPush push;
+  public BusPushMsgServiceImpl(ISysConfigService configService, BusPushMsgMapper busPushMsgMapper,
+      ISysUserService sysUserService) {
+    this.busPushMsgMapper = busPushMsgMapper;
+    this.appId = configService.selectConfigByKey("getui.appId");
+    this.appKey = configService.selectConfigByKey("getui.appKey");
+    this.masterSecret = configService.selectConfigByKey("getui.masterSecret");
+    this.sysUserService = sysUserService;
 
-	public BusPushMsgServiceImpl(ISysConfigService configService, BusPushMsgMapper busPushMsgMapper) {
-		this.configService = configService;
-		this.busPushMsgMapper = busPushMsgMapper;
-		this.appId = this.configService.selectConfigByKey("getui.appId");
-		this.appKey = this.configService.selectConfigByKey("getui.appKey");
-		this.masterSecret = this.configService.selectConfigByKey("getui.masterSecret");
+    push = new IGtPush(appKey, masterSecret);
+  }
 
-		push = new IGtPush(appKey, masterSecret);
-	}
+  /**
+   * 消息推送
+   */
+  @Override
+  public void create(String userName, String title, String content) {
+    SysUser user = sysUserService.selectUserByUserName(userName);
+    BusPushMsg pushMsg = new BusPushMsg();
+    pushMsg.setUserId(user.getUserId());
+    pushMsg.setClientId(user.getMobileId());
+    pushMsg.setTitle(title);
+    pushMsg.setContent(content);
+    this.create(pushMsg);
+  }
 
-	/**
-	* 新增
-	*/
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int create(BusPushMsg busPushMsg) {
-	    busPushMsg.setCreateTime(new Date());
-        busPushMsg.setCreateBy(SecurityUtils.getUsername());
-		busPushMsg.setPushStatus("0");
-		busPushMsg.setPushLoop(0);
-		return busPushMsgMapper.insert(busPushMsg);
-	}
+  /**
+   * 新增
+   */
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int create(BusPushMsg busPushMsg) {
+    busPushMsg.setCreateTime(new Date());
+    busPushMsg.setCreateBy(SecurityUtils.getUsername());
+    busPushMsg.setPushStatus("0");
+    busPushMsg.setPushLoop(0);
+    return busPushMsgMapper.insert(busPushMsg);
+  }
 
-	/**
-	* 删除
-	*/
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int delete(String[] ids) {
-		int r =0;
-		for (String id : ids) {
-			int j= busPushMsgMapper.delete(id);
-			r = r + j;
-		}
-		return	r;
-	}
+  /**
+   * 删除
+   */
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int delete(String[] ids) {
+    int r = 0;
+    for (String id : ids) {
+      int j = busPushMsgMapper.delete(id);
+      r = r + j;
+    }
+    return r;
+  }
 
-	/**
-	* 更新
-	*/
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int update(BusPushMsg busPushMsg) {
-		busPushMsg.setUpdateTime(new Date());
-    	busPushMsg.setUpdateBy(SecurityUtils.getUsername());
-		return busPushMsgMapper.update(busPushMsg);
-	}
+  /**
+   * 更新
+   */
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int update(BusPushMsg busPushMsg) {
+    busPushMsg.setUpdateTime(new Date());
+    busPushMsg.setUpdateBy(SecurityUtils.getUsername());
+    return busPushMsgMapper.update(busPushMsg);
+  }
 
-	/**
-	* 获取单个
-	*/
-	@Override
-	public BusPushMsg getInfo(String id) {
-		return busPushMsgMapper.getInfo(id);
-	}
+  /**
+   * 获取单个
+   */
+  @Override
+  public BusPushMsg getInfo(String id) {
+    return busPushMsgMapper.getInfo(id);
+  }
 
-	/**
-	* 查询列表
-	*/
-	@Override
-	public List<BusPushMsg> getList(BusPushMsg busPushMsg) {
-		return busPushMsgMapper.getList(busPushMsg);
-	}
+  /**
+   * 查询列表
+   */
+  @Override
+  public List<BusPushMsg> getList(BusPushMsg busPushMsg) {
+    return busPushMsgMapper.getList(busPushMsg);
+  }
 
-	@Override
-	public List<BusPushMsg> selectAppMsg() {
-		return busPushMsgMapper.selectAppMsg();
-	}
+  @Override
+  public List<BusPushMsg> selectAppMsg() {
+    return busPushMsgMapper.selectAppMsg();
+  }
 
-	@Override
-	public List<BusPushMsg> getListTop5(BusPushMsg busPushMsg) {
-		// 查询已推送的
-		busPushMsg.setPushStatus(PushEnum.PUSH_STATUS_SUCCES.getCode());
-		return busPushMsgMapper.getListTop5(busPushMsg);
-	}
+  @Override
+  public List<BusPushMsg> getListTop5(BusPushMsg busPushMsg) {
+    // 查询已推送的
+    busPushMsg.setPushStatus(PushEnum.PUSH_STATUS_SUCCES.getCode());
+    return busPushMsgMapper.getListTop5(busPushMsg);
+  }
 
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void updateBatch(List<BusPushMsg> msgPos) {
-		for (BusPushMsg msg : msgPos) {
-			busPushMsgMapper.update(msg);
-		}
-	}
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public void updateBatch(List<BusPushMsg> msgPos) {
+    for (BusPushMsg msg : msgPos) {
+      busPushMsgMapper.update(msg);
+    }
+  }
 
-	/**
-	 * 对单个用户推送消息
-	 *
-	 * @return
-	 */
-	@Override
-	public String pushToSingle(BusPushMsg msgPo) {
-		AbstractTemplate template = getTransmissionTemplate(msgPo.getContent());
-		// 单推消息类型
-		SingleMessage message = getSingleMessage(template);
-		Target target = new Target();
-		target.setAppId(appId);
-		target.setClientId(msgPo.getClientId());
-		IPushResult ret = null;
-		try {
-			if (push != null) {
-				ret = push.pushMessageToSingle(message, target);
-			}
-			else {
-				return "个推服务IGtPush创建异常";
-			}
-		} catch (RequestException e) {
-			log.error("消息发送失败,尝试1次重发", e);
-			ret = push.pushMessageToSingle(message, target, e.getRequestId());
-		}
-		if (ret != null) {
-			JSONObject jsonObject = new JSONObject();
-			jsonObject.putAll(ret.getResponse());
-			return jsonObject.toJSONString();
-		} else {
-			return "服务器响应异常";
-		}
-	}
+  /**
+   * 对单个用户推送消息
+   */
+  @Override
+  public String pushToSingle(BusPushMsg msgPo) {
+    AbstractTemplate template = getTransmissionTemplate(msgPo.getContent());
+    // 单推消息类型
+    SingleMessage message = getSingleMessage(template);
+    Target target = new Target();
+    target.setAppId(appId);
+    target.setClientId(msgPo.getClientId());
+    IPushResult ret;
+    try {
+      if (push != null) {
+        ret = push.pushMessageToSingle(message, target);
+      } else {
+        return "个推服务IGtPush创建异常";
+      }
+    } catch (RequestException e) {
+      log.error("消息发送失败,尝试1次重发", e);
+      ret = push.pushMessageToSingle(message, target, e.getRequestId());
+    }
+    if (ret != null) {
+      JSONObject jsonObject = new JSONObject();
+      jsonObject.putAll(ret.getResponse());
+      return jsonObject.toJSONString();
+    } else {
+      return "服务器响应异常";
+    }
+  }
 
-	/**
-	 * 透传消息,消息传递到客户端只有消息内容,展现形式由客户端自行定义
-	 * 注:ios端只支持透传消息
-	 *
-	 * @param content
-	 * @return
-	 */
-	private TransmissionTemplate getTransmissionTemplate(String content) {
-		TransmissionTemplate template = new TransmissionTemplate();
-		template.setAppId(appId);
-		template.setAppkey(appKey);
-		//透传消息设置,1为强制启动应用,客户端接收到消息后就会立即启动应用;2为等待应用启动
-		template.setTransmissionType(1);
-		template.setTransmissionContent(content);
-		return template;
-	}
+  /**
+   * 透传消息,消息传递到客户端只有消息内容,展现形式由客户端自行定义
+   * 注:ios端只支持透传消息
+   */
+  private TransmissionTemplate getTransmissionTemplate(String content) {
+    TransmissionTemplate template = new TransmissionTemplate();
+    template.setAppId(appId);
+    template.setAppkey(appKey);
+    //透传消息设置,1为强制启动应用,客户端接收到消息后就会立即启动应用;2为等待应用启动
+    template.setTransmissionType(1);
+    template.setTransmissionContent(content);
+    return template;
+  }
 
-	/**
-	 * 通知模板
-	 * @param title
-	 * @param text
-	 * @return
-	 */
-	private NotificationTemplate getNotificationTemplate(String title, String text) {
-		Style0 style = new Style0();
-		// 设置推送标题、推送内容
-		style.setTitle(title);
-		style.setText(text);
-		// style.setLogo("push.png");  // 设置推送图标
-		// 设置响铃、震动等推送效果
-		style.setRing(true);  // 设置响铃
-		style.setVibrate(true);  // 设置震动
+  /**
+   * 通知模板
+   */
+  private NotificationTemplate getNotificationTemplate(String title, String text) {
+    Style0 style = new Style0();
+    // 设置推送标题、推送内容
+    style.setTitle(title);
+    style.setText(text);
+    // style.setLogo("push.png");  // 设置推送图标
+    // 设置响铃、震动等推送效果
+    style.setRing(true);  // 设置响铃
+    style.setVibrate(true);  // 设置震动
 
-		// 选择通知模板
-		NotificationTemplate template = new NotificationTemplate();
-		template.setAppId(appId);
-		template.setAppkey(appKey);
-		template.setStyle(style);
-		return template;
-	}
+    // 选择通知模板
+    NotificationTemplate template = new NotificationTemplate();
+    template.setAppId(appId);
+    template.setAppkey(appKey);
+    template.setStyle(style);
+    return template;
+  }
 
-	private SingleMessage getSingleMessage(AbstractTemplate template) {
-		SingleMessage message = new SingleMessage();
-		message.setData(template);
-		// 设置消息离线,并设置离线时间
-		message.setOffline(true);
-		// 离线有效时间,单位为毫秒
-		message.setOfflineExpireTime(72 * 3600 * 1000);
-		message.setPriority(1);
-		// 判断客户端是否wifi环境下推送。1为仅在wifi环境下推送,0为不限制网络环境,默认不限
-		message.setPushNetWorkType(0);
-		return message;
-	}
+  private SingleMessage getSingleMessage(AbstractTemplate template) {
+    SingleMessage message = new SingleMessage();
+    message.setData(template);
+    // 设置消息离线,并设置离线时间
+    message.setOffline(true);
+    // 离线有效时间,单位为毫秒
+    message.setOfflineExpireTime(72 * 3600 * 1000);
+    message.setPriority(1);
+    // 判断客户端是否wifi环境下推送。1为仅在wifi环境下推送,0为不限制网络环境,默认不限
+    message.setPushNetWorkType(0);
+    return message;
+  }
 
-	/**
-	 * 批量单推
-	 * <p>
-	 * 当单推任务较多时,推荐使用该接口,可以减少与服务端的交互次数。
-	 */
-	@Override
-	public void pushToSingleBatch(List<BusPushMsg> msgPos) {
-		IBatch batch = push.getBatch();
-		IPushResult ret = null;
-		try {
-			//构建客户a的透传消息a
-			for (BusPushMsg msgPo : msgPos) {
-				constructClientTransMsg(msgPo.getClientId(), batch, msgPo.getContent());
-			}
-			ret = batch.submit();
-		} catch (Exception e) {
-			e.printStackTrace();
-			try {
-				ret = batch.retry();
-			} catch (IOException ex) {
-				ex.printStackTrace();
-			}
-		}
-		if (ret != null) {
-			log.info(ret.getResponse().toString());
-		} else {
-			log.info("服务器响应异常");
-		}
-	}
+  /**
+   * 批量单推
+   * <p>
+   * 当单推任务较多时,推荐使用该接口,可以减少与服务端的交互次数。
+   */
+  @Override
+  public void pushToSingleBatch(List<BusPushMsg> msgPos) {
+    IBatch batch = push.getBatch();
+    IPushResult ret = null;
+    try {
+      //构建客户a的透传消息a
+      for (BusPushMsg msgPo : msgPos) {
+        constructClientTransMsg(msgPo.getClientId(), batch, msgPo.getContent());
+      }
+      ret = batch.submit();
+    } catch (Exception e) {
+      e.printStackTrace();
+      try {
+        ret = batch.retry();
+      } catch (IOException ex) {
+        ex.printStackTrace();
+      }
+    }
+    if (ret != null) {
+      log.info(ret.getResponse().toString());
+    } else {
+      log.info("服务器响应异常");
+    }
+  }
 
-	private void constructClientTransMsg(String cid, IBatch batch, String content) throws Exception {
-		AbstractTemplate template = getTransmissionTemplate(content);
-		SingleMessage message = getSingleMessage(template);
-		// 设置推送目标,填入appid和clientId
-		Target target = new Target();
-		target.setAppId(appId);
-		target.setClientId(cid);
-		batch.add(message, target);
-	}
+  private void constructClientTransMsg(String cid, IBatch batch, String content) throws Exception {
+    AbstractTemplate template = getTransmissionTemplate(content);
+    SingleMessage message = getSingleMessage(template);
+    // 设置推送目标,填入appid和clientId
+    Target target = new Target();
+    target.setAppId(appId);
+    target.setClientId(cid);
+    batch.add(message, target);
+  }
 
-	/**
+  /**
 
-	 public BusPushMsgServiceImpl() {
+   public BusPushMsgServiceImpl() {
 
-	 }
+   }
 
-	 public BusPushMsgServiceImpl(String appId, String appKey, String masterSecret, boolean enable) {
-		 this.appId = appId;
-		 this.appKey = appKey;
-		 this.masterSecret = masterSecret;
-		 this.enable = enable;
-		 push = new IGtPush(appKey, masterSecret);
-	 }
+   public BusPushMsgServiceImpl(String appId, String appKey, String masterSecret, boolean enable) {
+   this.appId = appId;
+   this.appKey = appKey;
+   this.masterSecret = masterSecret;
+   this.enable = enable;
+   push = new IGtPush(appKey, masterSecret);
+   }
 
-	public static void main(String[] args) {
-		BusPushMsgServiceImpl push = new BusPushMsgServiceImpl("Y3xRJmer116Bb1HhqnZav7","N2oftDIHyC9o1Ue73Cx3fA","OZhDEZbGTZ9tc8P8IQ3Mk3",true);
-		BusPushMsg msgPo = new BusPushMsg();
-		msgPo.setClientId("d2a737569978aa43f42b2a8c562f69b1");
-		msgPo.setContent("测试服务器端push内容main");
-		String result = push.pushToSingle(msgPo);
-		System.out.println(result);
-	}
-	 */
+   public static void main(String[] args) {
+   BusPushMsgServiceImpl push = new BusPushMsgServiceImpl("Y3xRJmer116Bb1HhqnZav7","N2oftDIHyC9o1Ue73Cx3fA","OZhDEZbGTZ9tc8P8IQ3Mk3",true);
+   BusPushMsg msgPo = new BusPushMsg();
+   msgPo.setClientId("d2a737569978aa43f42b2a8c562f69b1");
+   msgPo.setContent("测试服务器端push内容main");
+   String result = push.pushToSingle(msgPo);
+   System.out.println(result);
+   }
+   */
 
 }

+ 4 - 0
railway-business/src/main/java/com/railway/business/safetool/domain/BaseSafetyTool.java

@@ -42,6 +42,10 @@ public class BaseSafetyTool extends BaseEntity{
     @Length(min = 1, max = 50, message = "【编号】长度必须介于 {min} 和 {max} 之间")
     private String toolCode;
 
+    @ApiModelProperty(value = "二维码编码")
+    @Length(min = 1, max = 64, message = "【二维码编码】长度必须介于 {min} 和 {max} 之间")
+    private String toolQcode;
+
     @ApiModelProperty(value = "电压等级")
     @Length(min = 1, max = 10, message = "【电压等级】长度必须介于 {min} 和 {max} 之间")
     private String elecLevel;

+ 7 - 2
railway-business/src/main/java/com/railway/business/safetool/mapper/BaseSafetyToolMapper.java

@@ -23,7 +23,7 @@ public interface BaseSafetyToolMapper {
     /**
     * 删除
     */
-    int delete(@Param("toolId") String toolId);
+    int delete(@Param("toolId") Long toolId);
 
     /**
     * 更新
@@ -33,7 +33,12 @@ public interface BaseSafetyToolMapper {
     /**
     * 获取单个
     */
-    BaseSafetyTool getInfo(@Param("toolId") String toolId);
+    BaseSafetyTool getInfo(@Param("toolId") Long toolId);
+
+    /**
+     * 获取单个
+     */
+    BaseSafetyTool getInfoByQcode(@Param("qcode") String qcode);
 
     /**
     * 查询列表

+ 7 - 2
railway-business/src/main/java/com/railway/business/safetool/service/IBaseSafetyToolService.java

@@ -17,7 +17,7 @@ public interface IBaseSafetyToolService{
     /**
     * 删除
     */
-    int delete(String[] toolIds);
+    int delete(Long[] toolIds);
 
     /**
     * 更新
@@ -27,7 +27,12 @@ public interface IBaseSafetyToolService{
     /**
     * 获取单个
     */
-    BaseSafetyTool getInfo(String toolId);
+    BaseSafetyTool getInfo(Long toolId);
+
+    /**
+     * 获取单个
+     */
+    BaseSafetyTool getInfoByQcode(String qcode);
 
     /**
     * 查询列表

+ 20 - 4
railway-business/src/main/java/com/railway/business/safetool/service/impl/BaseSafetyToolServiceImpl.java

@@ -3,6 +3,8 @@ package com.railway.business.safetool.service.impl;
 import com.railway.business.safetool.domain.BaseSafetyTool;
 import com.railway.business.safetool.mapper.BaseSafetyToolMapper;
 import com.railway.business.safetool.service.IBaseSafetyToolService;
+import com.railway.common.enums.QcodeEnum;
+import com.railway.common.qrcode.impl.SnowflakeClient;
 import com.railway.common.utils.SecurityUtils;
 import java.util.Date;
 import java.util.List;
@@ -20,9 +22,12 @@ import org.springframework.transaction.annotation.Transactional;
 public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
 
   private final BaseSafetyToolMapper baseSafetyToolMapper;
+  private final SnowflakeClient snowflakeClient;
 
-  public BaseSafetyToolServiceImpl(BaseSafetyToolMapper baseSafetyToolMapper) {
+  public BaseSafetyToolServiceImpl(BaseSafetyToolMapper baseSafetyToolMapper,
+      SnowflakeClient snowflakeClient) {
     this.baseSafetyToolMapper = baseSafetyToolMapper;
+    this.snowflakeClient = snowflakeClient;
   }
 
   /**
@@ -34,6 +39,9 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
     baseSafetyTool.setCreateTime(new Date());
     baseSafetyTool.setCreateBy(SecurityUtils.getUsername());
     baseSafetyTool.setState("1");
+    String qcode = snowflakeClient.code(QcodeEnum.LETTER_NUMBER) + "_"
+        + baseSafetyTool.getToolType() + "_" + baseSafetyTool.getToolCode();
+    baseSafetyTool.setToolQcode(qcode);
     return baseSafetyToolMapper.insert(baseSafetyTool);
   }
 
@@ -42,9 +50,9 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
    */
   @Override
   @Transactional(rollbackFor = Exception.class)
-  public int delete(String[] toolIds) {
+  public int delete(Long[] toolIds) {
     int r = 0;
-    for (String toolId : toolIds) {
+    for (Long toolId : toolIds) {
       int j = baseSafetyToolMapper.delete(toolId);
       r = r + j;
     }
@@ -66,10 +74,18 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
    * 获取单个
    */
   @Override
-  public BaseSafetyTool getInfo(String toolId) {
+  public BaseSafetyTool getInfo(Long toolId) {
     return baseSafetyToolMapper.getInfo(toolId);
   }
 
+  /**
+   * 获取单个
+   */
+  @Override
+  public BaseSafetyTool getInfoByQcode(String qcode) {
+    return baseSafetyToolMapper.getInfoByQcode(qcode);
+  }
+
   /**
    * 查询列表
    */

+ 376 - 358
railway-business/src/main/resources/mapper/safetool/BaseSafetyToolMapper.xml

@@ -1,372 +1,390 @@
 <?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">
+  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.railway.business.safetool.mapper.BaseSafetyToolMapper">
 
-    <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.BaseSafetyTool">
-                <result column="tool_id" property="toolId"/>
-                <result column="dept_id" property="deptId"/>
-                <result column="dept_name" property="deptName"/>
-                <result column="store_place" property="storePlace"/>
-                <result column="tool_name" property="toolName"/>
-                <result column="tool_type" property="toolType"/>
-                <result column="tool_code" property="toolCode"/>
-                <result column="elec_level" property="elecLevel"/>
-                <result column="unit" property="unit"/>
-                <result column="test_cycle" property="testCycle"/>
-                <result column="test_cycle_text" property="testCycleText"/>
-                <result column="last_test_date" property="lastTestDate"/>
-                <result column="next_test_date" property="nextTestDate"/>
-                <result column="test_result" property="testResult"/>
-                <result column="test_date" property="testDate"/>
-                <result column="test_result_desc" property="testResultDesc"/>
-                <result column="state" property="state"/>
-                <result column="scrap_reason" property="scrapReason"/>
-                <result column="scrap_date" property="scrapDate"/>
-                <result column="scrap_user" property="scrapUser"/>
-                <result column="replace_tool_id" property="replaceToolId"/>
-                <result column="produce_factory" property="produceFactory"/>
-                <result column="produce_date" property="produceDate"/>
-                <result column="remark" property="remark"/>
-                <result column="del_flag" property="delFlag"/>
-                <result column="create_by" property="createBy"/>
-                <result column="create_time" property="createTime"/>
-                <result column="update_by" property="updateBy"/>
-                <result column="update_time" property="updateTime"/>
-    </resultMap>
+  <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.BaseSafetyTool">
+    <result column="tool_id" property="toolId"/>
+    <result column="dept_id" property="deptId"/>
+    <result column="dept_name" property="deptName"/>
+    <result column="store_place" property="storePlace"/>
+    <result column="tool_name" property="toolName"/>
+    <result column="tool_type" property="toolType"/>
+    <result column="tool_code" property="toolCode"/>
+    <result column="elec_level" property="elecLevel"/>
+    <result column="unit" property="unit"/>
+    <result column="test_cycle" property="testCycle"/>
+    <result column="test_cycle_text" property="testCycleText"/>
+    <result column="last_test_date" property="lastTestDate"/>
+    <result column="next_test_date" property="nextTestDate"/>
+    <result column="test_result" property="testResult"/>
+    <result column="test_date" property="testDate"/>
+    <result column="test_result_desc" property="testResultDesc"/>
+    <result column="state" property="state"/>
+    <result column="scrap_reason" property="scrapReason"/>
+    <result column="scrap_date" property="scrapDate"/>
+    <result column="scrap_user" property="scrapUser"/>
+    <result column="replace_tool_id" property="replaceToolId"/>
+    <result column="produce_factory" property="produceFactory"/>
+    <result column="produce_date" property="produceDate"/>
+    <result column="remark" property="remark"/>
+    <result column="del_flag" property="delFlag"/>
+    <result column="create_by" property="createBy"/>
+    <result column="create_time" property="createTime"/>
+    <result column="update_by" property="updateBy"/>
+    <result column="update_time" property="updateTime"/>
+  </resultMap>
 
-    <sql id="Base_Column_List">
-        t.tool_id,
-        t.dept_id,
-        dept.dept_name,
-        t.store_place,
-        dict1.dict_label as tool_name,
-        t.tool_type,
-        t.tool_code,
-        t.elec_level,
-        dict1.remark unit,
-        t.test_cycle,
-        dict2.dict_label as test_cycle_text,
-        t.last_test_date,
-        t.next_test_date,
-        t.test_result,
-        t.test_date,
-        t.test_result_desc,
-        t.state,
-        t.scrap_reason,
-        t.scrap_date,
-        t.scrap_user,
-        t.replace_tool_id,
-        t.produce_factory,
-        t.produce_date,
-        t.remark,
-        t.del_flag,
-        t.create_by,
-        t.create_time,
-        t.update_by,
-        t.update_time
-    </sql>
+  <sql id="Base_Column_List">
+    t.tool_id,
+    t.dept_id,
+    dept.dept_name,
+    t.store_place,
+    dict1.dict_label as tool_name,
+    t.tool_type,
+    t.tool_code,
+    t.elec_level,
+    dict1.remark unit,
+    t.test_cycle,
+    dict2.dict_label as test_cycle_text,
+    t.last_test_date,
+    t.next_test_date,
+    t.test_result,
+    t.test_date,
+    t.test_result_desc,
+    t.state,
+    t.scrap_reason,
+    t.scrap_date,
+    t.scrap_user,
+    t.replace_tool_id,
+    t.produce_factory,
+    t.produce_date,
+    t.remark,
+    t.del_flag,
+    t.create_by,
+    t.create_time,
+    t.update_by,
+    t.update_time
+  </sql>
 
-    <insert id="insert" parameterType="com.railway.business.safetool.domain.BaseSafetyTool"  useGeneratedKeys="true" keyProperty="toolId">
-        INSERT INTO base_safety_tool
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test ='null != deptId'>
-                    dept_id,
-                    </if>
-                    <if test ='null != storePlace'>
-                    store_place,
-                    </if>
-                    <if test ='null != toolName'>
-                    tool_name,
-                    </if>
-                    <if test ='null != toolType'>
-                    tool_type,
-                    </if>
-                    <if test ='null != toolCode'>
-                    tool_code,
-                    </if>
-                    <if test ='null != elecLevel'>
-                    elec_level,
-                    </if>
-                    <if test ='null != unit'>
-                    unit,
-                    </if>
-                    <if test ='null != testCycle'>
-                    test_cycle,
-                    </if>
-                    <if test ='null != lastTestDate'>
-                    last_test_date,
-                    </if>
-                    <if test ='null != nextTestDate'>
-                    next_test_date,
-                    </if>
-                    <if test ='null != testResult'>
-                    test_result,
-                    </if>
-                    <if test ='null != testDate'>
-                    test_date,
-                    </if>
-                    <if test ='null != testResultDesc'>
-                    test_result_desc,
-                    </if>
-                    <if test ='null != state'>
-                    state,
-                    </if>
-                    <if test ='null != scrapReason'>
-                    scrap_reason,
-                    </if>
-                    <if test ='null != scrapDate'>
-                    scrap_date,
-                    </if>
-                    <if test ='null != scrapUser'>
-                    scrap_user,
-                    </if>
-                    <if test ='null != replaceToolId'>
-                    replace_tool_id,
-                    </if>
-                    <if test ='null != produceFactory'>
-                    produce_factory,
-                    </if>
-                    <if test ='null != produceDate'>
-                    produce_date,
-                    </if>
-                    <if test ='null != remark'>
-                    remark,
-                    </if>
-                    <if test ='null != delFlag'>
-                    del_flag,
-                    </if>
-                    <if test ='null != createBy'>
-                    create_by,
-                    </if>
-                    <if test ='null != createTime'>
-                    create_time,
-                    </if>
-                    <if test ='null != updateBy'>
-                    update_by,
-                    </if>
-                    <if test ='null != updateTime'>
-                    update_time
-                    </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-                    <if test ='null != deptId'>
-                    #{deptId},
-                    </if>
-                    <if test ='null != storePlace'>
-                    #{storePlace},
-                    </if>
-                    <if test ='null != toolName'>
-                    #{toolName},
-                    </if>
-                    <if test ='null != toolType'>
-                    #{toolType},
-                    </if>
-                    <if test ='null != toolCode'>
-                    #{toolCode},
-                    </if>
-                    <if test ='null != elecLevel'>
-                    #{elecLevel},
-                    </if>
-                    <if test ='null != unit'>
-                    #{unit},
-                    </if>
-                    <if test ='null != testCycle'>
-                    #{testCycle},
-                    </if>
-                    <if test ='null != lastTestDate'>
-                    #{lastTestDate},
-                    </if>
-                    <if test ='null != nextTestDate'>
-                    #{nextTestDate},
-                    </if>
-                    <if test ='null != testResult'>
-                    #{testResult},
-                    </if>
-                    <if test ='null != testDate'>
-                    #{testDate},
-                    </if>
-                    <if test ='null != testResultDesc'>
-                    #{testResultDesc},
-                    </if>
-                    <if test ='null != state'>
-                    #{state},
-                    </if>
-                    <if test ='null != scrapReason'>
-                    #{scrapReason},
-                    </if>
-                    <if test ='null != scrapDate'>
-                    #{scrapDate},
-                    </if>
-                    <if test ='null != scrapUser'>
-                    #{scrapUser},
-                    </if>
-                    <if test ='null != replaceToolId'>
-                    #{replaceToolId},
-                    </if>
-                    <if test ='null != produceFactory'>
-                    #{produceFactory},
-                    </if>
-                    <if test ='null != produceDate'>
-                    #{produceDate},
-                    </if>
-                    <if test ='null != remark'>
-                    #{remark},
-                    </if>
-                    <if test ='null != delFlag'>
-                    #{delFlag},
-                    </if>
-                    <if test ='null != createBy'>
-                    #{createBy},
-                    </if>
-                    <if test ='null != createTime'>
-                    #{createTime},
-                    </if>
-                    <if test ='null != updateBy'>
-                    #{updateBy},
-                    </if>
-                    <if test ='null != updateTime'>
-                    #{updateTime}
-                    </if>
-        </trim>
-    </insert>
+  <insert id="insert" parameterType="com.railway.business.safetool.domain.BaseSafetyTool"
+    useGeneratedKeys="true" keyProperty="toolId">
+    INSERT INTO base_safety_tool
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test='null != deptId'>
+        dept_id,
+      </if>
+      <if test='null != storePlace'>
+        store_place,
+      </if>
+      <if test='null != toolName'>
+        tool_name,
+      </if>
+      <if test='null != toolType'>
+        tool_type,
+      </if>
+      <if test='null != toolCode'>
+        tool_code,
+      </if>
+      <if test='null != elecLevel'>
+        elec_level,
+      </if>
+      <if test='null != unit'>
+        unit,
+      </if>
+      <if test='null != testCycle'>
+        test_cycle,
+      </if>
+      <if test='null != lastTestDate'>
+        last_test_date,
+      </if>
+      <if test='null != nextTestDate'>
+        next_test_date,
+      </if>
+      <if test='null != testResult'>
+        test_result,
+      </if>
+      <if test='null != testDate'>
+        test_date,
+      </if>
+      <if test='null != testResultDesc'>
+        test_result_desc,
+      </if>
+      <if test='null != state'>
+        state,
+      </if>
+      <if test='null != scrapReason'>
+        scrap_reason,
+      </if>
+      <if test='null != scrapDate'>
+        scrap_date,
+      </if>
+      <if test='null != scrapUser'>
+        scrap_user,
+      </if>
+      <if test='null != replaceToolId'>
+        replace_tool_id,
+      </if>
+      <if test='null != produceFactory'>
+        produce_factory,
+      </if>
+      <if test='null != produceDate'>
+        produce_date,
+      </if>
+      <if test='null != remark'>
+        remark,
+      </if>
+      <if test='null != delFlag'>
+        del_flag,
+      </if>
+      <if test='null != createBy'>
+        create_by,
+      </if>
+      <if test='null != createTime'>
+        create_time,
+      </if>
+      <if test='null != updateBy'>
+        update_by,
+      </if>
+      <if test='null != updateTime'>
+        update_time
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test='null != deptId'>
+        #{deptId},
+      </if>
+      <if test='null != storePlace'>
+        #{storePlace},
+      </if>
+      <if test='null != toolName'>
+        #{toolName},
+      </if>
+      <if test='null != toolType'>
+        #{toolType},
+      </if>
+      <if test='null != toolCode'>
+        #{toolCode},
+      </if>
+      <if test='null != elecLevel'>
+        #{elecLevel},
+      </if>
+      <if test='null != unit'>
+        #{unit},
+      </if>
+      <if test='null != testCycle'>
+        #{testCycle},
+      </if>
+      <if test='null != lastTestDate'>
+        #{lastTestDate},
+      </if>
+      <if test='null != nextTestDate'>
+        #{nextTestDate},
+      </if>
+      <if test='null != testResult'>
+        #{testResult},
+      </if>
+      <if test='null != testDate'>
+        #{testDate},
+      </if>
+      <if test='null != testResultDesc'>
+        #{testResultDesc},
+      </if>
+      <if test='null != state'>
+        #{state},
+      </if>
+      <if test='null != scrapReason'>
+        #{scrapReason},
+      </if>
+      <if test='null != scrapDate'>
+        #{scrapDate},
+      </if>
+      <if test='null != scrapUser'>
+        #{scrapUser},
+      </if>
+      <if test='null != replaceToolId'>
+        #{replaceToolId},
+      </if>
+      <if test='null != produceFactory'>
+        #{produceFactory},
+      </if>
+      <if test='null != produceDate'>
+        #{produceDate},
+      </if>
+      <if test='null != remark'>
+        #{remark},
+      </if>
+      <if test='null != delFlag'>
+        #{delFlag},
+      </if>
+      <if test='null != createBy'>
+        #{createBy},
+      </if>
+      <if test='null != createTime'>
+        #{createTime},
+      </if>
+      <if test='null != updateBy'>
+        #{updateBy},
+      </if>
+      <if test='null != updateTime'>
+        #{updateTime}
+      </if>
+    </trim>
+  </insert>
 
-    <delete id="delete">
-        UPDATE base_safety_tool
-        set del_flag='1'
-        WHERE tool_id = #{toolId}
-    </delete>
+  <delete id="delete">
+    UPDATE base_safety_tool
+    set del_flag='1'
+    WHERE tool_id = #{toolId}
+  </delete>
 
-    <update id="update" parameterType="com.railway.business.safetool.domain.BaseSafetyTool">
-        UPDATE base_safety_tool
-        <set>
-                    <if test ='null != deptId'>dept_id = #{deptId},</if>
-                    <if test ='null != storePlace'>store_place = #{storePlace},</if>
-                    <if test ='null != toolName'>tool_name = #{toolName},</if>
-                    <if test ='null != toolType'>tool_type = #{toolType},</if>
-                    <if test ='null != toolCode'>tool_code = #{toolCode},</if>
-                    <if test ='null != elecLevel'>elec_level = #{elecLevel},</if>
-                    <if test ='null != unit'>unit = #{unit},</if>
-                    <if test ='null != testCycle'>test_cycle = #{testCycle},</if>
-                    <if test ='null != lastTestDate'>last_test_date = #{lastTestDate},</if>
-                    <if test ='null != nextTestDate'>next_test_date = #{nextTestDate},</if>
-                    <if test ='null != testResult'>test_result = #{testResult},</if>
-                    <if test ='null != testDate'>test_date = #{testDate},</if>
-                    <if test ='null != testResultDesc'>test_result_desc = #{testResultDesc},</if>
-                    <if test ='null != state'>state = #{state},</if>
-                    <if test ='null != scrapReason'>scrap_reason = #{scrapReason},</if>
-                    <if test ='null != scrapDate'>scrap_date = #{scrapDate},</if>
-                    <if test ='null != scrapUser'>scrap_user = #{scrapUser},</if>
-                    <if test ='null != replaceToolId'>replace_tool_id = #{replaceToolId},</if>
-                    <if test ='null != produceFactory'>produce_factory = #{produceFactory},</if>
-                    <if test ='null != produceDate'>produce_date = #{produceDate},</if>
-                    <if test ='null != remark'>remark = #{remark},</if>
-                    <if test ='null != delFlag'>del_flag = #{delFlag},</if>
-                    <if test ='null != createBy'>create_by = #{createBy},</if>
-                    <if test ='null != createTime'>create_time = #{createTime},</if>
-                    <if test ='null != updateBy'>update_by = #{updateBy},</if>
-                    <if test ='null != updateTime'>update_time = #{updateTime}</if>
-        </set>
-        WHERE tool_id = #{toolId}
-    </update>
+  <update id="update" parameterType="com.railway.business.safetool.domain.BaseSafetyTool">
+    UPDATE base_safety_tool
+    <set>
+      <if test='null != deptId'>dept_id = #{deptId},</if>
+      <if test='null != storePlace'>store_place = #{storePlace},</if>
+      <if test='null != toolName'>tool_name = #{toolName},</if>
+      <if test='null != toolType'>tool_type = #{toolType},</if>
+      <if test='null != toolCode'>tool_code = #{toolCode},</if>
+      <if test='null != elecLevel'>elec_level = #{elecLevel},</if>
+      <if test='null != unit'>unit = #{unit},</if>
+      <if test='null != testCycle'>test_cycle = #{testCycle},</if>
+      <if test='null != lastTestDate'>last_test_date = #{lastTestDate},</if>
+      <if test='null != nextTestDate'>next_test_date = #{nextTestDate},</if>
+      <if test='null != testResult'>test_result = #{testResult},</if>
+      <if test='null != testDate'>test_date = #{testDate},</if>
+      <if test='null != testResultDesc'>test_result_desc = #{testResultDesc},</if>
+      <if test='null != state'>state = #{state},</if>
+      <if test='null != scrapReason'>scrap_reason = #{scrapReason},</if>
+      <if test='null != scrapDate'>scrap_date = #{scrapDate},</if>
+      <if test='null != scrapUser'>scrap_user = #{scrapUser},</if>
+      <if test='null != replaceToolId'>replace_tool_id = #{replaceToolId},</if>
+      <if test='null != produceFactory'>produce_factory = #{produceFactory},</if>
+      <if test='null != produceDate'>produce_date = #{produceDate},</if>
+      <if test='null != remark'>remark = #{remark},</if>
+      <if test='null != delFlag'>del_flag = #{delFlag},</if>
+      <if test='null != createBy'>create_by = #{createBy},</if>
+      <if test='null != createTime'>create_time = #{createTime},</if>
+      <if test='null != updateBy'>update_by = #{updateBy},</if>
+      <if test='null != updateTime'>update_time = #{updateTime}</if>
+    </set>
+    WHERE tool_id = #{toolId}
+  </update>
 
 
-    <select id="getInfo" resultMap="BaseResultMap">
-        SELECT
-        <include refid="Base_Column_List"/>
-        FROM base_safety_tool t
-        LEFT JOIN sys_dept dept on t.dept_id = dept.dept_id
-        LEFT JOIN sys_dict_data dict1 ON (t.tool_type = dict1.dict_value AND dict1.dict_type = 'tool_type')
-        LEFT JOIN sys_dict_data dict2 ON (t.test_cycle = dict2.dict_value AND dict2.dict_type = 'test_cycle')
-        WHERE t.del_flag='0' and t.tool_id = #{toolId}
+  <select id="getInfo" resultMap="BaseResultMap">
+    SELECT
+    <include refid="Base_Column_List"/>
+    FROM base_safety_tool t
+    LEFT JOIN sys_dept dept on t.dept_id = dept.dept_id
+    LEFT JOIN sys_dict_data dict1 ON (t.tool_type = dict1.dict_value AND dict1.dict_type =
+    'tool_type')
+    LEFT JOIN sys_dict_data dict2 ON (t.test_cycle = dict2.dict_value AND dict2.dict_type =
+    'test_cycle')
+    WHERE t.del_flag='0' and t.tool_id = #{toolId}
 
-    </select>
+  </select>
 
-    <select id="getList" resultMap="BaseResultMap">
-        SELECT
-        <include refid="Base_Column_List"/>
-        FROM base_safety_tool t
-        LEFT JOIN sys_dept dept on t.dept_id = dept.dept_id
-        LEFT JOIN sys_dict_data dict1 ON (t.tool_type = dict1.dict_value AND dict1.dict_type = 'tool_type')
-        LEFT JOIN sys_dict_data dict2 ON (t.test_cycle = dict2.dict_value AND dict2.dict_type = 'test_cycle')
-        <where>
-            t.del_flag='0'
-                <if test="deptId!=null and deptId!=''">
-                    and t.dept_id=#{deptId}
-                </if>
-                <if test="storePlace!=null and storePlace!=''">
-                    and t.store_place=#{storePlace}
-                </if>
-                <if test="toolName!=null and toolName!=''">
-                    and t.tool_name=#{toolName}
-                </if>
-                <if test="toolType!=null and toolType!=''">
-                    and t.tool_type=#{toolType}
-                </if>
-                <if test="toolCode!=null and toolCode!=''">
-                    and t.tool_code=#{toolCode}
-                </if>
-                <if test="elecLevel!=null and elecLevel!=''">
-                    and t.elec_level=#{elecLevel}
-                </if>
-                <if test="unit!=null and unit!=''">
-                    and t.unit=#{unit}
-                </if>
-                <if test="testCycle!=null and testCycle!=''">
-                    and t.test_cycle=#{testCycle}
-                </if>
-                <if test="lastTestDate!=null">
-                    and t.last_test_date=#{lastTestDate}
-                </if>
-                <if test="nextTestDate!=null">
-                    and t.next_test_date=#{nextTestDate}
-                </if>
-                <if test="testResult!=null and testResult!=''">
-                    and t.test_result=#{testResult}
-                </if>
-                <if test="testDate!=null">
-                    and t.test_date=#{testDate}
-                </if>
-                <if test="testResultDesc!=null and testResultDesc!=''">
-                    and t.test_result_desc=#{testResultDesc}
-                </if>
-                <if test="state!=null and state!=''">
-                    and t.state=#{state}
-                </if>
-                <if test="scrapReason!=null and scrapReason!=''">
-                    and t.scrap_reason=#{scrapReason}
-                </if>
-                <if test="scrapDate!=null and scrapDate!=''">
-                    and t.scrap_date=#{scrapDate}
-                </if>
-                <if test="scrapUser!=null and scrapUser!=''">
-                    and t.scrap_user=#{scrapUser}
-                </if>
-                <if test="replaceToolId!=null and replaceToolId!=''">
-                    and t.replace_tool_id=#{replaceToolId}
-                </if>
-                <if test="produceFactory!=null and produceFactory!=''">
-                    and t.produce_factory=#{produceFactory}
-                </if>
-                <if test="produceDate!=null">
-                    and t.produce_date=#{produceDate}
-                </if>
-                <if test="remark!=null and remark!=''">
-                    and t.remark=#{remark}
-                </if>
-                <if test="createBy!=null and createBy!=''">
-                    and t.create_by=#{createBy}
-                </if>
-                <if test="createTime!=null">
-                    and DATE_FORMAT(t.create_time, '%Y-%m-%d') = #{createTime}
-                </if>
-                <if test="updateBy!=null and updateBy!=''">
-                    and t.update_by=#{updateBy}
-                </if>
-                <if test="updateTime!=null">
-                    and DATE_FORMAT(t.update_time, '%Y-%m-%d') = #{updateTime}
-                </if>
-        </where>
-    </select>
+  <select id="getInfoByQcode"
+    resultType="com.railway.business.safetool.domain.BaseSafetyTool">
+    SELECT
+    <include refid="Base_Column_List"/>
+    FROM base_safety_tool t
+    LEFT JOIN sys_dept dept on t.dept_id = dept.dept_id
+    LEFT JOIN sys_dict_data dict1 ON (t.tool_type = dict1.dict_value AND dict1.dict_type =
+    'tool_type')
+    LEFT JOIN sys_dict_data dict2 ON (t.test_cycle = dict2.dict_value AND dict2.dict_type =
+    'test_cycle')
+    WHERE t.del_flag='0' and t.tool_qcode = #{qcode}
+  </select>
+
+  <select id="getList" resultMap="BaseResultMap">
+    SELECT
+    <include refid="Base_Column_List"/>
+    FROM base_safety_tool t
+    LEFT JOIN sys_dept dept on t.dept_id = dept.dept_id
+    LEFT JOIN sys_dict_data dict1 ON (t.tool_type = dict1.dict_value AND dict1.dict_type =
+    'tool_type')
+    LEFT JOIN sys_dict_data dict2 ON (t.test_cycle = dict2.dict_value AND dict2.dict_type =
+    'test_cycle')
+    <where>
+      t.del_flag='0'
+      <if test="deptId!=null and deptId!=''">
+        and t.dept_id=#{deptId}
+      </if>
+      <if test="storePlace!=null and storePlace!=''">
+        and t.store_place=#{storePlace}
+      </if>
+      <if test="toolName!=null and toolName!=''">
+        and t.tool_name=#{toolName}
+      </if>
+      <if test="toolType!=null and toolType!=''">
+        and t.tool_type=#{toolType}
+      </if>
+      <if test="toolCode!=null and toolCode!=''">
+        and t.tool_code=#{toolCode}
+      </if>
+      <if test="elecLevel!=null and elecLevel!=''">
+        and t.elec_level=#{elecLevel}
+      </if>
+      <if test="unit!=null and unit!=''">
+        and t.unit=#{unit}
+      </if>
+      <if test="testCycle!=null and testCycle!=''">
+        and t.test_cycle=#{testCycle}
+      </if>
+      <if test="lastTestDate!=null">
+        and t.last_test_date=#{lastTestDate}
+      </if>
+      <if test="nextTestDate!=null">
+        and t.next_test_date=#{nextTestDate}
+      </if>
+      <if test="testResult!=null and testResult!=''">
+        and t.test_result=#{testResult}
+      </if>
+      <if test="testDate!=null">
+        and t.test_date=#{testDate}
+      </if>
+      <if test="testResultDesc!=null and testResultDesc!=''">
+        and t.test_result_desc=#{testResultDesc}
+      </if>
+      <if test="state!=null and state!=''">
+        and t.state=#{state}
+      </if>
+      <if test="scrapReason!=null and scrapReason!=''">
+        and t.scrap_reason=#{scrapReason}
+      </if>
+      <if test="scrapDate!=null and scrapDate!=''">
+        and t.scrap_date=#{scrapDate}
+      </if>
+      <if test="scrapUser!=null and scrapUser!=''">
+        and t.scrap_user=#{scrapUser}
+      </if>
+      <if test="replaceToolId!=null and replaceToolId!=''">
+        and t.replace_tool_id=#{replaceToolId}
+      </if>
+      <if test="produceFactory!=null and produceFactory!=''">
+        and t.produce_factory=#{produceFactory}
+      </if>
+      <if test="produceDate!=null">
+        and t.produce_date=#{produceDate}
+      </if>
+      <if test="remark!=null and remark!=''">
+        and t.remark=#{remark}
+      </if>
+      <if test="createBy!=null and createBy!=''">
+        and t.create_by=#{createBy}
+      </if>
+      <if test="createTime!=null">
+        and DATE_FORMAT(t.create_time, '%Y-%m-%d') = #{createTime}
+      </if>
+      <if test="updateBy!=null and updateBy!=''">
+        and t.update_by=#{updateBy}
+      </if>
+      <if test="updateTime!=null">
+        and DATE_FORMAT(t.update_time, '%Y-%m-%d') = #{updateTime}
+      </if>
+    </where>
+  </select>
 
 </mapper>

+ 21 - 0
railway-common/pom.xml

@@ -147,6 +147,27 @@
       <artifactId>guava</artifactId>
     </dependency>
 
+    <!-- 工具 -->
+    <dependency>
+      <groupId>cn.hutool</groupId>
+      <artifactId>hutool-all</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.zxing</groupId>
+      <artifactId>core</artifactId>
+      <version>${zxing.version}</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/src/main/resources/lib/core-3.4.1.jar</systemPath>
+    </dependency>
+    <dependency>
+      <groupId>com.google.zxing</groupId>
+      <artifactId>javase</artifactId>
+      <version>${zxing.version}</version>
+      <scope>system</scope>
+      <systemPath>${project.basedir}/src/main/resources/lib/javase-3.4.1.jar</systemPath>
+    </dependency>
+
   </dependencies>
 
 </project>

+ 18 - 16
railway-common/src/main/java/com/railway/common/enums/DelFlagEnum.java

@@ -6,24 +6,26 @@ package com.railway.common.enums;
  * @author railway
  */
 public enum DelFlagEnum {
-    /** 删除状态 */
-    NOT_DELETE("0", "否"),
-    DELETED("1", "是"),
-    ;
+  /**
+   * 删除状态
+   */
+  NOT_DELETE("0", "否"),
+  DELETED("1", "是"),
+  ;
 
-    private final String code;
-    private final String info;
+  private final String code;
+  private final String info;
 
-    DelFlagEnum(String code, String info) {
-        this.code = code;
-        this.info = info;
-    }
+  DelFlagEnum(String code, String info) {
+    this.code = code;
+    this.info = info;
+  }
 
-    public String getCode() {
-        return code;
-    }
+  public String getCode() {
+    return code;
+  }
 
-    public String getInfo() {
-        return info;
-    }
+  public String getInfo() {
+    return info;
+  }
 }

+ 32 - 0
railway-common/src/main/java/com/railway/common/enums/QcodeEnum.java

@@ -0,0 +1,32 @@
+package com.railway.common.enums;
+
+/**
+ * 二维码编码类型
+ *
+ * @author ZhaoMn
+ */
+public enum QcodeEnum {
+
+  /**
+   * 二维码编码类型
+   */
+  NUMBER("0", "数字类型码"),
+  LETTER_NUMBER("1", "字母加数字类型码"),
+  ;
+
+  private final String code;
+  private final String info;
+
+  QcodeEnum(String code, String info) {
+    this.code = code;
+    this.info = info;
+  }
+
+  public String getCode() {
+    return code;
+  }
+
+  public String getInfo() {
+    return info;
+  }
+}

+ 43 - 0
railway-common/src/main/java/com/railway/common/qrcode/factory/AbstractSnowflake.java

@@ -0,0 +1,43 @@
+package com.railway.common.qrcode.factory;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 雪花抽象类
+ * @author ZhaoMn
+ */
+public class AbstractSnowflake {
+
+  /**
+   * 机器id所占的位数
+   */
+  protected final int workerIdBits = 14;
+  /**
+   * 序列在id中占的位数
+   */
+  protected final int sequenceBits = 18;
+  /**
+   * 时间截中占的位数
+   */
+  protected int timeBits = 31;
+
+  /**
+   * 开始时间截 (2021-01-01)
+   */
+  protected final long epochSeconds = TimeUnit.MILLISECONDS.toSeconds(1609430400000L);
+
+  /**
+   * 工作机器ID(0~16383)
+   */
+  protected long workerId;
+
+  /**
+   * 秒内序列(0~262413)
+   */
+  protected long sequence = 0L;
+
+  /**
+   * 上次生成ID的时间截
+   */
+  protected long lastTimestamp = -1L;
+}

+ 31 - 0
railway-common/src/main/java/com/railway/common/qrcode/factory/AbstractWorkerIdGeneratorFactory.java

@@ -0,0 +1,31 @@
+package com.railway.common.qrcode.factory;
+
+
+import com.railway.common.qrcode.impl.DefaultSnowflakeGenerator;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * workerId抽象工厂
+ *
+ * @author ZhaoMn
+ */
+public abstract class AbstractWorkerIdGeneratorFactory {
+
+  private static ConcurrentHashMap<Integer, DefaultSnowflakeGenerator> snowflakeMap = new ConcurrentHashMap<>();
+
+  public DefaultSnowflakeGenerator getSnowflakeGenerator(Integer workerId) {
+    if (snowflakeMap.containsKey(workerId)) {
+      return snowflakeMap.get(workerId);
+    }
+    synchronized (this) {
+      if (snowflakeMap.containsKey(workerId)) {
+        return snowflakeMap.get(workerId);
+      }
+      DefaultSnowflakeGenerator generator = new DefaultSnowflakeGenerator(workerId);
+      snowflakeMap.put(workerId, generator);
+      return generator;
+    }
+  }
+
+
+}

+ 118 - 0
railway-common/src/main/java/com/railway/common/qrcode/factory/BitsAllocator.java

@@ -0,0 +1,118 @@
+package com.railway.common.qrcode.factory;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.springframework.util.Assert;
+
+/**
+ * Allocate 64 bits for the UID(long)<br>
+ * sign (fixed 1bit) -> deltaSecond -> workerId -> sequence(within the same second)
+ *
+ * @author ZhaoMn
+ */
+public class BitsAllocator {
+
+  /**
+   * Total 64 bits
+   */
+  public static final int TOTAL_BITS = 1 << 6;
+
+  /**
+   * Bits for [sign-> second-> workId-> sequence]
+   */
+  private final int signBits = 1;
+  private final int timestampBits;
+  private final int workerIdBits;
+  private final int sequenceBits;
+
+  /**
+   * Max value for workId & sequence
+   */
+  private final long maxDeltaSeconds;
+  private final long maxWorkerId;
+  private final long maxSequence;
+
+  /**
+   * Shift for timestamp & workerId
+   */
+  private final int timestampShift;
+  private final int workerIdShift;
+
+  /**
+   * Constructor with timestampBits, workerIdBits, sequenceBits<br>
+   * The highest bit used for sign, so <code>63</code> bits for timestampBits, workerIdBits,
+   * sequenceBits
+   */
+  public BitsAllocator(int timestampBits, int workerIdBits, int sequenceBits) {
+    // make sure allocated 64 bits
+    int allocateTotalBits = signBits + timestampBits + workerIdBits + sequenceBits;
+    Assert.isTrue(allocateTotalBits == TOTAL_BITS, "allocate not enough 64 bits");
+
+    // initialize bits
+    this.timestampBits = timestampBits;
+    this.workerIdBits = workerIdBits;
+    this.sequenceBits = sequenceBits;
+
+    // initialize max value
+    this.maxDeltaSeconds = ~(-1L << timestampBits);
+    this.maxWorkerId = ~(-1L << workerIdBits);
+    this.maxSequence = ~(-1L << sequenceBits);
+
+    // initialize shift
+    this.timestampShift = workerIdBits + sequenceBits;
+    this.workerIdShift = sequenceBits;
+  }
+
+  /**
+   * Allocate bits for UID according to delta seconds & workerId & sequence<br>
+   * <b>Note that: </b>The highest bit will always be 0 for sign
+   */
+  public long allocate(long deltaSeconds, long workerId, long sequence) {
+    return (deltaSeconds << timestampShift) | (workerId << workerIdShift) | sequence;
+  }
+
+  /**
+   * Getters
+   */
+  public int getSignBits() {
+    return signBits;
+  }
+
+  public int getTimestampBits() {
+    return timestampBits;
+  }
+
+  public int getWorkerIdBits() {
+    return workerIdBits;
+  }
+
+  public int getSequenceBits() {
+    return sequenceBits;
+  }
+
+  public long getMaxDeltaSeconds() {
+    return maxDeltaSeconds;
+  }
+
+  public long getMaxWorkerId() {
+    return maxWorkerId;
+  }
+
+  public long getMaxSequence() {
+    return maxSequence;
+  }
+
+  public int getTimestampShift() {
+    return timestampShift;
+  }
+
+  public int getWorkerIdShift() {
+    return workerIdShift;
+  }
+
+  @Override
+  public String toString() {
+    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+  }
+
+}

+ 108 - 0
railway-common/src/main/java/com/railway/common/qrcode/impl/DefaultSnowflakeGenerator.java

@@ -0,0 +1,108 @@
+package com.railway.common.qrcode.impl;
+
+
+import com.railway.common.exception.base.BaseException;
+import com.railway.common.qrcode.factory.AbstractSnowflake;
+import com.railway.common.qrcode.factory.BitsAllocator;
+import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 雪花算法默认实现类
+ *
+ * @author ZhaoMn
+ */
+public class DefaultSnowflakeGenerator extends AbstractSnowflake {
+
+  private static final Logger logger = LoggerFactory.getLogger(DefaultSnowflakeGenerator.class);
+  /**
+   * Stable fields after spring bean initializing
+   */
+  protected BitsAllocator bitsAllocator;
+
+  public DefaultSnowflakeGenerator(int workerId) {
+    super.workerId = workerId;
+    // initialize bits allocator
+    bitsAllocator = new BitsAllocator(timeBits, workerIdBits, sequenceBits);
+
+    // initialize worker id
+    if (workerId > bitsAllocator.getMaxWorkerId()) {
+      throw new RuntimeException(
+          "Worker id " + workerId + " exceeds the max " + bitsAllocator.getMaxWorkerId());
+    }
+  }
+
+
+  public Long nextId() {
+    try {
+      return nextSnowId();
+    } catch (Exception e) {
+      logger.error("Generate unique id exception. ", e);
+      throw new BaseException("Generate unique id exception");
+    }
+  }
+
+
+  /**
+   * Get SnowId
+   *
+   * @return SnowId
+   * @throws BaseException in the case: Clock moved backwards; Exceeds the max timestamp
+   */
+  protected synchronized long nextSnowId() {
+    long currentSecond = getCurrentSecond();
+    if (currentSecond == lastTimestamp) {
+      // At the same second, increase sequence
+      sequence = (sequence + 1) & bitsAllocator.getMaxSequence();
+      // Exceed the max sequence, we wait the next second to generate SnowId
+      if (sequence == 0) {
+        currentSecond = getNextSecond(lastTimestamp);
+      }
+    } else if (currentSecond < lastTimestamp) {
+      // Clock moved backwards, refuse to generate SnowId
+      //计算时间差
+      long refusedSeconds = lastTimestamp - currentSecond;
+      logger.warn("Clock moved backwards. Refusing for {} seconds", refusedSeconds);
+      sequence = (sequence + 1) & bitsAllocator.getMaxSequence();
+      // Exceed the max sequence, we wait the next second to generate SnowId
+      if (sequence == 0) {
+        //使用未来时间
+        currentSecond = lastTimestamp + 1;
+      } else {
+        //使用未来时间
+        currentSecond = lastTimestamp;
+      }
+    } else {
+      // At the different second, sequence restart from zero
+      sequence = 0L;
+    }
+    lastTimestamp = currentSecond;
+    long deltaSeconds = currentSecond - epochSeconds;
+    // Allocate bits for SnowId
+    return bitsAllocator.allocate(deltaSeconds, workerId, sequence);
+  }
+
+  /**
+   * Get next millisecond
+   */
+  private long getNextSecond(long lastTimestamp) {
+    long timestamp = getCurrentSecond();
+    while (timestamp <= lastTimestamp) {
+      timestamp = getCurrentSecond();
+    }
+    return timestamp;
+  }
+
+  /**
+   * Get current second
+   */
+  private long getCurrentSecond() {
+    long currentSecond = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
+    if (currentSecond - epochSeconds > bitsAllocator.getMaxDeltaSeconds()) {
+      throw new BaseException(
+          "Timestamp bits is exhausted. Refusing UID generate. Now: " + currentSecond);
+    }
+    return currentSecond;
+  }
+}

+ 139 - 0
railway-common/src/main/java/com/railway/common/qrcode/impl/SnowflakeClient.java

@@ -0,0 +1,139 @@
+package com.railway.common.qrcode.impl;
+
+import com.railway.common.enums.QcodeEnum;
+import com.railway.common.qrcode.factory.AbstractWorkerIdGeneratorFactory;
+import com.railway.common.utils.snowflake.SnowflakeIdUtils;
+import java.util.Random;
+import org.springframework.stereotype.Service;
+
+/**
+ * 获取雪花随机ID
+ *
+ * @author ZhaoMn
+ */
+@Service
+public class SnowflakeClient extends AbstractWorkerIdGeneratorFactory {
+
+  /**
+   * 最小workerId
+   */
+  public static final int INIT_WORKER_ID = 0;
+  /**
+   * 最大workerId
+   */
+  public static final int MAX_WORKER_ID = 16383;
+
+  private static final Integer WORKER_ID = (int) SnowflakeIdUtils.nextLong(INIT_WORKER_ID,
+      MAX_WORKER_ID);
+
+  public static final int RADIX = 36;
+
+  public static final int DEFAULT_LENGTH = 17;
+
+  public static final int SNOWFLAKE_DEFAULT_LENGTH = 18;
+
+  private static final Random RANDOM = new Random();
+
+  private final static String[] RANDOM_ALL =
+      {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
+          "S", "T", "U",
+          "V", "W", "X", "Y", "Z", "#", "$", "*", "-", "_", "+", "=", "<", ">", "&", "^",
+          "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
+
+  private final static String[] RANDOM_NUMBER = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
+
+  private final static String[] RANDOM_LETTER_NUMBER = {"A", "B", "C", "D", "E", "F", "G", "H", "I",
+      "J", "K", "L",
+      "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5",
+      "6", "7", "8", "9", "0"};
+
+
+  /**
+   * 二维码
+   */
+  public String code(QcodeEnum qcodeEnum, Integer length) {
+    if (null == length || length < DEFAULT_LENGTH) {
+      length = DEFAULT_LENGTH;
+    }
+    switch (qcodeEnum) {
+      case NUMBER:
+        return numberCode(length);
+      case LETTER_NUMBER:
+        return letterNumberCode(length);
+      default:
+        return letterNumberCharCode(length);
+    }
+  }
+
+  /**
+   * 二维码
+   */
+  public String code(QcodeEnum qcodeEnum) {
+    switch (qcodeEnum) {
+      case NUMBER:
+        return numberCode(SNOWFLAKE_DEFAULT_LENGTH);
+      case LETTER_NUMBER:
+        return letterNumberCode(SNOWFLAKE_DEFAULT_LENGTH);
+      default:
+        return letterNumberCharCode(SNOWFLAKE_DEFAULT_LENGTH);
+    }
+  }
+
+
+  /**
+   * 获取码-指定workerId
+   *
+   * @return 数字类型
+   */
+  public long code(Integer workerId) {
+    if (workerId == null) {
+      throw new IllegalArgumentException("worker id is null");
+    }
+    return this.getSnowflakeGenerator(workerId).nextId();
+  }
+
+  /**
+   * 指定长度数字类型码
+   */
+  private String numberCode(Integer length) {
+    StringBuilder id = new StringBuilder(length);
+    String snowflakeId = Long.toString(code(WORKER_ID));
+    id.append(snowflakeId);
+    //不够length,后补随机长度
+    for (int i = 0; i < (length - snowflakeId.length()); i++) {
+      id.append(RANDOM_NUMBER[RANDOM.nextInt(RANDOM_NUMBER.length - 1)]);
+    }
+    return id.toString();
+  }
+
+
+  /**
+   * 指定长度字母加数字类型码
+   */
+  private String letterNumberCode(Integer length) {
+    StringBuilder id = new StringBuilder(length);
+    String snowflakeId = Long.toString(code(WORKER_ID), RADIX);
+    id.append(snowflakeId);
+    //不够length,后补随机长度
+    for (int i = 0; i < (length - snowflakeId.length()); i++) {
+      id.append(RANDOM_LETTER_NUMBER[RANDOM.nextInt(RANDOM_LETTER_NUMBER.length - 1)]);
+    }
+    return id.toString().toUpperCase();
+  }
+
+  /**
+   * 获取码-大写
+   */
+  private String letterNumberCharCode(Integer length) {
+    StringBuilder id = new StringBuilder(length);
+    String snowflakeId = Long.toString(code(WORKER_ID), RADIX);
+    id.append(snowflakeId);
+    //不够length,后补随机长度
+    for (int i = 0; i < (length - snowflakeId.length()); i++) {
+      id.append(RANDOM_ALL[RANDOM.nextInt(RANDOM_ALL.length - 1)]);
+    }
+    return id.toString().toUpperCase();
+  }
+
+
+}

+ 256 - 0
railway-common/src/main/java/com/railway/common/utils/QRCodeUtilEx.java

@@ -0,0 +1,256 @@
+package com.railway.common.utils;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.BinaryBitmap;
+import com.google.zxing.DecodeHintType;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatReader;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.Result;
+import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.common.HybridBinarizer;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.OutputStream;
+import java.util.Hashtable;
+import javax.imageio.ImageIO;
+import lombok.extern.slf4j.Slf4j;
+import sun.font.FontDesignMetrics;
+import sun.misc.BASE64Encoder;
+
+/**
+ * @author ZhaoMn
+ */
+@Slf4j
+public class QRCodeUtilEx {
+
+  private static final String CHARSET = "utf-8";
+  private static final String FORMAT_NAME = "JPG";
+  // 二维码尺寸
+  private static final int QRCODE_SIZE = 300;
+  // LOGO宽度
+  private static final int WIDTH = 60;
+  // LOGO高度
+  private static final int HEIGHT = 60;
+  // 字体大小
+  private static final int FONT_SIZE = 18;
+
+
+  private static BufferedImage createImage(String content, String bottomDes, String imgPath,
+      boolean needCompress) throws Exception {
+    Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
+    hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+    hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
+    hints.put(EncodeHintType.MARGIN, 1);
+    BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE,
+        QRCODE_SIZE, QRCODE_SIZE, hints);
+    int width = bitMatrix.getWidth();
+    int height = bitMatrix.getHeight();
+    int tempHeight = height;
+    boolean needDescription = (null != bottomDes && !"".equals(bottomDes));
+    if (needDescription) {
+      tempHeight += 30;
+    }
+    BufferedImage image = new BufferedImage(width, tempHeight, BufferedImage.TYPE_INT_RGB);
+    for (int x = 0; x < width; x++) {
+      for (int y = 0; y < height; y++) {
+        image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
+      }
+    }
+    // 插入图片
+    if (imgPath != null && !"".equals(imgPath)) {
+      QRCodeUtilEx.insertImage(image, imgPath, needCompress);
+    }
+    //添加底部文字
+    if (needDescription) {
+      QRCodeUtilEx.addFontImage(image, bottomDes);
+    }
+    return image;
+  }
+
+  /**
+   * 添加 底部图片文字
+   *
+   * @param source 图片源
+   * @param declareText 文字本文
+   */
+  private static void addFontImage(BufferedImage source, String declareText) {
+    BufferedImage textImage = strToImage(declareText, QRCODE_SIZE, 50);
+    Graphics2D graph = source.createGraphics();
+    //开启文字抗锯齿
+    graph.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+
+    int width = textImage.getWidth(null);
+    int height = textImage.getHeight(null);
+
+    graph.drawImage(textImage, 0, QRCODE_SIZE - 20, width, height, null);
+    graph.dispose();
+  }
+
+  private static BufferedImage strToImage(String str, int width, int height) {
+    BufferedImage textImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+    Graphics2D g2 = (Graphics2D) textImage.getGraphics();
+    //开启文字抗锯齿
+    g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+    g2.setBackground(Color.WHITE);
+    g2.clearRect(0, 0, width, height);
+    g2.setPaint(Color.BLACK);
+    FontRenderContext context = g2.getFontRenderContext();
+    Font font = new Font("微软雅黑", Font.BOLD, FONT_SIZE);
+    g2.setFont(font);
+    LineMetrics lineMetrics = font.getLineMetrics(str, context);
+    FontMetrics fontMetrics = FontDesignMetrics.getMetrics(font);
+    float offset = (width - fontMetrics.stringWidth(str)) / 2;
+    float y =
+        (height + lineMetrics.getAscent() - lineMetrics.getDescent() - lineMetrics.getLeading())
+            / 2;
+
+    g2.drawString(str, (int) offset, (int) y);
+
+    return textImage;
+  }
+
+  private static void insertImage(BufferedImage source, String imgPath, boolean needCompress)
+      throws Exception {
+    File file = new File(imgPath);
+    if (!file.exists()) {
+      System.err.println("" + imgPath + "   该文件不存在!");
+      return;
+    }
+    Image src = ImageIO.read(new File(imgPath));
+    int width = src.getWidth(null);
+    int height = src.getHeight(null);
+    // 压缩LOGO
+    if (needCompress) {
+      if (width > WIDTH) {
+        width = WIDTH;
+      }
+      if (height > HEIGHT) {
+        height = HEIGHT;
+      }
+      Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
+      BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+      Graphics g = tag.getGraphics();
+      // 绘制缩小后的图
+      g.drawImage(image, 0, 0, null);
+      g.dispose();
+      src = image;
+    }
+    // 插入LOGO
+    Graphics2D graph = source.createGraphics();
+    int x = (QRCODE_SIZE - width) / 2;
+    int y = (QRCODE_SIZE - height) / 2;
+    graph.drawImage(src, x, y, width, height, null);
+    Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
+    graph.setStroke(new BasicStroke(3f));
+    graph.draw(shape);
+    graph.dispose();
+  }
+
+  public static void encode(String content, String bottomDes, String imgPath, String destPath,
+      boolean needCompress) throws Exception {
+    BufferedImage image = QRCodeUtilEx.createImage(content, bottomDes, imgPath, needCompress);
+    mkdirs(destPath);
+    ImageIO.write(image, FORMAT_NAME, new File(destPath));
+  }
+
+  /**
+   * 获取二维码base64数据
+   */
+  public static String encodeStr(String content, String bottomDes) throws Exception {
+    BufferedImage image = QRCodeUtilEx.createImage(content, bottomDes, null, false);
+    //io流
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    //写入流中
+    ImageIO.write(image, FORMAT_NAME, baos);
+    //转换成字节
+    byte[] bytes = baos.toByteArray();
+    BASE64Encoder encoder = new BASE64Encoder();
+    //转换成base64串
+    String jpgBase64 = encoder.encodeBuffer(bytes).trim();
+    //删除 \r\n
+    jpgBase64 = jpgBase64.replaceAll("\n", "").replaceAll("\r", "");
+    return jpgBase64;
+  }
+
+  public static BufferedImage encode(String content, String bottomDes, String imgPath,
+      boolean needCompress) throws Exception {
+    return QRCodeUtilEx.createImage(content, bottomDes, imgPath, needCompress);
+  }
+
+  public static void mkdirs(String destPath) {
+    File file = new File(destPath);
+    // 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)
+    if (!file.exists() && !file.isDirectory()) {
+      file.mkdirs();
+    }
+  }
+
+  public static void encode(String content, String bottomDes, String imgPath, String destPath)
+      throws Exception {
+    QRCodeUtilEx.encode(content, bottomDes, imgPath, destPath, false);
+  }
+
+  public static void encode(String content, String bottomDes, String destPath) throws Exception {
+    QRCodeUtilEx.encode(content, bottomDes, null, destPath, false);
+  }
+
+  public static void encode(String content, String bottomDes, String imgPath, OutputStream output,
+      boolean needCompress)
+      throws Exception {
+    BufferedImage image = QRCodeUtilEx.createImage(content, bottomDes, imgPath, needCompress);
+    ImageIO.write(image, FORMAT_NAME, output);
+  }
+
+  public static void encode(String content, String bottomDes, OutputStream output)
+      throws Exception {
+    QRCodeUtilEx.encode(content, bottomDes, null, output, false);
+  }
+
+  public static String decode(File file) throws Exception {
+    BufferedImage image;
+    image = ImageIO.read(file);
+    if (image == null) {
+      return null;
+    }
+    BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);
+    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
+    Result result;
+    Hashtable<DecodeHintType, Object> hints = new Hashtable<>();
+    hints.put(DecodeHintType.CHARACTER_SET, CHARSET);
+    result = new MultiFormatReader().decode(bitmap, hints);
+    return result.getText();
+  }
+
+  public static String decode(String path) throws Exception {
+    return QRCodeUtilEx.decode(new File(path));
+  }
+
+  public static void main(String[] args) {
+    try {
+      String str = QRCodeUtilEx.encodeStr("1233444", "测试");
+      System.out.println(str);
+      QRCodeUtilEx.encode("1233444", "测试", "D:/111.jpg");
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+}

+ 54 - 0
railway-common/src/main/java/com/railway/common/utils/snowflake/SnowflakeIdUtils.java

@@ -0,0 +1,54 @@
+package com.railway.common.utils.snowflake;
+
+import java.util.Random;
+
+/**
+ * 算法工具类
+ *
+ * @author ZhaoMn
+ */
+public class SnowflakeIdUtils {
+
+
+  private static final Random RANDOM = new Random();
+
+  /**
+   * 最小workerId
+   */
+  public static final int INIT_WORKER_ID = 0;
+  /**
+   * 最大workerId
+   */
+  public static final int MAX_WORKER_ID = 16383;
+
+
+  public static long nextLong(final long startInclusive, final long endExclusive) {
+    isTrue(endExclusive >= startInclusive, "Start value must be smaller or equal to end value.");
+    isTrue(startInclusive >= 0, "Both range values must be non-negative.");
+
+    if (startInclusive == endExclusive) {
+      return startInclusive;
+    }
+    return (long) nextDouble(startInclusive, endExclusive);
+  }
+
+  public static void isTrue(final boolean expression, final String message,
+      final Object... values) {
+    if (!expression) {
+      throw new IllegalArgumentException(String.format(message, values));
+    }
+  }
+
+  public static double nextDouble(final double startInclusive, final double endInclusive) {
+    isTrue(endInclusive >= startInclusive, "Start value must be smaller or equal to end value.");
+    isTrue(startInclusive >= 0, "Both range values must be non-negative.");
+
+    if (startInclusive == endInclusive) {
+      return startInclusive;
+    }
+
+    return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextDouble());
+  }
+
+
+}

BIN
railway-common/src/main/resources/lib/core-3.4.1.jar


BIN
railway-common/src/main/resources/lib/javase-3.4.1.jar