| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.paramter.UserWorkAlarmParam; |
| | | import com.whyc.mapper.WorkAlarmMapper; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.pojo.UserWork; |
| | | import com.whyc.pojo.WorkAlarm; |
| | | import com.whyc.service.UserWorkService; |
| | | import com.whyc.service.WorkAlarmService; |
| | |
| | | |
| | | @GetMapping("/searchAllByUserIdAndStatus") |
| | | @ApiOperation(value = "获取告警信息") |
| | | public Response searchAllByUserIdAndStatus(int pageNum,int pageSize,Integer status){ |
| | | public Response searchAllByUserIdAndStatus(int pageNum,int pageSize,@RequestParam(required = false) Integer status){ |
| | | UserInf user = ActionUtil.getUser(); |
| | | return workAlarmService.searchByUserIdAndStatus(pageNum,pageSize,user.getUId().intValue(),status); |
| | | } |
| | |
| | | public Response uploadAlarmFile(@RequestParam MultipartFile[] files, @RequestBody UserWorkAlarmParam param){ |
| | | return userWorkService.uploadAlarmFile(files,param); |
| | | } |
| | | @PostMapping("/updateUserWork") |
| | | @ApiOperation("更新告警处理") |
| | | public Response updateUserWork(@RequestBody UserWork userWork){ |
| | | return userWorkService.addOrUpdate(userWork); |
| | | } |
| | | |
| | | @PostMapping("/serchByCondition") |
| | | @ApiOperation("查询告警处理详情") |
| | | public Response serchByCondition(@RequestBody UserWork userWork){ |
| | | return userWorkService.searchByCondition(userWork); |
| | | } |
| | | |
| | | @GetMapping("getTaskListWithFlag") |
| | | @ApiOperation("查询维护员告警列表") |
| | | public Response getTaskListWithFlag(@RequestParam Integer note,@RequestParam int pageNum,@RequestParam int pageSize){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | return workAlarmService.getTaskListWithFlag(userInf.getUId().intValue(),note,pageNum,pageSize); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import com.whyc.pojo.UserWork; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface UserWorkMapper extends CustomMapper<UserWork> { |
| | | } |
| | |
| | | |
| | | import com.whyc.pojo.BattDevAlarmData; |
| | | import com.whyc.pojo.BattalarmData; |
| | | import com.whyc.pojo.UserWork; |
| | | import com.whyc.pojo.WorkAlarm; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | List<BattalarmData> getBattAlarm(@Param("num") int num,@Param("recordId") long recordId); |
| | | |
| | | List<BattDevAlarmData> getDevAlarm(@Param("num") int num,@Param("recordId") long recordId); |
| | | |
| | | int updateStatus(@Param("id")int id,@Param("status")int status); |
| | | |
| | | List<WorkAlarm> getTaskListWithFlag(@Param("uId") Integer uId,@Param("status") Integer status,@Param("checkStatus") Integer checkStatus); |
| | | } |
| | |
| | | package com.whyc.pojo; |
| | | |
| | | 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 io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | |
| | | @Alias("UserWork") |
| | | @TableName(schema = "db_user",value = "tb_user_work") |
| | | public class UserWork { |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | @TableField("workId") |
| | | private Integer workId; |
| | | @TableField("userId") |
| | | private Integer userId; |
| | | @TableField("imageBefore") |
| | | private String imageBefore; //处理前照片 |
| | | @TableField("imageAfter") |
| | | private String imageAfter; //处理后照片 |
| | | private String description; //告警描述 |
| | | @TableField("workWay") |
| | | private String workWay; //处理方法 |
| | | @TableField("workSuggest") |
| | | private String workSuggest; //意见建议 |
| | | @TableField("managerId") |
| | | private Integer managerId; //审核人id |
| | | private String note; //审核意见 |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | @TableField("endTime") |
| | | private Date endTime; |
| | | @TableField("checkedTime") |
| | | private Date checkedTime;//审核时间 |
| | | /** |
| | | * TODO 建议 |
| | |
| | | * -1 :驳回 |
| | | * |
| | | */ |
| | | @TableField("checkStatus") |
| | | private Integer checkStatus; |
| | | } |
| | |
| | | package com.whyc.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | |
| | | @ApiModel(value="WorkAlarm对象") |
| | | @TableName(schema = "db_user",value = "tb_work_alarm") |
| | | public class WorkAlarm { |
| | | @TableId |
| | | private Integer id; |
| | | @TableField("alarmRecId") |
| | | private Integer alarmRecId;//告警id(电池组或者设备告警的num) |
| | | @TableField("alarmRecordId") |
| | | private Long alarmRecordId;//唯一识别号(电池组或者设备告警的record_id) |
| | | @TableField("stationId") |
| | | private Integer stationId; |
| | | @TableField(exist = false) |
| | | private String stationName; |
| | | @TableField("battGroupId") |
| | | private Integer battGroupId;//告警所属电池组id |
| | | @TableField(exist = false) |
| | | private String battGroupName;//告警所属电池组id |
| | | /**设备id*/ |
| | | @TableField("deviceId") |
| | | private Integer deviceId; |
| | | @TableField("alarmLevel") |
| | | private Integer alarmLevel; |
| | | @TableField("alarmName") |
| | | private String alarmName; |
| | | @TableField("managerId") |
| | | private Integer managerId;//管理员id |
| | | @TableField("userId") |
| | | private Integer userId;//维护员id |
| | | /**维护员id姓名*/ |
| | | @TableField(exist = false) |
| | | private String userName; |
| | | /** |
| | | * 0-未派发 |
| | |
| | | */ |
| | | private Integer status; //状态 |
| | | /**告警发生时间*/ |
| | | @TableField("alarmTime") |
| | | private Date alarmTime; |
| | | /**工单生成时间*/ |
| | | @TableField("createTime") |
| | | private Date createTime; |
| | | @TableField("dispatchTime") |
| | | private Date dispatchTime;//派单时间 |
| | | //告警信息 |
| | | @TableField(exist = false) |
| | | private BattalarmData alarmData; |
| | | //告警处理信息以及审核状态 |
| | | @TableField(exist = false) |
| | | private List<UserWork> userWorkList; |
| | | @TableField(exist = false) |
| | | private Integer flag; |
| | | } |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.paramter.UserWorkAlarmParam; |
| | | import com.whyc.mapper.UserWorkMapper; |
| | | import com.whyc.mapper.WorkAlarmMapper; |
| | | import com.whyc.pojo.UserWork; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | import org.springframework.core.env.Environment; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.jnlp.DownloadService2; |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | |
| | | public class UserWorkService { |
| | | @Resource |
| | | private UserWorkMapper mapper; |
| | | @Resource |
| | | private WorkAlarmMapper workAlarmMapper; |
| | | @Autowired |
| | | private Environment environment; |
| | | |
| | | public Response addOrUpdate(UserWork userWork){ |
| | | if (userWork.getUserId()==null || userWork.getId()==0){ |
| | | mapper.insert(userWork); |
| | | }else { |
| | | mapper.updateById(userWork); |
| | | } |
| | | //当状态为-1时,驳回操作,需要重新创建已派单订单;如果是3则为完成 同时更改wolkAlarm表的status |
| | | if ("-1".equals(userWork.getCheckStatus())||userWork.getCheckStatus()==-1){ |
| | | UserWork uw = new UserWork(); |
| | | uw.setWorkId(userWork.getWorkId()); |
| | | uw.setUserId(userWork.getUserId()); |
| | | uw.setCreateTime(new Date()); |
| | | uw.setEndTime(new Date()); |
| | | uw.setCheckStatus(1); |
| | | if(mapper.insert(uw)>0){ |
| | | return new Response().set(1,true,"操作成功"); |
| | | }else { |
| | | return new Response().set(1,false,"操作失败"); |
| | | } |
| | | } |
| | | if ("3".equals(userWork.getCheckStatus())|| userWork.getCheckStatus()==3){ |
| | | int bool = workAlarmMapper.updateStatus(userWork.getWorkId(),3); |
| | | if (bool>0){ |
| | | return new Response().set(1,true,"操作成功"); |
| | | }else { |
| | | return new Response().set(1,false,"操作失败"); |
| | | } |
| | | } |
| | | return new Response().set(1,true,"操作成功"); |
| | | } |
| | | |
| | | public Response searchByCondition(UserWork userWork){ |
| | | QueryWrapper<UserWork> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq(userWork.getUserId()!=null||userWork.getUserId()!=0,"userId",userWork.getUserId()); |
| | | queryWrapper.eq(userWork.getManagerId()!=null||userWork.getManagerId()!=0,"managerId",userWork.getManagerId()); |
| | | queryWrapper.eq(userWork.getWorkId()!=null||userWork.getWorkId()!=0,"workId",userWork.getWorkId()); |
| | | List<UserWork> list = mapper.selectList(queryWrapper); |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | public Response uploadAlarmFile(MultipartFile[] file, UserWorkAlarmParam param) { |
| | |
| | | return bl; |
| | | } |
| | | |
| | | public Response getTaskListWithFlag(Integer uId,Integer note,int pageNum,int pageSize){ |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | Integer status = null; |
| | | Integer checkStatus = null; |
| | | //查询未派单列表 |
| | | if(note==1){ |
| | | status = 0; |
| | | //此时还没生成user_work表记录 |
| | | checkStatus = null; |
| | | } |
| | | //查询已派单列表 |
| | | else if(note==2){ |
| | | status = 1; |
| | | checkStatus = null; |
| | | } |
| | | //查询待审核列表 |
| | | else if(note==3){ |
| | | status = 2; |
| | | checkStatus = 2; |
| | | } |
| | | //查询已完成列表 |
| | | else if(note==4){ |
| | | status = 3; |
| | | checkStatus = 3; |
| | | } |
| | | List<WorkAlarm> list = mapper.getTaskListWithFlag(uId,status,checkStatus); |
| | | PageInfo pageInfo = new PageInfo(list); |
| | | return new Response().set(1,pageInfo,"查询成功"); |
| | | } |
| | | |
| | | |
| | | public Response dispatchTask(){ |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | <?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.whyc.mapper.WorkAlarmMapper" > |
| | | <update id="updateStatus"> |
| | | UPDATE `db_user`.`tb_work_alarm` SET `status` = #{status} WHERE `id` = #{id} |
| | | </update> |
| | | |
| | | |
| | | <select id="searchByUserIdAndStatus" resultType="com.whyc.pojo.WorkAlarm"> |
| | | select alarm.* bInf.StationName as stationName |
| | | select alarm.* ,bInf.StationName as stationName |
| | | from db_user.tb_work_alarm alarm |
| | | inner join db_battinf.tb_battinf bInf on alarm.deviceId = bInf.FBSDeviceId |
| | | <where> |
| | | <if test="uId!=null"> |
| | | and alarm.userId = #{uId} |
| | | </if> |
| | | <if test="status!=null"> |
| | | <if test="status!=null and status!=0"> |
| | | and status = #{status} |
| | | </if> |
| | | </where> |
| | | union select alarm.* bInf.StationName as stationName |
| | | union select alarm.*, bInf.StationName as stationName |
| | | from db_user.tb_work_alarm alarm |
| | | inner join db_battinf.tb_battinf bInf on alarm.battGroupId = bInf.battGroupId |
| | | <where> |
| | | <if test="uId!=null"> |
| | | and alarm.userId = #{uId} |
| | | </if> |
| | | <if test="status!=null"> |
| | | <if test="status!=null and status!=0"> |
| | | and status = #{status} |
| | | </if> |
| | | </where> |
| | |
| | | <select id="getDevAlarm" resultType="com.whyc.pojo.BattDevAlarmData"> |
| | | select num from db_alarm.tb_devalarm_data where num = #{num} and record_id = #{recordId} |
| | | </select> |
| | | <select id="getTaskListWithFlag" resultType="com.whyc.pojo.WorkAlarm"> |
| | | select alarm.*, bInf.StationName as stationName,null as battGroupName,work.createTime as workCreateTime,work.endTime as workEndTime |
| | | from db_user.tb_work_alarm alarm left join db_user.tb_user_work work on alarm.id = work.workId |
| | | inner join db_battinf.tb_battinf bInf on alarm.deviceId = bInf.FBSDeviceId |
| | | <where> |
| | | <if test="uId!=null and uId!=0"> |
| | | and alarm.managerId = #{uId} |
| | | </if> |
| | | <if test="status!=null and status!=0"> |
| | | and Status =#{status} |
| | | </if> |
| | | <if test="checkStatus!=null and checkStatus!=0"> |
| | | and checkStatus =#{checkStatus} |
| | | </if> |
| | | </where> |
| | | union select alarm.*, bInf.StationName as stationName, bInf.BattGroupName as battGroupName, work.createTime as workCreateTime, work.endTime as workEndTime |
| | | from db_user.tb_work_alarm alarm left join db_user.tb_user_work work on alarm.id = work.workId |
| | | inner join db_battinf.tb_battinf bInf on alarm.battGroupId = bInf.battGroupId |
| | | <where> |
| | | <if test="uId!=null and uId!=0"> |
| | | and alarm.managerId = #{uId} |
| | | </if> |
| | | <if test="status!=null and status!=0"> |
| | | and Status =#{status} |
| | | </if> |
| | | <if test="checkStatus!=null and checkStatus!=0"> |
| | | and checkStatus =#{checkStatus} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | |
| | | </mapper> |