Commit 2c21ca29 by shenweidong

更新了根据单警柜查询警员接口

parent 51bb7926
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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: 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: cn.hutool:hutool-all:5.6.3" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.20" level="project" /> <orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.20" level="project" />
......
...@@ -80,7 +80,12 @@ public class CabinetController { ...@@ -80,7 +80,12 @@ public class CabinetController {
return returnMsg; return returnMsg;
} }
@PostMapping("/GetCabinetByOrgId")
@ApiOperation("根据组织机构获取单警柜及箱号信息")
public ResponseResult getCabinetByOrgId(@RequestBody Map<String, Object> msg){
ResponseResult returnMsg = cabinetService.getCabinetByOrgId(msg);
return returnMsg;
}
@PostMapping("/AddCabinetInfo") @PostMapping("/AddCabinetInfo")
@ApiOperation("添加单警柜") @ApiOperation("添加单警柜")
......
...@@ -43,4 +43,8 @@ public interface CabinetMapper extends BaseMapper<Cabinet> { ...@@ -43,4 +43,8 @@ public interface CabinetMapper extends BaseMapper<Cabinet> {
void setCabinetOutSumInventory(@Param("updateId") String id); void setCabinetOutSumInventory(@Param("updateId") String id);
void setCabinetPriceInventory(@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
...@@ -73,4 +73,11 @@ public interface CabinetService extends IService<Cabinet> { ...@@ -73,4 +73,11 @@ public interface CabinetService extends IService<Cabinet> {
* @return * @return
*/ */
boolean boxBindPolice(CabinetBoxReq req,String policeId); boolean boxBindPolice(CabinetBoxReq req,String policeId);
/**
* 根据组织机构获取单警柜及箱号信息
* @param msg
* @return
*/
ResponseResult getCabinetByOrgId(Map<String, Object> msg);
} }
...@@ -635,6 +635,30 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -635,6 +635,30 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
return policemanService.save(one2); return policemanService.save(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; ...@@ -17,6 +17,7 @@ import com.junmp.jyzb.service.PubOrgService;
import com.junmp.jyzb.utils.*; import com.junmp.jyzb.utils.*;
import com.junmp.v2.common.exception.base.ServiceException; import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil; import com.junmp.v2.common.util.BeanPlusUtil;
import com.sun.jna.platform.win32.ObjBase;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -657,36 +658,40 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -657,36 +658,40 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
} }
@Override @Override
public ResponseResult getPoliceData(Map<String, Object> cabinetId) { public ResponseResult getPoliceData(Map<String, Object> msg) {
try { try {
checkNotBlank(cabinetId.get("cabinetId"), "cabinetId不能为空"); checkNotBlank(msg.get("cabinetId"), "cabinetId不能为空");
checkNotBlank(msg.get("type"), "type不能为空");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage()); 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); Map<String, Object> oneCabinet = cabinetMapper.getOneCabinet(cabinetMsg);
if (oneCabinet.isEmpty()){ if (oneCabinet.isEmpty()){
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.NO_DATA,ReturnData.NO_DATA); return new ResponseResult(HttpStatus.ERROR,ReturnMsg.NO_DATA,ReturnData.NO_DATA);
} }
// 构建 Redis 缓存键 String type = msg.get("type").toString();
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);
}
Map<String, Object> allMsg = new HashMap<>(); 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>> allBoxMsg = cabinetBoxMapper.getBoxMsg(cabinetMsg);
List<Map<String, Object>> policeMsg = new ArrayList<>(); List<Map<String, Object>> policeMsg = new ArrayList<>();
for (Map<String, Object> boxMsg:allBoxMsg){ for (Map<String, Object> boxMsg:allBoxMsg){
...@@ -700,10 +705,68 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -700,10 +705,68 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
} }
} }
allMsg.put("policeList",policeMsg); 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 中 //将查询结果存入 Redis 中
redisUtils.set(redisKey, allMsg); //redisUtils.set(redisKey, allMsg);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,allMsg);
} }
/** /**
......
package com.junmp.jyzb.utils; package com.junmp.jyzb.utils;
import org.omg.CORBA.NO_PERMISSION;
/** /**
* 返回状态码 * 返回状态码
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
where p.id =#{id} where p.id =#{id}
</update> </update>
<select id="getAllCabinet" > <select id="getAllCabinet" resultType="com.junmp.jyzb.entity.Cabinet">
select select
c.id, c.id,
c.cabinet_num as cabinetNum, c.cabinet_num as cabinetNum,
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
select cabinet_num from base_cabinet where id =#{id} select cabinet_num from base_cabinet where id =#{id}
</select> </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 select
c.id, c.id,
c.cabinet_num as cabinetNum, c.cabinet_num as cabinetNum,
...@@ -210,4 +210,30 @@ SET price_total = ( ...@@ -210,4 +210,30 @@ SET price_total = (
where c.id = #{updateId} where c.id = #{updateId}
</if> </if>
</update> </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> </mapper>
\ No newline at end of file
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
p.sex, p.sex,
p.phone, p.phone,
p.photo, p.photo,
COALESCE(p.cabinet_box_id,null) as cabinetBoxId,
p.police_code AS policeCode, p.police_code AS policeCode,
c.id AS cabinetId, c.id AS cabinetId,
c.name AS cabinetName, c.name AS cabinetName,
...@@ -177,6 +178,7 @@ ...@@ -177,6 +178,7 @@
p.org_id_int AS orgId, p.org_id_int AS orgId,
o.org_name AS orgName, o.org_name AS orgName,
p.name AS name, p.name AS name,
COALESCE(p.cabinet_box_id,null) as cabinetBoxId,
p.sex, p.sex,
p.phone, p.phone,
p.photo, p.photo,
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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: 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: p6spy:p6spy:3.9.1" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.21" level="project" /> <orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.21" level="project" />
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
server: server:
tomcat: tomcat:
uri-encoding: UTF-8 #tomcat编码 uri-encoding: UTF-8 #tomcat编码
port: 10031 #tomcat端口 port: 10030 #tomcat端口
spring: spring:
main: main:
#bea同名类进行注册时,准许覆盖注册 #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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论