暂降事件
This commit is contained in:
@@ -33,6 +33,5 @@ public interface CsLedgerFeignClient {
|
||||
HttpResult<List<CsLedger>> queryLine(@RequestBody @Validated LineParamDTO lineParamdto);
|
||||
|
||||
@PostMapping("/queryDevDetail")
|
||||
|
||||
HttpResult<DevDetailDTO> queryDevDetail(@RequestParam("devId") String devId);
|
||||
}
|
||||
|
||||
@@ -64,36 +64,36 @@ public class CsEquipmentDeliveryAddParm{
|
||||
@NotBlank(message="装置程序版本不能为空!")
|
||||
private String programVersion;
|
||||
|
||||
/**
|
||||
* 调试人员
|
||||
*/
|
||||
@ApiModelProperty(value="调试人员")
|
||||
@NotBlank(message="调试人员不能为空!")
|
||||
private String debugPerson;
|
||||
|
||||
/**
|
||||
* 出厂日期
|
||||
*/
|
||||
@ApiModelProperty(value="出厂日期")
|
||||
@NotNull(message="出厂日期不能为空!")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date producteTime;
|
||||
|
||||
/**
|
||||
* 检修日期
|
||||
*/
|
||||
@ApiModelProperty(value="检修日期")
|
||||
@NotNull(message="检修日期不能为空!")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date checkTime;
|
||||
|
||||
/**
|
||||
* 调试日期
|
||||
*/
|
||||
@ApiModelProperty(value="调试日期")
|
||||
@NotNull(message="调试日期不能为空!")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date debugTime;
|
||||
// /**
|
||||
// * 调试人员
|
||||
// */
|
||||
// @ApiModelProperty(value="调试人员")
|
||||
// @NotBlank(message="调试人员不能为空!")
|
||||
// private String debugPerson;
|
||||
//
|
||||
// /**
|
||||
// * 出厂日期
|
||||
// */
|
||||
// @ApiModelProperty(value="出厂日期")
|
||||
// @NotNull(message="出厂日期不能为空!")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
// private Date producteTime;
|
||||
//
|
||||
// /**
|
||||
// * 检修日期
|
||||
// */
|
||||
// @ApiModelProperty(value="检修日期")
|
||||
// @NotNull(message="检修日期不能为空!")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
// private Date checkTime;
|
||||
//
|
||||
// /**
|
||||
// * 调试日期
|
||||
// */
|
||||
// @ApiModelProperty(value="调试日期")
|
||||
// @NotNull(message="调试日期不能为空!")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
// private Date debugTime;
|
||||
|
||||
/**
|
||||
* 合同号
|
||||
@@ -101,11 +101,11 @@ public class CsEquipmentDeliveryAddParm{
|
||||
@ApiModelProperty(value="合同号")
|
||||
private String cntractNo;
|
||||
|
||||
/**
|
||||
* 营销经理
|
||||
*/
|
||||
@ApiModelProperty(value="营销经理")
|
||||
private String salesManager;
|
||||
// /**
|
||||
// * 营销经理
|
||||
// */
|
||||
// @ApiModelProperty(value="营销经理")
|
||||
// private String salesManager;
|
||||
|
||||
/**
|
||||
* 装置接入方式
|
||||
|
||||
@@ -66,32 +66,32 @@ public class CsEquipmentDeliveryAuditParm {
|
||||
@ApiModelProperty(value="装置程序版本")
|
||||
private String programVersion;
|
||||
|
||||
/**
|
||||
* 调试人员
|
||||
*/
|
||||
@ApiModelProperty(value="调试人员")
|
||||
private String debugPerson;
|
||||
|
||||
/**
|
||||
* 出厂日期
|
||||
*/
|
||||
@ApiModelProperty(value="出厂日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date producteTime;
|
||||
|
||||
/**
|
||||
* 检修日期
|
||||
*/
|
||||
@ApiModelProperty(value="检修日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date checkTime;
|
||||
|
||||
/**
|
||||
* 调试日期
|
||||
*/
|
||||
@ApiModelProperty(value="调试日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date debugTime;
|
||||
// /**
|
||||
// * 调试人员
|
||||
// */
|
||||
// @ApiModelProperty(value="调试人员")
|
||||
// private String debugPerson;
|
||||
//
|
||||
// /**
|
||||
// * 出厂日期
|
||||
// */
|
||||
// @ApiModelProperty(value="出厂日期")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
// private Date producteTime;
|
||||
//
|
||||
// /**
|
||||
// * 检修日期
|
||||
// */
|
||||
// @ApiModelProperty(value="检修日期")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
// private Date checkTime;
|
||||
//
|
||||
// /**
|
||||
// * 调试日期
|
||||
// */
|
||||
// @ApiModelProperty(value="调试日期")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
// private Date debugTime;
|
||||
|
||||
/**
|
||||
* 合同号
|
||||
@@ -99,11 +99,11 @@ public class CsEquipmentDeliveryAuditParm {
|
||||
@ApiModelProperty(value="合同号")
|
||||
private String cntractNo;
|
||||
|
||||
/**
|
||||
* 营销经理
|
||||
*/
|
||||
@ApiModelProperty(value="营销经理")
|
||||
private String salesManager;
|
||||
// /**
|
||||
// * 营销经理
|
||||
// */
|
||||
// @ApiModelProperty(value="营销经理")
|
||||
// private String salesManager;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.njcn.csdevice.pojo.param;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/11/21 9:35【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class DeviceExcelTemplete implements Serializable {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 装置名称
|
||||
*/
|
||||
@Excel(name = "装置名称", width = 15)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 网关识别码
|
||||
*/
|
||||
@Excel(name = "网关识别码", width = 15)
|
||||
private String ndid;
|
||||
|
||||
/**
|
||||
* 装置类型(直连设备、网关设备、装置)
|
||||
*/
|
||||
@Excel(name = "装置类型(直连设备,网关设备)", width = 30)
|
||||
private String devType;
|
||||
|
||||
/**
|
||||
* 装置型号(pqs588、pqs680...)
|
||||
*/
|
||||
@Excel(name = "装置型号", width = 15)
|
||||
private String devModel;
|
||||
|
||||
/**
|
||||
* 装置接入方式(mqtt、cloud)
|
||||
*/
|
||||
@Excel(name = "装置接入方式(mqtt、cloud)", width = 25)
|
||||
private String devAccessMethod;
|
||||
|
||||
/**
|
||||
* 合同号
|
||||
*/
|
||||
@Excel(name = "合同号", width = 15)
|
||||
private String cntractNo;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
public static class IllegalityDeviceExcelTemplete extends DeviceExcelTemplete implements Serializable {
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Excel(name = "错误信息描述", width = 30)
|
||||
private String msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
|
||||
private String qrPath;
|
||||
|
||||
/**
|
||||
* 二维码文件路径
|
||||
* 设备当前流程(1:设备登记,2:功能调试,3:出厂调试),4:设备投运)
|
||||
*/
|
||||
@TableField(value = "process")
|
||||
private String process;
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.njcn.csdevice.utils;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams;
|
||||
import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/7/4
|
||||
*/
|
||||
public class ExcelStyleUtil implements IExcelExportStyler {
|
||||
// 数据行类型
|
||||
private static final String DATA_STYLES = "dataStyles";
|
||||
// 标题类型
|
||||
private static final String TITLE_STYLES = "titleStyles";
|
||||
//头样式
|
||||
private static final String HEADER_STYLES = "headerStyles";
|
||||
|
||||
//数据行样式
|
||||
private CellStyle styles;
|
||||
// 标题样式
|
||||
private CellStyle titleStyle;
|
||||
|
||||
// 标题样式
|
||||
private CellStyle headerStyle;
|
||||
|
||||
public ExcelStyleUtil(Workbook workbook) {
|
||||
this.init(workbook);
|
||||
}
|
||||
|
||||
private void init(Workbook workbook) {
|
||||
this.styles = initStyles(workbook);
|
||||
this.titleStyle = initTitleStyle(workbook);
|
||||
this.headerStyle = initTitleStyle(workbook);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CellStyle getHeaderStyle(short headerColor) {
|
||||
return headerStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 标题样式
|
||||
*/
|
||||
@Override
|
||||
public CellStyle getTitleStyle(short i) {
|
||||
return titleStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellStyle getStyles(boolean parity, ExcelExportEntity entity) {
|
||||
return styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取样式方法
|
||||
*
|
||||
* @param dataRow 数据行
|
||||
* @param obj 对象
|
||||
* @param data 数据
|
||||
*/
|
||||
@Override
|
||||
public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data) {
|
||||
return getStyles(true, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化--标题行样式
|
||||
* @param workbook
|
||||
* @return
|
||||
*/
|
||||
private CellStyle initTitleStyle(Workbook workbook) {
|
||||
return buildCellStyle(workbook,TITLE_STYLES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 头样式
|
||||
* @author cdf
|
||||
* @date 2022/7/4
|
||||
*/
|
||||
private CellStyle initHeaderStyle(Workbook workbook) {
|
||||
return buildCellStyle(workbook,HEADER_STYLES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化--数据行样式
|
||||
* @param workbook
|
||||
* @return
|
||||
*/
|
||||
private CellStyle initStyles(Workbook workbook) {
|
||||
return buildCellStyle(workbook,DATA_STYLES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置单元格样式
|
||||
* @param workbook
|
||||
* @param type 类型 用来区分是数据行样式还是标题样式
|
||||
* @return
|
||||
*/
|
||||
private CellStyle buildCellStyle(Workbook workbook,String type) {
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
// 字体样式
|
||||
Font font = workbook.createFont();
|
||||
if(TITLE_STYLES.equals(type)){
|
||||
font.setFontHeightInPoints((short)12);
|
||||
font.setBold(true);
|
||||
// 设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
}
|
||||
if(HEADER_STYLES.equals(type)){
|
||||
font.setFontHeightInPoints((short)12);
|
||||
font.setBold(true);
|
||||
// 设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.LEFT);
|
||||
}
|
||||
if(DATA_STYLES.equals(type)){
|
||||
font.setFontHeightInPoints((short)10);
|
||||
// 设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
}
|
||||
font.setFontName("Courier New");
|
||||
style.setFont(font);
|
||||
// 设置底边框
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
// 设置左边框
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
// 设置右边框;
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
// 设置顶边框;
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
// 设置底边颜色
|
||||
style.setBottomBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置左边框颜色;
|
||||
style.setLeftBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置右边框颜色;
|
||||
style.setRightBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置顶边框颜色;
|
||||
style.setTopBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||
// 设置自动换行;
|
||||
style.setWrapText(false);
|
||||
|
||||
|
||||
// 设置垂直对齐的样式为居中对齐;
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
return style;
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,34 @@
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>common-poi</artifactId>
|
||||
<groupId>com.njcn</groupId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
@@ -9,30 +11,34 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.enums.DeviceOperate;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
||||
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
||||
import com.njcn.csdevice.service.IMqttUserService;
|
||||
import com.njcn.csdevice.utils.ExcelStyleUtil;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
@@ -190,4 +196,29 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("导出设备模板")
|
||||
@GetMapping(value = "getExcelTemplate")
|
||||
public HttpResult<String> getExcelTemplate(HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("getExcelTemplate");
|
||||
|
||||
ExportParams exportParams = new ExportParams("批量导入模板(请严格按照模板标准填入数据)", "终端入网检测录入信息");
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceExcelTemplete.class, new ArrayList<DeviceExcelTemplete>());
|
||||
ExcelUtil.selectList(workbook, 2, 2, Stream.of("直连设备","网关设备").collect(Collectors.toList()).toArray(new String[]{}));
|
||||
ExcelUtil.selectList(workbook, 4, 4, Stream.of("mqtt","cloud").collect(Collectors.toList()).toArray(new String[]{}));
|
||||
String fileName = "设备模板.xlsx";
|
||||
ExportParams exportExcel = new ExportParams("设备模板", "设备模板");
|
||||
PoiUtil.exportFileByWorkbook(workbook, fileName, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("excel批量导入设备信息")
|
||||
@PostMapping(value = "importEquipment")
|
||||
public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importEquipment");
|
||||
csEquipmentDeliveryService.importEquipment(file, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -89,4 +92,6 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
|
||||
* @return
|
||||
*/
|
||||
CsEquipmentDeliveryPO findDevByNDid(String nDid);
|
||||
|
||||
void importEquipment(MultipartFile file, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -24,16 +30,22 @@ import com.njcn.csdevice.util.QRCodeUtil;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -74,6 +86,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@@ -86,18 +99,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
BeanUtils.copyProperties (csEquipmentDeliveryAddParm,csEquipmentDeliveryPo);
|
||||
csEquipmentDeliveryPo.setStatus ("1");
|
||||
csEquipmentDeliveryPo.setRunStatus(1);
|
||||
csEquipmentDeliveryPo.setProcess(1);
|
||||
|
||||
//生成二维码文件
|
||||
try {
|
||||
QrParam qrParam = new QrParam();
|
||||
qrParam.setData(csEquipmentDeliveryAddParm.getNdid());
|
||||
BufferedImage bufferedImage = QRCodeUtil.getBufferedImage(JSONObject.toJSONString(qrParam));
|
||||
InputStream inputStream = bufferedImageToInputStream(bufferedImage);
|
||||
String fileName = csEquipmentDeliveryAddParm.getNdid() + ".png";
|
||||
String filePath = fileStorageUtil.uploadStream(inputStream,OssPath.APP_DEVICE_QR,fileName);
|
||||
csEquipmentDeliveryPo.setQrPath(filePath);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String qr = this.createQr(csEquipmentDeliveryAddParm.getNdid());
|
||||
csEquipmentDeliveryPo.setQrPath(qr);
|
||||
|
||||
return this.save (csEquipmentDeliveryPo);
|
||||
}
|
||||
|
||||
@@ -311,6 +318,115 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getNdid,nDid).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importEquipment(MultipartFile file, HttpServletResponse response) {
|
||||
ImportParams params = new ImportParams ( );
|
||||
params.setHeadRows(1);
|
||||
params.setTitleRows(1);
|
||||
//第一个sheet为台账信息
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
try {
|
||||
ExcelImportResult<DeviceExcelTemplete> terminalBaseList = ExcelImportUtil.importExcelMore (file.getInputStream ( ), DeviceExcelTemplete.class, params);
|
||||
//如果存在非法数据,将不合格的数据导出
|
||||
List<DeviceExcelTemplete> trueCollect = new ArrayList<> ( );
|
||||
List<DeviceExcelTemplete.IllegalityDeviceExcelTemplete> falseCollect = new ArrayList<> ( );
|
||||
|
||||
for (int i = 0; i < terminalBaseList.getList ( ).size ( ); i++) {
|
||||
DeviceExcelTemplete deviceExcelTemplete = terminalBaseList.getList ( ).get (i);
|
||||
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (deviceExcelTemplete.getNdid ( ));
|
||||
if(!Objects.isNull (po)){
|
||||
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
|
||||
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
|
||||
idlegalityDeviceException.setMsg("NDID重复");
|
||||
falseCollect.add(idlegalityDeviceException);
|
||||
}
|
||||
if(Objects.equals(deviceExcelTemplete.getDevType(),DicDataEnum.GATEWAY_DEV.getName())){
|
||||
DictTreeVO data = dictTreeFeignClient.queryByCode(DicDataEnum.GATEWAY_DEV.getCode()).getData();
|
||||
deviceExcelTemplete.setDevType(data.getId());
|
||||
List<DictTreeVO> data1 = dictTreeFeignClient.query(data.getId()).getData();
|
||||
Map<String, DictTreeVO> collect = data1.stream().collect(Collectors.toMap(DictTreeVO::getCode, dictTreeVO -> dictTreeVO));
|
||||
if(collect.containsKey(deviceExcelTemplete.getDevModel())){
|
||||
deviceExcelTemplete.setDevModel(collect.get(deviceExcelTemplete.getDevModel()).getId());
|
||||
trueCollect.add(deviceExcelTemplete);
|
||||
}else {
|
||||
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
|
||||
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
|
||||
idlegalityDeviceException.setMsg("装置型号不正确");
|
||||
falseCollect.add(idlegalityDeviceException);
|
||||
}
|
||||
} else if (Objects.equals(deviceExcelTemplete.getDevType(),DicDataEnum.CONNECT_DEV.getName())) {
|
||||
DictTreeVO data = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
|
||||
deviceExcelTemplete.setDevType(data.getId());
|
||||
List<DictTreeVO> data1 = dictTreeFeignClient.query(data.getId()).getData();
|
||||
Map<String, DictTreeVO> collect = data1.stream().collect(Collectors.toMap(DictTreeVO::getCode, dictTreeVO -> dictTreeVO));
|
||||
if(collect.containsKey(deviceExcelTemplete.getDevModel())){
|
||||
deviceExcelTemplete.setDevModel(collect.get(deviceExcelTemplete.getDevModel()).getId());
|
||||
trueCollect.add(deviceExcelTemplete);
|
||||
}else {
|
||||
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
|
||||
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
|
||||
idlegalityDeviceException.setMsg("装置型号不正确");
|
||||
falseCollect.add(idlegalityDeviceException);
|
||||
}
|
||||
}else {
|
||||
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
|
||||
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException);
|
||||
idlegalityDeviceException.setMsg("装置类型不正确");
|
||||
falseCollect.add(idlegalityDeviceException);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (!CollectionUtils.isEmpty (trueCollect)) {
|
||||
List<CsEquipmentDeliveryPO> collect = trueCollect.stream ( ).map (temp -> {
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPO = new CsEquipmentDeliveryPO ( );
|
||||
BeanUtils.copyProperties (temp, csEquipmentDeliveryPO);
|
||||
String qr = this.createQr(temp.getNdid());
|
||||
csEquipmentDeliveryPO.setQrPath(qr);
|
||||
String path = this.createPath(temp.getNdid());
|
||||
csEquipmentDeliveryPO.setMac(path);
|
||||
csEquipmentDeliveryPO.setRunStatus(1);
|
||||
csEquipmentDeliveryPO.setStatus("1");
|
||||
csEquipmentDeliveryPO.setProcess(1);
|
||||
return csEquipmentDeliveryPO;
|
||||
}).collect (Collectors.toList ( ));
|
||||
this.saveOrUpdateBatch (collect, 500);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty (falseCollect)) {
|
||||
ExportParams exportExcel = new ExportParams ("批量导入模板(请严格按照模板标准填入数据)", "非法设备信息");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel (exportExcel, DeviceExcelTemplete.IllegalityDeviceExcelTemplete.class, falseCollect);
|
||||
PoiUtil.exportFileByWorkbook (workbook, "非法设备信息.xlsx", response);
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace ( );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ndid生成二维码
|
||||
* @param ndid
|
||||
* @return
|
||||
*/
|
||||
private String createQr(String ndid){
|
||||
String filePath ="";
|
||||
//生成二维码文件
|
||||
try {
|
||||
QrParam qrParam = new QrParam();
|
||||
qrParam.setData(ndid);
|
||||
BufferedImage bufferedImage = QRCodeUtil.getBufferedImage(JSONObject.toJSONString(qrParam));
|
||||
InputStream inputStream = bufferedImageToInputStream(bufferedImage);
|
||||
String fileName = ndid + ".png";
|
||||
filePath = fileStorageUtil.uploadStream(inputStream,OssPath.APP_DEVICE_QR,fileName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return filePath;
|
||||
|
||||
}
|
||||
|
||||
public InputStream bufferedImageToInputStream(BufferedImage image) {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try {
|
||||
@@ -322,4 +438,25 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/*将ndid转成mac地址*/
|
||||
public String createPath(String nDid) {
|
||||
// 使用StringBuilder来构建新的字符串
|
||||
StringBuilder output = new StringBuilder();
|
||||
// 遍历输入字符串,每两个字符分割并添加冒号
|
||||
for (int i = 0; i < nDid.length(); i += 2) {
|
||||
if (i > 0) {
|
||||
//添加冒号分隔符
|
||||
output.append(StrPool.COLON);
|
||||
}
|
||||
if (i + 1 < nDid.length()) {
|
||||
// 检查是否有足够的字符来分割成两组
|
||||
// 每两个字符添加到新字符串
|
||||
output.append(nDid.substring(i, i + 2));
|
||||
} else {
|
||||
// 如果只剩一个字符,可以根据需要添加处理逻辑
|
||||
output.append(nDid.charAt(i));
|
||||
}
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
public DevDetailDTO queryDevDetail(String devId) {
|
||||
DevDetailDTO device = new DevDetailDTO();
|
||||
CsLedger dev = this.findDataById(devId);
|
||||
device.setEquipmentName(dev.getId());
|
||||
device.setEquipmentName(dev.getName());
|
||||
device.setEquipmentId(devId);
|
||||
CsLedger project = this.findDataById(dev.getPid());
|
||||
device.setProjectId(project.getId());
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CsEventUserQueryParam {
|
||||
/**
|
||||
* 事件id
|
||||
*/
|
||||
private String eventId;
|
||||
private List<String> eventIds;
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
|
||||
@@ -3,11 +3,14 @@ package com.njcn.csharmonic.pojo.vo;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -53,7 +56,9 @@ public class EventDetailVO {
|
||||
/**
|
||||
* 事件时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
|
||||
@@ -41,4 +41,16 @@ public class EventUserController extends BaseController {
|
||||
Integer count = csEventUserPOService.queryEventCount(csEventUserQueryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateStatus")
|
||||
@ApiOperation("已读事件")
|
||||
@ApiImplicitParam(name = "csEventUserQueryParam", value = "暂降事件查询参数", required = true)
|
||||
public HttpResult<Boolean> updateStatus(@RequestBody CsEventUserQueryParam csEventUserQueryParam) {
|
||||
String methodDescribe = getMethodDescribe("updateStatus");
|
||||
csEventUserPOService.updateStatus(csEventUserQueryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.njcn.csharmonic.service.ILineTargetService;
|
||||
import com.njcn.csharmonic.service.StableDataService;
|
||||
import com.njcn.csharmonic.service.TemperatureService;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.CsStatisticalSetFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -47,6 +48,8 @@ public class MqttMessageHandler {
|
||||
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
||||
private final StableDataService stableDataService;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final TemperatureService temperatureService;
|
||||
private final DecimalFormat df = new DecimalFormat("#0.000");
|
||||
/**
|
||||
@@ -74,9 +77,11 @@ public class MqttMessageHandler {
|
||||
*/
|
||||
@MqttSubscribe(value = "/zl/askDevData/{devId}",qos = 1)
|
||||
public void responseTopoData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
|
||||
String topoDataJson =redisUtil.getStringByKey (devId);
|
||||
if(StringUtils.isEmpty(topoDataJson)){
|
||||
List<ThdDataVO> result = new ArrayList<>();
|
||||
List<ThdDataVO> tempList = new ArrayList<>();
|
||||
ExecutorService executorService = new ThreadPoolExecutor(40, 400,
|
||||
ExecutorService executorService = new ThreadPoolExecutor(10, 100,
|
||||
1, TimeUnit.MINUTES, new ArrayBlockingQueue<>(100, true),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
List<Future<List<ThdDataVO>>> resultList = new ArrayList< Future<List<ThdDataVO>>>();
|
||||
@@ -189,7 +194,12 @@ public class MqttMessageHandler {
|
||||
|
||||
|
||||
Gson gson = new Gson();
|
||||
publisher.send("/zl/devData/"+devId,gson.toJson(result),1,false);
|
||||
topoDataJson = gson.toJson(result);
|
||||
redisUtil.saveByKeyWithExpire(devId, (Object) topoDataJson,Long.valueOf(10*60));
|
||||
}
|
||||
|
||||
|
||||
publisher.send("/zl/devData/"+devId,topoDataJson,1,false);
|
||||
}
|
||||
|
||||
public String getCldidName( String cldid) {
|
||||
|
||||
@@ -21,4 +21,6 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
|
||||
Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam);
|
||||
|
||||
List<EventDetailVO> queryUserEventList(CsEventUserQueryParam csEventUserQueryParam);
|
||||
}
|
||||
|
||||
void updateStatus(CsEventUserQueryParam csEventUserQueryParam);
|
||||
}
|
||||
|
||||
@@ -49,4 +49,15 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
List<EventDetailVO> list = this.getBaseMapper().queryUserEventList(csEventUserQueryParam);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(CsEventUserQueryParam csEventUserQueryParam) {
|
||||
if(CollectionUtil.isEmpty(csEventUserQueryParam.getEventIds())){
|
||||
return;
|
||||
}
|
||||
csEventUserQueryParam.setUserId(RequestUtil.getUserIndex());
|
||||
this.lambdaUpdate().in(CsEventUserPO::getEventId,csEventUserQueryParam.getEventIds()).
|
||||
eq(CsEventUserPO::getUserId,csEventUserQueryParam.getUserId()).
|
||||
set(CsEventUserPO::getStatus,1).update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user