bug修复

This commit is contained in:
guoshengxiong 2024-09-05 17:44:32 +08:00
parent 956b934144
commit bff0d84786
3 changed files with 156 additions and 105 deletions

View File

@ -808,7 +808,14 @@
<select id="queryAlarmsByTime"
resultType="com.zhgd.xmgl.modules.bigdevice.entity.TowerAlarm">
select ta.* from tower_alarm ta where ta.add_time >= #{queryStartTime} and ta.add_time <![CDATA[<=]]>
select ta.* from tower_alarm ta
where ta.add_time >= #{queryStartTime} and ta.add_time <![CDATA[<=]]>
concat(#{queryEndTime},' 23:59:59') and ta.alarm_type=1
<if test="projectSn != null and projectSn != ''">
and ta.project_sn=#{projectSn}
</if>
<if test="devSn != null and devSn != ''">
and ta.dev_sn = #{devSn}
</if>
</select>
</mapper>

View File

@ -1,26 +1,32 @@
package com.zhgd.xmgl.modules.xz.controller;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhgd.annotation.OperLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import java.util.HashMap;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import com.zhgd.jeecg.common.api.vo.Result;
import org.apache.commons.collections.MapUtils;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.modules.xz.entity.FlowExceptionLog;
import com.zhgd.xmgl.modules.xz.service.IFlowExceptionLogService;
import org.simpleframework.xml.core.Validate;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.runtime.ProcessInstance;
import org.simpleframework.xml.core.Validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -35,15 +41,23 @@ import org.springframework.web.bind.annotation.*;
@Slf4j
@Api(tags = "工作流异常日志相关Api")
public class FlowExceptionLogController {
@Lazy
@Autowired
private IFlowExceptionLogService flowExceptionLogService;
IFlowExceptionLogService flowExceptionLogService;
@Lazy
@Autowired
RuntimeService runtimeService;
@Lazy
@Autowired
private ISystemUserService systemUserService;
/**
* 分页列表查询
*
* @return
*/
@OperLog(operModul = "工作流异常日志管理", operType = "分页查询", operDesc = "分页列表查询工作流异常日志信息")
@ApiOperation(value = "分页列表查询工作流异常日志信息", notes = "分页列表查询工作流异常日志信息", httpMethod="GET")
@ApiOperation(value = "分页列表查询工作流异常日志信息", notes = "分页列表查询工作流异常日志信息", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
@ -55,10 +69,11 @@ public class FlowExceptionLogController {
/**
* 列表查询
*
* @return
*/
@OperLog(operModul = "工作流异常日志管理", operType = "列表查询", operDesc = "列表查询工作流异常日志信息")
@ApiOperation(value = "列表查询工作流异常日志信息", notes = "列表查询工作流异常日志信息", httpMethod="GET")
@ApiOperation(value = "列表查询工作流异常日志信息", notes = "列表查询工作流异常日志信息", httpMethod = "GET")
@GetMapping(value = "/list")
public Result<List<FlowExceptionLog>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
return Result.success(flowExceptionLogService.queryList(param));
@ -66,24 +81,53 @@ public class FlowExceptionLogController {
/**
* 添加
*
* @param flowExceptionLog
* @return
*/
@OperLog(operModul = "工作流异常日志管理", operType = "添加", operDesc = "添加工作流异常日志信息")
@ApiOperation(value = "添加工作流异常日志信息", notes = "添加工作流异常日志信息" , httpMethod="POST")
@ApiOperation(value = "添加工作流异常日志信息", notes = "添加工作流异常日志信息", httpMethod = "POST")
@PostMapping(value = "/add")
public Result<FlowExceptionLog> add(@RequestBody @Validate FlowExceptionLog flowExceptionLog) {
flowExceptionLogService.add(flowExceptionLog);
return Result.ok();
}
@OperLog(operModul = "工作流异常日志管理", operType = "添加", operDesc = "从工作流添加工作流异常日志信息")
@ApiOperation(value = "从工作流添加工作流异常日志信息", notes = "从工作流添加工作流异常日志信息", httpMethod = "POST")
@PostMapping(value = "/flow/add")
public Result addFromFlow(@RequestBody @Validate Map<String, Object> param) {
log.info("从工作流添加工作流异常日志信息:{}", JSON.toJSONString(param));
String instanceId = MapUtils.getString(param, "instanceId");
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).singleResult();
Date startTime = processInstance.getStartTime();
String processDefinitionName = processInstance.getProcessDefinitionName();
String startUserId = processInstance.getStartUserId();
String projectSn = processInstance.getTenantId();
FlowExceptionLog log = new FlowExceptionLog();
log.setApprovalNumber(instanceId);
log.setApprovalType(processDefinitionName);
log.setProjectSn(projectSn);
log.setLaunchTime(startTime);
HashMap<String, Object> map = new HashMap<>(16);
map.put("userId", startUserId);
map.put("projectSn", projectSn);
List<SystemUser> userList = systemUserService.getProjectChildernSystemUserList(map);
log.setLauncherName(CollUtil.isNotEmpty(userList) ? userList.get(0).getRealName() : null);
log.setLaunchEnterpriseName(CollUtil.isNotEmpty(userList) ? userList.get(0).getEnterpriseName() : null);
log.setExceptionDetail("网络超时");
flowExceptionLogService.add(log);
return Result.ok();
}
/**
* 编辑
*
* @param flowExceptionLog
* @return
*/
@OperLog(operModul = "工作流异常日志管理", operType = "编辑", operDesc = "编辑工作流异常日志信息")
@ApiOperation(value = "编辑工作流异常日志信息", notes = "编辑工作流异常日志信息" , httpMethod="POST")
@ApiOperation(value = "编辑工作流异常日志信息", notes = "编辑工作流异常日志信息", httpMethod = "POST")
@PostMapping(value = "/edit")
public Result<FlowExceptionLog> edit(@RequestBody FlowExceptionLog flowExceptionLog) {
flowExceptionLogService.edit(flowExceptionLog);
@ -92,27 +136,29 @@ public class FlowExceptionLogController {
/**
* 通过id删除
*
* @return
*/
@OperLog(operModul = "工作流异常日志管理", operType = "删除", operDesc = "删除工作流异常日志信息")
@ApiOperation(value = "删除工作流异常日志信息", notes = "删除工作流异常日志信息" , httpMethod="POST")
@ApiOperation(value = "删除工作流异常日志信息", notes = "删除工作流异常日志信息", httpMethod = "POST")
@ApiImplicitParam(name = "id", value = "工作流异常日志ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
@PostMapping(value = "/delete")
public Result<FlowExceptionLog> delete(@ApiIgnore @RequestBody HashMap<String ,Object> map) {
public Result<FlowExceptionLog> delete(@ApiIgnore @RequestBody HashMap<String, Object> map) {
flowExceptionLogService.delete(MapUtils.getString(map, "id"));
return Result.ok();
}
/**
* 通过id查询
*
* @param id
* @return
*/
@OperLog(operModul = "工作流异常日志管理", operType = "通过id查询", operDesc = "通过id查询工作流异常日志信息")
@ApiOperation(value = "通过id查询工作流异常日志信息", notes = "通过id查询工作流异常日志信息" , httpMethod="GET")
@ApiOperation(value = "通过id查询工作流异常日志信息", notes = "通过id查询工作流异常日志信息", httpMethod = "GET")
@ApiImplicitParam(name = "id", value = "工作流异常日志ID", paramType = "query", required = true, dataType = "Integer")
@GetMapping(value = "/queryById")
public Result<FlowExceptionLog> queryById(@RequestParam(name="id",required=true) String id) {
public Result<FlowExceptionLog> queryById(@RequestParam(name = "id", required = true) String id) {
return Result.success(flowExceptionLogService.queryById(id));
}

View File

@ -3,11 +3,9 @@ package com.zhgd.xmgl.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhgd.xmgl.base.EmailService;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
import com.zhgd.xmgl.modules.xz.entity.FlowExceptionLog;
@ -33,7 +31,6 @@ import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
/**
* 发送邮件工具类 MailUtil
@ -49,6 +46,9 @@ public class EmailUtils implements EmailService {
@Lazy
@Autowired
RuntimeService runtimeService;
@Lazy
@Autowired
IFlowExceptionLogService flowExceptionLogService;
/**
* Spring Boot 提供了一个发送邮件的简单抽象使用的是下面这个接口这里直接注入即可使用
*/
@ -60,6 +60,15 @@ public class EmailUtils implements EmailService {
*/
@Value("${spring.mail.from}")
private String from;
@Lazy
@Autowired
private ISystemUserService systemUserService;
@Lazy
@Autowired
private WorkerInfoServiceImpl workerInfoService;
@Lazy
@Autowired
private EnterpriseInfoServiceImpl enterpriseInfoService;
public static void main(String[] args) {
EmailUtils mailService = new EmailUtils();
@ -157,20 +166,9 @@ public class EmailUtils implements EmailService {
}
}
@Lazy
@Autowired
IFlowExceptionLogService flowExceptionLogService;
@Lazy
@Autowired
private ISystemUserService systemUserService;
@Lazy
@Autowired
private WorkerInfoServiceImpl workerInfoService;
@Lazy
@Autowired
private EnterpriseInfoServiceImpl enterpriseInfoService;
/**
* 保存异常并发送工作流异常邮件
*
* @param paramStr
* @param e
* @param subject
@ -203,8 +201,8 @@ public class EmailUtils implements EmailService {
map.put("userId", startUserId);
map.put("projectSn", projectSn);
List<SystemUser> userList = systemUserService.getProjectChildernSystemUserList(map);
log.setLauncherName(CollUtil.isNotEmpty(userList)?userList.get(0).getRealName():null);
log.setLaunchEnterpriseName(CollUtil.isNotEmpty(userList)?userList.get(0).getEnterpriseName():null);
log.setLauncherName(CollUtil.isNotEmpty(userList) ? userList.get(0).getRealName() : null);
log.setLaunchEnterpriseName(CollUtil.isNotEmpty(userList) ? userList.get(0).getEnterpriseName() : null);
log.setExceptionDetail(detail);
flowExceptionLogService.add(log);
}