Commit 19a1f042 by 李小惠

修改单警柜模块以及人脸、指纹的各个接口

parent 14cd869f
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
<groupId>jakarta.validation</groupId> <groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId> <artifactId>jakarta.validation-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.junmp.jyzb</groupId>
<artifactId>jyzb-biz</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
package com.junmp.jyzb.api.bean.dto;
import com.junmp.v2.common.bean.request.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@Data
public class CabinetDto implements Serializable {
/**
* 单警柜ID
*/
@ApiModelProperty(value = "单警柜ID")
private String id;
/**
* 单警柜编号
*/
@ApiModelProperty(value = "单警柜编号")
private String cabinetNum;
/**
* 箱数
*/
@ApiModelProperty(value = "箱数")
private Integer num;
/**
* 单警柜名称
*/
@ApiModelProperty(value = "单警柜名称")
private String name;
/**
* 组织机构号
*/
@ApiModelProperty(value = "组织机构号")
private String orgId;
/**
* 位置信息
*/
@ApiModelProperty(value = "位置信息")
private String location;
/**
* 单警柜当前状态,0正常,1异常
*/
@ApiModelProperty(value = "单警柜当前状态,0正常,1异常")
private Integer state;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 更新人员
*/
@ApiModelProperty(value = "更新人员")
private String updateUser;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.junmp.jyzb.api.bean.req;
import com.baomidou.mybatisplus.annotation.TableField;
import com.junmp.v2.common.bean.request.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
public class CabinetBoxReq extends BaseRequest {
/**
* 主键ID
*/
@ApiModelProperty(value = "主键ID")
private String id;
/**
* 主柜ID
*/
@ApiModelProperty(value = "主柜ID")
private String cabinetId;
/**
* 箱号
*/
@ApiModelProperty(value = "箱号")
private Integer num;
/**
* 异常状态:1正常/0异常
*/
@ApiModelProperty(value = "异常状态:1正常/0异常")
private Integer state;
/**
* 异常原因
*/
@ApiModelProperty(value = "异常原因")
private String errorMsg;
/**
* 使用日志存储位置信息
*/
@ApiModelProperty(value = "使用日志存储位置信息")
private String logMap;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.junmp.jyzb.beanReq; package com.junmp.jyzb.api.bean.req;
import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.v2.common.bean.request.BaseRequest; import com.junmp.v2.common.bean.request.BaseRequest;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -77,10 +76,11 @@ public class CabinetReq extends BaseRequest { ...@@ -77,10 +76,11 @@ public class CabinetReq extends BaseRequest {
@ApiModelProperty(value = "更新人员") @ApiModelProperty(value = "更新人员")
private String updateUser; private String updateUser;
/** // /**
* 单警柜与箱门一对多关系 // * 单警柜与箱门一对多关系
*/ // */
private List<CabinetBox> list; //// private List<CabinetBox> list;
// private List<CabinetBox> a ;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
package com.junmp.jyzb.beanReq; package com.junmp.jyzb.api.bean.req;
import com.junmp.v2.common.bean.request.BaseRequest; import com.junmp.v2.common.bean.request.BaseRequest;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -14,27 +14,25 @@ public class PolicemanFingerReq extends BaseRequest { ...@@ -14,27 +14,25 @@ public class PolicemanFingerReq extends BaseRequest {
/** /**
* 指纹id * 指纹id
*/ */
@NotNull(message = "指纹主键不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "指纹id") @ApiModelProperty(value = "指纹id")
private Integer id; private Integer id;
/** /**
* 警员id * 警员id
*/ */
@NotNull(message = "警员id不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "警员id") @ApiModelProperty(value = "警员id")
private String policeId; private String policeId;
/** /**
* 指纹名称 * 指纹名称
*/ */
@ApiModelProperty(value = "警员id") @ApiModelProperty(value = "指纹名称")
private String name; private String name;
/** /**
* 指纹信息 * 指纹信息
*/ */
@NotNull(message = "指纹信息不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "指纹信息") @ApiModelProperty(value = "指纹信息")
private String fingerInfo; private String fingerInfo;
......
package com.junmp.jyzb.api.bean.req;
import com.baomidou.mybatisplus.annotation.TableField;
import com.junmp.v2.common.bean.request.BaseRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
public class PolicemanReq extends BaseRequest {
@NotNull(message = "警员主键不能为空", groups = {edit.class, delete.class, detail.class})
private String id;
@NotNull(message = "警员名字不能为空", groups = {edit.class, delete.class, detail.class})
private String name;
private String cabinetBoxId;
@NotNull(message = "组织机构不能为空", groups = {edit.class, delete.class, detail.class})
private String orgId;
private Long orgIdInt;
private Long departmentId;
private String policeCode;
private String sex;
private String faceInfo;
private Boolean isCreatedAccount;
private String doorCode;
private String password;
private String photo;
private String phone;
private Date createTime;
private Date updateTime;
private String idCard;
private String updateUser;
private Integer state;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
...@@ -2,11 +2,14 @@ package com.junmp.jyzb.api.bean.req; ...@@ -2,11 +2,14 @@ package com.junmp.jyzb.api.bean.req;
import com.junmp.v2.common.bean.request.BaseRequest; import com.junmp.v2.common.bean.request.BaseRequest;
import com.junmp.v2.validator.api.validators.unique.TableUniqueValue; import com.junmp.v2.validator.api.validators.unique.TableUniqueValue;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/** /**
* <pre> * <pre>
...@@ -95,4 +98,6 @@ public class ProductReq extends BaseRequest { ...@@ -95,4 +98,6 @@ public class ProductReq extends BaseRequest {
* 生产厂家名称 * 生产厂家名称
*/ */
private String mfBizName; private String mfBizName;
} }
package com.junmp.jyzb.api.bean.req; package com.junmp.jyzb.api.bean.req;
import com.junmp.v2.common.bean.request.BaseRequest; import com.junmp.v2.common.bean.request.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Date;
/** /**
* <pre> * <pre>
...@@ -63,4 +65,6 @@ public class ProductSkuReq extends BaseRequest { ...@@ -63,4 +65,6 @@ public class ProductSkuReq extends BaseRequest {
* 预览属性3 * 预览属性3
*/ */
private String attr3; private String attr3;
} }
...@@ -66,5 +66,13 @@ ...@@ -66,5 +66,13 @@
<version>31.1-jre</version> <version>31.1-jre</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.junmp.jyzb</groupId>
<artifactId>jyzb-api</artifactId>
</dependency>
<dependency>
<groupId>com.junmp.jyzb</groupId>
<artifactId>jyzb-api</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
package com.junmp.jyzb.controller; package com.junmp.jyzb.controller;
import com.junmp.jyzb.api.bean.req.CabinetBoxReq;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.Cabinet;
import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.jyzb.service.CabinetBoxService; import com.junmp.jyzb.service.CabinetBoxService;
import com.junmp.jyzb.service.CabinetService; import com.junmp.jyzb.service.CabinetService;
import com.junmp.jyzb.service.PoliceFingerService; import com.junmp.jyzb.service.PoliceFingerService;
...@@ -7,9 +11,12 @@ import com.junmp.jyzb.utils.HttpStatus; ...@@ -7,9 +11,12 @@ import com.junmp.jyzb.utils.HttpStatus;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.jyzb.utils.ReturnData; import com.junmp.jyzb.utils.ReturnData;
import com.junmp.jyzb.utils.ReturnMsg; import com.junmp.jyzb.utils.ReturnMsg;
import com.junmp.v2.common.bean.request.ValidationApi;
import com.junmp.v2.common.bean.response.ApiRes;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -74,11 +81,64 @@ public class CabinetController { ...@@ -74,11 +81,64 @@ public class CabinetController {
} }
@PostMapping("/getCabinetBoxInfo")
@ApiOperation("获取箱门列表") @PostMapping("/AddCabinetInfo")
public ResponseResult getCabinetBoxInfo(@RequestBody Map<String, Object> msg){ @ApiOperation("添加单警柜")
ResponseResult returnMsg = cabinetBoxService.getCabinetBoxInfo(msg); public ApiRes<Boolean> addCabinetInfo(@RequestBody CabinetReq req){
return returnMsg; boolean result = cabinetService.addCabinetInfo(req);
if (!result){
return ApiRes.failure("操作失败");
}
return ApiRes.success(result);
}
@PostMapping("/DeleteCabinetInfo")
@ApiOperation("删除单警柜信息")
public ApiRes<Boolean> deleteCabinetInfo(@RequestBody CabinetReq req) {
return ApiRes.success(cabinetService.deleteCabinetInfo(req));
}
@PostMapping("/ShowCabinetList")
@ApiOperation("查询单警柜列表")
public ApiRes<List<Cabinet>> showCabinetList(@RequestBody CabinetReq req,@RequestBody String includeLowerLevel){
List<Cabinet> allCabinetList = cabinetService.getAllCabinetList(req, includeLowerLevel);
if (allCabinetList.size()<=0){
return ApiRes.failure("查询失败,列表为null");
}
return ApiRes.success(cabinetService.getAllCabinetList(req,includeLowerLevel));
} }
//通过单警柜id查询单个箱门及其箱门信息
@PostMapping("/ShowOneCabinet")
@ApiOperation("查询单个单警柜及其箱门信息")
public ApiRes<Cabinet> showOneCabinet(@RequestBody CabinetReq req){
return ApiRes.success(cabinetService.showOneCabinet(req));
}
@PostMapping("/getCabinetBoxList")
@ApiOperation("通过单警柜id获取箱门列表")
public ApiRes<List<CabinetBox>> getCabinetBoxList(@RequestBody CabinetReq req){
return ApiRes.success(cabinetBoxService.getCabinetBoxList(req));
}
@PostMapping("/UpdateCabinetInfo")
@ApiOperation("修改单警柜信息")
public ApiRes<Boolean> updateCabinetInfo(@RequestBody CabinetReq req) {
boolean result = cabinetService.updateCabinetInfo(req);
if (!result){
return ApiRes.failure("操作失败");
}
return ApiRes.success(result);
}
@PostMapping("/boxBindPolice")
@ApiOperation("箱门绑定人员")
public ApiRes<Boolean> boxBindPolice(@RequestBody CabinetBoxReq req,@RequestBody String policeId) {
boolean result = cabinetService.boxBindPolice(req,policeId);
if (!result){
return ApiRes.failure("操作失败");
}
return ApiRes.success(result);
}
} }
\ No newline at end of file
//package com.junmp.jyzb.controller;
//
//import com.junmp.jyzb.beanReq.CabinetReq;
//import com.junmp.jyzb.doc.CabinetDoc;
//import com.junmp.jyzb.entity.Cabinet;
//import com.junmp.jyzb.service.CabinetService;
//import com.junmp.v2.common.bean.request.ValidationApi;
//import com.junmp.v2.common.bean.response.ApiRes;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.validation.annotation.Validated;
//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 java.util.List;
//
//@RestController
//@Slf4j
//@RequestMapping("/Cabinet")
//@Api(tags = "单警柜基础信息模块")
//public class CabinetController111 implements CabinetDoc {
// @Resource
// public CabinetService cabinetService;
//
// @PostMapping("/AddCabinet")
// @ApiOperation("添加单警柜")
// public ApiRes<Boolean> addCabinet(@RequestBody @Validated(CabinetReq.add.class) CabinetReq req) throws Exception {
// return ApiRes.success(cabinetService.addCabinet(req));
// }
//
//
// @PostMapping("/DeleteCabinet")
// @ApiOperation("删除单警柜信息")
// public ApiRes<Boolean> deleteCabinet(@RequestBody @Validated(ValidationApi.edit.class) CabinetReq req) throws Exception {
// return ApiRes.success(cabinetService.deleteCabinet(req));
// }
//
// @PostMapping("/ShowCabinet")
// @ApiOperation("查询单警柜列表")
// public ApiRes<List<Cabinet>> showCabinet(@RequestBody @Validated(ValidationApi.edit.class) CabinetReq req,String includeLowerLevel){
// return ApiRes.success(cabinetService.getAllCabinet(req,includeLowerLevel));
// }
//
//
// @PostMapping("/UpdateCabinet")
// @ApiOperation("修改单警柜信息")
// public ApiRes<Boolean> updateCabinet(@RequestBody @Validated(ValidationApi.edit.class) CabinetReq req) throws Exception {
// return ApiRes.success(cabinetService.updateCabinet(req));
// }
//
//
//// @PostMapping("/ErrorState")
//// @ApiOperation("单警柜状态变更")
//
//
//// @PostMapping("/GetCabinetDetail")
//// @ApiOperation("查询单警柜及其箱号信息")
//
//// @PostMapping("/getCabinetBoxInfo")
//// @ApiOperation("获取箱门列表")
//}
package com.junmp.jyzb.controller; package com.junmp.jyzb.controller;
import cn.hutool.core.util.ObjectUtil;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.api.bean.req.PolicemanReq;
import com.junmp.jyzb.entity.Policeman;
import com.junmp.jyzb.service.PolicemanService; import com.junmp.jyzb.service.PolicemanService;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.v2.common.bean.response.ApiRes;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
...@@ -29,23 +35,32 @@ public class PoliceController { ...@@ -29,23 +35,32 @@ public class PoliceController {
@PostMapping("/AddFaceInfo") @PostMapping("/AddFaceInfo")
@ApiOperation("添加警员面部信息") @ApiOperation("添加警员面部信息")
public ResponseResult addFaceInfo(@RequestBody Map<String,Object> msg) { public ApiRes<Boolean> addFaceInfo(@RequestBody PolicemanReq req) {
ResponseResult returnMsg = policemanService.addFaceInfo(msg); boolean b = policemanService.addFaceInfo(req);
return returnMsg; if (!b){
return ApiRes.failure("添加失败");
}
return ApiRes.success(b);
} }
@PostMapping("/updatefaceInfo") @PostMapping("/updateFaceInfo")
@ApiOperation("修改、删除人脸信息") @ApiOperation("修改、删除人脸信息")
public ResponseResult updateFaceInfo(@RequestBody Map<String,Object> msg) { public ApiRes<Boolean> updateFaceInfo(@RequestBody PolicemanReq req) {
ResponseResult returnMsg = policemanService.updateFaceInfo(msg); boolean b = policemanService.updateFaceInfo(req);
return returnMsg; if (!b){
return ApiRes.failure("操作失败");
}
return ApiRes.success(b);
} }
@PostMapping("/searchFaceInfo") @PostMapping("/searchFaceInfo")
@ApiOperation("查找人脸信息") @ApiOperation("查找人脸信息")
public ResponseResult searchFaceInfo(@RequestBody Map<String,Object> msg) { public ApiRes<Policeman> searchFaceInfo(@RequestBody PolicemanReq req) {
ResponseResult returnMsg = policemanService.searchFaceInfo(msg); Policeman policeman = policemanService.searchFaceInfo(req);
return returnMsg; if (ObjectUtil.isEmpty(policeman)){
return ApiRes.failure("未找到警员信息");
}
return ApiRes.success(policeman);
} }
...@@ -108,8 +123,12 @@ public class PoliceController { ...@@ -108,8 +123,12 @@ public class PoliceController {
**/ **/
@PostMapping("/policeList") @PostMapping("/policeList")
@ApiOperation("人员列表") @ApiOperation("人员列表")
public ResponseResult policeList(@RequestBody Map<String, Object> msg){ public ApiRes<List<Policeman>> policeList(@RequestBody CabinetReq req){
ResponseResult returnMsg =policemanService.getOrgPoliceman(msg); List<Policeman> orgPoliceman = policemanService.getOrgPoliceman(req);
return returnMsg; if (orgPoliceman.isEmpty()){
return ApiRes.failure("未查到人员信息");
} }
return ApiRes.success(orgPoliceman);
}
} }
package com.junmp.jyzb.controller; package com.junmp.jyzb.controller;
import com.junmp.jyzb.beanReq.PolicemanFingerReq; import com.junmp.jyzb.api.bean.req.PolicemanFingerReq;
import com.junmp.jyzb.doc.PolicemanFingerDoc; import com.junmp.jyzb.doc.PolicemanFingerDoc;
import com.junmp.jyzb.entity.PoliceFinger; import com.junmp.jyzb.entity.PoliceFinger;
import com.junmp.jyzb.service.PoliceFingerService; import com.junmp.jyzb.service.PoliceFingerService;
......
package com.junmp.jyzb.doc; package com.junmp.jyzb.doc;
import com.junmp.jyzb.api.bean.req.ProductReq;
import com.junmp.jyzb.beanReq.PolicemanFingerReq; import com.junmp.jyzb.api.bean.req.PolicemanFingerReq;
import com.junmp.jyzb.entity.PoliceFinger; import com.junmp.jyzb.entity.PoliceFinger;
import com.junmp.v2.common.bean.response.ApiRes; import com.junmp.v2.common.bean.response.ApiRes;
import com.junmp.v2.db.api.page.PageResult; import com.junmp.v2.db.api.page.PageResult;
......
package com.junmp.jyzb.entity; package com.junmp.jyzb.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
...@@ -22,6 +21,7 @@ public class Cabinet implements Serializable { ...@@ -22,6 +21,7 @@ public class Cabinet implements Serializable {
/** /**
* 单警柜ID * 单警柜ID
*/ */
@TableId(value = "id",type = IdType.ASSIGN_UUID )
@ApiModelProperty(value = "单警柜ID") @ApiModelProperty(value = "单警柜ID")
private String id; private String id;
...@@ -94,14 +94,14 @@ public class Cabinet implements Serializable { ...@@ -94,14 +94,14 @@ public class Cabinet implements Serializable {
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@TableField("create_time") @TableField(value="create_time")
private Date createTime; private Date createTime;
/** /**
* 更新时间 * 更新时间
*/ */
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
@TableField("update_time") @TableField(value = "update_time")
private Date updateTime; private Date updateTime;
/** /**
...@@ -124,9 +124,6 @@ public class Cabinet implements Serializable { ...@@ -124,9 +124,6 @@ public class Cabinet implements Serializable {
@ApiModelProperty(value = "箱数") @ApiModelProperty(value = "箱数")
private Integer num; private Integer num;
/**
* 单警柜与箱门一对多关系
*/
private List<CabinetBox> list; private List<CabinetBox> list;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
package com.junmp.jyzb.entity; package com.junmp.jyzb.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -18,6 +20,7 @@ public class CabinetBox implements Serializable { ...@@ -18,6 +20,7 @@ public class CabinetBox implements Serializable {
/** /**
* 主键ID * 主键ID
*/ */
@TableId(value = "id",type = IdType.ASSIGN_UUID)
@ApiModelProperty(value = "主键ID") @ApiModelProperty(value = "主键ID")
private String id; private String id;
......
...@@ -19,7 +19,7 @@ import java.util.Date; ...@@ -19,7 +19,7 @@ import java.util.Date;
@TableName("base_inventory") @TableName("base_inventory")
public class Inventory implements Serializable { public class Inventory implements Serializable {
@TableField("id") @TableId(value = "id",type=IdType.ASSIGN_UUID)
private String ID; private String ID;
/** /**
......
package com.junmp.jyzb.entity; package com.junmp.jyzb.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -18,9 +20,8 @@ import javax.validation.constraints.NotNull; ...@@ -18,9 +20,8 @@ import javax.validation.constraints.NotNull;
@TableName("base_police_finger") @TableName("base_police_finger")
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@TableName("base_police_finger")
public class PoliceFinger implements Serializable { public class PoliceFinger implements Serializable {
@TableField(value = "id") @TableId(value = "id",type= IdType.AUTO)
private Integer id; private Integer id;
@TableField(value = "police_id") @TableField(value = "police_id")
......
package com.junmp.jyzb.entity; package com.junmp.jyzb.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -20,7 +22,7 @@ import lombok.NoArgsConstructor; ...@@ -20,7 +22,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@TableName("base_policeman") @TableName("base_policeman")
public class Policeman implements Serializable { public class Policeman implements Serializable {
@TableField(value = "id") @TableId(value = "id")
private String id; private String id;
@TableField(value = "name") @TableField(value = "name")
...@@ -30,10 +32,8 @@ public class Policeman implements Serializable { ...@@ -30,10 +32,8 @@ public class Policeman implements Serializable {
private String cabinetBoxId; private String cabinetBoxId;
@TableField(value = "org_id_int") @TableField(value = "org_id_int")
private Long orgIdInt; private Long orgId;
@TableField(value = "org_id")
private String orgId;
@TableField(value = "department_id") @TableField(value = "department_id")
private Long departmentId; private Long departmentId;
...@@ -44,7 +44,7 @@ public class Policeman implements Serializable { ...@@ -44,7 +44,7 @@ public class Policeman implements Serializable {
@TableField(value = "sex") @TableField(value = "sex")
private String sex; private String sex;
@TableField(value = "face_info") @TableField(value = "face_info",updateStrategy = FieldStrategy.IGNORED)
private String faceInfo; private String faceInfo;
@TableField(value = "isCreatedAccount") @TableField(value = "isCreatedAccount")
......
package com.junmp.jyzb.exception.enums;
import com.junmp.v2.common.constant.CommonConstant;
import com.junmp.v2.common.exception.IExceptionEnum;
import lombok.Getter;
/**
* <pre>
*
* 描述:
* 版本:1.0.0
* 日期:2022/8/1 13:08
* 作者:ningzp@junmp.com.cn
* <br>修改记录
* <br>修改日期 修改人 修改内容
*
* </pre>
*/
@Getter
public enum CabinetExceptionEnum implements IExceptionEnum {
/**
* 组织机构不存在
*/
PUBORG_NOT_EXIST(CommonConstant.DEFAULT_USER_ERROR_CODE,"组织机构不存在"),
/**
* 单警柜编号重复
*/
CABINETID_IS_EXISTS(CommonConstant.DEFAULT_USER_ERROR_CODE,"单警柜编号重复"),
/**
* 单警柜不存在
*/
CABINET_ISNOT_EXISTS(CommonConstant.DEFAULT_USER_ERROR_CODE,"单警柜不存在"),
/**
* 传入参数错误
*/
PARAMETER_ERROR(CommonConstant.DEFAULT_USER_ERROR_CODE,"传入参数错误"),
/**
* 箱门id不存在
*/
CABINETBOX_ISNOT_EXISTS(CommonConstant.DEFAULT_USER_ERROR_CODE,"箱门id不存在"),
;
/**
* 错误编码
*/
private final Integer code;
/**
* 提示用户信息
*/
private final String message;
CabinetExceptionEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
}
package com.junmp.jyzb.exception.enums; package com.junmp.jyzb.exception.enums;
import com.junmp.jyzb.api.constant.JYZBConstant;
import com.junmp.v2.common.constant.CommonConstant; import com.junmp.v2.common.constant.CommonConstant;
import com.junmp.v2.common.exception.IExceptionEnum; import com.junmp.v2.common.exception.IExceptionEnum;
import lombok.Getter; import lombok.Getter;
......
...@@ -10,6 +10,11 @@ public enum PolicemanFingerExceptionEnum implements IExceptionEnum { ...@@ -10,6 +10,11 @@ public enum PolicemanFingerExceptionEnum implements IExceptionEnum {
* 警员指纹已存在 * 警员指纹已存在
*/ */
POLICEMAN_FINGER_EXCEPTION_ENUM(CommonConstant.DEFAULT_USER_ERROR_CODE,"警员指纹信息已存在"), POLICEMAN_FINGER_EXCEPTION_ENUM(CommonConstant.DEFAULT_USER_ERROR_CODE,"警员指纹信息已存在"),
/**
* 警员指纹不存在
*/
POLICEMAN_FINGER_NOTEXISTS(CommonConstant.DEFAULT_USER_ERROR_CODE,"警员指纹不存在"),
; ;
......
...@@ -15,4 +15,8 @@ public interface CabinetBoxMapper extends BaseMapper<CabinetBox> { ...@@ -15,4 +15,8 @@ public interface CabinetBoxMapper extends BaseMapper<CabinetBox> {
void changeCabinetState(CabinetBox cabinetBox); void changeCabinetState(CabinetBox cabinetBox);
String getOneCabinetBox(String cabinetBoxId); String getOneCabinetBox(String cabinetBoxId);
List<CabinetBox> selectByIdCabinetBoxes(String id);
} }
\ No newline at end of file
...@@ -13,7 +13,8 @@ public interface CabinetMapper extends BaseMapper<Cabinet> { ...@@ -13,7 +13,8 @@ public interface CabinetMapper extends BaseMapper<Cabinet> {
public int addCabinet(Cabinet cabinet); public int addCabinet(Cabinet cabinet);
public List<Map<String, Object>> getAllCabinet(); public List<Cabinet> getAllCabinet();
public List<Cabinet> getAllCabinetList();
Map<String, Object> getOneCabinet(String id); Map<String, Object> getOneCabinet(String id);
...@@ -33,7 +34,7 @@ public interface CabinetMapper extends BaseMapper<Cabinet> { ...@@ -33,7 +34,7 @@ public interface CabinetMapper extends BaseMapper<Cabinet> {
String getCabinetNumById(String id); String getCabinetNumById(String id);
List<Map<String, Object>> getAllCabinetByOrgList(List<String> allOrgId); List<Cabinet> getAllCabinetByOrgList(List<String> allOrgId);
void setCabinetSumInventory(@Param("updateId") String id); void setCabinetSumInventory(@Param("updateId") String id);
......
package com.junmp.jyzb.service; package com.junmp.jyzb.service;
import com.junmp.jyzb.utils.ResponseResult; import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.CabinetBox;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface CabinetBoxService{ public interface CabinetBoxService extends IService<CabinetBox> {
List<Map<String, Object>> getAllBoxMsg(String id); List<Map<String, Object>> getAllBoxMsg(String id);
ResponseResult getCabinetBoxInfo(Map<String, Object> msg); List<CabinetBox> getCabinetBoxList(CabinetReq req);
} }
package com.junmp.jyzb.service; package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.beanReq.CabinetReq; import com.junmp.jyzb.api.bean.req.CabinetBoxReq;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
...@@ -35,26 +36,41 @@ public interface CabinetService extends IService<Cabinet> { ...@@ -35,26 +36,41 @@ public interface CabinetService extends IService<Cabinet> {
* @param req * @param req
* @return * @return
*/ */
boolean addCabinet(CabinetReq req) throws Exception; boolean addCabinetInfo(CabinetReq req) ;
/** /**
* 删除单警柜 * 删除单警柜
* @param req * @param req
* @return * @return
*/ */
boolean deleteCabinet(CabinetReq req); boolean deleteCabinetInfo(CabinetReq req);
/** /**
* 查询单警柜信息 * 查询单警柜信息,通过组织机构id进行查询
* @param req * @param req
* @return * @return
*/ */
List<Cabinet> getAllCabinet(CabinetReq req,String includeLowerLevel); List<Cabinet> getAllCabinetList(CabinetReq req, String includeLowerLevel);
/**
* 通过单警柜id进行查询单个单警柜信息及其箱门信息
* @param req
* @return
*/
Cabinet showOneCabinet(CabinetReq req);
/** /**
* 修改单警柜信息 * 修改单警柜信息
* @param req * @param req
* @return * @return
*/ */
boolean updateCabinet(CabinetReq req) throws Exception; boolean updateCabinetInfo(CabinetReq req);
/**
* 箱门绑定人员
* @param req
* @return
*/
boolean boxBindPolice(CabinetBoxReq req,String policeId);
} }
package com.junmp.jyzb.service; package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.req.ProductReq; import com.junmp.jyzb.api.bean.req.PolicemanFingerReq;
import com.junmp.jyzb.beanReq.PolicemanFingerReq;
import com.junmp.jyzb.entity.PoliceFinger; import com.junmp.jyzb.entity.PoliceFinger;
import com.junmp.jyzb.entity.Product;
import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.v2.db.api.page.PageResult; import com.junmp.v2.db.api.page.PageResult;
import java.util.List; import java.util.List;
......
package com.junmp.jyzb.service; package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.api.bean.req.PolicemanReq;
import com.junmp.jyzb.entity.PoliceFinger; import com.junmp.jyzb.entity.PoliceFinger;
import com.junmp.jyzb.entity.Policeman;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface PolicemanService{ public interface PolicemanService extends IService<Policeman> {
ResponseResult addPoliceman(Map<String, Object> msg); ResponseResult addPoliceman(Map<String, Object> msg);
ResponseResult getOnePolice(Map<String, Object> id); ResponseResult getOnePolice(Map<String, Object> id);
...@@ -27,7 +31,7 @@ public interface PolicemanService{ ...@@ -27,7 +31,7 @@ public interface PolicemanService{
//查询指纹信息 //查询指纹信息
ResponseResult searchFingerInfo(Map<String, Object> msg); ResponseResult searchFingerInfo(Map<String, Object> msg);
ResponseResult addFaceInfo(Map<String, Object> msg); boolean addFaceInfo(PolicemanReq req);
ResponseResult changePoliceState(Map<String, Object> msg); ResponseResult changePoliceState(Map<String, Object> msg);
...@@ -37,10 +41,10 @@ public interface PolicemanService{ ...@@ -37,10 +41,10 @@ public interface PolicemanService{
ResponseResult getPoliceData(Map<String, Object> cabinetId); ResponseResult getPoliceData(Map<String, Object> cabinetId);
ResponseResult updateFaceInfo(Map<String, Object> msg); boolean updateFaceInfo(PolicemanReq req);
ResponseResult searchFaceInfo(Map<String, Object> msg); Policeman searchFaceInfo(PolicemanReq req);
//通过单警柜获取组织机构id,再获取组织机构下的所有警员信息 //通过单警柜获取组织机构id,再获取组织机构下的所有警员信息
ResponseResult getOrgPoliceman(Map<String, Object> msg); List<Policeman> getOrgPoliceman(CabinetReq req);
} }
package com.junmp.jyzb.service.impl; package com.junmp.jyzb.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.Cabinet;
import com.junmp.jyzb.entity.CabinetBox; import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.jyzb.mapper.CabinetBoxMapper; import com.junmp.jyzb.mapper.CabinetBoxMapper;
import com.junmp.jyzb.mapper.CabinetMapper;
import com.junmp.jyzb.service.CabinetBoxService; import com.junmp.jyzb.service.CabinetBoxService;
import com.junmp.jyzb.utils.HttpStatus; import com.junmp.jyzb.utils.HttpStatus;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
...@@ -16,11 +21,14 @@ import java.util.Map; ...@@ -16,11 +21,14 @@ import java.util.Map;
import static com.junmp.jyzb.utils.CheckBlank.checkNotBlank; import static com.junmp.jyzb.utils.CheckBlank.checkNotBlank;
@Service @Service
public class CabinetBoxServiceImpl implements CabinetBoxService { public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, CabinetBox> implements CabinetBoxService {
@Resource @Resource
private CabinetBoxMapper cabinetBoxMapper; private CabinetBoxMapper cabinetBoxMapper;
@Resource
private CabinetBoxService cabinetBoxService;
@Override @Override
public List<Map<String, Object>> getAllBoxMsg(String id) { public List<Map<String, Object>> getAllBoxMsg(String id) {
return cabinetBoxMapper.getBoxMsg(id); return cabinetBoxMapper.getBoxMsg(id);
...@@ -34,14 +42,9 @@ public class CabinetBoxServiceImpl implements CabinetBoxService { ...@@ -34,14 +42,9 @@ public class CabinetBoxServiceImpl implements CabinetBoxService {
* @return * @return
**/ **/
@Override @Override
public ResponseResult getCabinetBoxInfo(Map<String, Object> msg) { public List<CabinetBox> getCabinetBoxList(CabinetReq req) {
try { List<CabinetBox> cabinetBoxList = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>()
checkNotBlank(msg.get("cabinetId"), "cabinetId不能为空"); .eq(ObjectUtil.isNotEmpty(req.getId()),CabinetBox::getCabinetId, req.getId()));
} catch (IllegalArgumentException e) { return cabinetBoxList;
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage());
}
List<CabinetBox> cabinetBoxList = cabinetBoxMapper.selectList(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getCabinetId, msg.get("cabinetId")));
return new ResponseResult<>(HttpStatus.SUCCESS,"操作成功",cabinetBoxList);
} }
} }
...@@ -3,15 +3,27 @@ package com.junmp.jyzb.service.impl; ...@@ -3,15 +3,27 @@ package com.junmp.jyzb.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.beanReq.CabinetReq; import com.junmp.jyzb.api.bean.req.CabinetBoxReq;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
import com.junmp.jyzb.entity.CabinetBox; import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.jyzb.entity.Policeman;
import com.junmp.jyzb.entity.PubOrg;
import com.junmp.jyzb.exception.enums.CabinetExceptionEnum;
import com.junmp.jyzb.exception.enums.PolicemanExceptionEnum;
import com.junmp.jyzb.mapper.*; import com.junmp.jyzb.mapper.*;
import com.junmp.jyzb.service.CabinetBoxService;
import com.junmp.jyzb.service.CabinetService; import com.junmp.jyzb.service.CabinetService;
import com.junmp.jyzb.service.PolicemanService;
import com.junmp.jyzb.service.PubOrgService; import com.junmp.jyzb.service.PubOrgService;
import com.junmp.jyzb.utils.*; import com.junmp.jyzb.utils.*;
import com.junmp.v2.common.constant.CommonConstant;
import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil; import com.junmp.v2.common.util.BeanPlusUtil;
import org.checkerframework.checker.units.qual.A;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
...@@ -38,6 +50,11 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -38,6 +50,11 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Resource @Resource
private PubOrgService pubOrgService; private PubOrgService pubOrgService;
@Resource
private CabinetBoxService cabinetBoxService;
@Resource
private PolicemanService policemanService;
private static final String REDIS_CABINET = "Cabinet_"; private static final String REDIS_CABINET = "Cabinet_";
...@@ -51,22 +68,22 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -51,22 +68,22 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
checkNotBlank(msg.get("num"), "num不能为空"); checkNotBlank(msg.get("num"), "num不能为空");
checkNotBlank(msg.get("cabinetNum"), "cabinetNum不能为空"); checkNotBlank(msg.get("cabinetNum"), "cabinetNum不能为空");
} 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 cabinetNum = msg.get("cabinetNum").toString(); String cabinetNum = msg.get("cabinetNum").toString();
//查询传入的组织机构id是否存在 //查询传入的组织机构id是否存在
Long onePubOrg = pubOrgMapper.getOnePubOrg(msg.get("orgId").toString()); Long onePubOrg = pubOrgMapper.getOnePubOrg(msg.get("orgId").toString());
if (onePubOrg == null || onePubOrg.equals("")){ if (onePubOrg == null || onePubOrg.equals("")) {
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.ERROR,"该组织机构不存在"); return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, "该组织机构不存在");
} }
//查询是否有重复的cabinetNum //查询是否有重复的cabinetNum
Map<String, Object> hashCabinetNum = cabinetMapper.getCabinetByCabinetNum(cabinetNum); Map<String, Object> hashCabinetNum = cabinetMapper.getCabinetByCabinetNum(cabinetNum);
if (hashCabinetNum!=null){ if (hashCabinetNum != null) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,"主柜编号重复"); return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, "主柜编号重复");
} }
Cabinet cabinet =new Cabinet(); Cabinet cabinet = new Cabinet();
//将警员相关信息添加到警员表 //将警员相关信息添加到警员表
//生成一个uuid //生成一个uuid
String uuid = UUID.randomUUID().toString().replaceAll("-", ""); String uuid = UUID.randomUUID().toString().replaceAll("-", "");
...@@ -75,40 +92,40 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -75,40 +92,40 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
cabinet.setId(uuid); cabinet.setId(uuid);
cabinet.setCreateTime(currentDate); cabinet.setCreateTime(currentDate);
cabinet.setUpdateTime(currentDate); cabinet.setUpdateTime(currentDate);
cabinet.setOrgId((String) msg.get("orgId")); cabinet.setOrgId((Long) msg.get("orgId"));
cabinet.setName((String) msg.get("name")); cabinet.setName((String) msg.get("name"));
//cabinet.setUpdateUser((String) msg.get("updateUser")); //cabinet.setUpdateUser((String) msg.get("updateUser"));
cabinet.setLocation((String) msg.get("location")); cabinet.setLocation((String) msg.get("location"));
cabinet.setNum((String) msg.get("num")); cabinet.setNum((Integer) msg.get("num"));
cabinet.setCabinetNum(cabinetNum); cabinet.setCabinetNum(cabinetNum);
cabinetMapper.addCabinet(cabinet); cabinetMapper.addCabinet(cabinet);
/** /**
* 更新缓存 * 更新缓存
* */ * */
//构建Redis缓存键 //构建Redis缓存键
String redisKey = REDIS_CABINET + "true" +'_'+ msg.get("orgId").toString(); String redisKey = REDIS_CABINET + "true" + '_' + msg.get("orgId").toString();
// 从 Redis 中获取数据 // 从 Redis 中获取数据
List<Map<String, Object>> cachedDataTrue = redisUtils.findCachedData(redisKey); List<Map<String, Object>> cachedDataTrue = redisUtils.findCachedData(redisKey);
if (cachedDataTrue != null) { if (cachedDataTrue != null) {
cachedDataTrue.add(0,msg); cachedDataTrue.add(0, msg);
//将查询结果存入 Redis 中 //将查询结果存入 Redis 中
redisUtils.set(redisKey, cachedDataTrue); redisUtils.set(redisKey, cachedDataTrue);
} }
//构建Redis缓存键 //构建Redis缓存键
redisKey = REDIS_CABINET + "false" +'_'+ msg.get("orgId").toString(); redisKey = REDIS_CABINET + "false" + '_' + msg.get("orgId").toString();
// 从 Redis 中获取数据 // 从 Redis 中获取数据
List<Map<String, Object>> cachedDataFalse = redisUtils.findCachedData(redisKey); List<Map<String, Object>> cachedDataFalse = redisUtils.findCachedData(redisKey);
if (cachedDataFalse != null) { if (cachedDataFalse != null) {
cachedDataFalse.add(0,msg); cachedDataFalse.add(0, msg);
//将查询结果存入 Redis 中 //将查询结果存入 Redis 中
redisUtils.set(redisKey, cachedDataFalse); redisUtils.set(redisKey, cachedDataFalse);
} }
return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS,uuid); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS, uuid);
} }
@Override @Override
public Map<String,Object> getOneCabinet(String id) { public Map<String, Object> getOneCabinet(String id) {
return cabinetMapper.getOneCabinet(id); return cabinetMapper.getOneCabinet(id);
} }
...@@ -119,16 +136,16 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -119,16 +136,16 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
try { try {
checkNotBlank(msg.get("cabinetList"), "cabinetList不能为空"); checkNotBlank(msg.get("cabinetList"), "cabinetList不能为空");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage()); return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, e.getMessage());
} }
//批量删除操作 //批量删除操作
List<Object> cabinetList = (List<Object>) msg.get("cabinetList"); List<Object> cabinetList = (List<Object>) msg.get("cabinetList");
for (Object cabinetId:cabinetList){ for (Object cabinetId : cabinetList) {
cabinetMapper.deleteCabinet(cabinetId.toString()); cabinetMapper.deleteCabinet(cabinetId.toString());
} }
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS);
} }
//查询某组织机构的所有子机构 //查询某组织机构的所有子机构
...@@ -153,40 +170,40 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -153,40 +170,40 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
checkNotBlank(msg.get("name"), "name不能为空"); checkNotBlank(msg.get("name"), "name不能为空");
checkNotBlank(msg.get("orgId"), "orgId不能为空"); checkNotBlank(msg.get("orgId"), "orgId不能为空");
} 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 cabinetNum = msg.get("cabinetNum").toString(); String cabinetNum = msg.get("cabinetNum").toString();
//查询传入的组织机构id是否存在 //查询传入的组织机构id是否存在
Long onePubOrg = pubOrgMapper.getOnePubOrg(msg.get("orgId").toString()); Long onePubOrg = pubOrgMapper.getOnePubOrg(msg.get("orgId").toString());
if (onePubOrg == null || onePubOrg.equals("")){ if (onePubOrg == null || onePubOrg.equals("")) {
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.ERROR,"该组织机构不存在"); return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, "该组织机构不存在");
} }
//查询是否有重复的cabinetNum //查询是否有重复的cabinetNum
Map<String, Object> hashCabinetNum = cabinetMapper.getCabinetByCabinetNum(cabinetNum); Map<String, Object> hashCabinetNum = cabinetMapper.getCabinetByCabinetNum(cabinetNum);
//判断policeCode是否有变动 //判断policeCode是否有变动
String oldCabinetNum = cabinetMapper.getCabinetNumById(msg.get("id").toString()); String oldCabinetNum = cabinetMapper.getCabinetNumById(msg.get("id").toString());
if (oldCabinetNum!=null && !oldCabinetNum.equals(cabinetNum)){ if (oldCabinetNum != null && !oldCabinetNum.equals(cabinetNum)) {
if (hashCabinetNum!=null){ if (hashCabinetNum != null) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,"主柜编号重复"); return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, "主柜编号重复");
} }
} }
Cabinet cabinet =new Cabinet(); Cabinet cabinet = new Cabinet();
//生成当前时间 //生成当前时间
Date currentDate = DateTimeUtil.getCurrentDateTime(); Date currentDate = DateTimeUtil.getCurrentDateTime();
cabinet.setUpdateTime(currentDate); cabinet.setUpdateTime(currentDate);
cabinet.setId((String) msg.get("id")); cabinet.setId((String) msg.get("id"));
cabinet.setCabinetNum((String) msg.get("cabinetNum")); cabinet.setCabinetNum((String) msg.get("cabinetNum"));
cabinet.setName((String) msg.get("name")); cabinet.setName((String) msg.get("name"));
cabinet.setOrgId((String) msg.get("orgId")); cabinet.setOrgId((Long) msg.get("orgId"));
cabinet.setLocation((String) msg.get("location")); cabinet.setLocation((String) msg.get("location"));
//cabinet.setUpdateUser((String) msg.get("updateUser")); //cabinet.setUpdateUser((String) msg.get("updateUser"));
//cabinet.setState((Integer) msg.get("errorState")); //cabinet.setState((Integer) msg.get("errorState"));
cabinetMapper.updateCabinet(cabinet); cabinetMapper.updateCabinet(cabinet);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS);
} }
@Override @Override
...@@ -195,30 +212,30 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -195,30 +212,30 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
try { try {
checkNotBlank(msg.get("cabinetId"), "cabinetId不能为空"); checkNotBlank(msg.get("cabinetId"), "cabinetId不能为空");
checkNotBlank(msg.get("cabinetBoxList"), "cabinetBoxList不能为空"); checkNotBlank(msg.get("cabinetBoxList"), "cabinetBoxList不能为空");
List<Map<String,Object>> boxMsg = (List<Map<String,Object>>)msg.get("cabinetBoxList"); List<Map<String, Object>> boxMsg = (List<Map<String, Object>>) msg.get("cabinetBoxList");
for (Map<String,Object> box:boxMsg){ for (Map<String, Object> box : boxMsg) {
checkNotBlank(box.get("cabinetBoxId"), "cabinetBoxId不能为空"); checkNotBlank(box.get("cabinetBoxId"), "cabinetBoxId不能为空");
checkNotBlank(box.get("state"), "state不能为空"); checkNotBlank(box.get("state"), "state不能为空");
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage()); return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, e.getMessage());
} }
//判断组织机构id是否正确 //判断组织机构id是否正确
CabinetBox cabinetBox =new CabinetBox(); CabinetBox cabinetBox = new CabinetBox();
//读取单警柜id //读取单警柜id
cabinetBox.setCabinetId(msg.get("cabinetId").toString()); cabinetBox.setCabinetId(msg.get("cabinetId").toString());
//获取cabinetBoxList //获取cabinetBoxList
List<Map<String,Object>> boxMsg = (List<Map<String,Object>>)msg.get("cabinetBoxList"); List<Map<String, Object>> boxMsg = (List<Map<String, Object>>) msg.get("cabinetBoxList");
for (Map<String,Object> box:boxMsg){ for (Map<String, Object> box : boxMsg) {
cabinetBox.setId((String) box.get("cabinetBoxId")); cabinetBox.setId((String) box.get("cabinetBoxId"));
cabinetBox.setState((Integer) box.get("state")); cabinetBox.setState((Integer) box.get("state"));
cabinetBox.setErrorMsg((String) box.get("errorMsg")); cabinetBox.setErrorMsg((String) box.get("errorMsg"));
cabinetBoxMapper.changeCabinetState(cabinetBox); cabinetBoxMapper.changeCabinetState(cabinetBox);
} }
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS);
} }
@Override @Override
...@@ -233,10 +250,10 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -233,10 +250,10 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
checkNotBlank(msg.get("orgId"), "orgId不能为空"); checkNotBlank(msg.get("orgId"), "orgId不能为空");
checkNotBlank(msg.get("IncludeLowerLevel"), "IncludeLowerLevel不能为空"); checkNotBlank(msg.get("IncludeLowerLevel"), "IncludeLowerLevel不能为空");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage()); return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, e.getMessage());
} }
List<Map<String, Object>> allCabinet=new ArrayList<>(); List<Map<String, Object>> allCabinet = new ArrayList<>();
// // 构建 Redis 缓存键 // // 构建 Redis 缓存键
// String redisKey = REDIS_CABINET; // String redisKey = REDIS_CABINET;
...@@ -265,20 +282,20 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -265,20 +282,20 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
// } // }
//如果组织机构是浙江省公安厅 //如果组织机构是浙江省公安厅
if (msg.get("orgId").toString().equals("1369509498032808905") && msg.get("IncludeLowerLevel").toString().equals("true")){ // if (msg.get("orgId").toString().equals("1369509498032808905") && msg.get("IncludeLowerLevel").toString().equals("true")) {
allCabinet = cabinetMapper.getAllCabinet(); // allCabinet = cabinetMapper.getAllCabinet();
//将查询结果存入 Redis 中 // //将查询结果存入 Redis 中
//redisUtils.set(redisKey, allCabinet); // //redisUtils.set(redisKey, allCabinet);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,allCabinet); // return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS, allCabinet);
} // }
//获取该组织机构下所有仓库的id //获取该组织机构下所有仓库的id
List<String> allOrgId =getAllOrgId(msg); // List<String> allOrgId = getAllOrgId(msg);
if (allOrgId.isEmpty()){ // if (allOrgId.isEmpty()) {
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.ERROR,"未查询到相关信息"); // return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR, "未查询到相关信息");
} // }
//
allCabinet = getAllCabinetByOrg(msg,allOrgId); // allCabinet = getAllCabinetByOrg(msg, allOrgId);
//List<Map<String, Object>> selectedCabinets = new ArrayList<>(); // 存放匹配到的柜子信息的列表 //List<Map<String, Object>> selectedCabinets = new ArrayList<>(); // 存放匹配到的柜子信息的列表
...@@ -295,8 +312,6 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -295,8 +312,6 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
// } // }
// String orgId = msg.get("orgId").toString(); // String orgId = msg.get("orgId").toString();
// List<String> allCabinetId =getAllCabinetId(msg); // List<String> allCabinetId =getAllCabinetId(msg);
// for (String cabinetId :allCabinetId){ // for (String cabinetId :allCabinetId){
...@@ -308,22 +323,22 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -308,22 +323,22 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
// //
//将查询结果存入 Redis 中 //将查询结果存入 Redis 中
//redisUtils.set(redisKey, allCabinet); //redisUtils.set(redisKey, allCabinet);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,allCabinet); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS, allCabinet);
} }
private List<String> getAllOrgId(Map<String, Object> msg) { private List<String> getAllOrgId(CabinetReq req, String includeLowerLevel) {
List<String> allOrg = new ArrayList<>(); List<String> allOrg = new ArrayList<>();
if (msg.get("IncludeLowerLevel").equals("false")){ if (includeLowerLevel.equals("false")) {
allOrg.add((String) msg.get("orgId")); allOrg.add(req.getOrgId());
}else if(msg.get("IncludeLowerLevel").equals("true")){ } else if (includeLowerLevel.equals("true")) {
//查询某组织机构的本级及下级 //查询某组织机构的本级及下级
allOrg = pubOrgService.getLowerOrg(msg.get("orgId").toString()); allOrg = pubOrgService.getLowerOrg(req.getOrgId());
} }
return allOrg; return allOrg;
} }
private List<Map<String, Object>> getAllCabinetByOrg(Map<String, Object> msg, List<String> allOrgId) { private List<Cabinet> getAllCabinetByOrg( List<String> allOrgId) {
List<Map<String, Object>> allCabinet = new ArrayList<>(); List<Cabinet> allCabinet = new ArrayList<>();
allCabinet = cabinetMapper.getAllCabinetByOrgList(allOrgId); allCabinet = cabinetMapper.getAllCabinetByOrgList(allOrgId);
return allCabinet; return allCabinet;
} }
...@@ -331,12 +346,12 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -331,12 +346,12 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Override @Override
public List<String> getAllCabinetId(Map<String, Object> msg) { public List<String> getAllCabinetId(Map<String, Object> msg) {
//如果组织机构是最高级的,获取所有id //如果组织机构是最高级的,获取所有id
if (msg.get("orgId").toString().equals("1369509498032808905")){ if (msg.get("orgId").toString().equals("1369509498032808905")) {
//构建 Redis 缓存键 //构建 Redis 缓存键
String redisKey = "getAllCabinetId_"+msg.get("IncludeLowerLevel")+'_'+msg.get("orgId"); String redisKey = "getAllCabinetId_" + msg.get("IncludeLowerLevel") + '_' + msg.get("orgId");
// 从 Redis 中获取数据 // 从 Redis 中获取数据
List<String> cachedData = redisUtils.findCachedData(redisKey); List<String> cachedData = redisUtils.findCachedData(redisKey);
if (cachedData!=null){ if (cachedData != null) {
return cachedData; return cachedData;
} }
List<String> allCabinetId = cabinetMapper.getAllCabinetIdByHighest(); List<String> allCabinetId = cabinetMapper.getAllCabinetIdByHighest();
...@@ -346,18 +361,18 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -346,18 +361,18 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
} }
//构建 Redis 缓存键 //构建 Redis 缓存键
String redisKey = "getAllCabinetId_"+msg.get("IncludeLowerLevel")+'_'+msg.get("orgId"); String redisKey = "getAllCabinetId_" + msg.get("IncludeLowerLevel") + '_' + msg.get("orgId");
// 从 Redis 中获取数据 // 从 Redis 中获取数据
List<String> cachedData = redisUtils.findCachedData(redisKey); List<String> cachedData = redisUtils.findCachedData(redisKey);
if (cachedData!=null){ if (cachedData != null) {
return cachedData; return cachedData;
} }
List<String> cabinetId = new ArrayList<>(); List<String> cabinetId = new ArrayList<>();
if (msg.get("IncludeLowerLevel").equals("false")){ if (msg.get("IncludeLowerLevel").equals("false")) {
cabinetId = cabinetMapper.getAllCabinetId(msg.get("orgId").toString()); cabinetId = cabinetMapper.getAllCabinetId(msg.get("orgId").toString());
}else{ } else {
List<String> orgIds = getSubIds(msg.get("orgId").toString()); //调用本级及下级的所有组织机构的id List<String> orgIds = getSubIds(msg.get("orgId").toString()); //调用本级及下级的所有组织机构的id
for (String orgId:orgIds){ for (String orgId : orgIds) {
List<String> allPoliceId = cabinetMapper.getAllCabinetId(orgId); List<String> allPoliceId = cabinetMapper.getAllCabinetId(orgId);
cabinetId.addAll(allPoliceId); cabinetId.addAll(allPoliceId);
} }
...@@ -373,25 +388,25 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -373,25 +388,25 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
try { try {
checkNotBlank(msg.get("id"), "id不能为空"); checkNotBlank(msg.get("id"), "id不能为空");
} 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 idMsg = msg.get("id").toString(); String idMsg = msg.get("id").toString();
Map<String, Object> cabinetMsg = getOneCabinet(idMsg); Map<String, Object> cabinetMsg = getOneCabinet(idMsg);
if (cabinetMsg==null){ if (cabinetMsg == null) {
return new ResponseResult(HttpStatus.NO_DATA,ReturnMsg.NO_DATA, ReturnData.NO_DATA); return new ResponseResult(HttpStatus.NO_DATA, ReturnMsg.NO_DATA, ReturnData.NO_DATA);
} }
List<Map<String, Object>> allBoxMsg = cabinetBoxMapper.getBoxMsg(idMsg); List<Map<String, Object>> allBoxMsg = cabinetBoxMapper.getBoxMsg(idMsg);
cabinetMsg.put("cabinetBoxList",allBoxMsg); cabinetMsg.put("cabinetBoxList", allBoxMsg);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS,cabinetMsg); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS, cabinetMsg);
} }
public ResponseResult setCabinetInventory(Map<String, Object> msg) { public ResponseResult setCabinetInventory(Map<String, Object> msg) {
String id; String id;
if (msg.containsKey("locationId") && msg.get("locationId")!=""){ if (msg.containsKey("locationId") && msg.get("locationId") != "") {
id = msg.get("locationId").toString(); id = msg.get("locationId").toString();
}else { } else {
id = null; id = null;
} }
//统计仓库 装备总数 //统计仓库 装备总数
...@@ -408,91 +423,249 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -408,91 +423,249 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
/** /**
* 添加单警柜 * 添加单警柜
*
* @param req * @param req
* @return * @return
*/ */
@Transactional
@Override @Override
public boolean addCabinet(CabinetReq req) throws Exception { public boolean addCabinetInfo(CabinetReq req) {
Cabinet cabinet = new Cabinet(); Cabinet cabinet = new Cabinet();
//查询传日的组织机构id是否存在 //查询传入的组织机构id是否存在
Long onePubOrg = pubOrgMapper.getOnePubOrg(req.getOrgId()); LambdaQueryWrapper<PubOrg> pubOrgWrapper = PubOrgWrapper(Long.parseLong(req.getOrgId()));
if(onePubOrg == null || onePubOrg.equals("")){ PubOrg puborg = pubOrgService.getOne(pubOrgWrapper);
throw new Exception("该组织机构不存在");
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(CabinetExceptionEnum.PUBORG_NOT_EXIST);
} }
//查询是否有重复的单警柜编号 //查询是否有重复的单警柜编号
Map<String, Object> hashCabinetNum = cabinetMapper.getCabinetByCabinetNum(req.getCabinetNum()); LambdaQueryWrapper<Cabinet> wrapper2 = CabinetWrapper(req);
if (hashCabinetNum!=null){ wrapper2.eq(ObjectUtil.isNotEmpty(req.getCabinetNum()),Cabinet::getCabinetNum,req.getCabinetNum());
throw new Exception("单警柜编号重复"); List<Cabinet> list = this.list(wrapper2);
} if (list.size()>0) {
BeanPlusUtil.copyProperties(req,cabinet); //抛出单警柜重复异常
String uuid = UUID.randomUUID().toString().replaceAll("-", ""); throw new ServiceException(CabinetExceptionEnum.CABINETID_IS_EXISTS);
cabinet.setId(uuid); }
BeanPlusUtil.copyProperties(req, cabinet);
cabinet.setCreateTime(DateTimeUtil.getCurrentDateTime()); cabinet.setCreateTime(DateTimeUtil.getCurrentDateTime());
cabinet.setUpdateTime(DateTimeUtil.getCurrentDateTime()); cabinet.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return this.save(cabinet); boolean result = save(cabinet);
LambdaQueryWrapper<Cabinet> wrapper3 = CabinetWrapper(req);
wrapper3.eq(ObjectUtil.isNotEmpty(ObjectUtil.isNotEmpty(req.getCabinetNum())), Cabinet::getCabinetNum, req.getCabinetNum())
.eq(ObjectUtil.isNotEmpty(ObjectUtil.isNotEmpty(req.getOrgId())), Cabinet::getOrgId, req.getOrgId())
.eq(ObjectUtil.isNotEmpty(ObjectUtil.isNotEmpty(req.getName())), Cabinet::getName, req.getName());
Cabinet one = getOne(wrapper3);
for (int i = 1; i <= req.getNum(); i++) {
CabinetBox cabinetBox = new CabinetBox();
cabinetBox.setCabinetId(one.getId());
cabinetBox.setState(1);
cabinetBox.setNum(i);
//保存
cabinetBoxService.save(cabinetBox);
} }
return result;
}
/** /**
* 删除单警柜 * 删除单警柜
*
* @param req * @param req
* @return * @return
*/ */
@Override @Override
public boolean deleteCabinet(CabinetReq req) { public boolean deleteCabinetInfo(CabinetReq req) {
this.removeById(req.getId()); //通过单警柜id查询出他的箱门数
return true; LambdaQueryWrapper<Cabinet> wrapper = CabinetWrapper(req)
.eq(ObjectUtil.isNotEmpty(req.getId()), Cabinet::getId, req.getId());
Cabinet cabinet = this.getOne(wrapper);
//如果查询不到单警柜抛出异常
if (ObjectUtil.isEmpty(cabinet)) {
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
//通过单警柜id循环遍历出并删除所有箱门信息
LambdaQueryWrapper<CabinetBox> eq = CabinetboxWrapper(req)
.eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getCabinetId, req.getId());
List<CabinetBox> list = cabinetBoxService.list(eq);
for (CabinetBox cabinetBox: list) {
cabinetBoxService.removeById(cabinetBox.getId());
}
//删除单警柜id
return this.removeById(cabinet.getId());
} }
/** /**
* 获取单警柜列表 * 获取单警柜列表
* @param req *通过机构id进行查询
* @param req 单警柜信息
* @param includeLowerLevel true:查询本级及下级 false:查询本级
* @return * @return
*/ */
@Override @Override
public List<Cabinet> getAllCabinet(CabinetReq req,String includeLowerLevel) { public List<Cabinet> getAllCabinetList(CabinetReq req, String includeLowerLevel) {
List<Cabinet> cabinets = new ArrayList<>();
//如果组织机构时浙江省公安厅
if (req.getOrgId().equals("1369509498032808905") && includeLowerLevel.equals("true")) {
cabinets = cabinetMapper.getAllCabinet();
return cabinets;
}
//分两种情况,如果说是本级及下级(全部)所有的单警柜信息,则incluLowerLevel为true,如果是查询本级的单警柜信息则为false
if (includeLowerLevel.equals("true") || includeLowerLevel.equals("false")) {
List<String> allOrgId = getAllOrgId(req, includeLowerLevel);
if (allOrgId.isEmpty()) {
//抛出组织机构不存在异常
throw new ServiceException(CabinetExceptionEnum.PUBORG_NOT_EXIST);
}
cabinets = getAllCabinetByOrg(allOrgId);
return cabinets;
} else {
//传递的数据是否正确,不正确抛异常(只接受true、false)
throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
}
}
return null; /**
* 通过单警柜id查询单个单警柜及其箱门信息
* @param req
* @return
*/
@Override
public Cabinet showOneCabinet(CabinetReq req) {
LambdaQueryWrapper<Cabinet> eq = CabinetWrapper(req)
.eq(ObjectUtil.isNotEmpty(req.getId()), Cabinet::getId, req.getId());
Cabinet one = getOne(eq);
if (ObjectUtil.isNull(one)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
LambdaQueryWrapper<CabinetBox> eq1 = CabinetboxWrapper(req)
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), CabinetBox::getCabinetId, req.getOrgId());
List<CabinetBox> list = cabinetBoxService.list(eq1);
one.setList(list);
return one;
} }
/** /**
* 修改单警柜信息 * 修改单警柜信息
* 新增箱数
* @param req * @param req
* @return * @return
*/ */
@Override @Override
public boolean updateCabinet(CabinetReq req) throws Exception { public boolean updateCabinetInfo(CabinetReq req) {
//查询传日的组织机构id是否存在 //查询传入的组织机构id是否存在
Long onePubOrg = pubOrgMapper.getOnePubOrg(req.getOrgId()); LambdaQueryWrapper<PubOrg> pubOrgwrapper = PubOrgWrapper(Long.parseLong(req.getOrgId()));
if(onePubOrg == null || onePubOrg.equals("")){ PubOrg puborg = pubOrgService.getOne(pubOrgwrapper);
throw new Exception("该组织机构不存在"); if (ObjectUtil.isEmpty(puborg)) {
} //抛出组织机构不存在异常
//查询是否有重复的cabinetNum throw new ServiceException(CabinetExceptionEnum.PUBORG_NOT_EXIST);
Map<String, Object> hashCabinetNum = cabinetMapper.getCabinetByCabinetNum(req.getCabinetNum());
//判断policeCode是否有变动
String oldCabinetNum = cabinetMapper.getCabinetNumById(req.getId());
if (oldCabinetNum!=null && !oldCabinetNum.equals(req.getCabinetNum())){
if (hashCabinetNum!=null){
throw new Exception("主柜编号重复");
} }
//查询是否有重复的单警柜编号
LambdaQueryWrapper<Cabinet> wrapper2 = CabinetWrapper(req);
wrapper2.eq(ObjectUtil.isNotEmpty(req.getCabinetNum()),Cabinet::getCabinetNum,req.getCabinetNum());
List<Cabinet> list = this.list(wrapper2);
if (list.size()>0) {
//抛出单警柜重复异常
throw new ServiceException(CabinetExceptionEnum.CABINETID_IS_EXISTS);
} }
Cabinet cabinet =new Cabinet(); Cabinet cabinet = new Cabinet();
BeanPlusUtil.copyProperties(req,cabinet); BeanPlusUtil.copyProperties(req, cabinet);
//如果新增箱门个数,那么对应的箱门表中也需要插入对应对应数量的箱门记录条数
LambdaQueryWrapper<Cabinet> eq = CabinetWrapper(req)
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), Cabinet::getOrgId, req.getOrgId())
.eq(ObjectUtil.isNotEmpty(req.getCabinetNum()), Cabinet::getCabinetNum, req.getCabinetNum());
Cabinet cabinet1 = this.getOne(eq);
Integer oldNum = cabinet1.getNum();
Integer totalBoxNum = cabinet1.getNum()+req.getNum();
//循环新增箱数信息
for (int i= oldNum+1;i<=totalBoxNum;i++){
CabinetBox cabinetBox = new CabinetBox();
//箱门id
String id = UUID.randomUUID().toString();
cabinetBox.setId(id);
cabinetBox.setCabinetId(req.getId());
cabinet.setState(1);
cabinetBox.setNum(i);
//保存
cabinetBoxService.save(cabinetBox);
}
//总箱门数就是原来的箱门数+新增的箱门数
cabinet.setNum(totalBoxNum);
return this.updateById(cabinet); return this.updateById(cabinet);
} }
/**
* 箱门绑定人员
* 箱门id-->人员
* @param req
* @return
*/
@Override
public boolean boxBindPolice(CabinetBoxReq req,String policeId) {
//通过箱门id查询出箱门信息
CabinetBox one = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getId, req.getId()));
if (ObjectUtil.isEmpty(one)){
//箱门id不存在
throw new ServiceException(CabinetExceptionEnum.CABINETBOX_ISNOT_EXISTS);
}
//获取箱门的主柜id
String cabinetId = one.getCabinetId();
//通过主柜id获取机构id
Cabinet one1 = getOne(new LambdaQueryWrapper<Cabinet>()
.eq(ObjectUtil.isNotEmpty(cabinetId), Cabinet::getId,cabinetId));
if (ObjectUtil.isEmpty(one1)){
//单警柜不存在异常
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
long orgId = one1.getOrgId();
//通过警员id获取警员所在的机构id
Policeman one2 = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(policeId), Policeman::getId, policeId));
if (ObjectUtil.isEmpty(one2)){
//警员不存在异常
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
Long orgId1 = one2.getOrgId();
//判断两个机构id是否相同,相同则可以绑定,不相同则绑定失败
if (!orgId1.equals(orgId)){
return false;
}
one2.setCabinetBoxId(one.getId());
return policemanService.save(one2);
}
//查询的各种条件信息 //查询的各种条件信息
private LambdaQueryWrapper<Cabinet> createWrapper(CabinetReq req) { //单警柜主柜查询条件
private LambdaQueryWrapper<Cabinet> CabinetWrapper(CabinetReq req) {
LambdaQueryWrapper<Cabinet> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Cabinet> wrapper = new LambdaQueryWrapper<>();
//查询全部
if (ObjectUtil.isEmpty(req)) { if (ObjectUtil.isEmpty(req)) {
return wrapper; return wrapper;
} }
//单警柜id return wrapper;
wrapper.like(ObjectUtil.isNotEmpty(req.getId()), Cabinet::getId, req.getId()); }
//模糊查询
//机构id //箱门的查询条件
wrapper.like(ObjectUtil.isNotEmpty(req.getOrgId()), Cabinet::getOrgId, req.getOrgId()); private LambdaQueryWrapper<CabinetBox> CabinetboxWrapper(CabinetReq req) {
wrapper.orderByDesc(Cabinet::getUpdateTime); LambdaQueryWrapper<CabinetBox> wrapper = new LambdaQueryWrapper<>();
//查询全部
if (ObjectUtil.isEmpty(req)) {
return wrapper;
}
return wrapper;
}
//查询机构id是否存在
private LambdaQueryWrapper<PubOrg> PubOrgWrapper(long orgId) {
LambdaQueryWrapper<PubOrg> wrapper = new LambdaQueryWrapper<>();
//查询全部
if (ObjectUtil.isEmpty(orgId)) {
return wrapper;
}
//查询机构id是否存在
wrapper.eq(ObjectUtil.isNotEmpty(orgId),PubOrg::getOrgId,orgId);
return wrapper; return wrapper;
} }
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import com.junmp.jyzb.mapper.EquipmentSizeMapper; import com.junmp.jyzb.mapper.EquipmentSizeMapper;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import static com.junmp.jyzb.utils.CheckBlank.checkNotBlank; import static com.junmp.jyzb.utils.CheckBlank.checkNotBlank;
...@@ -65,7 +66,7 @@ public class EquipmentSizeServiceImpl extends ServiceImpl<EquipmentSizeMapper, E ...@@ -65,7 +66,7 @@ public class EquipmentSizeServiceImpl extends ServiceImpl<EquipmentSizeMapper, E
size.setCode((String) msg.get("code")); size.setCode((String) msg.get("code"));
size.setName((String) msg.get("name")); size.setName((String) msg.get("name"));
size.setNote((String) msg.get("note")); size.setNote((String) msg.get("note"));
size.setPrice((Double) msg.get("price")); size.setPrice((BigDecimal) msg.get("price"));
size.setEpcType((Integer) msg.get("epcType")); size.setEpcType((Integer) msg.get("epcType"));
equipmentSizeMapper.addSize(size); equipmentSizeMapper.addSize(size);
...@@ -132,7 +133,7 @@ public class EquipmentSizeServiceImpl extends ServiceImpl<EquipmentSizeMapper, E ...@@ -132,7 +133,7 @@ public class EquipmentSizeServiceImpl extends ServiceImpl<EquipmentSizeMapper, E
size.setName((String) msg.get("name")); size.setName((String) msg.get("name"));
size.setNote((String) msg.get("note")); size.setNote((String) msg.get("note"));
size.setUpdateTime(currentDate); size.setUpdateTime(currentDate);
size.setPrice((Double) msg.get("price")); size.setPrice((BigDecimal) msg.get("price"));
//size.setState((Integer) msg.get("state")); //size.setState((Integer) msg.get("state"));
size.setEpcType((Integer) msg.get("epcType")); size.setEpcType((Integer) msg.get("epcType"));
equipmentSizeMapper.updateSize(size); equipmentSizeMapper.updateSize(size);
......
...@@ -4,13 +4,9 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -4,13 +4,9 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.req.ProductReq; import com.junmp.jyzb.api.bean.req.PolicemanFingerReq;
import com.junmp.jyzb.api.exception.enums.ProductExceptionEnum;
import com.junmp.jyzb.beanReq.PolicemanFingerReq;
import com.junmp.jyzb.entity.PoliceFinger; import com.junmp.jyzb.entity.PoliceFinger;
import com.junmp.jyzb.entity.Product;
import com.junmp.jyzb.exception.enums.PolicemanFingerExceptionEnum; import com.junmp.jyzb.exception.enums.PolicemanFingerExceptionEnum;
import com.junmp.jyzb.mapper.ProductMapper;
import com.junmp.jyzb.service.PoliceFingerService; import com.junmp.jyzb.service.PoliceFingerService;
import com.junmp.jyzb.utils.DateTimeUtil; import com.junmp.jyzb.utils.DateTimeUtil;
import com.junmp.v2.common.exception.base.ServiceException; import com.junmp.v2.common.exception.base.ServiceException;
...@@ -41,23 +37,36 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -41,23 +37,36 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
//新增指纹信息 //新增指纹信息
@Override @Override
public boolean addFingerInfo(PolicemanFingerReq req) { public boolean addFingerInfo(PolicemanFingerReq req) {
PoliceFinger policeFinger = new PoliceFinger(); PoliceFinger policeFinger = getOne(new LambdaQueryWrapper<PoliceFinger>()
BeanPlusUtil.copyProperties(req, policeFinger); .eq(ObjectUtil.isNotEmpty(req.getPoliceId()),PoliceFinger::getPoliceId,req.getPoliceId())
.eq(ObjectUtil.isNotEmpty(req.getFingerInfo()),PoliceFinger::getFingerInfo,req.getFingerInfo()));
//指纹信息存在抛出异常
if (ObjectUtil.isNotNull(policeFinger)) {
throw new ServiceException(PolicemanFingerExceptionEnum.POLICEMAN_FINGER_EXCEPTION_ENUM);
}
PoliceFinger policeFinger1=new PoliceFinger();
BeanPlusUtil.copyProperties(req, policeFinger1);
//创建时间 //创建时间
policeFinger.setCreateTime(DateTimeUtil.getCurrentDateTime()); policeFinger1.setCreateTime(DateTimeUtil.getCurrentDateTime());
//更新时间 //更新时间
policeFinger.setUpdateTime(DateTimeUtil.getCurrentDateTime()); policeFinger1.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return this.save(policeFinger);
return this.save(policeFinger1);
} }
//修改指纹信息 //修改指纹信息
@Override @Override
public boolean updateFingerInfo(PolicemanFingerReq req) { public boolean updateFingerInfo(PolicemanFingerReq req) {
PoliceFinger policeFinger = this.queryPolicemanFinger(req); PoliceFinger one = getOne(new LambdaQueryWrapper<PoliceFinger>()
BeanPlusUtil.copyProperties(req,policeFinger); .eq(ObjectUtil.isNotEmpty(req.getId()), PoliceFinger::getId, req.getId()));
//指纹id错误,指纹信息不存在
if (ObjectUtil.isNull(one)){
throw new ServiceException(PolicemanFingerExceptionEnum.POLICEMAN_FINGER_NOTEXISTS);
}
BeanPlusUtil.copyProperties(req,one);
//更新时间 //更新时间
policeFinger.setUpdateTime(DateTimeUtil.getCurrentDateTime()); one.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return this.updateById(policeFinger); return this.updateById(one);
} }
//查询指纹信息 //查询指纹信息
...@@ -87,15 +96,6 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -87,15 +96,6 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
return PageResultFactory.createPageResult(page); return PageResultFactory.createPageResult(page);
} }
//添加指纹时判断指纹是否存在,如果存在则抛出异常
//异常信息为:指纹信息已经存在
private PoliceFinger queryPolicemanFinger(PolicemanFingerReq req) {
PoliceFinger policeFinger = this.getById(req);
if (ObjectUtil.isNull(policeFinger)) {
throw new ServiceException(PolicemanFingerExceptionEnum.POLICEMAN_FINGER_EXCEPTION_ENUM);
}
return policeFinger;
}
//查询的各种条件信息 //查询的各种条件信息
private LambdaQueryWrapper<PoliceFinger> createWrapper(PolicemanFingerReq req) { private LambdaQueryWrapper<PoliceFinger> createWrapper(PolicemanFingerReq req) {
...@@ -105,7 +105,7 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -105,7 +105,7 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
} }
//根据业务编码查询 //根据业务编码查询
//警员id //警员id
wrapper.like(ObjectUtil.isNotEmpty(req.getPoliceId()), PoliceFinger::getPoliceId, req.getPoliceId()); wrapper.eq(ObjectUtil.isNotEmpty(req.getPoliceId()), PoliceFinger::getPoliceId, req.getPoliceId());
//根据企业名称模糊查询 //根据企业名称模糊查询
//指纹名称 //指纹名称
wrapper.like(ObjectUtil.isNotEmpty(req.getName()), PoliceFinger::getName, req.getName()); wrapper.like(ObjectUtil.isNotEmpty(req.getName()), PoliceFinger::getName, req.getName());
......
package com.junmp.jyzb.service.impl; package com.junmp.jyzb.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.req.CabinetReq;
import com.junmp.jyzb.api.bean.req.PolicemanReq;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.jyzb.entity.PoliceFinger; import com.junmp.jyzb.entity.PoliceFinger;
import com.junmp.jyzb.exception.enums.PolicemanExceptionEnum;
import com.junmp.jyzb.mapper.*; import com.junmp.jyzb.mapper.*;
import com.junmp.jyzb.service.CabinetService;
import com.junmp.jyzb.service.PolicemanService; import com.junmp.jyzb.service.PolicemanService;
import com.junmp.jyzb.service.PubOrgService; 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.util.BeanPlusUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -45,6 +53,12 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -45,6 +53,12 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Resource @Resource
private PubOrgService pubOrgService; private PubOrgService pubOrgService;
@Resource
private CabinetService cabinetService;
@Resource
private PolicemanService policemanService;
private static final String REDIS_POLICE = "Policeman_"; private static final String REDIS_POLICE = "Policeman_";
private static final String REDIS_ORG = "Organization_"; private static final String REDIS_ORG = "Organization_";
...@@ -97,7 +111,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -97,7 +111,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
police.setUpdateTime(currentDate); police.setUpdateTime(currentDate);
police.setId(uuid); police.setId(uuid);
police.setOrgId((String) policeman.get("orgId")); police.setOrgId((Long) policeman.get("orgId"));
police.setName((String) policeman.get("name")); police.setName((String) policeman.get("name"));
police.setPoliceCode((String) policeman.get("policeCode")); police.setPoliceCode((String) policeman.get("policeCode"));
police.setSex((String) policeman.get("sex")); police.setSex((String) policeman.get("sex"));
...@@ -263,7 +277,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -263,7 +277,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//police.setId(uuid); //police.setId(uuid);
String id = policeman.get("id").toString(); String id = policeman.get("id").toString();
police.setId(id); police.setId(id);
police.setOrgId((String) policeman.get("orgId")); police.setOrgId((Long) policeman.get("orgId"));
police.setName((String) policeman.get("name")); police.setName((String) policeman.get("name"));
police.setPoliceCode((String) policeman.get("policeCode")); police.setPoliceCode((String) policeman.get("policeCode"));
police.setSex((String) policeman.get("sex")); police.setSex((String) policeman.get("sex"));
...@@ -489,20 +503,19 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -489,20 +503,19 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
} }
@Override @Override
public ResponseResult addFaceInfo(Map<String, Object> msg) { public boolean addFaceInfo(PolicemanReq req) {
try { //面部信息为null或者为空
checkNotBlank(msg.get("policeId"), "policeId不能为空"); if (ObjectUtil.isNull(req.getFaceInfo()) || ObjectUtil.isEmpty(req.getFaceInfo())){
checkNotBlank(msg.get("faceInfo"), "faceInfo不能为空"); return false;
} catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage());
} }
Date currentDate = DateTimeUtil.getCurrentDateTime(); Policeman police = getOne(new LambdaQueryWrapper<Policeman>()
Policeman police =new Policeman(); .eq(ObjectUtil.isNotEmpty(req.getId()),Policeman::getId,req.getId()));
police.setId(msg.get("policeId").toString()); if (ObjectUtil.isNull(police)){
police.setFaceInfo(msg.get("faceInfo").toString()); throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
police.setUpdateTime(currentDate); }
policemanMapper.addFaceInfo(police); police.setFaceInfo(req.getFaceInfo());
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS); police.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return policemanService.updateById(police);
} }
@Override @Override
...@@ -696,23 +709,23 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -696,23 +709,23 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
/** /**
* @author lxh * @author lxh
* @description 更新人脸信息\删除人脸信息 * @description 更新人脸信息\删除人脸信息
* 删除时:传一个null的人脸信息即可
* @since 2023/7/18 15:02 * @since 2023/7/18 15:02
* @param * @param
* @return * @return
**/ **/
@Override @Override
public ResponseResult updateFaceInfo(Map<String, Object> msg) { public boolean updateFaceInfo(PolicemanReq req) {
try{ //警员id不能为空
checkNotBlank(msg.get("policeId"),"policeId不能为空"); if (ObjectUtil.isEmpty(req.getId()) || ObjectUtil.isNull(req.getId())){
}catch (IllegalArgumentException e){ return false;
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.ERROR,e.getMessage());
} }
Policeman police =new Policeman(); LambdaQueryWrapper<Policeman> eq = PolicemanWrapper(req)
police.setId(msg.get("policeId").toString()); .eq(ObjectUtil.isNotEmpty(req.getId()), Policeman::getId, req.getId());
police.setFaceInfo(msg.get("faceInfo").toString()); Policeman police = policemanService.getOne(eq);
police.setFaceInfo(req.getFaceInfo());
police.setUpdateTime(DateTimeUtil.getCurrentDateTime()); police.setUpdateTime(DateTimeUtil.getCurrentDateTime());
policemanMapper.updatePolice(police); return policemanService.updateById(police);
return new ResponseResult(HttpStatus.SUCCESS,ReturnMsg.PASS);
} }
...@@ -724,38 +737,45 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -724,38 +737,45 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
* @return * @return
**/ **/
@Override @Override
public ResponseResult searchFaceInfo(Map<String, Object> msg) { public Policeman searchFaceInfo(PolicemanReq req) {
//警员id不能为空 //警员id不能为空
try { if (ObjectUtil.isEmpty(req.getId()) || ObjectUtil.isNull(req.getId())){
checkNotBlank(msg.get("policeId"), "policeId不能为空"); return null;
} catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage());
} }
Policeman policeman = policemanMapper.selectOne(new LambdaQueryWrapper<Policeman>() LambdaQueryWrapper<Policeman> eq = PolicemanWrapper(req)
.eq(Policeman::getId, msg.get("policeId"))); .eq(ObjectUtil.isNotEmpty(req.getId()), Policeman::getId, req.getId());
return new ResponseResult(HttpStatus.SUCCESS,"操作成功",policeman); Policeman policeman = policemanService.getOne(eq);
if (ObjectUtil.isNull(policeman)){
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
return policeman;
} }
//通过单警柜获取组织机构id,再获取组织机构下的所有警员信息 //通过单警柜获取组织机构id,再获取组织机构下的所有警员信息
@Override @Override
public ResponseResult getOrgPoliceman(Map<String, Object> msg) { public List<Policeman> getOrgPoliceman(CabinetReq req) {
try {
checkNotBlank(msg.get("cabinetId"), "cabinetId不能为空");
} catch (IllegalArgumentException e) {
return new ResponseResult(HttpStatus.ERROR, ReturnMsg.ERROR,e.getMessage());
}
//通过警柜id获取组织机构id //通过警柜id获取组织机构id
Cabinet cabinet = cabinetMapper.selectOne(new LambdaQueryWrapper<Cabinet>() Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getId, msg.get("cabinetId"))); .eq(ObjectUtil.isNotEmpty(req.getId()),Cabinet::getId, req.getId()));
if (ObjectUtil.isNull(cabinet)){ if (ObjectUtil.isNull(cabinet)){
return new ResponseResult(HttpStatus.ERROR,ReturnMsg.NO_DATA,ReturnData.NO_DATA); return null;
} }
long orgId = cabinet.getOrgId(); long orgId = cabinet.getOrgId();
//通过机构id获取机构下所有的警员信息 //通过机构id获取机构下所有的警员信息
List<Policeman> policemenList = policemanMapper.selectList(new LambdaQueryWrapper<Policeman>() List<Policeman> policemenList = policemanService.list(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getOrgId, orgId)); .eq(Policeman::getOrgId, orgId));
return new ResponseResult<>(HttpStatus.SUCCESS,"操作成功",policemenList); return policemenList;
}
private LambdaQueryWrapper<Policeman> PolicemanWrapper(PolicemanReq req) {
LambdaQueryWrapper<Policeman> wrapper = new LambdaQueryWrapper<>();
//查询全部
if (ObjectUtil.isEmpty(req)) {
return wrapper;
}
return wrapper;
} }
} }
...@@ -253,7 +253,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -253,7 +253,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
@Override @Override
public List<String> getLowerOrg(String orgId) { public List<String> getLowerOrg(String orgId) {
//构建 Redis 缓存� //构建 Redis 缓存�
String redisKey = "showPubOrgList_"+orgId; String redisKey = "getLowerOrg";
// �Redis 中获取数� // �Redis 中获取数�
List<PubOrg> cachedData = redisUtils.findCachedData(redisKey); List<PubOrg> cachedData = redisUtils.findCachedData(redisKey);
...@@ -265,44 +265,52 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -265,44 +265,52 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
redisUtils.set(redisKey, menuList); redisUtils.set(redisKey, menuList);
} }
List<String> resultList = new ArrayList<>(); // 存储最终的菜单树结� List<String> resultList = new ArrayList<>(); // 存储最终的菜单树结果
Map<Long, List<String>> childrenMap = new HashMap<>(); // 存储每个菜单项的子菜单映� Map<String, List<String>> childrenMap = new HashMap<>(); // 存储每个菜单项的子菜单映射
resultList.add(orgId); //将自己加入到返回的List中
// 构建子菜单映射表 // 构建子菜单映射表
for (PubOrg menu : menuList) { for (PubOrg menu : menuList) {
String org = menu.getOrgId().toString(); String org = menu.getOrgId().toString();
if (!childrenMap.containsKey(menu.getOrgParentId())) { // 如果父菜单还不存在于映射表中 if (!childrenMap.containsKey(menu.getOrgParentId().toString())) { // 如果父菜单还不存在于映射表中
childrenMap.put(menu.getOrgParentId(), new ArrayList<>()); // 创建一个新的子菜单列表 childrenMap.put(menu.getOrgParentId().toString(), new ArrayList<>()); // 创建一个新的子菜单列表
} }
childrenMap.get(menu.getOrgParentId()).add(org); // 将当前菜单项放入对应的子菜单列表� childrenMap.get(menu.getOrgParentId().toString()).add(org); // 将当前菜单项放入对应的子菜单列表中
} }
BigInteger orgInfo = new BigInteger(orgId); // 获取顶级菜单的标识符 Long orgInfo = Long.valueOf(orgId);//获取输入的组织机构id信息
//Long orgInfo = new BigInteger(orgId); // 获取顶级菜单的标识符
// 获取顶级菜单 // 获取顶级菜单
List<String> topMenus = childrenMap.get(orgInfo); List<String> topMenus = childrenMap.get(orgId);
// 迭代构建菜单 // 迭代构建菜单
if (topMenus != null) { if (topMenus != null) {
Queue<String> queue = new LinkedList<>(); // 使用队列结构辅助构建菜单�
queue.addAll(topMenus); // 将当前顶级菜单项放入队列�
while (!queue.isEmpty()) { for (String topMenu : topMenus) {
String currentMenu = queue.poll(); // 取出队首的当前菜单项 Stack<String> stack = new Stack<>(); // 使用栈结构辅助构建菜单树
//Long currentMenuId = currentMenu; // 获取当前菜单项的标识� stack.push(topMenu); // 将当前顶级菜单项放入栈中
while (!stack.isEmpty()) {
String currentMenu = stack.pop(); // 取出队首的当前菜单项
//Long currentMenuId = currentMenu; // 获取当前菜单项的标识符
if (childrenMap.containsKey(currentMenu)) { // 如果当前菜单项有子菜单
List<String> children = childrenMap.get(currentMenu); // 获取子菜单列表
if (childrenMap.containsKey(currentMenu)) { // 如果当前菜单项有子菜� for (int i = children.size() - 1; i >= 0; i--) {
List<String> children = childrenMap.get(currentMenu); // 获取子菜单列� stack.push(children.get(i));
//currentMenu.put("children", children); // 将子菜单列表放入当前菜单项中�children"字段 }
queue.addAll(children); // 将子菜单项放入队列中
} }
resultList.add(currentMenu); // 将已经处理完的当前菜单项添加到结果列表中 resultList.add(currentMenu); // 将已经处理完的当前菜单项添加到结果列表中
} }
} }
//redisUtils.set(redisKey, resultList); }
return resultList; return resultList;
} }
......
...@@ -6,9 +6,8 @@ ...@@ -6,9 +6,8 @@
<!--@Table base_cabinet_box--> <!--@Table base_cabinet_box-->
<id column="id" jdbcType="VARCHAR" property="id" /> <id column="id" jdbcType="VARCHAR" property="id" />
<result column="cabinet_id" jdbcType="VARCHAR" property="cabinetId" /> <result column="cabinet_id" jdbcType="VARCHAR" property="cabinetId" />
<result column="police_id" jdbcType="VARCHAR" property="policeId" /> <result column="num" jdbcType="INTEGER" property="num" />
<result column="police_name" jdbcType="VARCHAR" property="policeName" /> <result column="state" jdbcType="INTEGER" property="state" />
<result column="error_state" jdbcType="INTEGER" property="errorState" />
<result column="error_msg" jdbcType="VARCHAR" property="errorMsg" /> <result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
<result column="log_map" jdbcType="VARCHAR" property="logMap" /> <result column="log_map" jdbcType="VARCHAR" property="logMap" />
</resultMap> </resultMap>
...@@ -34,4 +33,8 @@ ...@@ -34,4 +33,8 @@
from base_cabinet_box b from base_cabinet_box b
where b.id =#{cabinetBoxId} where b.id =#{cabinetBoxId}
</select> </select>
<select id="selectByIdCabinetBoxes" resultType="com.junmp.jyzb.entity.CabinetBox"
parameterType="java.lang.String">
select * from base_cabinet_box b where b.cabinet_id=#{id}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="createUser" column="create_user" /> <result property="createUser" column="create_user" />
<result property="updateUser" column="update_user" /> <result property="updateUser" column="update_user" />
<result property="num" column="num" />
<collection property="list" ofType="com.junmp.jyzb.entity.CabinetBox" column="cabinet_id"
select="com.junmp.jyzb.mapper.CabinetBoxMapper.selectById">
</collection>
</resultMap> </resultMap>
...@@ -60,7 +64,7 @@ ...@@ -60,7 +64,7 @@
where p.id =#{id} where p.id =#{id}
</update> </update>
<select id="getAllCabinet" resultType="Map"> <select id="getAllCabinet" >
select select
c.id, c.id,
c.cabinet_num as cabinetNum, c.cabinet_num as cabinetNum,
...@@ -75,6 +79,7 @@ ...@@ -75,6 +79,7 @@
c.out_sum as outSum c.out_sum as outSum
from base_cabinet c from base_cabinet c
left join pub_org o on c.org_id_int =o.org_id left join pub_org o on c.org_id_int =o.org_id
</select> </select>
<select id="getAllCabinetId" resultType="String"> <select id="getAllCabinetId" resultType="String">
...@@ -130,8 +135,28 @@ ...@@ -130,8 +135,28 @@
#{item} #{item}
</foreach> </foreach>
</select> </select>
<select id="getAllCabinetList" resultType="com.junmp.jyzb.entity.Cabinet">
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 in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<update id="setCabinetSumInventory"> <update id="setCabinetSumInventory">
UPDATE base_cabinet AS c UPDATE base_cabinet AS c
SET sum = ( SET sum = (
SELECT count(i.id) SELECT count(i.id)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论