Commit 81c51629 by 赵剑炜

Merge branch 'develop' into develop-zhaojw

parents e79c4c38 83faf830
......@@ -20,6 +20,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jyzb-api" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.6.3" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.20" level="project" />
......
......@@ -81,7 +81,12 @@ public class CabinetController {
return returnMsg;
}
@PostMapping("/GetCabinetByOrgId")
@ApiOperation("根据组织机构获取单警柜及箱号信息")
public ResponseResult getCabinetByOrgId(@RequestBody Map<String, Object> msg){
ResponseResult returnMsg = cabinetService.getCabinetByOrgId(msg);
return returnMsg;
}
@PostMapping("/AddCabinetInfo")
@ApiOperation("添加单警柜信息(新)")
......
......@@ -46,4 +46,8 @@ public interface CabinetMapper extends BaseMapper<Cabinet> {
void setCabinetOutSumInventory(@Param("updateId") String id);
void setCabinetPriceInventory(@Param("updateId") String id);
List<Map<String, Object>> getCabinetByOrgId(String orgId);
String getOrgByCabinet(String cabinetId);
}
\ No newline at end of file
......@@ -75,4 +75,11 @@ public interface CabinetService extends IService<Cabinet> {
* @return
*/
boolean boxBindPolice(CabinetBoxReq req);
/**
* 根据组织机构获取单警柜及箱号信息
* @param msg
* @return
*/
ResponseResult getCabinetByOrgId(Map<String, Object> msg);
}
......@@ -652,6 +652,30 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
return policemanService.updateById(one2);
}
@Override
public ResponseResult getCabinetByOrgId(Map<String, Object> msg) {
try {
checkNotBlank(msg.get("orgId"), "orgId不能为空");
} catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, e.getMessage());
}
// 根据组织机构获取该组织机构下所有单警柜
List<Map<String,Object>> allCabinet = new ArrayList<>();
allCabinet = cabinetMapper.getCabinetByOrgId(msg.get("orgId").toString());
// 遍历allCabinet
for (Map<String,Object> oneCabinet:allCabinet){
String cabinetId = oneCabinet.get("id").toString();
// 根据单警柜id获取箱号信息
List<Map<String,Object>> allBox = new ArrayList<>();
allBox = cabinetBoxMapper.getBoxMsg(cabinetId);
oneCabinet.put("allBoxMsg",allBox);
}
return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS, allCabinet);
}
//查询的各种条件信息
//单警柜主柜查询条件
......
......@@ -17,6 +17,7 @@ import com.junmp.jyzb.service.PubOrgService;
import com.junmp.jyzb.utils.*;
import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil;
import com.sun.jna.platform.win32.ObjBase;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
......@@ -657,36 +658,40 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
}
@Override
public ResponseResult getPoliceData(Map<String, Object> cabinetId) {
public ResponseResult getPoliceData(Map<String, Object> msg) {
try {
checkNotBlank(cabinetId.get("cabinetId"), "cabinetId不能为空");
checkNotBlank(msg.get("cabinetId"), "cabinetId不能为空");
checkNotBlank(msg.get("type"), "type不能为空");
} catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage());
}
//如果没有找到该单警柜,返回对应信息
String cabinetMsg = cabinetId.get("cabinetId").toString();
String cabinetMsg = msg.get("cabinetId").toString();
Map<String, Object> oneCabinet = cabinetMapper.getOneCabinet(cabinetMsg);
if (oneCabinet.isEmpty()){
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.NO_DATA,ReturnData.NO_DATA);
}
// 构建 Redis 缓存键
String redisKey = "getPoliceData" + cabinetId.get("cabinetId").toString();
// 从 Redis 中获取数据
Map<String, Object> cachedData = redisUtils.findCachedData(redisKey);
if (cachedData != null) {
//将Long类型的数据转化为Date
// for (Map<String,Object> one:cachedData){
// Long dataMsg = (Long) one.get("updateTime");
// one.put("updateTime", redisUtils.getDate(dataMsg));
// allPoliceman.add(one);
// }
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,cachedData);
}
String type = msg.get("type").toString();
//存放返回的数据
Map<String, Object> allMsg = new HashMap<>();
allMsg.put("cabinetName",oneCabinet.get("name"));
if (type.equals("all")){
//根据单警柜id获取组织机构id
String orgId = cabinetMapper.getOrgByCabinet(msg.get("cabinetId").toString());
//根据组织机构id,查询所有的警员
List<Map<String, Object>> allPolicemanByOrg = policemanMapper.getAllPolicemanByOrg(orgId);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,allPolicemanByOrg);
}else if(type.equals("single")){
allMsg.put("id",oneCabinet.get("id"));
allMsg.put("cabinetNum",oneCabinet.get("cabinetNum"));
allMsg.put("name",oneCabinet.get("name"));
allMsg.put("orgId",oneCabinet.get("orgId"));
allMsg.put("orgName",oneCabinet.get("orgName"));
allMsg.put("location",oneCabinet.get("location"));
List<Map<String, Object>> allBoxMsg = cabinetBoxMapper.getBoxMsg(cabinetMsg);
List<Map<String, Object>> policeMsg = new ArrayList<>();
for (Map<String, Object> boxMsg:allBoxMsg){
......@@ -700,10 +705,68 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
}
}
allMsg.put("policeList",policeMsg);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,allMsg);
}else if(type.equals("allBind")){
//构建存放返回信息的List
List<Map<String,Object>> returnMsg = new ArrayList<>();
//根据单警柜id获取组织机构id
String orgId = cabinetMapper.getOrgByCabinet(msg.get("cabinetId").toString());
//根据组织机构id获取下面的所有单警柜
List<Map<String, Object>> allCabinet = cabinetMapper.getCabinetByOrgId(orgId);
//根据单警柜的List,查询所有绑定的警员信息
for (Map<String, Object> one:allCabinet){
//构建cabinet的map
Map<String, Object> cabinetMap = new HashMap<>();
cabinetMap.put("id",one.get("id"));
cabinetMap.put("cabinetNum",one.get("cabinetNum"));
cabinetMap.put("name",one.get("name"));
cabinetMap.put("orgId",one.get("orgId"));
cabinetMap.put("orgName",one.get("orgName"));
cabinetMap.put("location",one.get("location"));
List<Map<String, Object>> allBoxMsg = cabinetBoxMapper.getBoxMsg(one.get("id").toString());
List<Map<String, Object>> policeMsg = new ArrayList<>();
for (Map<String, Object> boxMsg:allBoxMsg){
String cabinetBoxId = boxMsg.get("cabinetBoxId").toString();
List<String> allPoliceIdByBoxId = policemanMapper.getAllPoliceIdByBoxId(cabinetBoxId);
for(String policeId:allPoliceIdByBoxId){
Map<String, Object> onePolice = policemanMapper.getOnePolice(policeId);
List<Map<String, Object>> fingerprints= policeFingerMapper.getFingersByUserId(policeId);
onePolice.put("fingerMsg",fingerprints);
policeMsg.add(onePolice);
}
}
cabinetMap.put("policeList",policeMsg);
//将cabinetMap放入list
returnMsg.add(cabinetMap);
}
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,returnMsg);
}else {
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.ERROR,"传入的type有误");
}
// // 构建 Redis 缓存键
// String redisKey = "getPoliceData" + cabinetId.get("cabinetId").toString();
// // 从 Redis 中获取数据
// Map<String, Object> cachedData = redisUtils.findCachedData(redisKey);
// if (cachedData != null) {
// //将Long类型的数据转化为Date
//// for (Map<String,Object> one:cachedData){
//// Long dataMsg = (Long) one.get("updateTime");
//// one.put("updateTime", redisUtils.getDate(dataMsg));
//// allPoliceman.add(one);
//// }
// return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,cachedData);
// }
//将查询结果存入 Redis 中
redisUtils.set(redisKey, allMsg);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,allMsg);
//redisUtils.set(redisKey, allMsg);
}
/**
......
package com.junmp.jyzb.utils;
import org.omg.CORBA.NO_PERMISSION;
/**
* 返回状态码
......
......@@ -115,7 +115,7 @@
select cabinet_num from base_cabinet where id =#{id}
</select>
<select id="getAllCabinetByOrgList" parameterType="java.util.List" resultType="java.util.Map">
<select id="getAllCabinetByOrgList" parameterType="java.util.List" resultType="com.junmp.jyzb.entity.Cabinet">
select
c.id,
c.cabinet_num as cabinetNum,
......@@ -231,4 +231,30 @@ SET price_total = (
where c.id = #{updateId}
</if>
</update>
<select id="getOrgByCabinet" resultType="String">
select
o.org_id
from base_cabinet c
join pub_org o on c.org_id_int =o.org_id
where c.id = #{cabinetId}
</select>
<select id="getCabinetByOrgId" resultType="map">
select
c.id,
c.cabinet_num as cabinetNum,
c.name,
o.org_id as orgId,
o.org_name as orgName,
c.location,
c.state,
c.update_time as updateTime,
c.sum as sum,
c.in_sum as inSum,
c.out_sum as outSum
from base_cabinet c
left join pub_org o on c.org_id_int =o.org_id
where c.org_id_int = #{orgId}
</select>
</mapper>
\ No newline at end of file
......@@ -39,6 +39,7 @@
p.sex,
p.phone,
p.photo,
COALESCE(p.cabinet_box_id,null) as cabinetBoxId,
p.police_code AS policeCode,
c.id AS cabinetId,
c.name AS cabinetName,
......@@ -177,6 +178,7 @@
p.org_id_int AS orgId,
o.org_name AS orgName,
p.name AS name,
COALESCE(p.cabinet_box_id,null) as cabinetBoxId,
p.sex,
p.phone,
p.photo,
......
......@@ -31,6 +31,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jyzb-api" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.4" level="project" />
<orderEntry type="library" name="Maven: p6spy:p6spy:3.9.1" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.21" level="project" />
......
......@@ -4,7 +4,7 @@
server:
tomcat:
uri-encoding: UTF-8 #tomcat编码
port: 10031 #tomcat端口
port: 10030 #tomcat端口
spring:
main:
#bea同名类进行注册时,准许覆盖注册
......
artifactId=jyzb-mq-consumer
groupId=com.junmp.jyzb
version=1.0.0
artifactId=jyzb-mq-producer
groupId=com.junmp.jyzb
version=1.0.0
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论