Commit ad6ee1e9 by wang_jiaxing

消息通知,每日警情相关接口,添加嫌疑人时发送录比反消息

parent e1ed2272
package org.springblade.founder.qgccj.service.impl; package org.springblade.founder.qgccj.service.impl;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.secure.utils.SecureUtil; import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.founder.asj.dao.HnJbAsjXsMapper;
import org.springblade.founder.asj.dao.QgJbAsjXsMapper;
import org.springblade.founder.bzptbz.service.SysDictitemService; import org.springblade.founder.bzptbz.service.SysDictitemService;
import org.springblade.founder.qgccj.VO.UserVO; import org.springblade.founder.qgccj.VO.UserVO;
import org.springblade.founder.qgccj.entity.TbGlAsjRyQgccj; import org.springblade.founder.qgccj.entity.TbGlAsjRyQgccj;
...@@ -11,6 +14,8 @@ import org.springblade.founder.qgccj.service.TbGlAsjRyService; ...@@ -11,6 +14,8 @@ import org.springblade.founder.qgccj.service.TbGlAsjRyService;
import org.springblade.founder.qgccj.service.TbStRyService; import org.springblade.founder.qgccj.service.TbStRyService;
import org.springblade.founder.qgccj.service.TbXwZbfzxyrQgccjService; import org.springblade.founder.qgccj.service.TbXwZbfzxyrQgccjService;
import org.springblade.founder.qgccj.util.BeanCopyUtil; import org.springblade.founder.qgccj.util.BeanCopyUtil;
import org.springblade.founder.socketio.entity.TbFwXxdl;
import org.springblade.founder.socketio.service.IMessageService;
import org.springblade.founder.utils.SysXxzjbhService; import org.springblade.founder.utils.SysXxzjbhService;
import org.springblade.modules.system.entity.XzxtUser; import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -31,51 +36,57 @@ import java.util.List; ...@@ -31,51 +36,57 @@ import java.util.List;
*/ */
@Service @Service
public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService { public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService {
@Autowired @Autowired
private TbXwZbfzxyrQgccjMapper tbXwZbfzxyrDao; private TbXwZbfzxyrQgccjMapper tbXwZbfzxyrDao;
@Autowired @Autowired
private TbGlAsjRyService autoTbGlAsjRyService; private TbGlAsjRyService autoTbGlAsjRyService;
@Autowired @Autowired
private TbStRyService autoTbStRyService; private TbStRyService autoTbStRyService;
@Autowired @Autowired
private SysXxzjbhService xxzjbhService; private SysXxzjbhService xxzjbhService;
@Autowired @Autowired
private SysDictitemService sysDictitemService; private SysDictitemService sysDictitemService;
@Autowired
private IMessageService messageService;
@Autowired
private HnJbAsjXsMapper hnJbAsjXsMapper;
@Autowired
private QgJbAsjXsMapper qgJbAsjXsMapper;
/**
* 通过ID查询单条数据
*
* @param xxzjbh 主键
* @return 实例对象
*/
@Override
public TbXwZbfzxyrQgccj queryById(String xxzjbh) {
return this.tbXwZbfzxyrDao.queryById(xxzjbh);
}
/**
* 分页查询
*
* @param tbXwZbfzxyr 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<TbXwZbfzxyrQgccj> queryByPage(TbXwZbfzxyrQgccj tbXwZbfzxyr, PageRequest pageRequest) {
long total = this.tbXwZbfzxyrDao.count(tbXwZbfzxyr);
return new PageImpl<>(this.tbXwZbfzxyrDao.queryAllByLimit(tbXwZbfzxyr, pageRequest), pageRequest, total);
}
/** /**
* 通过ID查询单条数据 * 新增数据
* *
* @param xxzjbh 主键 * @param tbXwZbfzxyr 实例对象
* @return 实例对象 * @return 实例对象
*/ */
@Override @Override
public TbXwZbfzxyrQgccj queryById(String xxzjbh) { public String insert(TbXwZbfzxyrQgccj thisObj) {
return this.tbXwZbfzxyrDao.queryById(xxzjbh);
}
/**
* 分页查询
*
* @param tbXwZbfzxyr 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<TbXwZbfzxyrQgccj> queryByPage(TbXwZbfzxyrQgccj tbXwZbfzxyr, PageRequest pageRequest) {
long total = this.tbXwZbfzxyrDao.count(tbXwZbfzxyr);
return new PageImpl<>(this.tbXwZbfzxyrDao.queryAllByLimit(tbXwZbfzxyr, pageRequest), pageRequest, total);
}
/**
* 新增数据
*
* @param tbXwZbfzxyr 实例对象
* @return 实例对象
*/
@Override
public String insert(TbXwZbfzxyrQgccj thisObj) {
XzxtUser xzxtUser = SecureUtil.getUserXzxt(); XzxtUser xzxtUser = SecureUtil.getUserXzxt();
String xxzjbh = xxzjbhService.getXxzjbh(xzxtUser.getUnitcode(),null);//xxzjbh String xxzjbh = xxzjbhService.getXxzjbh(xzxtUser.getUnitcode(), null);//xxzjbh
//抓捕犯罪嫌疑人 复用后,重新生成人员编号 //抓捕犯罪嫌疑人 复用后,重新生成人员编号
// thisObj.setZhfzxyrAsjxgrybh(autoSeqService.ngzbhzhFnVal("TB_ST_RY")); // thisObj.setZhfzxyrAsjxgrybh(autoSeqService.ngzbhzhFnVal("TB_ST_RY"));
String asjxgrybh = xxzjbhService.getZcxwYwbh(xzxtUser.getUnitcode(), null, "tb_st_ry", "P"); String asjxgrybh = xxzjbhService.getZcxwYwbh(xzxtUser.getUnitcode(), null, "tb_st_ry", "P");
...@@ -110,18 +121,51 @@ public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService { ...@@ -110,18 +121,51 @@ public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService {
//需求变更:子项信息不操作下方这张表。tb_xw_zbfzxyr表没有该字段,跟侦查指令有关 //需求变更:子项信息不操作下方这张表。tb_xw_zbfzxyr表没有该字段,跟侦查指令有关
// thisObj.setAsjzcxwlbdm("0434");//在侦查终结下录入抓捕犯罪嫌疑人,在抓捕犯罪嫌疑人下可以查到在侦查 // thisObj.setAsjzcxwlbdm("0434");//在侦查终结下录入抓捕犯罪嫌疑人,在抓捕犯罪嫌疑人下可以查到在侦查
this.tbXwZbfzxyrDao.insert(thisObj); this.tbXwZbfzxyrDao.insert(thisObj);
return xxzjbh;
} if (StringUtils.isNotEmpty(thisObj.getZhfzxyrCyzjZjhm())) {
try {
/** TbFwXxdl xxdl = getXyrLbfXxdl(thisObj.getZhfzxyrXm(), thisObj.getZhfzxyrCyzjZjhm(), thisObj.getAsjbh());
* 修改数据 if (xxdl != null) {
* messageService.sendMessage(xxdl);
* @param tbXwZbfzxyr 实例对象 }
* @return 实例对象 } catch (Exception e) {
*/ e.printStackTrace();
@Override }
public TbXwZbfzxyrQgccj update(TbXwZbfzxyrQgccj thisObj) { }
return xxzjbh;
}
private TbFwXxdl getXyrLbfXxdl(String xm, String sfzh, String asjbh) {
List<String> hnAsjbhList = hnJbAsjXsMapper.getAsjbhListZjhm(sfzh);
List<String> qgAsjbhList = qgJbAsjXsMapper.getAsjbhListZjhm(sfzh, hnAsjbhList);
hnAsjbhList.remove(asjbh);
qgAsjbhList.remove(asjbh);
if (hnAsjbhList.size() == 0 && qgAsjbhList.size() == 0) {
return null;
}
TbFwXxdl tbFwXxdl = new TbFwXxdl();
tbFwXxdl.setXxbt("新增嫌疑人录比反消息提醒");
tbFwXxdl.setXxlx("010000"); //录比反消息提醒
tbFwXxdl.setXxname("新增嫌疑人录比反消息提醒");
tbFwXxdl.setFsrName("系统");
tbFwXxdl.setSfydPdbz("0");
XzxtUser xzxtUser = SecureUtil.getUserXzxt();
tbFwXxdl.setJsrZjhm(xzxtUser.getIdentitycard());
String xxnr = "您在案件:" + asjbh + "中添加的嫌疑人:" + xm + "(" + sfzh + ")在全省还涉及" +
(hnAsjbhList.size()) + "起案件," + "在全国还涉及" + (qgAsjbhList.size()) + "起案件。";
tbFwXxdl.setXxnr(xxnr);
return tbFwXxdl;
}
/**
* 修改数据
*
* @param tbXwZbfzxyr 实例对象
* @return 实例对象
*/
@Override
public TbXwZbfzxyrQgccj update(TbXwZbfzxyrQgccj thisObj) {
//TbStRy //TbStRy
TbStRyQgccj autoTbStRy = new TbStRyQgccj(); TbStRyQgccj autoTbStRy = new TbStRyQgccj();
BeanCopyUtil.copy(thisObj, autoTbStRy, BeanCopyUtil.OperationType.UPDATE); BeanCopyUtil.copy(thisObj, autoTbStRy, BeanCopyUtil.OperationType.UPDATE);
...@@ -142,7 +186,7 @@ public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService { ...@@ -142,7 +186,7 @@ public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService {
autoTbGlAsjRy.setAsjxgryjsAsjxgryjsdm("06"); autoTbGlAsjRy.setAsjxgryjsAsjxgryjsdm("06");
autoTbGlAsjRy.setAsjxgryjsDmbcms("抓捕犯罪嫌疑人"); autoTbGlAsjRy.setAsjxgryjsDmbcms("抓捕犯罪嫌疑人");
TbGlAsjRyQgccj date=autoTbGlAsjRyService.query(thisObj.getZhfzxyrAsjxgrybh(),thisObj.getAsjbh()); TbGlAsjRyQgccj date = autoTbGlAsjRyService.query(thisObj.getZhfzxyrAsjxgrybh(), thisObj.getAsjbh());
autoTbGlAsjRy.setXxzjbh(date.getXxzjbh()); autoTbGlAsjRy.setXxzjbh(date.getXxzjbh());
// sendCbfService.LBFPostEvent(thisObj,"Rygj");//人员-活动轨迹比反模型 // sendCbfService.LBFPostEvent(thisObj,"Rygj");//人员-活动轨迹比反模型
...@@ -151,51 +195,50 @@ public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService { ...@@ -151,51 +195,50 @@ public class TbXwZbfzxyrServiceQgccjImpl implements TbXwZbfzxyrQgccjService {
// sendCbfService.LBFPostEvent(thisObj,"Rybjxx");//人员-背景信息 // sendCbfService.LBFPostEvent(thisObj,"Rybjxx");//人员-背景信息
autoTbStRyService.update(autoTbStRy); autoTbStRyService.update(autoTbStRy);
autoTbGlAsjRyService.update(autoTbGlAsjRy); autoTbGlAsjRyService.update(autoTbGlAsjRy);
thisObj.updateProperties(); thisObj.updateProperties();
this.tbXwZbfzxyrDao.update(thisObj); this.tbXwZbfzxyrDao.update(thisObj);
return this.queryById(thisObj.getXxzjbh()); return this.queryById(thisObj.getXxzjbh());
} }
/** /**
* 通过主键删除数据 * 通过主键删除数据
* *
* @param xxzjbh 主键 * @param xxzjbh 主键
* @return 是否成功 * @return 是否成功
*/ */
@Override @Override
public boolean deleteById(String xxzjbh) { public boolean deleteById(String xxzjbh) {
TbXwZbfzxyrQgccj tbXwZbfzxyrQgccj = tbXwZbfzxyrDao.queryById(xxzjbh); TbXwZbfzxyrQgccj tbXwZbfzxyrQgccj = tbXwZbfzxyrDao.queryById(xxzjbh);
tbXwZbfzxyrQgccj.deleteProperties(); tbXwZbfzxyrQgccj.deleteProperties();
autoTbStRyService.deleteById(tbXwZbfzxyrQgccj.getZhfzxyrAsjxgrybh()); autoTbStRyService.deleteById(tbXwZbfzxyrQgccj.getZhfzxyrAsjxgrybh());
autoTbGlAsjRyService.deleteById(tbXwZbfzxyrQgccj.getZhfzxyrAsjxgrybh(),tbXwZbfzxyrQgccj.getAsjbh()); autoTbGlAsjRyService.deleteById(tbXwZbfzxyrQgccj.getZhfzxyrAsjxgrybh(), tbXwZbfzxyrQgccj.getAsjbh());
return this.tbXwZbfzxyrDao.delete(tbXwZbfzxyrQgccj) > 0; return this.tbXwZbfzxyrDao.delete(tbXwZbfzxyrQgccj) > 0;
} }
@Override @Override
public int queryCount(String asjbh, Integer page, Integer limit) { public int queryCount(String asjbh, Integer page, Integer limit) {
TbXwZbfzxyrQgccj t =new TbXwZbfzxyrQgccj(); TbXwZbfzxyrQgccj t = new TbXwZbfzxyrQgccj();
t.setAsjbh(asjbh); t.setAsjbh(asjbh);
return tbXwZbfzxyrDao.count(t); return tbXwZbfzxyrDao.count(t);
} }
@Override @Override
public List<UserVO> queryAll(String asjbh, Integer page, Integer limit) { public List<UserVO> queryAll(String asjbh, Integer page, Integer limit) {
page = (page-1) * limit; page = (page - 1) * limit;
limit = page +limit; limit = page + limit;
List<TbXwZbfzxyrQgccj> tbXwZbfzxyrQgccjs=tbXwZbfzxyrDao.queryAll(asjbh,page,limit); List<TbXwZbfzxyrQgccj> tbXwZbfzxyrQgccjs = tbXwZbfzxyrDao.queryAll(asjbh, page, limit);
if (CollectionUtils.isEmpty(tbXwZbfzxyrQgccjs)){ if (CollectionUtils.isEmpty(tbXwZbfzxyrQgccjs)) {
return null; return null;
} }
List<UserVO> userVOS=new ArrayList<>(); List<UserVO> userVOS = new ArrayList<>();
for (TbXwZbfzxyrQgccj t:tbXwZbfzxyrQgccjs) { for (TbXwZbfzxyrQgccj t : tbXwZbfzxyrQgccjs) {
userVOS.add(new UserVO(t)); userVOS.add(new UserVO(t));
} }
return userVOS; return userVOS;
......
package org.springblade.founder.socketio.controller;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.founder.socketio.entity.TbFwXxdl;
import org.springblade.founder.socketio.service.IMessageService;
import org.springblade.founder.utils.R;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
*消息管理
* @author wangyang
* @date 2019/4/16
*/
@Slf4j
@Controller
public class MessageController {
@Autowired
private IMessageService messageService;
@RequestMapping("/sendMessage")
@ResponseBody
public String sendMessage(TbFwXxdl tbFwXxdl){
return messageService.sendMessage(tbFwXxdl);
}
/**
* 获取最新30天内未读消息
* @param tbFwXxdl
* @return
*/
@RequestMapping("/getXxList")
@ResponseBody
public R getXxList(TbFwXxdl tbFwXxdl){
XzxtUser user = SecureUtil.getUserXzxt();
String page = tbFwXxdl.getPage();
String rows = tbFwXxdl.getRows();
// 开始行数
int begin = Integer.parseInt(rows) * (Integer.parseInt(page) - 1);
// 取几行
int end = Integer.parseInt(rows) * Integer.parseInt(page);
tbFwXxdl.setBegin(begin);
tbFwXxdl.setEnd(end);
tbFwXxdl.setJsrZjhm(user.getIdentitycard());
// 获取最新消息30天内容 未读
List<TbFwXxdl> tbFwXxdls = messageService.getZxXxWdList(tbFwXxdl);
int count=messageService.getZxXxWdTotalCount(tbFwXxdl);
return R.ok().data("rows",tbFwXxdls).data("total",count);
}
@RequestMapping("/updateXxzt")
@ResponseBody
public R updateXxzt(String xxid){
try {
messageService.updateXxzt(xxid);
return R.ok().data("xxbh",xxid);
} catch (Exception e) {
e.printStackTrace();
log.error("错误日志", e);
return R.error(e.getMessage());
}
}
@RequestMapping("/updateXxztAll")
@ResponseBody
public R updateXxztAll(TbFwXxdl tbFwXxdl){
try {
XzxtUser user = SecureUtil.getUserXzxt();
tbFwXxdl.setJsrZjhm(user.getIdentitycard());
int count = messageService.updateXxztAll(tbFwXxdl);
return R.ok().data("count",count);
} catch (Exception e) {
e.printStackTrace();
log.error("错误日志", e);
return R.error(e.getMessage());
}
}
/**
* 获取未读消息数目
* @return
*/
@RequestMapping("/getWdxxCount")
@ResponseBody
public R getWdxxCount(){
int xxCount=messageService.getWdxxCount();
return R.ok().data("xxCount",xxCount);
}
}
package org.springblade.founder.socketio.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.founder.socketio.entity.TbFwXxdl;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @author wangyang
* @date 2019/4/17
*/
@Component
@Mapper
public interface NewsDao {
//根据单位代码获取单位用户列表
List<XzxtUser> getUserListByUnitCode(String receiveUnitCode);
//消息入库
int insertNews(TbFwXxdl tbFwXxdl);
//获取最新30天内未读消息总条数
int getZxXxWdTotalCount(TbFwXxdl tbFwXxdl);
// 获取所有未读消息
List<TbFwXxdl> getXxWdlList(TbFwXxdl tbFwXxdl);
// 最新消息30天内所有未读消息
List<TbFwXxdl> getZxXxWdlList(TbFwXxdl tbFwXxdl);
// 根据消息id更新消息状态
int updateXxztById(String xxid);
// 更新全部未读消息
int updateXxztAll(TbFwXxdl tbFwXxdl);
}
package org.springblade.founder.socketio.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface UserDao {
XzxtUser queryUserBySfz(String fsrZjhm);
}
<?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="org.springblade.founder.socketio.dao.UserDao">
<select id="queryUserBySfz" resultType="org.springblade.modules.system.entity.XzxtUser">
select UNITCODE as unitcode,
TRUE_NAME as truename,
IDENTITYCARD as identitycard
from SYS_USER
where IDENTITYCARD = #{fsrZjhm}
and scbz = 0
</select>
</mapper>
<?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="org.springblade.founder.socketio.dao.NewsDao">
<!-- 根据单位代码查询本单位用户列表 -->
<select id="getUserListByUnitCode" parameterType="java.lang.String" resultType="org.springblade.modules.system.entity.XzxtUser">
SELECT * FROM SYS_USER WHERE unitcode=#{value} AND SCBZ='0' AND IDENTITYCARD IS NOT NULL
</select>
<!-- 新增 -->
<insert id="insertNews" parameterType="org.springblade.founder.socketio.entity.TbFwXxdl">
INSERT INTO TB_FW_XXDL (
XXID
,YWDX
,XXBT
,XXNR
,XXLX
,JSR_ZJHM
,FSR_ZJHM
,FSR_NAME
,FSSJ
,SFYD_PDBZ
,YDSJ
,SCSJ
,XXSC_PDBZ
,XXBH
,JSDW_DM
)
VALUES(
#{ xxid , jdbcType=VARCHAR }
,#{ ywdx , jdbcType=VARCHAR }
,#{ xxbt , jdbcType=VARCHAR }
,#{ xxnr , jdbcType=VARCHAR }
,#{ xxlx , jdbcType=VARCHAR }
,#{ jsrZjhm , jdbcType=VARCHAR }
,#{ fsrZjhm , jdbcType=VARCHAR }
,#{ fsrName , jdbcType=VARCHAR }
,sysdate
,'0'
,null
,null
,'0'
,#{ xxbh , jdbcType=VARCHAR }
,#{ jsdwDm , jdbcType=VARCHAR }
)
</insert>
<!-- 获取最新消息的列表(30天内未读消息) -->
<select id="getZxXxWdlList" parameterType="org.springblade.founder.socketio.entity.TbFwXxdl"
resultType="org.springblade.founder.socketio.entity.TbFwXxdl">
SELECT
*
FROM
(
SELECT
news.*, ROWNUM rn
FROM
(
SELECT
XXID as xxid,
ywdx as ywdx,
xxbt as xxbt,
xxnr as xxnr,
xxlx as xxlx,
(select name from SYS_DICTITEM where GROUPID='CODE_XXLXXL' and scbz = '0' and length(code)=6 and code=xxlx) as xxname,
jsr_zjhm as jsrZjhm,
fsr_zjhm as fsrZjhm,
fsr_name as fsrName,
to_char(fssj,'yyyy-MM-dd hh24:mi') as fssj,
sfyd_pdbz as sfydPdbz,
ydsj as ydsj,
xxbh as xxbh
from TB_FW_XXDL
where xxsc_pdbz = '0' and length(xxlx)=6
AND to_char(fssj,'YY/MM/DD') <![CDATA[>=]]> to_char(SYSDATE - 30,'YY/MM/DD')
AND sfyd_pdbz = '0'
<if test="jsrZjhm != null and jsrZjhm != ''">
and jsr_zjhm = #{jsrZjhm}
</if>
ORDER BY sfyd_pdbz , fssj DESC
) news
where ROWNUM <![CDATA[<=]]>
#{end}
) where rn > #{begin}
</select>
<!-- 获取最新消息的列表 ,根据消息类型 -->
<select id="getXxWdlList" parameterType="org.springblade.founder.socketio.entity.TbFwXxdl"
resultType="org.springblade.founder.socketio.entity.TbFwXxdl">
SELECT
*
FROM
(
SELECT
news.*, ROWNUM rn
FROM
(
select
XXID as xxid,
ywdx as ywdx,
xxbt as xxbt,
xxnr as xxnr,
xxlx as xxlx,
jsr_zjhm as jsrZjhm,
(select name from SYS_DICTITEM where GROUPID='CODE_XXLXXL' and scbz = '0' and length(code)=6 and code=xxlx) as xxname,
fsr_zjhm as fsrZjhm,
fsr_name as fsrName,
to_char(fssj,'yyyy-MM-dd hh24:mi') as fssj,
sfyd_pdbz as sfydPdbz,
ydsj as ydsj,
xxbh as xxbh
from TB_FW_XXDL
where xxsc_pdbz = '0' and length(xxlx)=6
<if test="qryType != null and qryType == '0'.toString()">
AND xxlx like '0801%'
</if>
<if test="qryType != null and qryType == '1'.toString()">
AND xxlx like '0802%'
</if>
<if test="qryType != null and qryType == '2'.toString()">
AND xxlx like '0803%'
</if>
<if test="jsrZjhm != null and jsrZjhm != ''">
and jsr_zjhm = #{jsrZjhm}
</if>
<if test="sfydPdbz != null and sfydPdbz != ''">
and sfyd_pdbz = #{sfydPdbz}
</if>
ORDER BY fssj DESC
) news
where ROWNUM <![CDATA[<=]]>
#{end}
) where rn > #{begin}
</select>
<!-- 获取最新30天内消息未读数 -->
<select id="getZxXxWdTotalCount" parameterType="org.springblade.founder.socketio.entity.TbFwXxdl"
resultType="java.lang.Integer">
select count(*)
from TB_FW_XXDL t
where xxsc_pdbz = '0' and
length(xxlx)=6
<if test="jsrZjhm != null and jsrZjhm != ''">
AND jsr_zjhm = #{jsrZjhm}
</if>
<if test="sfydPdbz != null and sfydPdbz != ''">
and sfyd_pdbz = #{sfydPdbz}
</if>
</select>
<update id="updateXxztById">
update TB_FW_XXDL set SFYD_PDBZ = '1' where XXID = #{xxid ,jdbcType=VARCHAR}
</update>
<update id="updateXxztAll">
update TB_FW_XXDL set SFYD_PDBZ = '1'
where xxsc_pdbz = '0' and
length(xxlx)=6
<if test="jsrZjhm != null and jsrZjhm != ''">
AND jsr_zjhm = #{jsrZjhm}
</if>
AND sfyd_pdbz = '0'
</update>
</mapper>
package org.springblade.founder.socketio.entity;
import lombok.Getter;
import lombok.Setter;
/**
*消息队列类
* @author wangyang
* @date 2019/4/16
*/
@Getter
@Setter
public class TbFwXxdl {
//消息ID
private String xxid;
//业务对象(案事件编号、人员编号、线索对象)
private String ywdx;
//消息标题
private String xxbt;
//消息内容
private String xxnr;
//消息类型
private String xxlx;
//接收人证件号码
private String jsrZjhm;
//发送人证件号码
private String fsrZjhm;
//发送人姓名
private String fsrName;
//发送时间
private String fssj;
//是否以读判断标志
private String sfydPdbz;
//已读时间
private String ydsj;
//删除时间
private String scsj;
//删除标志
private String xxscPdbz;
//消息编号
private String xxbh;
//消息类型名称
private String xxname;
private String page;
private String rows;
//分页查询开始行数
private int begin;
//分页查询取多少行
private int end;
//接收单位
private String jsdwDm;
private String qryType;
}
package org.springblade.founder.socketio.service;
import org.springblade.founder.socketio.entity.TbFwXxdl;
import java.util.List;
/**
*消息中心Service
* @author wangyang
* @date 2019/4/20
*/
public interface IMessageService {
//写消息到消息队列
String sendMessage(TbFwXxdl tbFwXxdl);
//消息队列信息最新消息未读数 1、查询最新消息未读数 2、查询最新消息未读数(案件编号)
int getZxXxWdTotalCount(TbFwXxdl tbFwXxdl);
//获取最新未读消息信息列表
List<TbFwXxdl> getZxXxWdList(TbFwXxdl tbFwXxdl);
//更新消息
int updateXxzt(String xxid);
int updateXxztAll(TbFwXxdl tbFwXxdl);
int getWdxxCount();
void addMessage(String xxbt, String xxlx, String xxnr, String jsdwdm, String jsrZjhm);
}
package org.springblade.founder.socketio.service.impl;
import com.alibaba.druid.util.StringUtils;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.founder.socketio.dao.NewsDao;
import org.springblade.founder.socketio.dao.UserDao;
import org.springblade.founder.socketio.entity.TbFwXxdl;
import org.springblade.founder.socketio.service.IMessageService;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
/**
*
* @author wangyang
* @date 2019/4/20
*/
@Service
public class MessageServiceImpl implements IMessageService {
@Autowired
private NewsDao newsDao;
@Autowired
private UserDao userDao;
@Override
public String sendMessage(TbFwXxdl tbFwXxdl) {
if (!StringUtils.isEmpty(tbFwXxdl.getJsdwDm()) && !StringUtils.isEmpty(tbFwXxdl.getJsrZjhm()) ){
return "发送消息失败,接收人、接收单位不能同时存在!";
}
if (StringUtils.isEmpty(tbFwXxdl.getFsrZjhm()) && StringUtils.isEmpty(tbFwXxdl.getFsrName())){
return "发送消息失败,发送人信息不能为空!";
}
if (StringUtils.isEmpty(tbFwXxdl.getXxbt())){
return "发送消息失败,消息标题不能为空!";
}
if (StringUtils.isEmpty(tbFwXxdl.getXxlx())){
return "发送消息失败,消息类型不能为空!";
}
if (StringUtils.isEmpty(tbFwXxdl.getXxnr())){
return "发送消息失败,消息内容不能为空!";
}
if (StringUtils.isEmpty(tbFwXxdl.getJsrZjhm())&& StringUtils.isEmpty(tbFwXxdl.getJsdwDm())){
return "发送消息失败,接收者信息不能为空!";
}
//消息编号
tbFwXxdl.setXxbh(UUID.randomUUID().toString().replace("-", ""));
// 存放接收者身份证号
HashSet<String> idCadeList = new HashSet<String>();
if (tbFwXxdl.getJsrZjhm() != null){
String idCard =tbFwXxdl.getJsrZjhm();
if(idCard.contains(",")){
idCadeList.addAll(Arrays.asList(idCard.split(",")));
}else {
idCadeList.add(idCard);
}
}
// 接收单位
String receiveUnitCode = tbFwXxdl.getJsdwDm();
// 消息发送给指定单位 接收单位处理start
if (!"".equals(receiveUnitCode) && receiveUnitCode != null) {
// 根据单位代码获取单位用户列表
List<XzxtUser> unitUsers = newsDao.getUserListByUnitCode(receiveUnitCode);
if (unitUsers != null && unitUsers.size() > 0) {
for (XzxtUser u : unitUsers) {
if (!idCadeList.contains(u.getIdentitycard())) {
// 指定单位下所有用户也放入list
idCadeList.add(u.getIdentitycard());
}
}
}
}
// 消息接收单位处理end
XzxtUser user = null;
String fsrZjhm = tbFwXxdl.getFsrZjhm();
String fsrName = tbFwXxdl.getFsrName();
// 通过消息发送人身份证号码获取发送人信息
if (fsrName == null || "".equals(fsrName)) {
user = userDao.queryUserBySfz(fsrZjhm);
if (user == null) {
return "发送消息失败,发送人信息不存在!";
}
//发送人姓名
fsrName = user.getRealname() == null ? user.getRealname() : user.getRealname().trim();
}
String result = "";
if (idCadeList != null && idCadeList.size() > 0) {
for (String idCade : idCadeList) {
TbFwXxdl insertNews = new TbFwXxdl();
insertNews.setJsrZjhm(idCade);
//消息编号
insertNews.setXxbh(tbFwXxdl.getXxbh());
//发送人姓名
insertNews.setFsrName(fsrName);
//接收单位代码
if (tbFwXxdl.getJsdwDm()!=null){
insertNews.setJsdwDm(tbFwXxdl.getJsdwDm());
}
//发送人证件号码
insertNews.setFsrZjhm(tbFwXxdl.getFsrZjhm());
insertNews.setXxbt(tbFwXxdl.getXxbt());
insertNews.setXxlx(tbFwXxdl.getXxlx());
insertNews.setXxname(tbFwXxdl.getXxname());
insertNews.setXxnr(tbFwXxdl.getXxnr());
insertNews.setYwdx(tbFwXxdl.getYwdx());
insertNews.setSfydPdbz("0");
//设置消息ID
insertNews.setXxid(UUID.randomUUID().toString().replace("-", ""));
// 根据身份证号码获取用户信息
XzxtUser jsr = userDao.queryUserBySfz(insertNews.getJsrZjhm());
if (jsr != null) {
int flag = newsDao.insertNews(insertNews);
if (flag == 1) {
/* insertNews.setXxbt("您有一条新消息!");
// 推送消息
Socketio.sendMessage(insertNews);*/
} else {
return "发送消息失败,消息队列信息新增出错";
}
} else {
return "发送消息失败,接收人信息不存在!";
}
}
result = tbFwXxdl.getXxbh();
}
return result;
}
@Override
public int getZxXxWdTotalCount(TbFwXxdl tbFwXxdl) {
return newsDao.getZxXxWdTotalCount(tbFwXxdl);
}
@Override
public List<TbFwXxdl> getZxXxWdList(TbFwXxdl tbFwXxdl) {
return newsDao.getXxWdlList(tbFwXxdl);
}
@Override
public int updateXxzt(String xxid) {
return newsDao.updateXxztById(xxid);
}
@Override
public int updateXxztAll(TbFwXxdl tbFwXxdl) {
return newsDao.updateXxztAll(tbFwXxdl);
}
@Override
public int getWdxxCount() {
TbFwXxdl tbFwXxdl = new TbFwXxdl();
XzxtUser user = SecureUtil.getUserXzxt();
tbFwXxdl.setJsrZjhm(user.getIdentitycard());
tbFwXxdl.setSfydPdbz("0");
return newsDao.getZxXxWdTotalCount(tbFwXxdl);
}
@Override
public void addMessage(String xxbt, String xxlx, String xxnr, String jsdwdm, String jsrZjhm) {
XzxtUser user = SecureUtil.getUserXzxt();
String fsrName = user.getRealname();
String fsrZjhm = user.getIdentitycard();
TbFwXxdl tbFwXxdl = new TbFwXxdl();
tbFwXxdl.setXxbt(xxbt);
tbFwXxdl.setXxlx(xxlx);
tbFwXxdl.setXxname(xxbt);
tbFwXxdl.setXxnr(xxnr);
tbFwXxdl.setYwdx("xs");
tbFwXxdl.setFsrName(fsrName);
tbFwXxdl.setFsrZjhm(fsrZjhm);
tbFwXxdl.setSfydPdbz("0");
tbFwXxdl.setJsdwDm(jsdwdm);
tbFwXxdl.setJsrZjhm(jsrZjhm);
sendMessage(tbFwXxdl);
}
}
...@@ -107,4 +107,16 @@ public class DateUtil { ...@@ -107,4 +107,16 @@ public class DateUtil {
} }
return dateStr; return dateStr;
} }
/**
* 获取本周的第一天
* @return String
* **/
public static String getWeekStart(){
Calendar cal=Calendar.getInstance();
cal.add(Calendar.WEEK_OF_MONTH, 0);
cal.set(Calendar.DAY_OF_WEEK, 2);
Date time=cal.getTime();
return new SimpleDateFormat("yyyy-MM-dd").format(time)+" 00:00:00";
}
} }
package org.springblade.founder.xxtz.controller;
import org.springblade.founder.utils.R;
import org.springblade.founder.xxtz.service.XxtzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/xxtz")
public class XxtzController {
@Autowired
private XxtzService xxtzService;
@PostMapping("/jqtz")
public R getJqxx(String type){
try {
String jqtz = xxtzService.getJqxx(type);
return R.ok().data("jqtz", jqtz);
} catch (Exception e){
e.printStackTrace();
return R.error(e.getMessage());
}
}
}
package org.springblade.founder.xxtz.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface XxtzMapper {
Integer selectXsajCountByDw(@Param("dwlike") String dwlike, @Param("date") String date);
Integer selectYphXsajCountByDw(@Param("dwlike") String dwlike, @Param("date") String date);
}
<?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="org.springblade.founder.xxtz.mapper.XxtzMapper">
<select id="selectXsajCountByDw" resultType="java.lang.Integer">
select count(1)
from TB_ST_ASJ
where XXSC_PDBZ = '0'
and XXDJDW_GAJGJGDM like #{dwlike} || '%'
and ASJFSSJ_ASJFSKSSJ <![CDATA[ > ]]> #{date}
</select>
<select id="selectYphXsajCountByDw" resultType="java.lang.Integer">
select count(1)
from TB_ST_ASJ
where XXSC_PDBZ = '0'
and ZCJDDM = '0600'
and XXDJDW_GAJGJGDM like #{dwlike} || '%'
and ASJFSSJ_ASJFSKSSJ <![CDATA[ > ]]> #{date}
</select>
</mapper>
package org.springblade.founder.xxtz.service;
import java.text.ParseException;
public interface XxtzService {
/**
* getJqxx 查询警情
* @param type: 类型 0今日 1本周
* @return java.lang.String
* @author lystar
* 2021/12/1 17:16
*/
String getJqxx(String type);
}
package org.springblade.founder.xxtz.service.impl;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.founder.utils.DateUtil;
import org.springblade.founder.utils.Utils;
import org.springblade.founder.xxtz.mapper.XxtzMapper;
import org.springblade.founder.xxtz.service.XxtzService;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
@Service
public class XxtzServiceImpl implements XxtzService {
@Autowired
private XxtzMapper xxtzMapper;
@Override
public String getJqxx(String type) {
XzxtUser userXzxt = SecureUtil.getUserXzxt();
String dwlike = Utils.getDwlikeByUnitCode(userXzxt.getUnitcode());
String date;
String jqxx;
if ("0".equals(type)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
date = sdf.format(new Date());
} else {
date = DateUtil.getWeekStart();
}
Integer xsajsl = xxtzMapper.selectXsajCountByDw(dwlike, date);
if ("0".equals(type)) {
jqxx = "今日警情:本辖区今日发生刑事案件数量为:" + xsajsl + "起!";
} else {
Integer yphxsajsl = xxtzMapper.selectYphXsajCountByDw(dwlike, date);
jqxx = "本周态势:本辖区本周发生刑事案件数量为:" + xsajsl + "起!<br />" +
"已成功破获案件数量为:" + yphxsajsl + "起!";
}
return jqxx;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment