商家更新设备信息时生成sn和mac更换日志
This commit is contained in:
parent
2a1a4b87d7
commit
9fb7f3c641
|
@ -31,8 +31,11 @@ public class DeviceConverterImpl implements DeviceConverter {
|
|||
DeviceBO bo = new DeviceBO();
|
||||
bo.setDeviceId(data.getDeviceId());
|
||||
bo.setRemark(data.getRemark());
|
||||
bo.setDeviceNo(data.getDeviceNo());
|
||||
bo.setDeviceName(data.getDeviceName());
|
||||
bo.setCustomPicture(data.getCustomPicture());
|
||||
bo.setUserId(userId);
|
||||
bo.setMac(data.getMac());
|
||||
|
||||
// 仅允许商户修改的字段
|
||||
if (deviceValidator.isMch(data.getDeviceId(), userId)) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ruoyi.ss.snLog.domain.SnLog;
|
||||
import com.ruoyi.ss.snLog.service.SnLogService;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -152,6 +153,8 @@ public class DeviceServiceImpl implements DeviceService
|
|||
|
||||
@Autowired
|
||||
private TransactionAssembler transactionAssembler;
|
||||
@Autowired
|
||||
private SnLogService snLogService;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -251,20 +254,23 @@ public class DeviceServiceImpl implements DeviceService
|
|||
// 生成SnLog记录
|
||||
SnLog snLog = new SnLog();
|
||||
snLog.setDeviceId(data.getDeviceId());
|
||||
snLog.setUserId(SecurityUtils.getUserId());
|
||||
snLog.setMac(data.getMac());
|
||||
snLog.setUserId(data.getUserId());
|
||||
snLog.setOldSn(deviceVO.getDeviceNo());
|
||||
snLog.setNewSn(data.getDeviceNo());
|
||||
snLog.setUpdateTime(DateUtils.getNowDate());
|
||||
snLog.setOldMac(deviceVO.getMac());
|
||||
if (data.getMac()!=null) {
|
||||
snLog.setNewMac(data.getMac());
|
||||
}
|
||||
snLogService.insertSnLog(snLog);
|
||||
|
||||
// 更新主表
|
||||
int update = deviceMapper.updateSmDevice(data);
|
||||
ServiceUtil.assertion(update != 1, "更新设备失败");
|
||||
|
||||
|
||||
|
||||
// 后校验
|
||||
DeviceVO vo = this.selectById(data.getDeviceId());
|
||||
|
||||
deviceAssembler.assembleBonusList(vo);
|
||||
deviceValidator.afterCheck(vo);
|
||||
|
||||
|
|
|
@ -28,9 +28,13 @@ public class SnLog extends BaseEntity
|
|||
@ApiModelProperty("操作人id")
|
||||
private Long userId;
|
||||
|
||||
@Excel(name = "设备Mac号")
|
||||
@ApiModelProperty("设备Mac号")
|
||||
private String mac;
|
||||
@Excel(name = "设备原Mac号")
|
||||
@ApiModelProperty("设备原Mac号")
|
||||
private String oldMac;
|
||||
|
||||
@Excel(name = "设备新Mac号")
|
||||
@ApiModelProperty("设备新Mac号")
|
||||
private String newMac;
|
||||
|
||||
@Excel(name = "原sn")
|
||||
@ApiModelProperty("原sn")
|
||||
|
|
|
@ -0,0 +1,206 @@
|
|||
<?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.ruoyi.ss.snLog.mapper.SnLogMapper">
|
||||
|
||||
<resultMap type="SnLogVO" id="SnLogResult" autoMapping="true">
|
||||
<result property="id" column="id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="oldMac" column="old_mac" />
|
||||
<result property="newMac" column="new_mac" />
|
||||
<result property="oldSn" column="old_sn" />
|
||||
<result property="newSn" column="new_sn" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSnLogVo">
|
||||
select
|
||||
id,
|
||||
device_id,
|
||||
user_id,
|
||||
old_mac,
|
||||
new_mac,
|
||||
old_sn,
|
||||
new_sn,
|
||||
update_time
|
||||
from ss_sn_log
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.id != null "> and id = #{query.id}</if>
|
||||
<if test="query.deviceId != null "> and device_id = #{query.deviceId}</if>
|
||||
<if test="query.userId != null "> and user_id = #{query.userId}</if>
|
||||
<if test="query.oldMac != null and query.oldMac != ''"> and old_mac like concat('%', #{query.oldMac}, '%')</if>
|
||||
<if test="query.newMac != null and query.newMac != ''"> and new_mac like concat('%', #{query.newMac}, '%')</if>
|
||||
<if test="query.oldSn != null and query.oldSn != ''"> and old_sn = #{query.oldSn}</if>
|
||||
<if test="query.newSn != null and query.newSn != ''"> and new_sn = #{query.newSn}</if>
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
<select id="selectSnLogList" parameterType="SnLogQuery" resultMap="SnLogResult">
|
||||
<include refid="selectSnLogVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSnLogById" parameterType="Long" resultMap="SnLogResult">
|
||||
<include refid="selectSnLogVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSnLog" parameterType="SnLog" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ss_sn_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="oldMac != null">old_mac,</if>
|
||||
<if test="newMac != null">new_mac,</if>
|
||||
<if test="oldSn != null">old_sn,</if>
|
||||
<if test="newSn != null">new_sn,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="oldMac != null">#{oldMac},</if>
|
||||
<if test="newMac != null">#{newMac},</if>
|
||||
<if test="oldSn != null">#{oldSn},</if>
|
||||
<if test="newSn != null">#{newSn},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsert" parameterType="SnLog" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ss_sn_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
device_id,
|
||||
user_id,
|
||||
old_mac,
|
||||
new_mac,
|
||||
old_sn,
|
||||
new_sn,
|
||||
update_time,
|
||||
</trim>
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="i.deviceId != null ">#{i.deviceId},</if>
|
||||
<if test="i.deviceId == null ">default,</if>
|
||||
<if test="i.userId != null ">#{i.userId},</if>
|
||||
<if test="i.userId == null ">default,</if>
|
||||
<if test="i.oldMac != null ">#{i.oldMac},</if>
|
||||
<if test="i.oldMac == null ">default,</if>
|
||||
<if test="i.newMac == null ">#{i.newMac},</if>
|
||||
<if test="i.newMac == null ">default,</if>
|
||||
<if test="i.oldSn != null ">#{i.oldSn},</if>
|
||||
<if test="i.oldSn == null ">default,</if>
|
||||
<if test="i.newSn != null ">#{i.newSn},</if>
|
||||
<if test="i.newSn == null ">default,</if>
|
||||
<if test="i.updateTime != null ">#{i.updateTime},</if>
|
||||
<if test="i.updateTime == null ">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="batchUpdate">
|
||||
update ss_sn_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<foreach open="device_id = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.deviceId != null ">
|
||||
WHEN #{item.id} THEN #{item.deviceId}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `device_id`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="user_id = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.userId != null ">
|
||||
WHEN #{item.id} THEN #{item.userId}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `user_id`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="mac = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.mac != null ">
|
||||
WHEN #{item.id} THEN #{item.mac}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `mac`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="oldSn = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.oldSn != null ">
|
||||
WHEN #{item.id} THEN #{item.oldSn}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `oldSn`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="newSn = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.newSn != null ">
|
||||
WHEN #{item.id} THEN #{item.newSn}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `newSn`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="update_time = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.updateTime != null ">
|
||||
WHEN #{item.id} THEN #{item.updateTime}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `update_time`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
where id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateSnLog" parameterType="SnLog">
|
||||
update ss_sn_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<include refid="updateColumns"/>
|
||||
</trim>
|
||||
where id = #{data.id}
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.deviceId != null">device_id = #{data.deviceId},</if>
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.oldMac != null">old_mac = #{data.oldMac},</if>
|
||||
<if test="data.newMac != null">new_mac = #{data.newMac},</if>
|
||||
<if test="data.oldSn != null">old_sn = #{data.oldSn},</if>
|
||||
<if test="data.newSn != null">new_sn = #{data.newSn},</if>
|
||||
<if test="data.updateTime != null">update_time = #{data.updateTime},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteSnLogById" parameterType="Long">
|
||||
delete from ss_sn_log where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSnLogByIds" parameterType="String">
|
||||
delete from ss_sn_log where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user