Commit a612be28 authored by lisong's avatar lisong

添加监管码导出

parent 7065f92c
package com.yeejoin.amos.boot.module.tzs.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum ImageSizeEnums {
/**
* 导出监管码、96333码尺寸
*/
// 监管码-大
JG_BIG("JG_BIG", "bigBg.png", 350, 350, 60, 720, 190, 0, 0, 780, 680),
// 监管码-中
JG_MID("JG_MID", "centreBg.png", 230, 230, 40, 480, 170, 0, 0, 520, 525),
// 监管码-小
JG_MIN("JG_MIN", "smallBg.png", 170, 170, 30, 360, 110, 0, 0, 380, 355),
// 96333电梯码
DT("DT", "dt.png", 170, 170, 30, 30, 110, 0, 0, 330, 355);
String code;
String bgPath;
Integer with;
Integer height;
Integer size;
Integer imagesX;
Integer imagesY;
Integer text1X;
Integer text1Y;
Integer text2X;
Integer text2Y;
public static ImageSizeEnums getEnumByCode(String code) {
for (ImageSizeEnums value : ImageSizeEnums.values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
}
...@@ -84,6 +84,7 @@ public interface IdxFeignService { ...@@ -84,6 +84,7 @@ public interface IdxFeignService {
FeignClientResult<String> submit(@RequestParam(value = "pageId") long pageId, FeignClientResult<String> submit(@RequestParam(value = "pageId") long pageId,
@RequestParam(value = "taskId",required = false) String taskId, @RequestParam(value = "taskId",required = false) String taskId,
@RequestParam(value = "planInstanceId", required = false) String planInstanceId, @RequestParam(value = "planInstanceId", required = false) String planInstanceId,
@RequestParam(value = "bizField", required = false) String bizField,
@RequestParam(value = "topic", required = false) String topic, @RequestParam(value = "topic", required = false) String topic,
@RequestParam(value = "tableName", required = false) String tableName, @RequestParam(value = "tableName", required = false) String tableName,
@RequestBody Map<String, Object> kv) throws Exception; @RequestBody Map<String, Object> kv) throws Exception;
......
...@@ -345,6 +345,7 @@ ...@@ -345,6 +345,7 @@
<if test="dto.ORG_BRANCH_NAME != '' and dto.ORG_BRANCH_NAME != null">and ORG_BRANCH_NAME = #{dto.ORG_BRANCH_NAME}</if> <if test="dto.ORG_BRANCH_NAME != '' and dto.ORG_BRANCH_NAME != null">and ORG_BRANCH_NAME = #{dto.ORG_BRANCH_NAME}</if>
<if test="dto.USE_PLACE != '' and dto.USE_PLACE != null">and USE_PLACE = #{dto.USE_PLACE}</if> <if test="dto.USE_PLACE != '' and dto.USE_PLACE != null">and USE_PLACE = #{dto.USE_PLACE}</if>
<if test="dto.STATUS != '' and dto.STATUS != null">and STATUS = #{dto.STATUS}</if> <if test="dto.STATUS != '' and dto.STATUS != null">and STATUS = #{dto.STATUS}</if>
<if test="dto.EQU_CATEGORY != '' and dto.EQU_CATEGORY != null">and EQU_CATEGORY = #{dto.EQU_CATEGORY}</if>
<if test="dto.USE_UNIT_CREDIT_CODE != '' and dto.USE_UNIT_CREDIT_CODE != null">and USE_UNIT_CREDIT_CODE like concat('%', #{dto.USE_UNIT_CREDIT_CODE},'%')</if> <if test="dto.USE_UNIT_CREDIT_CODE != '' and dto.USE_UNIT_CREDIT_CODE != null">and USE_UNIT_CREDIT_CODE like concat('%', #{dto.USE_UNIT_CREDIT_CODE},'%')</if>
<if test="dto.ORG_BRANCH_CODE != '' and dto.ORG_BRANCH_CODE != null">and ORG_BRANCH_CODE like concat('%', #{dto.ORG_BRANCH_CODE},'%')</if> <if test="dto.ORG_BRANCH_CODE != '' and dto.ORG_BRANCH_CODE != null">and ORG_BRANCH_CODE like concat('%', #{dto.ORG_BRANCH_CODE},'%')</if>
<if test='dto.ids != null'> and SEQUENCE_NBR in <if test='dto.ids != null'> and SEQUENCE_NBR in
......
package com.yeejoin.amos.boot.module.tzs.biz.controller; package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -13,13 +14,16 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.EquipExportDto; ...@@ -13,13 +14,16 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.EquipExportDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo; import com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.api.enums.ImageSizeEnums;
import com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService; import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.tzs.api.vo.EquipExportVo; import com.yeejoin.amos.boot.module.tzs.api.vo.EquipExportVo;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.EquipmentCategoryServiceImpl; import com.yeejoin.amos.boot.module.tzs.biz.service.impl.EquipmentCategoryServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.utils.ImageUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -30,10 +34,12 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -30,10 +34,12 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.io.*;
import java.util.Collection; import java.net.URL;
import java.util.List; import java.util.*;
import java.util.Map; import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/** /**
* 装备分类 * 装备分类
...@@ -55,6 +61,13 @@ public class EquipmentCategoryController extends BaseController { ...@@ -55,6 +61,13 @@ public class EquipmentCategoryController extends BaseController {
EquipmentCategoryMapper equipmentCategoryMapper; EquipmentCategoryMapper equipmentCategoryMapper;
@Value("${regulatory_code_prefix}")
String REGULATORY_CODE_PREFIX ;
/**
* 监管码背景图路径
*/
private static final String BASE_PATH = "amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/resources/temp/";
/** /**
* 新增装备分类 * 新增装备分类
...@@ -374,6 +387,64 @@ public class EquipmentCategoryController extends BaseController { ...@@ -374,6 +387,64 @@ public class EquipmentCategoryController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/exportImage")
@ApiOperation(httpMethod = "GET", value = "设备监管码下载", notes = "设备监管码下载")
public void exportImage(HttpServletResponse response, @RequestParam("code") String code, @RequestParam("type") String type) throws IOException {
FileInputStream bgImgFile = null;
ImageSizeEnums imageSizeEnums = ImageSizeEnums.getEnumByCode(type);
try {
bgImgFile = new FileInputStream(BASE_PATH + imageSizeEnums.getBgPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
File QrCodeFile = new File(BASE_PATH + code + ".png");
ImageUtils.creatQRCode(QrCodeFile, bgImgFile, imageSizeEnums.getWith(), imageSizeEnums.getHeight(), REGULATORY_CODE_PREFIX+code, "", code, imageSizeEnums.getSize(), imageSizeEnums.getImagesX(), imageSizeEnums.getImagesY(), imageSizeEnums.getText1X(), imageSizeEnums.getText1Y(), imageSizeEnums.getText2X(), imageSizeEnums.getText2Y());
ImageUtils.downloadResource(code + ".png", BASE_PATH + code + ".png", response);
QrCodeFile.delete();
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/exportImageZip")
@ApiOperation(httpMethod = "GET", value = "设备信息导出", notes = "设备信息导出")
public void exportImageZip(HttpServletResponse response, EquipExportDto dto, @RequestParam("type") String type) throws IOException {
File delete = new File(BASE_PATH + "images");
if (!delete.exists()) {
delete.mkdir();
}
ImageSizeEnums imageSizeEnums = ImageSizeEnums.getEnumByCode(type);
//创建list 存放图片
List<File> fileList = new ArrayList<>();
List<EquipExportVo> equipExportData = equipmentCategoryServiceImpl.getEquipExportData(dto);
List<EquipExportVo> unique = equipExportData.stream().collect(
Collectors. collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getSupervisoryCode() + ";" + o.getCode96333()))), ArrayList::new)
);
for (EquipExportVo equipExportDatum : unique) {
FileInputStream bgImgFile = new FileInputStream(BASE_PATH + imageSizeEnums.getBgPath());
if ("DT".equals(type) && !ObjectUtils.isEmpty(equipExportDatum.getCode96333())) {
File QrCodeFile = new File(BASE_PATH + "images/" + equipExportDatum.getCode96333() + ".png");
ImageUtils.creatQRCode(QrCodeFile, bgImgFile, imageSizeEnums.getWith(), imageSizeEnums.getHeight(), REGULATORY_CODE_PREFIX+equipExportDatum.getCode96333(), "", equipExportDatum.getCode96333(), imageSizeEnums.getSize(), imageSizeEnums.getImagesX(), imageSizeEnums.getImagesY(), imageSizeEnums.getText1X(), imageSizeEnums.getText1Y(), imageSizeEnums.getText2X(), imageSizeEnums.getText2Y());
fileList.add(new File(BASE_PATH + "images/" + equipExportDatum.getCode96333() + ".png"));
} else if (!ObjectUtils.isEmpty(equipExportDatum.getSupervisoryCode())) {
File QrCodeFile = new File(BASE_PATH + "images/" + equipExportDatum.getSupervisoryCode() + ".png");
ImageUtils.creatQRCode(QrCodeFile, bgImgFile, imageSizeEnums.getWith(), imageSizeEnums.getHeight(), REGULATORY_CODE_PREFIX+equipExportDatum.getSupervisoryCode(), "", equipExportDatum.getSupervisoryCode(), imageSizeEnums.getSize(), imageSizeEnums.getImagesX(), imageSizeEnums.getImagesY(), imageSizeEnums.getText1X(), imageSizeEnums.getText1Y(), imageSizeEnums.getText2X(), imageSizeEnums.getText2Y());
fileList.add(new File(BASE_PATH + "images/" + equipExportDatum.getSupervisoryCode() + ".png"));
}
bgImgFile.close();
}
File zipFile = new File(BASE_PATH + "images/imageZip.zip");
zipFile.createTempFile("imageZip", ".zip");
// 调用压缩方法
ImageUtils.zipFiles(fileList, zipFile);
ImageUtils.downloadResourceZip("imageZip.zip", BASE_PATH + "images/imageZip.zip", response);
zipFile.delete();
ImageUtils.deleteAllFilesOfDir(delete);
if (delete.exists()) {
ImageUtils.deleteAllFilesOfDir(delete);
}
}
} }
...@@ -780,18 +780,19 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -780,18 +780,19 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
String userIdsTask = String.join(",", task); String userIdsTask = String.join(",", task);
// 添加被检查企业下的人员id // 添加被检查企业下的人员id
objectMap.put("CHECKED_COMPANY_USERS", userIds); objectMap.put("CHECKED_COMPANY_USERS", userIds);
objectMap.put("CHECKED_COMPANY_USER_ids", userIdsTask);
// 表单信息提交 // 表单信息提交
FeignClientResult<String> submit = idxFeignService.submit(pageId, taskId, planInstanceId, topic, tableName, objectMap); FeignClientResult<String> submit = idxFeignService.submit(pageId, taskId, planInstanceId,"CHECKED_COMPANY_USER_ids", topic, tableName, objectMap);
if ("200".equals(String.valueOf(submit.getStatus()))) { // if ("200".equals(String.valueOf(submit.getStatus()))) {
JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
jsonObject.put("title", "企业整改"); // jsonObject.put("title", "企业整改");
jsonObject.put("userIds", userIdsTask); // jsonObject.put("userIds", userIdsTask);
logger.info("idx执行任务更新参数,{}", JSONObject.toJSONString(jsonObject)); // logger.info("idx执行任务更新参数,{}", JSONObject.toJSONString(jsonObject));
//FeignClientResult<JSONObject> jsonObjectFeignClientResult = idxFeignService.updateAmosTask(taskId, jsonObject); // //FeignClientResult<JSONObject> jsonObjectFeignClientResult = idxFeignService.updateAmosTask(taskId, jsonObject);
updateAmosTask(taskId, jsonObject); // updateAmosTask(taskId, jsonObject);
//logger.info("idx执行任务更新任务返回参数,{}", JSONObject.toJSONString(jsonObjectFeignClientResult)); // //logger.info("idx执行任务更新任务返回参数,{}", JSONObject.toJSONString(jsonObjectFeignClientResult));
//
} // }
return "ok"; return "ok";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment