|
|
@@ -129,7 +129,7 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
|
|
|
@Override
|
|
|
public BaseSafetyTool getInfoByQcode(String qcode) {
|
|
|
BaseSafetyTool tool = safetyToolMapper.getInfoByQcode(qcode);
|
|
|
- if(null != tool){
|
|
|
+ if (null != tool) {
|
|
|
setBaseSafetyTool(tool);
|
|
|
}
|
|
|
return tool;
|
|
|
@@ -147,7 +147,7 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
|
|
|
}
|
|
|
// 查询该工具相关的 待送检 计划
|
|
|
List<SecScheduled> scheduledList = scheduledMapper.listScheduled(tool.getToolId());
|
|
|
- if(CollectionUtils.isNotEmpty(scheduledList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(scheduledList)) {
|
|
|
tool.setScheduledId(scheduledList.get(0).getId());
|
|
|
tool.setTestState(ToolTestStateEnum.NOT_CONFIRM.getCode());
|
|
|
return;
|
|
|
@@ -168,12 +168,12 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<BaseSafetyTool> getList(BaseSafetyTool baseSafetyTool) {
|
|
|
- if(SecurityUtils.isNotLabUser()){
|
|
|
+ if (SecurityUtils.isNotLabUser()) {
|
|
|
baseSafetyTool.setDeptId(SecurityUtils.getDeptId());
|
|
|
}
|
|
|
List<BaseSafetyTool> list = safetyToolMapper.getList(baseSafetyTool);
|
|
|
- for(BaseSafetyTool tool : list){
|
|
|
- if(StringUtils.isEmpty(tool.getToolQcode()) || StringUtils.isEmpty(tool.getQcodeUrl())) {
|
|
|
+ for (BaseSafetyTool tool : list) {
|
|
|
+ if (StringUtils.isEmpty(tool.getToolQcode()) || StringUtils.isEmpty(tool.getQcodeUrl())) {
|
|
|
setTool(tool);
|
|
|
update(tool);
|
|
|
}
|
|
|
@@ -207,12 +207,12 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
|
|
|
return export(list);
|
|
|
}
|
|
|
|
|
|
- private AjaxResult export(List<BaseSafetyTool> tools){
|
|
|
- if(CollectionUtils.isEmpty(tools)){
|
|
|
+ private AjaxResult export(List<BaseSafetyTool> tools) {
|
|
|
+ if (CollectionUtils.isEmpty(tools)) {
|
|
|
return AjaxResult.error("没查到要导出的记录");
|
|
|
}
|
|
|
// 如果只有一条,直接发图片
|
|
|
- if(tools.size() == 1){
|
|
|
+ if (tools.size() == 1) {
|
|
|
BaseSafetyTool tool = tools.get(0);
|
|
|
String fileName = tool.getToolCode() + ".jpg";
|
|
|
log.info("{} - {}", fileName, tool.getQcodeUrl());
|
|
|
@@ -221,13 +221,13 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
|
|
|
// 如果多条,打包压缩后发
|
|
|
String tmpPath = localFilePath + "/安全工具二维码图片_" + DateUtils.dateTimeNow() + "/";
|
|
|
File tmpFile = new File(tmpPath);
|
|
|
- if(!tmpFile.exists() && !tmpFile.mkdirs()){
|
|
|
+ if (!tmpFile.exists() && !tmpFile.mkdirs()) {
|
|
|
return AjaxResult.error("临时目录创建失败");
|
|
|
}
|
|
|
log.info(" * 开始整理二维码图片文件 * ");
|
|
|
long time1 = System.currentTimeMillis();
|
|
|
int i = 0;
|
|
|
- for (BaseSafetyTool tool : tools){
|
|
|
+ for (BaseSafetyTool tool : tools) {
|
|
|
long t1 = System.currentTimeMillis();
|
|
|
String jpgPath = tmpPath + tool.getToolCode() + ".jpg";
|
|
|
HttpUtils.download(tool.getQcodeUrl(), jpgPath);
|
|
|
@@ -247,9 +247,9 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
|
|
|
return sysFileService.uploadFile(zipFilePath);
|
|
|
}
|
|
|
|
|
|
- private void setTool(BaseSafetyTool tool){
|
|
|
+ private void setTool(BaseSafetyTool tool) {
|
|
|
String qcode = tool.getToolQcode();
|
|
|
- if(StringUtils.isEmpty(qcode)) {
|
|
|
+ if (StringUtils.isEmpty(qcode)) {
|
|
|
qcode = snowflakeClient.code(QcodeEnum.LETTER_NUMBER) + "_"
|
|
|
+ tool.getToolType() + "_" + tool.getToolCode();
|
|
|
tool.setToolQcode(qcode);
|
|
|
@@ -300,11 +300,20 @@ public class BaseSafetyToolServiceImpl implements IBaseSafetyToolService {
|
|
|
@Override
|
|
|
public void refresh() {
|
|
|
List<BaseSafetyTool> list = safetyToolMapper.getList(new BaseSafetyTool());
|
|
|
- for(BaseSafetyTool tool : list){
|
|
|
- if(StringUtils.isEmpty(tool.getToolQcode()) || StringUtils.isEmpty(tool.getQcodeUrl())) {
|
|
|
+ for (BaseSafetyTool tool : list) {
|
|
|
+ if (StringUtils.isEmpty(tool.getToolQcode()) || StringUtils.isEmpty(tool.getQcodeUrl())) {
|
|
|
setTool(tool);
|
|
|
update(tool);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void rebuild() {
|
|
|
+ List<BaseSafetyTool> list = safetyToolMapper.getList(new BaseSafetyTool());
|
|
|
+ for (BaseSafetyTool tool : list) {
|
|
|
+ setTool(tool);
|
|
|
+ update(tool);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|