工单管理优化
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
package com.xzzn.web.controller.ems;
|
||||
|
||||
import com.xzzn.common.core.controller.BaseController;
|
||||
import com.xzzn.common.core.domain.AjaxResult;
|
||||
import com.xzzn.common.core.page.TableDataInfo;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.EmsAlarmRecords;
|
||||
import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo;
|
||||
import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo;
|
||||
import com.xzzn.ems.service.IEmsAlarmRecordsService;
|
||||
@ -34,4 +37,22 @@ public class EmsAlarmRecordsController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成工单
|
||||
*/
|
||||
@PostMapping("/createTicketNo")
|
||||
public AjaxResult createTicketNo(@RequestBody EmsAlarmRecords emsAlarmRecords)
|
||||
{
|
||||
Long id = emsAlarmRecords.getId();
|
||||
if (id == null) {
|
||||
return error("告警id不能为空");
|
||||
}
|
||||
String ticketNo= iEmsAlarmRecordsService.createTicketNo(id,getUserId());
|
||||
if (StringUtils.isNotEmpty(ticketNo) && ticketNo.contains("T")) {
|
||||
return AjaxResult.success("操作成功", ticketNo);
|
||||
} else {
|
||||
return error(ticketNo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -102,4 +102,15 @@ public class EmsTicketController extends BaseController
|
||||
{
|
||||
return toAjax(emsTicketService.deleteEmsTicketByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 废弃工单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:ticket:delete')")
|
||||
@Log(title = "工单主", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/drop")
|
||||
public AjaxResult drop(@RequestBody EmsTicket emsTicket)
|
||||
{
|
||||
return toAjax(emsTicketService.dropEmsTicketById(emsTicket.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,6 +58,10 @@ public class EmsAlarmRecords extends BaseEntity
|
||||
@Excel(name = "设备名称,用于标识设备")
|
||||
private String deviceName;
|
||||
|
||||
/** 工单号(规则:T+日期+6位随机) */
|
||||
@Excel(name = "工单号", readConverterExp = "规=则:T+日期+6位随机")
|
||||
private String ticketNo;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
@ -158,6 +162,14 @@ public class EmsAlarmRecords extends BaseEntity
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public String getTicketNo() {
|
||||
return ticketNo;
|
||||
}
|
||||
|
||||
public void setTicketNo(String ticketNo) {
|
||||
this.ticketNo = ticketNo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
@ -176,6 +188,7 @@ public class EmsAlarmRecords extends BaseEntity
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("deviceName", getDeviceName())
|
||||
.append("ticketNo", getTicketNo())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,6 +53,10 @@ public class EmsTicket extends BaseEntity
|
||||
@Excel(name = "处理人ID")
|
||||
private Long workUserId;
|
||||
|
||||
/** 0-已废弃 1-有效 */
|
||||
@Excel(name = "0-已废弃 1-有效")
|
||||
private Long isDelete;
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
@ -143,6 +147,14 @@ public class EmsTicket extends BaseEntity
|
||||
return workUserId;
|
||||
}
|
||||
|
||||
public Long getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(Long isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
@ -159,6 +171,7 @@ public class EmsTicket extends BaseEntity
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("workUserId", getWorkUserId())
|
||||
.append("isDelete", getIsDelete())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,12 @@ public class AlarmRecordListResponseVo {
|
||||
/** 状态 */
|
||||
private String status;
|
||||
|
||||
/** 工单号 */
|
||||
private String ticketNo;
|
||||
|
||||
/** 告警唯一标识 */
|
||||
private String id;
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
@ -75,4 +81,20 @@ public class AlarmRecordListResponseVo {
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTicketNo() {
|
||||
return ticketNo;
|
||||
}
|
||||
|
||||
public void setTicketNo(String ticketNo) {
|
||||
this.ticketNo = ticketNo;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,14 @@ public class SiteMonitorHomeAlarmVo {
|
||||
*/
|
||||
private String alarmContent;
|
||||
|
||||
/**
|
||||
* 工单号
|
||||
*/
|
||||
private String ticketNo;
|
||||
|
||||
/** 告警唯一标识 */
|
||||
private String id;
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
@ -43,4 +51,20 @@ public class SiteMonitorHomeAlarmVo {
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTicketNo() {
|
||||
return ticketNo;
|
||||
}
|
||||
|
||||
public void setTicketNo(String ticketNo) {
|
||||
this.ticketNo = ticketNo;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,4 +59,11 @@ public interface EmsTicketMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsTicketByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 废弃工单-isDelete=0
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public int dropEmsTicketById(String id);
|
||||
}
|
||||
|
||||
@ -67,4 +67,13 @@ public interface IEmsAlarmRecordsService
|
||||
* @return
|
||||
*/
|
||||
public List<AlarmRecordListResponseVo> getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo);
|
||||
|
||||
/**
|
||||
* 生产工单号
|
||||
*
|
||||
* @param id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public String createTicketNo(Long id, Long userId);
|
||||
}
|
||||
|
||||
@ -59,4 +59,11 @@ public interface IEmsTicketService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsTicketById(String id);
|
||||
|
||||
/**
|
||||
* 废弃工单-物理删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public int dropEmsTicketById(String id);
|
||||
}
|
||||
|
||||
@ -1,9 +1,18 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.xzzn.common.core.domain.entity.SysUser;
|
||||
import com.xzzn.common.core.domain.model.LoginUser;
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.EmsTicket;
|
||||
import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo;
|
||||
import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo;
|
||||
import com.xzzn.ems.mapper.EmsTicketMapper;
|
||||
import com.xzzn.ems.service.IEmsTicketService;
|
||||
import com.xzzn.system.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xzzn.ems.mapper.EmsAlarmRecordsMapper;
|
||||
@ -21,6 +30,12 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService
|
||||
{
|
||||
@Autowired
|
||||
private EmsAlarmRecordsMapper emsAlarmRecordsMapper;
|
||||
@Autowired
|
||||
private IEmsTicketService emsTicketService;
|
||||
@Autowired
|
||||
private EmsTicketMapper emsTicketMapper;
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
/**
|
||||
* 查询告警记录
|
||||
@ -100,4 +115,50 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService
|
||||
public List<AlarmRecordListResponseVo> getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo) {
|
||||
return emsAlarmRecordsMapper.getAlarmRecordDetailList(requestVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTicketNo(Long id, Long userId) {
|
||||
String ticketNo = "";
|
||||
// 校验告警记录是否存在
|
||||
EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.selectEmsAlarmRecordsById(id);
|
||||
if (emsAlarmRecords == null) {
|
||||
return "告警记录不存在";
|
||||
}
|
||||
// 工单号是否存在
|
||||
if (StringUtils.isNotEmpty(emsAlarmRecords.getTicketNo())) {
|
||||
return "工单号已存在";
|
||||
}
|
||||
// 随机生成工单:T+日期+6位随机
|
||||
ticketNo = createRandomTicketNo();
|
||||
// 更新告警表
|
||||
emsAlarmRecords.setTicketNo(ticketNo);
|
||||
emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords);
|
||||
// 不存在-默认userId
|
||||
if (userId == null) {
|
||||
userId = 1L;
|
||||
}
|
||||
SysUser user = sysUserMapper.selectUserById(userId);
|
||||
// 插入工单表
|
||||
EmsTicket emsTicket = new EmsTicket();
|
||||
emsTicket.setTicketNo(ticketNo);
|
||||
emsTicket.setTitle("工单"+id.toString());
|
||||
emsTicket.setContent(emsAlarmRecords.getAlarmContent());
|
||||
emsTicket.setUserId(userId.toString());
|
||||
emsTicket.setWorkUserId(userId);
|
||||
emsTicket.setCreateTime(DateUtils.getNowDate());
|
||||
emsTicket.setCreateBy(user.getUserName());
|
||||
emsTicket.setUpdateTime(DateUtils.getNowDate());
|
||||
emsTicket.setUpdateBy(user.getUserName());
|
||||
emsTicketMapper.insertEmsTicket(emsTicket);
|
||||
return ticketNo;
|
||||
}
|
||||
|
||||
private String createRandomTicketNo() {
|
||||
String ticketNo = "";
|
||||
String nowDate = DateUtils.dateTime();
|
||||
ticketNo = "T" + nowDate + String.format("%06d", new Random().nextInt(1000000));
|
||||
return ticketNo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -94,4 +94,16 @@ public class EmsTicketServiceImpl implements IEmsTicketService
|
||||
{
|
||||
return emsTicketMapper.deleteEmsTicketById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除工单主信息-物理删除
|
||||
*
|
||||
* @param id 工单主主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int dropEmsTicketById(String id)
|
||||
{
|
||||
return emsTicketMapper.dropEmsTicketById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,10 +20,11 @@
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="deviceName" column="device_name" />
|
||||
<result property="ticketNo" column="ticket_no" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsAlarmRecordsVo">
|
||||
select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, device_name from ems_alarm_records
|
||||
select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, device_name, ticket_no from ems_alarm_records
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsAlarmRecordsList" parameterType="EmsAlarmRecords" resultMap="EmsAlarmRecordsResult">
|
||||
@ -38,6 +39,7 @@
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="ticketNo != null and ticketNo != ''"> and ticket_no = #{ticketNo}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -63,6 +65,7 @@
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null and deviceId != ''">device_id,</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name,</if>
|
||||
<if test="ticketNo != null">ticket_no,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceType != null">#{deviceType},</if>
|
||||
@ -79,6 +82,7 @@
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
|
||||
<if test="ticketNo != null">#{ticketNo},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -99,6 +103,7 @@
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
|
||||
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
|
||||
<if test="ticketNo != null">ticket_no = #{ticketNo},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@ -116,7 +121,10 @@
|
||||
|
||||
<select id="getAlarmRecordsBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.vo.SiteMonitorHomeAlarmVo">
|
||||
select device_name as deviceName,
|
||||
status,alarm_content as alarmContent
|
||||
status,
|
||||
alarm_content as alarmContent,
|
||||
ticket_no as ticketNo,
|
||||
id
|
||||
from ems_alarm_records
|
||||
where site_id = #{siteId}
|
||||
</select>
|
||||
@ -140,7 +148,9 @@
|
||||
<select id="getAlarmRecordDetailList" parameterType="AlarmRecordListRequestVo" resultType="com.xzzn.ems.domain.vo.AlarmRecordListResponseVo">
|
||||
select t.device_name as deviceName,t.alarm_level as alarmLevel,
|
||||
t.alarm_content as alarmContent,t.status as status,
|
||||
t.alarm_start_time as alarmStartTime,t.alarm_end_time as alarmEndTime
|
||||
t.alarm_start_time as alarmStartTime,t.alarm_end_time as alarmEndTime,
|
||||
t.ticket_no as ticketNo,
|
||||
t.id
|
||||
from ems_alarm_records t
|
||||
where t.site_id = #{siteId}
|
||||
<if test="deviceType != null and deviceType != ''">
|
||||
|
||||
@ -18,15 +18,17 @@
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="workUserId" column="work_user_id" />
|
||||
<result property="isDelete" column="isDelete" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsTicketVo">
|
||||
select id, ticket_no, user_id, title, content, images, status, create_time, complete_time, create_by, update_by, update_time, work_user_id from ems_ticket
|
||||
select id, ticket_no, user_id, title, content, images, status, create_time, complete_time, create_by, update_by, update_time, work_user_id, isDelete from ems_ticket
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsTicketList" parameterType="EmsTicket" resultMap="EmsTicketResult">
|
||||
<include refid="selectEmsTicketVo"/>
|
||||
<where>
|
||||
isDelete = 1
|
||||
<if test="ticketNo != null and ticketNo != ''"> and ticket_no = #{ticketNo}</if>
|
||||
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
@ -41,6 +43,7 @@
|
||||
<select id="selectEmsTicketById" parameterType="String" resultMap="EmsTicketResult">
|
||||
<include refid="selectEmsTicketVo"/>
|
||||
where id = #{id}
|
||||
and isDelete = 1
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsTicket" parameterType="EmsTicket" useGeneratedKeys="true" keyProperty="id">
|
||||
@ -58,6 +61,7 @@
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="workUserId != null">work_user_id,</if>
|
||||
<if test="isDelete != null">isDelete,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="ticketNo != null and ticketNo != ''">#{ticketNo},</if>
|
||||
@ -72,6 +76,7 @@
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="workUserId != null">#{workUserId},</if>
|
||||
<if test="isDelete != null">#{isDelete},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -90,6 +95,7 @@
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="workUserId != null">work_user_id = #{workUserId},</if>
|
||||
<if test="isDelete != null">isDelete = #{isDelete},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@ -104,4 +110,8 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="dropEmsTicketById" parameterType="String">
|
||||
update ems_ticket set isDelete = 0 where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user