Commit a8077ed7 by YANGYANG

时空缓存记录提交(湖南)

parent 5b6c2022
package com.founder.commonutils.model.newPublicEntity;
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 com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sk_service_cache")
@ApiModel(value="时空缓存表", description="")
public class SkServiceCache implements Serializable {
@TableId(type = IdType.INPUT)
@ApiModelProperty(value = "主键编号")
@TableField("xxzjbh")
private String xxzjbh;
@ApiModelProperty(value = "登陆者证件号")
@TableField("ypmc")
private String ypmc;
@ApiModelProperty(value = "研判号码")
@TableField("objectvalue")
private String objectvalue;
@ApiModelProperty(value = "类型字典")
@TableField("objecttype")
private String objecttype;
@ApiModelProperty(value = "号码类型")
@TableField("objectname")
private String objectname;
@ApiModelProperty(value = "研判时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date ypsj;
@ApiModelProperty(value = "证件号码")
@TableField("zjhm")
private String zjhm;
@ApiModelProperty(value = "用户名")
@TableField("name")
private String name;
@ApiModelProperty(value = "数据json")
@TableField("yptj")
private String yptjStringJson;
@ApiModelProperty(value = "数据json")
@TableField(exist = false)
private Map<Object,Object> yptj;
@ApiModelProperty(value = "研判开始时间")
@TableField(exist = false)
private String ypsjkssj;
@ApiModelProperty(value = "研判结束时间")
@TableField(exist = false)
private String ypsjjssj;
@ApiModelProperty(value = "当前页")
@TableField(exist = false)
private int page;
@ApiModelProperty(value = "每页数")
@TableField(exist = false)
private int pageSize;
}
package com.founder.servicebase.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.founder.commonutils.model.newPublicEntity.MapRestResult;
import com.founder.commonutils.model.newPublicEntity.SkServiceCache;
import com.founder.commonutils.model.newPublicEntity.SysUser;
import com.founder.commonutils.util.KeyUtil;
import com.founder.servicebase.logs.OperLog;
import com.founder.servicebase.logs.OperationType;
import com.founder.servicebase.mapper.mysqlMapper.SysDictitemAllMapper;
import com.founder.servicebase.service.SkCacheService;
import com.founder.servicebase.service.SkDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* 时空服务列表表控制层
*
* @author yangyang
* @since 2022-10-14
*/
@RestController
@RequestMapping("SkService")
@Api(tags = "SK服务信息")
public class SkServiceCacheController extends ApiController {
@Resource
private SkCacheService skCacheService;
@Resource
SysDictitemAllMapper sysDictitemAllMapper;
@Autowired
private SkDictionaryService skDictionaryService;
@PostMapping("saveSkCache")
@ApiOperation(value = "时空_新增可视化缓存记录")
@OperLog(message = "时空_新增可视化缓存记录", operation = OperationType.ADD)
public MapRestResult saveKsh(@RequestBody SkServiceCache skServiceCache, HttpServletRequest request) {
SysUser user = (SysUser)request.getAttribute("user");
skServiceCache.setXxzjbh(KeyUtil.getUUIDKey("SK"));
skServiceCache.setZjhm(user.getIdentitycard());
skServiceCache.setName(user.getTrueName());
skServiceCache.setYptjStringJson(JSONObject.toJSON(skServiceCache.getYptj()).toString());
boolean save = skCacheService.save(skServiceCache);
if (save) {
return new MapRestResult();
} else {
return new MapRestResult().error("保存失败");
}
}
@PostMapping("deleteSkCache")
@ApiOperation(value = "时空_删除缓存服务信息")
@OperLog(message = "时空_删除缓存服务信息", operation = OperationType.DELETE)
public MapRestResult deleteKshCacheById(String xxzjbh) {
int delete = skCacheService.deleteKshCacheById(xxzjbh);
if (delete>0) {
return new MapRestResult();
} else {
return new MapRestResult(200,"无此xxzjbh",null);
}
}
@PostMapping("querySkCache")
@ApiOperation(value = "时空_查询缓存服务列表信息")
@OperLog(message = "时空_查询缓存服务列表信息", operation = OperationType.QUERY)
public MapRestResult KshCache(@RequestBody SkServiceCache skServiceCache, HttpServletRequest request) {
SysUser user = (SysUser)request.getAttribute("user");
//分页
Page page = new Page(skServiceCache.getPage(), skServiceCache.getPageSize());
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("zjhm", user.getIdentitycard());
if (skServiceCache.getYpmc()!=null&& !"".equals(skServiceCache.getYpmc())){ // 研判名称
queryWrapper.like("ypmc",skServiceCache.getYpmc());
}
if (skServiceCache.getObjecttype()!=null&& !"".equals(skServiceCache.getObjecttype())){ // 研判类型
queryWrapper.like("objecttype",skServiceCache.getObjecttype());
}
//时间
if (skServiceCache.getYpsjkssj() != null) {
queryWrapper.ge("str_to_date(ypsj,'%Y-%m-%d %H:%i:%s')", skServiceCache.getYpsjkssj());
}
if (skServiceCache.getYpsjjssj() != null) {
queryWrapper.le("str_to_date(ypsj,'%Y-%m-%d %H:%i:%s')", skServiceCache.getYpsjjssj());
}
queryWrapper.orderByDesc("ypsj");
IPage page1 = skCacheService.page(page, queryWrapper);
List<SkServiceCache> listResult = page1.getRecords();
listResult.stream().forEach(q->{
Map<Object,Object> map = JSON.parseObject(q.getYptjStringJson(), Map.class);
map.forEach((k, v) -> {
// 代码翻译
if(k.equals("区域")){
if("1".equals(v)){
map.put(k,"所属分局");
}else if("2".equals(v)){
map.put(k,"所属派出所");
}
}else if(k.equals("标签")){
List<String> bqs = (List<String>) v;
List<String> names = sysDictitemAllMapper.getNameByCodeBq(bqs);
map.put(k,names);
}else if(k.equals("轨迹类型")){
map.put(k,skDictionaryService.findDmmcByDmAndDmlx((String) v,"GJ"));
}
});
q.setYptj(map);
});
return new MapRestResult(200, "OK", page1.getTotal(), page1.getRecords());
}
}
package com.founder.servicebase.mapper.mysqlMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.founder.commonutils.model.newPublicEntity.SkServiceCache;
import org.springframework.stereotype.Component;
/**
* 服务列表(SkService)表数据库访问层
*
* @author yangyang
* @since 2022-10-14
*/
@Component
public interface SkCacheMapper extends BaseMapper<SkServiceCache> {
}
package com.founder.servicebase.mapper.mysqlMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper
@Component
public interface SysDictitemAllMapper {
List<String> getNameByCodeBq(List<String> codeArray);
}
<?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.founder.servicebase.mapper.mysqlMapper.SysDictitemAllMapper">
<!-- 根据code查询name值-->
<select id="getNameByCodeBq" parameterType="java.util.List" resultType="java.lang.String">
select name from sys_dictitem where scbz='0'
and groupid IN('CODE_AJLB','CODE_AJXZ','CODE_AJXLB')
and code IN
<foreach collection="list" item="code" index="index"
open="(" close=")" separator=",">
#{code}
</foreach>
</select>
</mapper>
\ No newline at end of file
package com.founder.servicebase.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.founder.commonutils.model.newPublicEntity.SkServiceCache;
/**
* 服务列表(SkCacheService)表服务接口
*
* @author yangyang
* @since 2022-10-14
*/
public interface SkCacheService extends IService<SkServiceCache> {
int deleteKshCacheById(String xxzjbh);
}
package com.founder.servicebase.service.serviceimpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.founder.commonutils.model.newPublicEntity.SkServiceCache;
import com.founder.servicebase.mapper.mysqlMapper.SkCacheMapper;
import com.founder.servicebase.service.SkCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 服务列表(SkService)表服务实现类
*
* @author yangyang
* @since 2022-10-14
*/
@Service("SkCacheService")
public class SkCacheServiceImpl extends ServiceImpl<SkCacheMapper, SkServiceCache> implements SkCacheService {
@Autowired
SkCacheMapper skCacheMapper;
@Override
public int deleteKshCacheById(String xxzjbh) {
return skCacheMapper.deleteById(xxzjbh);
}
}
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