携稳配电箱修复
This commit is contained in:
parent
664aacafa5
commit
200a0ba6b5
@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@ -118,11 +118,13 @@ public class ElectricalData implements Serializable {
|
||||
@ApiModelProperty(value = "环境温度")
|
||||
private java.lang.String ambientTemperature;
|
||||
|
||||
@ApiModelProperty(value = "携稳id")
|
||||
private Long xiewenId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "时间")
|
||||
private java.lang.String time;
|
||||
|
||||
|
||||
public ElectricalData(String devSn, String uploadTime, String voltageA, String voltageB, String voltageC, String phaseCurrentA, String phaseCurrentB, String phaseCurrentC, String electricLeakage, String cableTemperatureA, String cableTemperatureB, String cableTemperatureC, String cableTemperatureD) {
|
||||
this.devSn = devSn;
|
||||
this.uploadTime = uploadTime;
|
||||
|
||||
@ -8,16 +8,20 @@ import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.frontier.entity.FrontierProtectionDevAlarm;
|
||||
import com.zhgd.xmgl.modules.frontier.service.IFrontierProtectionDevAlarmService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@ -102,9 +106,14 @@ public class FrontierProtectionDevAlarmController {
|
||||
if (frontierProtectionDevAlarmEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
frontierProtectionDevAlarmService.updateById(frontierProtectionDevAlarm);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
if (Objects.equals(frontierProtectionDevAlarm.getHandleDone(), 1)) {
|
||||
UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getCredentials();
|
||||
frontierProtectionDevAlarm.setOperateId(userInfo.getUserId());
|
||||
frontierProtectionDevAlarm.setOperateTime(new Date());
|
||||
}
|
||||
frontierProtectionDevAlarmService.updateById(frontierProtectionDevAlarm);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -14,9 +14,12 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -125,5 +128,19 @@ public class FrontierProtectionDevCurrentDataController {
|
||||
public Result deleteById(Long id) {
|
||||
return Result.success(frontierProtectionDevCurrentDataService.removeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation(value = "导出excel临边防护-设备实时数据", notes = "导出excel临边防护-设备实时数据", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(FrontierProtectionDevCurrentDataQO qo, HttpServletRequest request, HttpServletResponse response) {
|
||||
return frontierProtectionDevCurrentDataService.exportXls(qo, request, response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -96,9 +96,15 @@ public class FrontierProtectionDev implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "使用状态1正常2异常")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "班组名称")
|
||||
private String teamName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "在线状态(0.离线 1.在线)")
|
||||
private java.lang.Integer online;
|
||||
}
|
||||
|
||||
|
||||
@ -102,6 +102,21 @@ public class FrontierProtectionDevAlarm implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 操作人id
|
||||
*/
|
||||
@Excel(name = "操作人id", width = 15)
|
||||
@ApiModelProperty(value = "操作人id")
|
||||
private java.lang.Long operateId;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private java.util.Date operateTime;
|
||||
|
||||
@ApiModelProperty(value = "设备位置")
|
||||
@TableField(exist = false)
|
||||
@ -109,5 +124,9 @@ public class FrontierProtectionDevAlarm implements Serializable {
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
@TableField(exist = false)
|
||||
private String devName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private java.lang.String operateName;
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -41,6 +42,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "dev_sn")
|
||||
@ApiModelProperty(value = "临边防护设备sn")
|
||||
@Excel(name = "临边防护设备sn", width = 15)
|
||||
private String devSn;
|
||||
|
||||
/**
|
||||
@ -48,6 +50,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "battery")
|
||||
@ApiModelProperty(value = "剩余电量百分比(0-100)")
|
||||
@Excel(name = "剩余电量百分比(%)", width = 15)
|
||||
private Float battery;
|
||||
|
||||
/**
|
||||
@ -55,6 +58,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "proximity")
|
||||
@ApiModelProperty(value = "人员靠近 1-正常;2-入侵;3-正常入侵")
|
||||
@Excel(name = "人员靠近", width = 15, replace = {"正常_1", "入侵_2", "正常入侵_3"})
|
||||
private Integer proximity;
|
||||
|
||||
/**
|
||||
@ -64,6 +68,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
@ApiModelProperty(value = "采集时间")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "上报时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date receiveTime;
|
||||
|
||||
/**
|
||||
@ -89,6 +94,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "port_status1")
|
||||
@ApiModelProperty(value = "线锁1 状态 1-正常;2-断开;3-正常断开")
|
||||
@Excel(name = "线锁1", width = 20, replace = {"正常_1", "断开_2", "正常断开_3"})
|
||||
private Integer portStatus1;
|
||||
|
||||
/**
|
||||
@ -96,6 +102,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "port_status2")
|
||||
@ApiModelProperty(value = "线锁2 状态 1-正常;2-断开;3-正常断开")
|
||||
@Excel(name = "线锁2", width = 20, replace = {"正常_1", "断开_2", "正常断开_3"})
|
||||
private Integer portStatus2;
|
||||
|
||||
/**
|
||||
@ -103,6 +110,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "mag_status1")
|
||||
@ApiModelProperty(value = "磁锁1 状态 1-正常;2-报警;3-失效")
|
||||
@Excel(name = "磁锁1", width = 20, replace = {"正常_1", "报警_2", "失效_3"})
|
||||
private Integer magStatus1;
|
||||
|
||||
/**
|
||||
@ -110,6 +118,7 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "mag_status2")
|
||||
@ApiModelProperty(value = "磁锁2 状态 1-正常;2-报警;3-失效")
|
||||
@Excel(name = "磁锁2", width = 20, replace = {"正常_1", "报警_2", "失效_3"})
|
||||
private Integer magStatus2;
|
||||
|
||||
/**
|
||||
@ -117,12 +126,21 @@ public class FrontierProtectionDevCurrentData implements Serializable {
|
||||
*/
|
||||
@TableField(value = "anti_cross")
|
||||
@ApiModelProperty(value = "防翻越 1-正常;2-报警;3-失效")
|
||||
@Excel(name = "防翻越", width = 20, replace = {"正常_1", "报警_2", "失效_3"})
|
||||
private Integer antiCross;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
@Excel(name = "设备名称", width = 15, orderNum = "-1")
|
||||
private String devName;
|
||||
|
||||
@ApiModelProperty(value = "所属项目唯一标识")
|
||||
@TableField(exist = false)
|
||||
private String projectSn;
|
||||
@ApiModelProperty(value = "运行状态(正常,xxx报警)")
|
||||
@TableField(exist = false)
|
||||
private String operatingStatus;
|
||||
|
||||
public FrontierProtectionDevCurrentData(String devSn, Date receiveTime, Float battery, Integer proximity, Integer antiCross) {
|
||||
this.id = IdUtil.getSnowflake().nextId();
|
||||
this.devSn = devSn;
|
||||
|
||||
@ -122,5 +122,8 @@ public class FrontierProtectionDevCurrentDataQO implements Serializable {
|
||||
*/
|
||||
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss 结束时间")
|
||||
private String endUpdateDate;
|
||||
|
||||
@ApiModelProperty(value = "所属项目唯一标识")
|
||||
private String projectSn;
|
||||
}
|
||||
|
||||
|
||||
@ -30,5 +30,7 @@ public interface FrontierProtectionDevCurrentDataMapper extends BaseMapper<Front
|
||||
int insertOrUpdateBatch(@Param("entities") List<FrontierProtectionDevCurrentData> entities);
|
||||
|
||||
IPage<FrontierProtectionDevCurrentData> selectPageDetail(Page<FrontierProtectionDevCurrentData> page, @Param(Constants.WRAPPER) QueryWrapper<FrontierProtectionDevCurrentData> wrapper);
|
||||
|
||||
List<FrontierProtectionDevCurrentData> selectPageDetailList(@Param(Constants.WRAPPER) QueryWrapper<FrontierProtectionDevCurrentData> wrapper);
|
||||
}
|
||||
|
||||
|
||||
@ -42,5 +42,11 @@
|
||||
fpd on fpd.dev_sn=fpdcd.dev_sn
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectPageDetailList" resultMap="FrontierProtectionDevCurrentDataMap">
|
||||
select fpdcd.*,fpd.dev_name from frontier_protection_dev_current_data fpdcd inner join frontier_protection_dev
|
||||
fpd on fpd.dev_sn=fpdcd.dev_sn
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@ -30,7 +30,10 @@
|
||||
</insert>
|
||||
|
||||
<select id="selectPageDetail" resultType="com.zhgd.xmgl.modules.frontier.entity.FrontierProtectionDev">
|
||||
select fpd.*,i.team_name from frontier_protection_dev fpd left join team_info i on i.id=fpd.team_info_id
|
||||
select fpd.*,i.team_name,IFNULL(((case when round((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(fpd.update_date))/60)<=30
|
||||
then 1 else 0 end)),0)
|
||||
online
|
||||
from frontier_protection_dev fpd left join team_info i on i.id=fpd.duty_team_info_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -6,6 +6,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.xmgl.modules.frontier.entity.FrontierProtectionDevCurrentData;
|
||||
import com.zhgd.xmgl.modules.frontier.entity.qo.FrontierProtectionDevCurrentDataQO;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
/**
|
||||
@ -23,5 +27,7 @@ public interface FrontierProtectionDevCurrentDataService extends IService<Fronti
|
||||
* @param devDataArray
|
||||
*/
|
||||
void lrkAdd(JSONArray devDataArray);
|
||||
|
||||
ModelAndView exportXls(FrontierProtectionDevCurrentDataQO qo, HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
||||
|
||||
|
||||
@ -16,9 +16,16 @@ import com.zhgd.xmgl.modules.frontier.mapper.FrontierProtectionDevCurrentDataMap
|
||||
import com.zhgd.xmgl.modules.frontier.service.FrontierProtectionDevCurrentDataService;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -37,8 +44,14 @@ public class FrontierProtectionDevCurrentDataServiceImpl extends ServiceImpl<Fro
|
||||
|
||||
@Override
|
||||
public IPage<FrontierProtectionDevCurrentData> selectPageInfo(Page<FrontierProtectionDevCurrentData> page, FrontierProtectionDevCurrentDataQO frontierProtectionDevCurrentDataQo) {
|
||||
String alias = "fpdcd.";
|
||||
// 查询临边防护-设备实时数据条件 根据需求调整
|
||||
QueryWrapper<FrontierProtectionDevCurrentData> wrapper = getFrontierProtectionDevCurrentDataQueryWrapper(frontierProtectionDevCurrentDataQo);
|
||||
|
||||
return frontierProtectionDevCurrentDataMapper.selectPageDetail(page, wrapper);
|
||||
}
|
||||
|
||||
private QueryWrapper<FrontierProtectionDevCurrentData> getFrontierProtectionDevCurrentDataQueryWrapper(FrontierProtectionDevCurrentDataQO frontierProtectionDevCurrentDataQo) {
|
||||
String alias = "fpdcd.";
|
||||
QueryWrapper<FrontierProtectionDevCurrentData> wrapper = new QueryWrapper<FrontierProtectionDevCurrentData>()
|
||||
// 通过devId临边防护设备id 精准查询
|
||||
.eq(CharSequenceUtil.isNotBlank(frontierProtectionDevCurrentDataQo.getDevSn()), alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getDevSn), frontierProtectionDevCurrentDataQo.getDevSn())
|
||||
@ -49,7 +62,7 @@ public class FrontierProtectionDevCurrentDataServiceImpl extends ServiceImpl<Fro
|
||||
// 采集时间 之后
|
||||
.ge(CharSequenceUtil.isNotBlank(frontierProtectionDevCurrentDataQo.getStartReceiveTime()), alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getReceiveTime), frontierProtectionDevCurrentDataQo.getStartReceiveTime())
|
||||
// 采集时间 之前
|
||||
.le(CharSequenceUtil.isNotBlank(frontierProtectionDevCurrentDataQo.getEndReceiveTime()), alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getReceiveTime), frontierProtectionDevCurrentDataQo.getEndReceiveTime() != null ? DateUtil.endOfDay(DateUtil.parseDate(frontierProtectionDevCurrentDataQo.getEndReceiveTime())) : null)
|
||||
.le(CharSequenceUtil.isNotBlank(frontierProtectionDevCurrentDataQo.getEndReceiveTime()), alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getReceiveTime), StringUtils.isNotBlank(frontierProtectionDevCurrentDataQo.getEndReceiveTime()) ? DateUtil.endOfDay(DateUtil.parseDate(frontierProtectionDevCurrentDataQo.getEndReceiveTime())) : null)
|
||||
// 创建时间 yyyy-MM-dd HH:mm:ss 之后
|
||||
.ge(CharSequenceUtil.isNotBlank(frontierProtectionDevCurrentDataQo.getStartCreateDate()), alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getCreateDate), frontierProtectionDevCurrentDataQo.getStartCreateDate())
|
||||
// 创建时间 yyyy-MM-dd HH:mm:ss 之前
|
||||
@ -68,9 +81,9 @@ public class FrontierProtectionDevCurrentDataServiceImpl extends ServiceImpl<Fro
|
||||
.eq(frontierProtectionDevCurrentDataQo.getMagStatus2() != null, alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getMagStatus2), frontierProtectionDevCurrentDataQo.getMagStatus2())
|
||||
// 通过antiCross防翻越 1-正常;2-报警;3-失效 精准查询
|
||||
.eq(frontierProtectionDevCurrentDataQo.getAntiCross() != null, alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getAntiCross), frontierProtectionDevCurrentDataQo.getAntiCross())
|
||||
.eq(StringUtils.isNotBlank(frontierProtectionDevCurrentDataQo.getProjectSn()), alias + ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getProjectSn), frontierProtectionDevCurrentDataQo.getProjectSn())
|
||||
.orderByDesc(ReflectionUtil.getFieldNameToUlc(FrontierProtectionDevCurrentData::getReceiveTime));
|
||||
|
||||
return frontierProtectionDevCurrentDataMapper.selectPageDetail(page, wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,6 +94,20 @@ public class FrontierProtectionDevCurrentDataServiceImpl extends ServiceImpl<Fro
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView exportXls(FrontierProtectionDevCurrentDataQO qo, HttpServletRequest request, HttpServletResponse response) {
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
QueryWrapper<FrontierProtectionDevCurrentData> queryWrapper = getFrontierProtectionDevCurrentDataQueryWrapper(qo);
|
||||
List<FrontierProtectionDevCurrentData> pageList = frontierProtectionDevCurrentDataMapper.selectPageDetailList(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "临边防护-实时数据列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, FrontierProtectionDevCurrentData.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("临边防护-实时数据列表", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过联睿科的json构建设备实时数据
|
||||
*
|
||||
|
||||
@ -11,6 +11,7 @@ import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDevAlarm;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDevCurrentData;
|
||||
import com.zhgd.xmgl.modules.poisonous.service.IPoisonousGasDevAlarmService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.util.DateUtil;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -23,6 +24,7 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
@ -33,9 +35,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -131,6 +131,11 @@ public class PoisonousGasDevAlarmController {
|
||||
if (poisonousGasDevAlarmEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
if (Objects.equals(poisonousGasDevAlarm.getHandleDone(), 1)) {
|
||||
UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getCredentials();
|
||||
poisonousGasDevAlarm.setOperateId(userInfo.getUserId());
|
||||
poisonousGasDevAlarm.setOperateTime(new Date());
|
||||
}
|
||||
poisonousGasDevAlarmService.updateById(poisonousGasDevAlarm);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
@ -204,75 +209,5 @@ public class PoisonousGasDevAlarmController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation(value = "导出excel有毒气体-报警信息", notes = "导出excel有毒气体-报警信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<PoisonousGasDevAlarm> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
PoisonousGasDevAlarm poisonousGasDevAlarm = JSON.parseObject(deString, PoisonousGasDevAlarm.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(poisonousGasDevAlarm, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<PoisonousGasDevAlarm> pageList = poisonousGasDevAlarmService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "有毒气体-报警列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, PoisonousGasDevAlarm.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("有毒气体-报警列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入有毒气体-报警信息", notes = "通过excel导入有毒气体-报警信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<PoisonousGasDevAlarm> listPoisonousGasDevAlarms = ExcelImportUtil.importExcel(file.getInputStream(), PoisonousGasDevAlarm.class, params);
|
||||
for (PoisonousGasDevAlarm poisonousGasDevAlarmExcel : listPoisonousGasDevAlarms) {
|
||||
poisonousGasDevAlarmService.save(poisonousGasDevAlarmExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listPoisonousGasDevAlarms.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -69,13 +69,7 @@ public class PoisonousGasDevController {
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<PoisonousGasDev>> result = new Result<IPage<PoisonousGasDev>>();
|
||||
QueryWrapper<PoisonousGasDev> queryWrapper = QueryGenerator.initQueryWrapper(poisonousGasDev, req.getParameterMap());
|
||||
Page<PoisonousGasDev> page = new Page<PoisonousGasDev>(pageNo, pageSize);
|
||||
IPage<PoisonousGasDev> pageList = poisonousGasDevService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
return Result.success(poisonousGasDevService.queryPageList(poisonousGasDev, pageNo, pageSize, req));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,75 +196,4 @@ public class PoisonousGasDevController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation(value = "导出excel有毒气体-设备信息", notes = "导出excel有毒气体-设备信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<PoisonousGasDev> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
PoisonousGasDev poisonousGasDev = JSON.parseObject(deString, PoisonousGasDev.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(poisonousGasDev, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<PoisonousGasDev> pageList = poisonousGasDevService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "有毒气体-设备列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, PoisonousGasDev.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("有毒气体-设备列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入有毒气体-设备信息", notes = "通过excel导入有毒气体-设备信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<PoisonousGasDev> listPoisonousGasDevs = ExcelImportUtil.importExcel(file.getInputStream(), PoisonousGasDev.class, params);
|
||||
for (PoisonousGasDev poisonousGasDevExcel : listPoisonousGasDevs) {
|
||||
poisonousGasDevService.save(poisonousGasDevExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listPoisonousGasDevs.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -67,16 +67,8 @@ public class PoisonousGasDevCurrentDataController {
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<PoisonousGasDevCurrentData>> result = new Result<IPage<PoisonousGasDevCurrentData>>();
|
||||
QueryWrapper<PoisonousGasDevCurrentData> queryWrapper = QueryGenerator.initQueryWrapper(poisonousGasDevCurrentData, req.getParameterMap());
|
||||
queryWrapper.ge(poisonousGasDevCurrentData.getQueryStartTime() != null, ReflectionUtil.getFieldNameToUlc(PoisonousGasDevCurrentData::getUpdateDate), poisonousGasDevCurrentData.getQueryStartTime())
|
||||
.le(poisonousGasDevCurrentData.getQueryEndTime() != null, ReflectionUtil.getFieldNameToUlc(PoisonousGasDevCurrentData::getUpdateDate), poisonousGasDevCurrentData.getQueryEndTime() != null ? DateUtil.endOfDay(poisonousGasDevCurrentData.getQueryEndTime()) : null)
|
||||
.orderByDesc(ReflectionUtil.getFieldNameToUlc(PoisonousGasDevCurrentData::getUpdateDate));
|
||||
Page<PoisonousGasDevCurrentData> page = new Page<>(pageNo, pageSize);
|
||||
IPage<PoisonousGasDevCurrentData> pageList = poisonousGasDevCurrentDataService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
|
||||
return Result.success(poisonousGasDevCurrentDataService.queryPageList(poisonousGasDevCurrentData, pageNo, pageSize, req));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,67 +208,9 @@ public class PoisonousGasDevCurrentDataController {
|
||||
*/
|
||||
@ApiOperation(value = "导出excel有毒气体-数据信息", notes = "导出excel有毒气体-数据信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<PoisonousGasDevCurrentData> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
PoisonousGasDevCurrentData poisonousGasDevCurrentData = JSON.parseObject(deString, PoisonousGasDevCurrentData.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(poisonousGasDevCurrentData, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<PoisonousGasDevCurrentData> pageList = poisonousGasDevCurrentDataService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "有毒气体-数据列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, PoisonousGasDevCurrentData.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("有毒气体-数据列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response, PoisonousGasDevCurrentData poisonousGasDevCurrentData) {
|
||||
return poisonousGasDevCurrentDataService.exportXls(request, response, poisonousGasDevCurrentData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入有毒气体-数据信息", notes = "通过excel导入有毒气体-数据信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<PoisonousGasDevCurrentData> listPoisonousGasDevCurrentDatas = ExcelImportUtil.importExcel(file.getInputStream(), PoisonousGasDevCurrentData.class, params);
|
||||
for (PoisonousGasDevCurrentData poisonousGasDevCurrentDataExcel : listPoisonousGasDevCurrentDatas) {
|
||||
poisonousGasDevCurrentDataService.save(poisonousGasDevCurrentDataExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listPoisonousGasDevCurrentDatas.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
package com.zhgd.xmgl.modules.poisonous.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 有毒气体-设备
|
||||
@ -23,76 +23,87 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
@TableName("poisonous_gas_dev")
|
||||
@ApiModel(value = "PoisonousGasDev实体类", description = "PoisonousGasDev")
|
||||
public class PoisonousGasDev implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private java.lang.Long id;
|
||||
/**
|
||||
* 设备sn
|
||||
*/
|
||||
@Excel(name = "设备sn", width = 15)
|
||||
@ApiModelProperty(value = "设备sn")
|
||||
private java.lang.String devSn;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@Excel(name = "设备名称", width = 15)
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private java.lang.String devName;
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
@Excel(name = "安装位置", width = 15)
|
||||
@ApiModelProperty(value = "安装位置")
|
||||
private java.lang.String location;
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
@Excel(name = "设备型号", width = 15)
|
||||
@ApiModelProperty(value = "设备型号")
|
||||
private java.lang.String deviceModel;
|
||||
/**
|
||||
* 厂家名称
|
||||
*/
|
||||
@Excel(name = "厂家名称", width = 15)
|
||||
@ApiModelProperty(value = "厂家名称")
|
||||
private java.lang.String factoryName;
|
||||
/**
|
||||
* 使用状态1正常2异常
|
||||
*/
|
||||
@Excel(name = "使用状态1正常2异常", width = 15)
|
||||
@ApiModelProperty(value = "使用状态1正常2异常")
|
||||
private java.lang.Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private java.lang.String remark;
|
||||
/**
|
||||
* 项目sn
|
||||
*/
|
||||
@Excel(name = "项目sn", width = 15)
|
||||
@ApiModelProperty(value = "项目sn")
|
||||
private java.lang.String projectSn;
|
||||
/**
|
||||
* 创建时间 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@Excel(name = "创建时间 yyyy-MM-dd HH:mm:ss", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createDate;
|
||||
/**
|
||||
* 更新时间 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@Excel(name = "更新时间 yyyy-MM-dd HH:mm:ss", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateDate;
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private java.lang.Long id;
|
||||
/**
|
||||
* 设备sn
|
||||
*/
|
||||
@Excel(name = "设备sn", width = 15)
|
||||
@ApiModelProperty(value = "设备sn")
|
||||
private java.lang.String devSn;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@Excel(name = "设备名称", width = 15)
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private java.lang.String devName;
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
@Excel(name = "安装位置", width = 15)
|
||||
@ApiModelProperty(value = "安装位置")
|
||||
private java.lang.String location;
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
@Excel(name = "设备型号", width = 15)
|
||||
@ApiModelProperty(value = "设备型号")
|
||||
private java.lang.String deviceModel;
|
||||
/**
|
||||
* 厂家名称
|
||||
*/
|
||||
@Excel(name = "厂家名称", width = 15)
|
||||
@ApiModelProperty(value = "厂家名称")
|
||||
private java.lang.String factoryName;
|
||||
/**
|
||||
* 使用状态1正常2异常
|
||||
*/
|
||||
@Excel(name = "使用状态1正常2异常", width = 15)
|
||||
@ApiModelProperty(value = "使用状态1正常2异常")
|
||||
private java.lang.Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private java.lang.String remark;
|
||||
/**
|
||||
* 项目sn
|
||||
*/
|
||||
@Excel(name = "项目sn", width = 15)
|
||||
@ApiModelProperty(value = "项目sn")
|
||||
private java.lang.String projectSn;
|
||||
/**
|
||||
* 创建时间 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@Excel(name = "创建时间 yyyy-MM-dd HH:mm:ss", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createDate;
|
||||
/**
|
||||
* 更新时间 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@Excel(name = "更新时间 yyyy-MM-dd HH:mm:ss", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateDate;
|
||||
|
||||
@ApiModelProperty(value = "责任班组id")
|
||||
private Long dutyTeamInfoId;
|
||||
|
||||
@ApiModelProperty(value = "责任班组名称")
|
||||
@TableField(exist = false)
|
||||
private String dutyTeamInfoName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "在线状态(0.离线 1.在线)")
|
||||
private java.lang.Integer online;
|
||||
}
|
||||
|
||||
@ -88,6 +88,7 @@ public class PoisonousGasDevAlarm implements Serializable {
|
||||
@Excel(name = "操作人id", width = 15)
|
||||
@ApiModelProperty(value = "操作人id")
|
||||
private java.lang.Long operateId;
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@ -134,4 +135,7 @@ public class PoisonousGasDevAlarm implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@TableField(exist = false)
|
||||
private Date queryEndTime;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private java.lang.String operateName;
|
||||
}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
package com.zhgd.xmgl.modules.poisonous.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Description: 有毒气体-设备
|
||||
@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@Mapper
|
||||
public interface PoisonousGasDevMapper extends BaseMapper<PoisonousGasDev> {
|
||||
|
||||
IPage<PoisonousGasDev> queryPageList(Page<PoisonousGasDev> page, @Param(Constants.WRAPPER) QueryWrapper<PoisonousGasDev> queryWrapper);
|
||||
}
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
<?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">
|
||||
<mapper namespace="com.zhgd.xmgl.modules.poisonous.mapper.PoisonousGasDevMapper">
|
||||
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev">
|
||||
select pgd.*, ti.team_name
|
||||
from poisonous_gas_dev pgd
|
||||
join team_info ti on ti.id = pgd.duty_team_info_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.zhgd.xmgl.modules.poisonous.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDevCurrentData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -16,4 +20,8 @@ public interface IPoisonousGasDevCurrentDataService extends IService<PoisonousGa
|
||||
List<PoisonousGasDevCurrentData> queryNewestDatalistGroupByDev(PoisonousGasDevCurrentData poisonousGasDevCurrentData);
|
||||
|
||||
void addDataFromTcp(String hexString);
|
||||
|
||||
ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response, PoisonousGasDevCurrentData poisonousGasDevCurrentData);
|
||||
|
||||
IPage<PoisonousGasDevCurrentData> queryPageList(PoisonousGasDevCurrentData poisonousGasDevCurrentData, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
}
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
package com.zhgd.xmgl.modules.poisonous.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @Description: 有毒气体-设备
|
||||
@ -11,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IPoisonousGasDevService extends IService<PoisonousGasDev> {
|
||||
|
||||
IPage<PoisonousGasDev> queryPageList(PoisonousGasDev poisonousGasDev, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
|
||||
}
|
||||
|
||||
@ -1,21 +1,32 @@
|
||||
package com.zhgd.xmgl.modules.poisonous.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDevAlarm;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDevCurrentData;
|
||||
import com.zhgd.xmgl.modules.poisonous.enums.AlarmEnum;
|
||||
import com.zhgd.xmgl.modules.poisonous.enums.PoisonousTypeEnum;
|
||||
import com.zhgd.xmgl.modules.poisonous.mapper.PoisonousGasDevAlarmMapper;
|
||||
import com.zhgd.xmgl.modules.poisonous.mapper.PoisonousGasDevCurrentDataMapper;
|
||||
import com.zhgd.xmgl.modules.poisonous.mapper.PoisonousGasDevMapper;
|
||||
import com.zhgd.xmgl.modules.poisonous.service.IPoisonousGasDevCurrentDataService;
|
||||
import com.zhgd.xmgl.util.DateUtil;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
@ -95,4 +106,34 @@ public class PoisonousGasDevCurrentDataServiceImpl extends ServiceImpl<Poisonous
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<PoisonousGasDevCurrentData> queryPageList(PoisonousGasDevCurrentData poisonousGasDevCurrentData, Integer pageNo, Integer pageSize, HttpServletRequest req) {
|
||||
QueryWrapper<PoisonousGasDevCurrentData> queryWrapper = getPoisonousGasDevCurrentDataQueryWrapper(poisonousGasDevCurrentData, req);
|
||||
Page<PoisonousGasDevCurrentData> page = new Page<>(pageNo, pageSize);
|
||||
return page(page, queryWrapper);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private QueryWrapper<PoisonousGasDevCurrentData> getPoisonousGasDevCurrentDataQueryWrapper(PoisonousGasDevCurrentData poisonousGasDevCurrentData, HttpServletRequest req) {
|
||||
QueryWrapper<PoisonousGasDevCurrentData> queryWrapper = QueryGenerator.initQueryWrapper(poisonousGasDevCurrentData, req.getParameterMap());
|
||||
queryWrapper.ge(poisonousGasDevCurrentData.getQueryStartTime() != null, ReflectionUtil.getFieldNameToUlc(PoisonousGasDevCurrentData::getUpdateDate), poisonousGasDevCurrentData.getQueryStartTime())
|
||||
.le(poisonousGasDevCurrentData.getQueryEndTime() != null, ReflectionUtil.getFieldNameToUlc(PoisonousGasDevCurrentData::getUpdateDate), poisonousGasDevCurrentData.getQueryEndTime() != null ? DateUtil.endOfDay(poisonousGasDevCurrentData.getQueryEndTime()) : null)
|
||||
.orderByDesc(ReflectionUtil.getFieldNameToUlc(PoisonousGasDevCurrentData::getUpdateDate));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response, PoisonousGasDevCurrentData poisonousGasDevCurrentData) {
|
||||
QueryWrapper<PoisonousGasDevCurrentData> queryWrapper = getPoisonousGasDevCurrentDataQueryWrapper(poisonousGasDevCurrentData, request);
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<PoisonousGasDevCurrentData> pageList = list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "有毒气体-数据列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, PoisonousGasDevCurrentData.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("有毒气体-数据列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,18 @@
|
||||
package com.zhgd.xmgl.modules.poisonous.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.poisonous.entity.PoisonousGasDev;
|
||||
import com.zhgd.xmgl.modules.poisonous.mapper.PoisonousGasDevMapper;
|
||||
import com.zhgd.xmgl.modules.poisonous.service.IPoisonousGasDevService;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Description: 有毒气体-设备
|
||||
@ -15,5 +22,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
*/
|
||||
@Service
|
||||
public class PoisonousGasDevServiceImpl extends ServiceImpl<PoisonousGasDevMapper, PoisonousGasDev> implements IPoisonousGasDevService {
|
||||
@Autowired
|
||||
PoisonousGasDevMapper poisonousGasDevMapper;
|
||||
|
||||
@Override
|
||||
public IPage<PoisonousGasDev> queryPageList(PoisonousGasDev poisonousGasDev, Integer pageNo, Integer pageSize, HttpServletRequest req) {
|
||||
QueryWrapper<PoisonousGasDev> queryWrapper = QueryGenerator.initQueryWrapper(poisonousGasDev, req.getParameterMap(), null,
|
||||
ReflectionUtil.getFieldNameList(PoisonousGasDev::getDevName), "pgd.");
|
||||
queryWrapper.orderByDesc(ReflectionUtil.getFieldNameToUlc(PoisonousGasDev::getCreateDate));
|
||||
Page<PoisonousGasDev> page = new Page<PoisonousGasDev>(pageNo, pageSize);
|
||||
return poisonousGasDevMapper.queryPageList(page, queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +1,39 @@
|
||||
package com.zhgd.xmgl.modules.smoke.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||
import com.zhgd.xmgl.modules.smoke.entity.SmokeDevAlarm;
|
||||
import com.zhgd.xmgl.modules.smoke.service.ISmokeDevAlarmService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -51,226 +48,232 @@ import com.alibaba.fastjson.JSON;
|
||||
@Slf4j
|
||||
@Api(tags = "SmokeDevAlarmController相关Api")
|
||||
public class SmokeDevAlarmController {
|
||||
@Autowired
|
||||
private ISmokeDevAlarmService smokeDevAlarmService;
|
||||
@Autowired
|
||||
private ISmokeDevAlarmService smokeDevAlarmService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 分页列表查询烟感报警数据信息", notes = "分页列表查询烟感报警数据信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<SmokeDevAlarm>> queryPageList(SmokeDevAlarm smokeDevAlarm,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SmokeDevAlarm>> result = new Result<IPage<SmokeDevAlarm>>();
|
||||
QueryWrapper<SmokeDevAlarm> queryWrapper = QueryGenerator.initQueryWrapper(smokeDevAlarm, req.getParameterMap());
|
||||
Page<SmokeDevAlarm> page = new Page<SmokeDevAlarm>(pageNo, pageSize);
|
||||
IPage<SmokeDevAlarm> pageList = smokeDevAlarmService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 分页列表查询烟感报警数据信息", notes = "分页列表查询烟感报警数据信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<SmokeDevAlarm>> queryPageList(SmokeDevAlarm smokeDevAlarm,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SmokeDevAlarm>> result = new Result<>();
|
||||
QueryWrapper<SmokeDevAlarm> queryWrapper = QueryGenerator.initQueryWrapper(smokeDevAlarm, req.getParameterMap());
|
||||
queryWrapper.orderByDesc(ReflectionUtil.getFieldNameToUlc(SmokeDevAlarm::getAlarmTime));
|
||||
Page<SmokeDevAlarm> page = new Page<SmokeDevAlarm>(pageNo, pageSize);
|
||||
IPage<SmokeDevAlarm> pageList = smokeDevAlarmService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 列表查询烟感报警数据信息", notes = "列表查询烟感报警数据信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<SmokeDevAlarm>> queryList(SmokeDevAlarm smokeDevAlarm,
|
||||
HttpServletRequest req) {
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 列表查询烟感报警数据信息", notes = "列表查询烟感报警数据信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<SmokeDevAlarm>> queryList(SmokeDevAlarm smokeDevAlarm,
|
||||
HttpServletRequest req) {
|
||||
|
||||
QueryWrapper<SmokeDevAlarm> queryWrapper = QueryGenerator.initQueryWrapper(smokeDevAlarm, req.getParameterMap());
|
||||
return Result.success(smokeDevAlarmService.list(queryWrapper));
|
||||
}
|
||||
QueryWrapper<SmokeDevAlarm> queryWrapper = QueryGenerator.initQueryWrapper(smokeDevAlarm, req.getParameterMap());
|
||||
return Result.success(smokeDevAlarmService.list(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 添加烟感报警数据信息", notes = "添加烟感报警数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SmokeDevAlarm> add(@RequestBody SmokeDevAlarm smokeDevAlarm) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
try {
|
||||
smokeDevAlarmService.save(smokeDevAlarm);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 添加烟感报警数据信息", notes = "添加烟感报警数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SmokeDevAlarm> add(@RequestBody SmokeDevAlarm smokeDevAlarm) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
try {
|
||||
smokeDevAlarmService.save(smokeDevAlarm);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑烟感报警数据信息", notes = "编辑烟感报警数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<SmokeDevAlarm> edit(@RequestBody SmokeDevAlarm smokeDevAlarm) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
SmokeDevAlarm smokeDevAlarmEntity = smokeDevAlarmService.getById(smokeDevAlarm.getId());
|
||||
if (smokeDevAlarmEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
smokeDevAlarmService.updateById(smokeDevAlarm);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param smokeDevAlarm
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑烟感报警数据信息", notes = "编辑烟感报警数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<SmokeDevAlarm> edit(@RequestBody SmokeDevAlarm smokeDevAlarm) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
SmokeDevAlarm smokeDevAlarmEntity = smokeDevAlarmService.getById(smokeDevAlarm.getId());
|
||||
if (smokeDevAlarmEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
if (Objects.equals(smokeDevAlarm.getHandleDone(), 1)) {
|
||||
UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getCredentials();
|
||||
smokeDevAlarm.setOperateId(userInfo.getUserId());
|
||||
smokeDevAlarm.setOperateTime(new Date());
|
||||
}
|
||||
smokeDevAlarmService.updateById(smokeDevAlarm);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除烟感报警数据信息", notes = "删除烟感报警数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<SmokeDevAlarm> delete(@RequestBody String id) {
|
||||
JSONObject jsonObject = JSON.parseObject(id, JSONObject.class);
|
||||
id = String.valueOf(jsonObject.get("id"));
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
SmokeDevAlarm smokeDevAlarm = smokeDevAlarmService.getById(id);
|
||||
if (smokeDevAlarm == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = smokeDevAlarmService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除烟感报警数据信息", notes = "删除烟感报警数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<SmokeDevAlarm> delete(@RequestBody String id) {
|
||||
JSONObject jsonObject = JSON.parseObject(id, JSONObject.class);
|
||||
id = String.valueOf(jsonObject.get("id"));
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
SmokeDevAlarm smokeDevAlarm = smokeDevAlarmService.getById(id);
|
||||
if (smokeDevAlarm == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = smokeDevAlarmService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "批量删除烟感报警数据信息", notes = "批量删除烟感报警数据信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警数据ID字符串", paramType = "query", required = true, dataType = "String")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<SmokeDevAlarm> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
this.smokeDevAlarmService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "批量删除烟感报警数据信息", notes = "批量删除烟感报警数据信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警数据ID字符串", paramType = "query", required = true, dataType = "String")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<SmokeDevAlarm> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
this.smokeDevAlarmService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询烟感报警数据信息", notes = "通过id查询烟感报警数据信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警数据ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SmokeDevAlarm> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
SmokeDevAlarm smokeDevAlarm = smokeDevAlarmService.getById(id);
|
||||
if (smokeDevAlarm == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(smokeDevAlarm);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询烟感报警数据信息", notes = "通过id查询烟感报警数据信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警数据ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SmokeDevAlarm> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SmokeDevAlarm> result = new Result<SmokeDevAlarm>();
|
||||
SmokeDevAlarm smokeDevAlarm = smokeDevAlarmService.getById(id);
|
||||
if (smokeDevAlarm == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(smokeDevAlarm);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation(value = "导出excel烟感报警数据信息", notes = "导出excel烟感报警数据信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SmokeDevAlarm> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
SmokeDevAlarm smokeDevAlarm = JSON.parseObject(deString, SmokeDevAlarm.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(smokeDevAlarm, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation(value = "导出excel烟感报警数据信息", notes = "导出excel烟感报警数据信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SmokeDevAlarm> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
SmokeDevAlarm smokeDevAlarm = JSON.parseObject(deString, SmokeDevAlarm.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(smokeDevAlarm, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SmokeDevAlarm> pageList = smokeDevAlarmService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "烟感报警数据列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SmokeDevAlarm.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("烟感报警数据列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SmokeDevAlarm> pageList = smokeDevAlarmService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "烟感报警数据列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SmokeDevAlarm.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("烟感报警数据列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入烟感报警数据信息", notes = "通过excel导入烟感报警数据信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SmokeDevAlarm> listSmokeDevAlarms = ExcelImportUtil.importExcel(file.getInputStream(), SmokeDevAlarm.class, params);
|
||||
for (SmokeDevAlarm smokeDevAlarmExcel : listSmokeDevAlarms) {
|
||||
smokeDevAlarmService.save(smokeDevAlarmExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listSmokeDevAlarms.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入烟感报警数据信息", notes = "通过excel导入烟感报警数据信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SmokeDevAlarm> listSmokeDevAlarms = ExcelImportUtil.importExcel(file.getInputStream(), SmokeDevAlarm.class, params);
|
||||
for (SmokeDevAlarm smokeDevAlarmExcel : listSmokeDevAlarms) {
|
||||
smokeDevAlarmService.save(smokeDevAlarmExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listSmokeDevAlarms.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,42 +1,39 @@
|
||||
package com.zhgd.xmgl.modules.smoke.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhgd.xmgl.modules.smoke.service.ISmokeDevService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||
import com.zhgd.xmgl.modules.smoke.entity.SmokeDev;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.smoke.service.ISmokeDevService;
|
||||
import com.zhgd.xmgl.util.ReflectionUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@ -51,226 +48,227 @@ import com.alibaba.fastjson.JSON;
|
||||
@Slf4j
|
||||
@Api(tags = "SmokeDevController相关Api")
|
||||
public class SmokeDevController {
|
||||
@Autowired
|
||||
private ISmokeDevService smokeDevService;
|
||||
@Autowired
|
||||
private ISmokeDevService smokeDevService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param smokeDev
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 分页列表查询烟感报警设备信息", notes = "分页列表查询烟感报警设备信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<SmokeDev>> queryPageList(SmokeDev smokeDev,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SmokeDev>> result = new Result<IPage<SmokeDev>>();
|
||||
QueryWrapper<SmokeDev> queryWrapper = QueryGenerator.initQueryWrapper(smokeDev, req.getParameterMap());
|
||||
Page<SmokeDev> page = new Page<SmokeDev>(pageNo, pageSize);
|
||||
IPage<SmokeDev> pageList = smokeDevService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param smokeDev
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 分页列表查询烟感报警设备信息", notes = "分页列表查询烟感报警设备信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<SmokeDev>> queryPageList(SmokeDev smokeDev,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SmokeDev>> result = new Result<IPage<SmokeDev>>();
|
||||
QueryWrapper<SmokeDev> queryWrapper = QueryGenerator.initQueryWrapper(smokeDev, req.getParameterMap(), null, ReflectionUtil.getFieldNameList(SmokeDev::getDevSn));
|
||||
queryWrapper.orderByDesc(ReflectionUtil.getFieldNameToUlc(SmokeDev::getCreateDate));
|
||||
Page<SmokeDev> page = new Page<SmokeDev>(pageNo, pageSize);
|
||||
IPage<SmokeDev> pageList = smokeDevService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param smokeDev
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 列表查询烟感报警设备信息", notes = "列表查询烟感报警设备信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<SmokeDev>> queryList(SmokeDev smokeDev,
|
||||
HttpServletRequest req) {
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param smokeDev
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 列表查询烟感报警设备信息", notes = "列表查询烟感报警设备信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<SmokeDev>> queryList(SmokeDev smokeDev,
|
||||
HttpServletRequest req) {
|
||||
|
||||
QueryWrapper<SmokeDev> queryWrapper = QueryGenerator.initQueryWrapper(smokeDev, req.getParameterMap());
|
||||
return Result.success(smokeDevService.list(queryWrapper));
|
||||
}
|
||||
QueryWrapper<SmokeDev> queryWrapper = QueryGenerator.initQueryWrapper(smokeDev, req.getParameterMap());
|
||||
return Result.success(smokeDevService.list(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param smokeDev
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 添加烟感报警设备信息", notes = "添加烟感报警设备信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SmokeDev> add(@RequestBody SmokeDev smokeDev) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
try {
|
||||
smokeDevService.save(smokeDev);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param smokeDev
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = " 添加烟感报警设备信息", notes = "添加烟感报警设备信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SmokeDev> add(@RequestBody SmokeDev smokeDev) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
try {
|
||||
smokeDevService.save(smokeDev);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.info(e.getMessage());
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param smokeDev
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑烟感报警设备信息", notes = "编辑烟感报警设备信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<SmokeDev> edit(@RequestBody SmokeDev smokeDev) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
SmokeDev smokeDevEntity = smokeDevService.getById(smokeDev.getId());
|
||||
if (smokeDevEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
smokeDevService.updateById(smokeDev);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param smokeDev
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑烟感报警设备信息", notes = "编辑烟感报警设备信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<SmokeDev> edit(@RequestBody SmokeDev smokeDev) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
SmokeDev smokeDevEntity = smokeDevService.getById(smokeDev.getId());
|
||||
if (smokeDevEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
smokeDevService.updateById(smokeDev);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除烟感报警设备信息", notes = "删除烟感报警设备信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<SmokeDev> delete(@RequestBody String id) {
|
||||
JSONObject jsonObject = JSON.parseObject(id, JSONObject.class);
|
||||
id = String.valueOf(jsonObject.get("id"));
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
SmokeDev smokeDev = smokeDevService.getById(id);
|
||||
if (smokeDev == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = smokeDevService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除烟感报警设备信息", notes = "删除烟感报警设备信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<SmokeDev> delete(@RequestBody String id) {
|
||||
JSONObject jsonObject = JSON.parseObject(id, JSONObject.class);
|
||||
id = String.valueOf(jsonObject.get("id"));
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
SmokeDev smokeDev = smokeDevService.getById(id);
|
||||
if (smokeDev == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = smokeDevService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "批量删除烟感报警设备信息", notes = "批量删除烟感报警设备信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警设备ID字符串", paramType = "query", required = true, dataType = "String")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<SmokeDev> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
this.smokeDevService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "批量删除烟感报警设备信息", notes = "批量删除烟感报警设备信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警设备ID字符串", paramType = "query", required = true, dataType = "String")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<SmokeDev> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
} else {
|
||||
this.smokeDevService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询烟感报警设备信息", notes = "通过id查询烟感报警设备信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警设备ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SmokeDev> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
SmokeDev smokeDev = smokeDevService.getById(id);
|
||||
if (smokeDev == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(smokeDev);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过id查询烟感报警设备信息", notes = "通过id查询烟感报警设备信息", httpMethod = "GET")
|
||||
@ApiImplicitParam(name = "id", value = "烟感报警设备ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SmokeDev> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SmokeDev> result = new Result<SmokeDev>();
|
||||
SmokeDev smokeDev = smokeDevService.getById(id);
|
||||
if (smokeDev == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(smokeDev);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation(value = "导出excel烟感报警设备信息", notes = "导出excel烟感报警设备信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SmokeDev> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
SmokeDev smokeDev = JSON.parseObject(deString, SmokeDev.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(smokeDev, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@ApiOperation(value = "导出excel烟感报警设备信息", notes = "导出excel烟感报警设备信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SmokeDev> queryWrapper = null;
|
||||
try {
|
||||
String paramsStr = request.getParameter("paramsStr");
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
SmokeDev smokeDev = JSON.parseObject(deString, SmokeDev.class);
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(smokeDev, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SmokeDev> pageList = smokeDevService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "烟感报警设备列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SmokeDev.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("烟感报警设备列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SmokeDev> pageList = smokeDevService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "烟感报警设备列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SmokeDev.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("烟感报警设备列表数据", "导出人:Jeecg", "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入烟感报警设备信息", notes = "通过excel导入烟感报警设备信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SmokeDev> listSmokeDevs = ExcelImportUtil.importExcel(file.getInputStream(), SmokeDev.class, params);
|
||||
for (SmokeDev smokeDevExcel : listSmokeDevs) {
|
||||
smokeDevService.save(smokeDevExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listSmokeDevs.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入烟感报警设备信息", notes = "通过excel导入烟感报警设备信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SmokeDev> listSmokeDevs = ExcelImportUtil.importExcel(file.getInputStream(), SmokeDev.class, params);
|
||||
for (SmokeDev smokeDevExcel : listSmokeDevs) {
|
||||
smokeDevService.save(smokeDevExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listSmokeDevs.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.zhgd.xmgl.modules.smoke.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@ -113,7 +114,7 @@ public class SmokeDevAlarm implements Serializable {
|
||||
*/
|
||||
@Excel(name = "操作人id", width = 15)
|
||||
@ApiModelProperty(value = "操作人id")
|
||||
private java.lang.Integer operateId;
|
||||
private java.lang.Long operateId;
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
@ -122,4 +123,7 @@ public class SmokeDevAlarm implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private java.util.Date operateTime;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private java.lang.String operateName;
|
||||
}
|
||||
|
||||
@ -79,7 +79,6 @@ public class JwtTokenFilter extends OncePerRequestFilter {
|
||||
validateOtherProfile(request);
|
||||
}
|
||||
}
|
||||
//log.info(request.getRequestURI());
|
||||
filterChain.doFilter(request, response);
|
||||
sjUser.remove();
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.zhgd.xmgl.security;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.exception.CustomException;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
||||
import io.jsonwebtoken.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -32,6 +35,8 @@ public class JwtTokenProvider {
|
||||
|
||||
@Autowired
|
||||
private MyUserDetailsImpl myUserDetailsImpl;
|
||||
@Autowired
|
||||
private SystemUserMapper systemUserMapper;
|
||||
|
||||
@PostConstruct
|
||||
protected void init() {
|
||||
@ -100,5 +105,4 @@ public class JwtTokenProvider {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.zhgd.xmgl.security;
|
||||
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
@ -21,7 +22,7 @@ import java.util.List;
|
||||
* @create: 2019-09-24 11:02
|
||||
**/
|
||||
|
||||
@Component(value="CustomUserDetailsService")
|
||||
@Component(value = "CustomUserDetailsService")
|
||||
public class MyUserDetailsImpl implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
@ -42,15 +43,7 @@ public class MyUserDetailsImpl implements UserDetailsService {
|
||||
return "admin";
|
||||
}
|
||||
});
|
||||
return org.springframework.security.core.userdetails.User//
|
||||
.withUsername(username)//
|
||||
.password(user.getPassword())//
|
||||
.accountExpired(false)//
|
||||
.accountLocked(false)//
|
||||
.credentialsExpired(false)//
|
||||
.authorities(grantedAuthorityList)
|
||||
.disabled(false)//
|
||||
.build();
|
||||
return new UserInfo(username, user.getPassword(), true, true, true, true, grantedAuthorityList, user.getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
28
src/main/java/com/zhgd/xmgl/security/entity/UserInfo.java
Normal file
28
src/main/java/com/zhgd/xmgl/security/entity/UserInfo.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.zhgd.xmgl.security.entity;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class UserInfo extends User {
|
||||
private Long userId;
|
||||
|
||||
public UserInfo(String username, String password, Collection<? extends GrantedAuthority> authorities, Long userId) {
|
||||
super(username, password, authorities);
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public UserInfo(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities, Long userId) {
|
||||
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
@ -3,17 +3,22 @@ package com.zhgd.xmgl.task;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.xmgl.modules.electrical.entity.ElectricalData;
|
||||
import com.zhgd.xmgl.modules.electrical.entity.ElectricalDev;
|
||||
import com.zhgd.xmgl.modules.electrical.mapper.ElectricalDataMapper;
|
||||
import com.zhgd.xmgl.modules.electrical.service.IElectricalDataService;
|
||||
import com.zhgd.xmgl.modules.electrical.service.IElectricalDevService;
|
||||
import com.zhgd.xmgl.util.XiwonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
@ -33,11 +38,13 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class ElectricalTask {
|
||||
@Resource
|
||||
private IElectricalDataService electricalDataService;
|
||||
@Resource
|
||||
private ElectricalDataMapper electricalDataMapper;
|
||||
|
||||
@Resource
|
||||
private IElectricalDevService electricalDevService;
|
||||
|
||||
@Value("${xiwon.postElectricRealTimeData}")
|
||||
@Value("${xiwon.postElectricRealTimeData:}")
|
||||
private String postElectricRealTimeData;
|
||||
|
||||
@Resource
|
||||
@ -52,40 +59,54 @@ public class ElectricalTask {
|
||||
@SchedulerLock(name = "getElectricRealTimeData", lockAtMostFor = 1000 * 60 * 5, lockAtLeastFor = 1000 * 60 * 3)
|
||||
@Scheduled(cron = "0 0/5 * * * ?")
|
||||
public void getElectricRealTimeData() {
|
||||
if (StringUtils.isNotBlank(postElectricRealTimeData)) {
|
||||
// 请求参数
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
map.put("state", 0);
|
||||
map.put("pageSize", "1");
|
||||
map.put("pageNum", "1");
|
||||
// 获取所有
|
||||
List<ElectricalDev> devList = electricalDevService.list();
|
||||
devList.forEach(dev -> CompletableFuture.supplyAsync(() -> {
|
||||
return doGetElectricRealTimeData(map, dev);
|
||||
}).exceptionally(throwable -> {
|
||||
log.error("err:", throwable);
|
||||
return null;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 请求参数
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
map.put("state", 0);
|
||||
map.put("pageSize", "1");
|
||||
map.put("pageNum", "1");
|
||||
// 获取所有
|
||||
List<ElectricalDev> devList = electricalDevService.list();
|
||||
// TODO 待处理最后一条数据重复插入
|
||||
devList.forEach(dev -> CompletableFuture.supplyAsync(() -> {
|
||||
// 设备sn
|
||||
String devSn = dev.getDevSn();
|
||||
// 请求携稳的接口
|
||||
JSONObject realTimeData = xiwonUtil.postForm(postElectricRealTimeData, map, JSONObject.class, (() -> map.put("deviceSn", devSn)));
|
||||
log.info("携稳接口响应数据:{}", realTimeData);
|
||||
Integer code = realTimeData.getInteger("code");
|
||||
// code校验是否成功请求
|
||||
if (code == HttpStatus.OK.value()) {
|
||||
JSONArray dataArray = realTimeData.getJSONArray("data");
|
||||
if (CollUtil.isNotEmpty(dataArray)) {
|
||||
// 解析请求到的参数,保存到我们的数据库
|
||||
JSONObject data = dataArray.getJSONObject(0);
|
||||
ElectricalData electricalData = new ElectricalData(devSn, data.getString("dataTime"), data.getString("voltageA"), data.getString("voltageB"),
|
||||
data.getString("voltageC"), data.getString("currentA"), data.getString("currentB"), data.getString("currentC"),
|
||||
data.getString("leakage"), data.getString("temperatureA"), data.getString("temperatureB"), data.getString("temperatureC"), data.getString("temperatureD"));
|
||||
electricalDataService.saveElectricalData(electricalData);
|
||||
} else {
|
||||
log.error("设备sn:{},当前无数据!", devSn);
|
||||
}
|
||||
} else {
|
||||
log.error("设备sn:{},请求失败!当前code:{},msg:{}", devSn, code, realTimeData.getString("msg"));
|
||||
}
|
||||
return true;
|
||||
})
|
||||
);
|
||||
private boolean doGetElectricRealTimeData(Map<String, Object> map, ElectricalDev dev) {
|
||||
// 设备sn
|
||||
String devSn = dev.getDevSn();
|
||||
ElectricalData newestData = electricalDataMapper.selectOne(new LambdaQueryWrapper<ElectricalData>().eq(ElectricalData::getDevSn, devSn).orderByDesc(ElectricalData::getUploadTime).last("limit 1"));
|
||||
// 请求携稳的接口
|
||||
JSONObject realTimeData = xiwonUtil.postForm(postElectricRealTimeData, map, JSONObject.class, (() -> {
|
||||
if (newestData != null && newestData.getXiewenId() != null) {
|
||||
map.put("dataId", newestData.getXiewenId());
|
||||
}
|
||||
return map.put("deviceSn", devSn);
|
||||
}));
|
||||
log.info("携稳接口响应数据(配电箱):{}", realTimeData);
|
||||
Integer code = realTimeData.getInteger("code");
|
||||
// code校验是否成功请求
|
||||
if (code == HttpStatus.OK.value()) {
|
||||
JSONArray dataArray = realTimeData.getJSONArray("data");
|
||||
if (CollUtil.isNotEmpty(dataArray)) {
|
||||
// 解析请求到的参数,保存到我们的数据库
|
||||
JSONObject data = dataArray.getJSONObject(0);
|
||||
ElectricalData electricalData = new ElectricalData(devSn, data.getString("dataTime"), data.getString("voltageA"), data.getString("voltageB"),
|
||||
data.getString("voltageC"), data.getString("currentA"), data.getString("currentB"), data.getString("currentC"),
|
||||
data.getString("leakage"), data.getString("temperatureA"), data.getString("temperatureB"), data.getString("temperatureC"), data.getString("temperatureD"));
|
||||
electricalData.setXiewenId(data.getLong("id"));
|
||||
electricalDataService.saveElectricalData(electricalData);
|
||||
} else {
|
||||
log.error("设备sn:{},当前无数据!", devSn);
|
||||
}
|
||||
} else {
|
||||
log.error("设备sn:{},请求失败!当前code:{},msg:{}", devSn, code, realTimeData.getString("msg"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ server.tomcat.basedir=C:/jxj/prod/backEnd/tempImage/
|
||||
#server.tomcat.basedir=F:/zhgd/tempImage/
|
||||
#arcsoft.dllPath=F:/zhgd/dll
|
||||
arcsoft.dllPath=C:/jxj/prod/backEnd/dll
|
||||
security.enable=false
|
||||
security.enable=true
|
||||
isGetStandardData=false
|
||||
isGetEnvironmentData=false
|
||||
isGetFaceFeatureDate=false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user