大棚删除新增逻辑。完善系统消息中心逻辑
parent
1cc4f67d3b
commit
468ea12025
|
|
@ -167,6 +167,10 @@ public class DeviceStatusHandler {
|
|||
// 湿度上下限
|
||||
BigDecimal humiUp = agriInfo.getHumiUp();
|
||||
BigDecimal humiLow = agriInfo.getHumiLow();
|
||||
if (BigDecimal.ZERO.compareTo(tempUp) == 0
|
||||
&& BigDecimal.ZERO.compareTo(tempLow) == 0
|
||||
&& BigDecimal.ZERO.compareTo(humiUp) == 0
|
||||
&& BigDecimal.ZERO.compareTo(humiLow) == 0) return;
|
||||
List<SysAgriInfo> msgList = new ArrayList<>();
|
||||
// 仅当up且所有key为数字时,才更新最新状态缓存
|
||||
for (String key : payloadObj.keySet()) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.agri.common.annotation.Log;
|
|||
import com.agri.common.core.controller.BaseController;
|
||||
import com.agri.common.core.domain.AjaxResult;
|
||||
import com.agri.common.core.page.TableDataInfo;
|
||||
import com.agri.common.enums.AgriEnum;
|
||||
import com.agri.common.enums.BusinessType;
|
||||
import com.agri.common.utils.SecurityUtils;
|
||||
import com.agri.common.utils.poi.ExcelUtil;
|
||||
|
|
@ -12,16 +11,14 @@ import com.agri.system.domain.SysAgriInfo;
|
|||
import com.agri.system.domain.SysUserAgri;
|
||||
import com.agri.system.domain.vo.AgriInfoView;
|
||||
import com.agri.system.service.ISysAgriInfoService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.agri.system.service.ISysUserAgriService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 大棚管理Controller
|
||||
|
|
@ -36,6 +33,8 @@ public class SysAgriInfoController extends BaseController
|
|||
@Autowired
|
||||
private ISysAgriInfoService sysAgriInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserAgriService userAgriService;
|
||||
/**
|
||||
* 查询大棚管理列表
|
||||
*/
|
||||
|
|
@ -149,12 +148,24 @@ public class SysAgriInfoController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('assets:agri:edit')")
|
||||
@Log(title = "大棚管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/renameAgriName")
|
||||
public AjaxResult renameAgriName(@RequestParam("imei") String imei, @RequestParam("newAgriName") String newAgriName)
|
||||
public AjaxResult renameAgriName(@RequestParam("agriId") String agriId,
|
||||
@RequestParam("imei") String imei,
|
||||
@RequestParam("newAgriName") String newAgriName)
|
||||
{
|
||||
boolean update = sysAgriInfoService.lambdaUpdate()
|
||||
.eq(SysAgriInfo::getImei, imei)
|
||||
.set(SysAgriInfo::getAgriName, newAgriName)
|
||||
.update();
|
||||
boolean update = false;
|
||||
if (SecurityUtils.isAdmin()) {
|
||||
update = sysAgriInfoService.lambdaUpdate()
|
||||
.eq(SysAgriInfo::getImei, imei)
|
||||
.set(SysAgriInfo::getAgriName, newAgriName)
|
||||
.update();
|
||||
} else {
|
||||
update = userAgriService.lambdaUpdate()
|
||||
.eq(SysUserAgri::getUserId, SecurityUtils.getUserId())
|
||||
.eq(SysUserAgri::getAgriId, imei)
|
||||
.set(SysUserAgri::getAgriName, newAgriName)
|
||||
.update();
|
||||
}
|
||||
|
||||
return update? success():error();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ public class SysMessageController extends BaseController
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('warn:message:list')")
|
||||
@GetMapping("/getMessage")
|
||||
public AjaxResult getMessage(SysMessage sysMessage)
|
||||
{
|
||||
List<SysMessage> list = sysMessageService.selectSysMessageList(sysMessage);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出系统消息中心列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,13 +1,19 @@
|
|||
package com.agri.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.agri.common.annotation.Excel;
|
||||
import com.agri.common.core.domain.BaseEntity;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统消息中心对象 sys_message
|
||||
|
|
@ -23,6 +29,8 @@ public class SysMessage extends BaseEntity
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 消息主键ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String imei;
|
||||
|
|
@ -58,4 +66,9 @@ public class SysMessage extends BaseEntity
|
|||
@Excel(name = "跳转链接地址")
|
||||
private String linkUrl;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private LocalDate monitorDate;
|
||||
|
||||
private List<String> imeiList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ public class SysUserAgri extends BaseEntity
|
|||
@Excel(name = "大棚ID")
|
||||
private String agriId;
|
||||
|
||||
/** 大棚名称 */
|
||||
@Excel(name = "大棚名称")
|
||||
private String agriName;
|
||||
|
||||
/** 协同用户ID */
|
||||
@Excel(name = "协同用户ID")
|
||||
private Long userId;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import com.agri.system.service.ISysUserAgriService;
|
|||
import com.agri.system.util.UrlEncodeUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -18,6 +20,7 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class AgriServiceImpl implements AgriService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AgriServiceImpl.class);
|
||||
|
||||
@Resource
|
||||
private ISysUserAgriService userAgriService;
|
||||
|
|
@ -37,6 +40,10 @@ public class AgriServiceImpl implements AgriService {
|
|||
|
||||
List<SysUserAgri> agriUser
|
||||
= userAgriService.findAgriUser(new SysUserAgri(idList));
|
||||
if (CollectionUtils.isEmpty(agriUser)) {
|
||||
log.info("大棚未关联用户,暂停推送消息");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<SysMessage> msgList = new ArrayList<>();
|
||||
for (SysAgriInfo agriInfo : offlineList) {
|
||||
|
|
@ -50,7 +57,6 @@ public class AgriServiceImpl implements AgriService {
|
|||
message.setLinkUrl(UrlEncodeUtil.buildControlPageUrl(agriInfo, "/pages/home/control/index?agriInfo="));
|
||||
for (SysUserAgri userAgri : agriUser){
|
||||
message.setReceiver(userAgri.getUserId());
|
||||
|
||||
}
|
||||
msgList.add(message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ public class SysAgriInfoServiceImpl extends ServiceImpl<SysAgriInfoMapper, SysAg
|
|||
SysUserAgri sysUserAgri = new SysUserAgri();
|
||||
sysUserAgri.setAgriId(sysAgriInfo.getImei());
|
||||
sysUserAgri.setUserId(userId);
|
||||
sysUserAgri.setAgriName(sysAgriInfo.getAgriName());
|
||||
sysUserAgri.setInviteBy(SecurityUtils.getUserId());
|
||||
sysUserAgri.setInviteTime(new Date());
|
||||
sysUserAgri.setRemark("用户所有者绑定");
|
||||
|
|
@ -213,7 +214,7 @@ public class SysAgriInfoServiceImpl extends ServiceImpl<SysAgriInfoMapper, SysAg
|
|||
sysUserAgri.setStatus(AgriEnum.ENABLED.getCode());
|
||||
sysUserAgri.setAcceptTime(new Date());
|
||||
userAgriService.save(sysUserAgri);
|
||||
resultMap.put("msg", "关联用户成功!");
|
||||
resultMap.put("msg", "关联大棚成功!");
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.agri.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.agri.common.core.domain.model.LoginUser;
|
||||
import com.agri.common.utils.DateUtils;
|
||||
import com.agri.common.utils.SecurityUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.agri.system.mapper.SysMessageMapper;
|
||||
|
|
@ -39,6 +42,9 @@ public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMess
|
|||
@Override
|
||||
public List<SysMessage> selectSysMessageList(SysMessage sysMessage)
|
||||
{
|
||||
if (!SecurityUtils.isAdmin()) {
|
||||
sysMessage.setReceiver(SecurityUtils.getUserId());
|
||||
}
|
||||
return baseMapper.selectSysMessageList(sysMessage);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.agri.system.util;
|
|||
import com.agri.system.domain.SysAgriInfo;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
|
|
@ -12,6 +14,7 @@ import java.net.URLEncoder;
|
|||
*/
|
||||
public class UrlEncodeUtil {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UrlEncodeUtil.class);
|
||||
/**
|
||||
* 【和你 JS 完全等价】生成跳转URL
|
||||
*/
|
||||
|
|
@ -21,7 +24,8 @@ public class UrlEncodeUtil {
|
|||
JSONObject agriObj = new JSONObject();
|
||||
agriObj.put("imei", agriInfo.getImei());
|
||||
agriObj.put("agriName", agriInfo.getAgriName());
|
||||
agriObj.put("agriId", agriInfo.getId());
|
||||
agriObj.put("agriId", agriInfo.getId().toString());
|
||||
log.info("agriInfo:{}", agriInfo);
|
||||
agriObj.put("workMode", agriInfo.getWorkMode());
|
||||
|
||||
// 2. JSON.stringify
|
||||
|
|
|
|||
|
|
@ -52,12 +52,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SELECT
|
||||
agri.id,
|
||||
agri.imei,
|
||||
agri.agri_name,
|
||||
agri.work_mode,
|
||||
agri.quilt_num,
|
||||
agri.film_num,
|
||||
agri.blind_num,
|
||||
user_agri.user_id,
|
||||
case when
|
||||
user_agri.user_id is null
|
||||
then
|
||||
agri.agri_name
|
||||
else
|
||||
user_agri.agri_name
|
||||
end
|
||||
as agri_name,
|
||||
dtu_last.time,
|
||||
dtu_last.ts,
|
||||
dtu_last.temp1,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectSysImeiAutoLogList" parameterType="SysImeiAutoLog" resultMap="SysImeiAutoLogResult">
|
||||
<include refid="selectSysImeiAutoLogVo"/>
|
||||
<where>
|
||||
<if test="receiver == null"> and receiver = #{receiver} </if>
|
||||
<if test="imei != null and imei != ''"> and imei = #{imei}</if>
|
||||
<if test="rollFilm != null and rollFilm != ''"> and roll_film = #{rollFilm}</if>
|
||||
<if test="monitorDate != null"> and DATE_FORMAT(create_time, '%Y-%m-%d') = #{monitorDate}</if>
|
||||
|
|
|
|||
|
|
@ -28,12 +28,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectSysMessageList" parameterType="SysMessage" resultMap="SysMessageResult">
|
||||
<include refid="selectSysMessageVo"/>
|
||||
<where>
|
||||
<if test="monitorDate != null"> and DATE_FORMAT(create_time, '%Y-%m-%d') = #{monitorDate}</if>
|
||||
<if test="receiver != null and receiver != ''"> and receiver = #{receiver}</if>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
<if test="msgType != null and msgType != ''"> and msg_type = #{msgType}</if>
|
||||
<if test="readStatus != null "> and read_status = #{readStatus}</if>
|
||||
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
|
||||
<if test="imeiList != null and imeiList.size() > 0">
|
||||
imei IN
|
||||
<foreach collection="imeiList" item="imei" open="(" separator="," close=")">
|
||||
#{imei}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by create_time asc
|
||||
</select>
|
||||
|
||||
<select id="selectSysMessageById" parameterType="Long" resultMap="SysMessageResult">
|
||||
|
|
|
|||
|
|
@ -180,6 +180,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sys_user_agri user_agri
|
||||
LEFT JOIN sys_user `u` ON user_agri.user_id = `u`.user_id and `u`.del_flag=0
|
||||
<where>
|
||||
<if test="idList != null and idList.size() > 0">
|
||||
user_agri.agri_id IN
|
||||
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="agriId != null "> and user_agri.agri_id = #{agriId}</if>
|
||||
<if test="role != null "> and user_agri.role = #{role}</if>
|
||||
<if test="permMask != null "> and user_agri.perm_mask = #{permMask}</if>
|
||||
|
|
@ -189,13 +195,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="acceptTime != null "> and user_agri.accept_time = #{acceptTime}</if>
|
||||
<if test="version != null "> and user_agri.version = #{version}</if>
|
||||
<if test="sysUser != null ">
|
||||
<if test="sysUser.idList != null and sysUser.idList.size() > 0">
|
||||
`u`.user_id IN
|
||||
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="sysUser.userId != null and sysUser.userId != 0">
|
||||
AND `u`.user_id = #{sysUser.userId}
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue