Commit 73ce52ca by 李小惠

修改单警柜,仓库,警员错误信息

parent af146aa8
...@@ -41,7 +41,7 @@ public class CabinetReq extends BaseRequest { ...@@ -41,7 +41,7 @@ public class CabinetReq extends BaseRequest {
* 组织机构号 * 组织机构号
*/ */
@ApiModelProperty(value = "组织机构号") @ApiModelProperty(value = "组织机构号")
private String orgId; private Long orgId;
/** /**
* 位置信息 * 位置信息
......
...@@ -5,6 +5,7 @@ import lombok.Data; ...@@ -5,6 +5,7 @@ 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 java.util.Date; import java.util.Date;
@Data @Data
...@@ -16,9 +17,10 @@ public class PolicemanReq extends BaseRequest { ...@@ -16,9 +17,10 @@ public class PolicemanReq extends BaseRequest {
private String name; private String name;
@NotBlank(message = "箱门id不能为空", groups = {edit.class, delete.class, detail.class}) @NotBlank(message = "箱门id不能为空", groups = {edit.class, delete.class})
private String cabinetBoxId; private String cabinetBoxId;
@NotNull(message = "组织机构id不能为空",groups = {})
private Long orgId; private Long orgId;
private Long departmentId; private Long departmentId;
......
...@@ -43,9 +43,9 @@ public class UpdateCabinetReq extends BaseRequest { ...@@ -43,9 +43,9 @@ public class UpdateCabinetReq extends BaseRequest {
/** /**
* 组织机构号 * 组织机构号
*/ */
@NotBlank(message = "组织机构号不能为空", groups = {add.class,edit.class, detail.class}) @NotNull(message = "组织机构号不能为空", groups = {add.class,edit.class, detail.class})
@ApiModelProperty(value = "组织机构号") @ApiModelProperty(value = "组织机构号")
private String orgId; private Long orgId;
/** /**
* 位置信息 * 位置信息
......
...@@ -14,20 +14,20 @@ public class UpdatePolicemanReq extends BaseRequest { ...@@ -14,20 +14,20 @@ public class UpdatePolicemanReq extends BaseRequest {
@NotNull(message = "警员主键不能为空", groups = {add.class,edit.class, delete.class, detail.class}) @NotNull(message = "警员主键不能为空", groups = {add.class,edit.class, delete.class, detail.class})
private String id; private String id;
@NotNull(message = "警员名字不能为空", groups = {add.class,edit.class, delete.class, detail.class}) @NotNull(message = "警员名字不能为空", groups = {add.class,edit.class})
private String name; private String name;
private String cabinetBoxId; private String cabinetBoxId;
@NotNull(message = "组织机构id不能为空", groups = {add.class,edit.class, delete.class, detail.class}) @NotNull(message = "组织机构id不能为空", groups = {add.class,edit.class})
private Long orgId; private Long orgId;
private Long departmentId; private Long departmentId;
@NotNull(message = "警员编号不能为空", groups = {add.class,edit.class, delete.class, detail.class}) @NotNull(message = "警员编号不能为空", groups = {add.class,edit.class})
private String policeCode; private String policeCode;
@NotNull(message = "性别不能为空", groups = {add.class,edit.class, delete.class, detail.class}) @NotNull(message = "性别不能为空", groups = {add.class,edit.class})
private String sex; private String sex;
private String faceInfo; private String faceInfo;
...@@ -38,7 +38,7 @@ public class UpdatePolicemanReq extends BaseRequest { ...@@ -38,7 +38,7 @@ public class UpdatePolicemanReq extends BaseRequest {
private String password; private String password;
@NotNull(message = "电话不能为空", groups = {add.class,edit.class, delete.class, detail.class}) @NotNull(message = "电话不能为空", groups = {add.class,edit.class})
private String photo; private String photo;
private String phone; private String phone;
...@@ -47,7 +47,7 @@ public class UpdatePolicemanReq extends BaseRequest { ...@@ -47,7 +47,7 @@ public class UpdatePolicemanReq extends BaseRequest {
private Date updateTime; private Date updateTime;
@NotNull(message = "身份证号不能为空", groups = {add.class,edit.class, delete.class, detail.class}) @NotNull(message = "身份证号不能为空", groups = {add.class,edit.class})
private String idCard; private String idCard;
private String updateUser; private String updateUser;
......
...@@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@Slf4j @Slf4j
...@@ -35,6 +34,13 @@ public class CabinetController { ...@@ -35,6 +34,13 @@ public class CabinetController {
private CabinetBoxService cabinetBoxService; private CabinetBoxService cabinetBoxService;
@PostMapping("/AddCabinetInfo")
@ApiOperation("添加单警柜信息")
public ApiRes<String> addCabinetInfo(@RequestBody @Validated(ValidationApi.add.class) UpdateCabinetReq req){
String cabinetId = cabinetService.addCabinetInfo(req);
return ApiRes.success(cabinetId);
}
@PostMapping("/ErrorState") @PostMapping("/ErrorState")
@ApiOperation("单警柜状态变更") @ApiOperation("单警柜状态变更")
public ApiRes<Boolean> ChangeCabinetState(@RequestBody UpdateCabinetReq req) { public ApiRes<Boolean> ChangeCabinetState(@RequestBody UpdateCabinetReq req) {
...@@ -45,12 +51,6 @@ public class CabinetController { ...@@ -45,12 +51,6 @@ public class CabinetController {
return ApiRes.success(result); return ApiRes.success(result);
} }
@PostMapping("/AddCabinetInfo")
@ApiOperation("添加单警柜信息")
public ApiRes<String> addCabinetInfo(@RequestBody @Validated(ValidationApi.add.class) UpdateCabinetReq req){
String cabinetId = cabinetService.addCabinetInfo(req);
return ApiRes.success(cabinetId);
}
@PostMapping("/DeleteCabinetInfo") @PostMapping("/DeleteCabinetInfo")
@ApiOperation("删除单警柜信息") @ApiOperation("删除单警柜信息")
...@@ -73,11 +73,12 @@ public class CabinetController { ...@@ -73,11 +73,12 @@ public class CabinetController {
//通过单警柜id查询单个箱门及其箱门信息 //通过单警柜id查询单个箱门及其箱门信息
@PostMapping("/ShowOneCabinet") @PostMapping("/ShowOneCabinet")
@ApiOperation("查询单个单警柜及其箱门信息") @ApiOperation("查询单个单警柜及其箱门信息")
public ApiRes<CabinetDto> showOneCabinet(@RequestBody CabinetReq req){ public ApiRes<CabinetDto> showOneCabinet(@RequestBody @Validated(ValidationApi.detail.class) CabinetReq req){
return ApiRes.success(cabinetService.showOneCabinet(req)); return ApiRes.success(cabinetService.showOneCabinet(req));
} }
//根据组织机构id查询出单警柜的详细信息
@PostMapping("/ShowCabinetList") @PostMapping("/ShowCabinetList")
@ApiOperation("查询单警柜列表") @ApiOperation("查询单警柜列表")
public ApiRes<List<CabinetDto>> showCabinetList(@RequestBody CabinetReq req){ public ApiRes<List<CabinetDto>> showCabinetList(@RequestBody CabinetReq req){
...@@ -108,8 +109,8 @@ public class CabinetController { ...@@ -108,8 +109,8 @@ public class CabinetController {
@PostMapping("/SearchOrgId") @PostMapping("/SearchOrgId")
@ApiOperation("/根据单警柜id查询组织机构id") @ApiOperation("/根据单警柜id查询组织机构id")
public ApiRes<Long> SearchOrgId(String id){ public ApiRes<Long> SearchOrgId(@RequestBody @Validated(ValidationApi.detail.class) CabinetReq req){
return ApiRes.success(cabinetService.SearchOrgId(id)); return ApiRes.success(cabinetService.SearchOrgId(req));
} }
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.junmp.jyzb.controller; ...@@ -3,6 +3,7 @@ package com.junmp.jyzb.controller;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.junmp.jyzb.api.bean.dto.PoliceDto; import com.junmp.jyzb.api.bean.dto.PoliceDto;
import com.junmp.jyzb.api.bean.dto.PolicemanDto; import com.junmp.jyzb.api.bean.dto.PolicemanDto;
import com.junmp.jyzb.api.bean.query.CabinetReq;
import com.junmp.jyzb.api.bean.query.PolicemanReq; import com.junmp.jyzb.api.bean.query.PolicemanReq;
import com.junmp.jyzb.api.bean.req.UpdatePolicemanReq; import com.junmp.jyzb.api.bean.req.UpdatePolicemanReq;
import com.junmp.jyzb.entity.Policeman; import com.junmp.jyzb.entity.Policeman;
...@@ -37,7 +38,7 @@ public class PoliceController { ...@@ -37,7 +38,7 @@ public class PoliceController {
@PostMapping("/DeletePolice") @PostMapping("/DeletePolice")
@ApiOperation("删除警员信息") @ApiOperation("删除警员信息")
public ApiRes<Boolean> DeletePolice(@RequestBody UpdatePolicemanReq req) { public ApiRes<Boolean> DeletePolice(@RequestBody @Validated(ValidationApi.delete.class) UpdatePolicemanReq req) {
boolean b = policemanService.DeletePolice(req); boolean b = policemanService.DeletePolice(req);
if (!b){ if (!b){
return ApiRes.failure("删除失败"); return ApiRes.failure("删除失败");
...@@ -71,8 +72,8 @@ public class PoliceController { ...@@ -71,8 +72,8 @@ public class PoliceController {
//根据组织机构id查询,只查询本级,不包含下级 //根据组织机构id查询,只查询本级,不包含下级
@PostMapping("/ShowPoliceList") @PostMapping("/ShowPoliceList")
@ApiOperation("查询某个组织机构下的所有警员信息") @ApiOperation("查询某个组织机构下的所有警员信息")
public ApiRes<PoliceDto> GetAllPolicemanList(Long orgId){ public ApiRes<PoliceDto> GetAllPolicemanList(PolicemanReq req){
PoliceDto policeDto = policemanService.GetAllPolicemanList(orgId); PoliceDto policeDto = policemanService.GetAllPolicemanList(req.getOrgId());
return ApiRes.success(policeDto); return ApiRes.success(policeDto);
} }
...@@ -85,7 +86,7 @@ public class PoliceController { ...@@ -85,7 +86,7 @@ public class PoliceController {
*/ */
@PostMapping("/GetPoliceDetail") @PostMapping("/GetPoliceDetail")
@ApiOperation("查询单个警员信息") @ApiOperation("查询单个警员信息")
public ApiRes<PolicemanDto> GetOnePolice(@RequestBody PolicemanReq req) { public ApiRes<PolicemanDto> GetOnePolice(@RequestBody @Validated(ValidationApi.detail.class) PolicemanReq req) {
return ApiRes.success(policemanService.GetOnePolice(req)); return ApiRes.success(policemanService.GetOnePolice(req));
} }
...@@ -97,9 +98,9 @@ public class PoliceController { ...@@ -97,9 +98,9 @@ public class PoliceController {
*/ */
@PostMapping("/GetPoliceData") @PostMapping("/GetPoliceData")
@ApiOperation("查询与单警柜绑定的警员信息") //根据单警柜id查询 @ApiOperation("查询与单警柜绑定的警员信息") //根据单警柜id查询
public ApiRes<PoliceDto> GetPoliceData(String id){ public ApiRes<PoliceDto> GetPoliceData(CabinetReq req){
//获取该组织机构下所有警员的id //获取该组织机构下所有警员的id
PoliceDto policeDto = policemanService.GetPoliceData(id); PoliceDto policeDto = policemanService.GetPoliceData(req.getId());
return ApiRes.success(policeDto); return ApiRes.success(policeDto);
} }
...@@ -115,7 +116,7 @@ public class PoliceController { ...@@ -115,7 +116,7 @@ public class PoliceController {
@PostMapping("/AddFaceInfo") @PostMapping("/AddFaceInfo")
@ApiOperation("添加警员面部信息") @ApiOperation("添加警员面部信息")
public ApiRes<Boolean> AddFaceInfo(@RequestBody UpdatePolicemanReq req) { public ApiRes<Boolean> AddFaceInfo(@RequestBody @Validated(ValidationApi.detail.class) UpdatePolicemanReq req) {
boolean b = policemanService.AddFaceInfo(req); boolean b = policemanService.AddFaceInfo(req);
if (!b){ if (!b){
return ApiRes.failure("添加失败"); return ApiRes.failure("添加失败");
...@@ -125,7 +126,7 @@ public class PoliceController { ...@@ -125,7 +126,7 @@ public class PoliceController {
@PostMapping("/UpdateFaceInfo") @PostMapping("/UpdateFaceInfo")
@ApiOperation("修改、删除人脸信息") @ApiOperation("修改、删除人脸信息")
public ApiRes<Boolean> UpdateFaceInfo(@RequestBody UpdatePolicemanReq req) { public ApiRes<Boolean> UpdateFaceInfo(@RequestBody @Validated(ValidationApi.detail.class) UpdatePolicemanReq req) {
boolean b = policemanService.UpdateFaceInfo(req); boolean b = policemanService.UpdateFaceInfo(req);
if (!b){ if (!b){
return ApiRes.failure("操作失败"); return ApiRes.failure("操作失败");
...@@ -135,7 +136,7 @@ public class PoliceController { ...@@ -135,7 +136,7 @@ public class PoliceController {
@PostMapping("/SearchFaceInfo") @PostMapping("/SearchFaceInfo")
@ApiOperation("查找人脸信息") @ApiOperation("查找人脸信息")
public ApiRes<Policeman> SearchFaceInfo(@RequestBody PolicemanReq req) { public ApiRes<Policeman> SearchFaceInfo(@RequestBody @Validated(ValidationApi.detail.class) PolicemanReq req) {
Policeman policeman = policemanService.SearchFaceInfo(req); Policeman policeman = policemanService.SearchFaceInfo(req);
if (ObjectUtil.isEmpty(policeman)){ if (ObjectUtil.isEmpty(policeman)){
return ApiRes.failure("未找到警员信息"); return ApiRes.failure("未找到警员信息");
......
...@@ -28,7 +28,7 @@ public class PolicemanFingerController implements PolicemanFingerDoc { ...@@ -28,7 +28,7 @@ public class PolicemanFingerController implements PolicemanFingerDoc {
@PostMapping("/AddFingerInfo") @PostMapping("/AddFingerInfo")
@ApiOperation("添加指纹信息") @ApiOperation("添加指纹信息")
public ApiRes<Boolean> addFingerInfo(@RequestBody @Validated(ValidationApi.add.class) UpdatePoliceFingerReq req) { public ApiRes<Integer> addFingerInfo(@RequestBody @Validated(ValidationApi.add.class) UpdatePoliceFingerReq req) {
return ApiRes.success(policeFingerService.addFingerInfo(req)) ; return ApiRes.success(policeFingerService.addFingerInfo(req)) ;
} }
......
...@@ -14,7 +14,7 @@ import java.util.List; ...@@ -14,7 +14,7 @@ import java.util.List;
@Api(value = "警员指纹管理",tags = "警员指纹管理接口") @Api(value = "警员指纹管理",tags = "警员指纹管理接口")
public interface PolicemanFingerDoc { public interface PolicemanFingerDoc {
@ApiOperation(value = "添加指纹信息", tags = "警员指纹管理接口") @ApiOperation(value = "添加指纹信息", tags = "警员指纹管理接口")
ApiRes<Boolean> addFingerInfo(UpdatePoliceFingerReq req); ApiRes<Integer> addFingerInfo(UpdatePoliceFingerReq req);
@ApiOperation(value = "修改指纹信息", tags = "警员指纹管理接口") @ApiOperation(value = "修改指纹信息", tags = "警员指纹管理接口")
ApiRes<Boolean> updateFingerInfo(UpdatePoliceFingerReq req); ApiRes<Boolean> updateFingerInfo(UpdatePoliceFingerReq req);
......
...@@ -20,6 +20,7 @@ public class User implements Serializable { ...@@ -20,6 +20,7 @@ public class User implements Serializable {
@TableField(value = "real_name") @TableField(value = "real_name")
private String realName; private String realName;
private String nickName; private String nickName;
private String account; private String account;
private String password; private String password;
......
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
@Mapper @Mapper
public interface CabinetMapper extends BaseMapper<Cabinet> { public interface CabinetMapper extends BaseMapper<Cabinet> {
List<Cabinet> getAllCabinetByOrgList(@Param("allOrgId") List<String> allOrgId); List<Cabinet> getAllCabinetByOrgList(@Param("allOrgId") List<Long> allOrgId);
......
...@@ -68,5 +68,10 @@ public interface CabinetService extends IService<Cabinet> { ...@@ -68,5 +68,10 @@ public interface CabinetService extends IService<Cabinet> {
*/ */
boolean ChangeCabinetState(UpdateCabinetReq req); boolean ChangeCabinetState(UpdateCabinetReq req);
Long SearchOrgId(String id); //根据单警柜id查询出组织机构id
Long SearchOrgId(CabinetReq req);
//判断单警柜是否存在
Cabinet CabinetExist(String id);
} }
...@@ -17,7 +17,7 @@ public interface PoliceFingerService extends IService<PoliceFinger> { ...@@ -17,7 +17,7 @@ public interface PoliceFingerService extends IService<PoliceFinger> {
* @param req * @param req
* @return * @return
*/ */
boolean addFingerInfo(UpdatePoliceFingerReq req); Integer addFingerInfo(UpdatePoliceFingerReq req);
/** /**
* 更新指纹信息 * 更新指纹信息
......
...@@ -50,4 +50,6 @@ public interface PolicemanService extends IService<Policeman> { ...@@ -50,4 +50,6 @@ public interface PolicemanService extends IService<Policeman> {
boolean PoliceBindBox(PolicemanReq req); boolean PoliceBindBox(PolicemanReq req);
//判断警员信息是否存在
Policeman PoliceExist(String policeId);
} }
...@@ -16,7 +16,7 @@ public interface PubOrgService extends IService<PubOrg> { ...@@ -16,7 +16,7 @@ public interface PubOrgService extends IService<PubOrg> {
ResponseResult setShortName(Map<String, Object> orgId); ResponseResult setShortName(Map<String, Object> orgId);
List<String> getLowerOrg(String orgId); List<Long> getLowerOrg(Long orgId);
ResponseResult setOrgParentIds(); ResponseResult setOrgParentIds();
...@@ -25,4 +25,7 @@ public interface PubOrgService extends IService<PubOrg> { ...@@ -25,4 +25,7 @@ public interface PubOrgService extends IService<PubOrg> {
Boolean ChangeState(UpdateOrgReq req); Boolean ChangeState(UpdateOrgReq req);
//根据组织机构id查询出组织机构是否存在
PubOrg PubOrgExist(Long id);
} }
...@@ -44,4 +44,7 @@ public interface WarehouseService extends IService<Warehouse> { ...@@ -44,4 +44,7 @@ public interface WarehouseService extends IService<Warehouse> {
ResponseResult setWarehouseInventory(Map<String, Object> msg); ResponseResult setWarehouseInventory(Map<String, Object> msg);
//通过仓库id 判断仓库是否存在
Warehouse WarehoustExist(String id);
} }
...@@ -26,8 +26,6 @@ import java.util.Map; ...@@ -26,8 +26,6 @@ import java.util.Map;
@Service @Service
public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, CabinetBox> implements CabinetBoxService { public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, CabinetBox> implements CabinetBoxService {
@Resource
private CabinetBoxMapper cabinetBoxMapper;
@Resource @Resource
private CabinetService cabinetService; private CabinetService cabinetService;
...@@ -51,11 +49,6 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet ...@@ -51,11 +49,6 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean AddBoxInfo(UpdateCabinetBoxReq req) { public boolean AddBoxInfo(UpdateCabinetBoxReq req) {
CabinetBox one = this.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getId, req.getId()));
if (ObjectUtil.isNotNull(one)){
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_IS_EXISTS);
}
CabinetBox cabinetBox = new CabinetBox(); CabinetBox cabinetBox = new CabinetBox();
BeanPlusUtil.copyProperties(req,cabinetBox); BeanPlusUtil.copyProperties(req,cabinetBox);
//添加单警柜箱门信息默认状态为1 //添加单警柜箱门信息默认状态为1
......
...@@ -31,7 +31,6 @@ import javax.annotation.Resource; ...@@ -31,7 +31,6 @@ import javax.annotation.Resource;
import java.util.*; import java.util.*;
import static com.junmp.jyzb.utils.CheckBlank.checkNotBlank;
@Service @Service
public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> implements CabinetService { public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> implements CabinetService {
...@@ -49,8 +48,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -49,8 +48,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
private PolicemanService policemanService; private PolicemanService policemanService;
private List<String> getAllOrgId(CabinetReq req, String includeLowerLevel) { private List<Long> getAllOrgId(CabinetReq req, String includeLowerLevel) {
List<String> allOrg = new ArrayList<>(); List<Long> allOrg = new ArrayList<>();
if (includeLowerLevel.equals("false")) { if (includeLowerLevel.equals("false")) {
allOrg.add(req.getOrgId()); allOrg.add(req.getOrgId());
} else if (includeLowerLevel.equals("true")) { } else if (includeLowerLevel.equals("true")) {
...@@ -60,7 +59,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -60,7 +59,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
return allOrg; return allOrg;
} }
private List<Cabinet> getAllCabinetByOrg( List<String> allOrgId) { private List<Cabinet> getAllCabinetByOrg( List<Long> allOrgId) {
List<Cabinet> allCabinet = new ArrayList<>(); List<Cabinet> allCabinet = new ArrayList<>();
allCabinet = cabinetMapper.getAllCabinetByOrgList(allOrgId); allCabinet = cabinetMapper.getAllCabinetByOrgList(allOrgId);
return allCabinet; return allCabinet;
...@@ -97,12 +96,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -97,12 +96,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
public String addCabinetInfo(UpdateCabinetReq req) { public String addCabinetInfo(UpdateCabinetReq req) {
Cabinet cabinet = new Cabinet(); Cabinet cabinet = new Cabinet();
//查询传入的组织机构id是否存在 //查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>() pubOrgService.PubOrgExist(req.getOrgId());
.eq(ObjectUtil.isNotEmpty(req.getOrgId()),PubOrg::getOrgId,req.getOrgId()));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
}
//查询是否有重复的单警柜编号 //查询是否有重复的单警柜编号
List<Cabinet> list = this.list(new LambdaQueryWrapper<Cabinet>() List<Cabinet> list = this.list(new LambdaQueryWrapper<Cabinet>()
.eq(ObjectUtil.isNotEmpty(req.getCabinetNum()),Cabinet::getCabinetNum,req.getCabinetNum())); .eq(ObjectUtil.isNotEmpty(req.getCabinetNum()),Cabinet::getCabinetNum,req.getCabinetNum()));
...@@ -151,12 +145,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -151,12 +145,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
//遍历单警柜id列表 //遍历单警柜id列表
for (String id:cabinetIdList) { for (String id:cabinetIdList) {
//通过单警柜id查询出他的箱门数 //通过单警柜id查询出他的箱门数
Cabinet cabinet = this.getOne(new LambdaQueryWrapper<Cabinet>() Cabinet cabinet = CabinetExist(id);
.eq(ObjectUtil.isNotEmpty(id), Cabinet::getId,id));
//如果查询不到单警柜抛出异常
if (ObjectUtil.isEmpty(cabinet)) {
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
//查询出单警柜之后添加到列表中 //查询出单警柜之后添加到列表中
cabinetList.add(cabinet); cabinetList.add(cabinet);
//通过单警柜id循环遍历出并删除所有箱门信息 //通过单警柜id循环遍历出并删除所有箱门信息
...@@ -197,6 +186,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -197,6 +186,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
*/ */
@Override @Override
public List<CabinetDto> getAllCabinetList(CabinetReq req) { public List<CabinetDto> getAllCabinetList(CabinetReq req) {
//判断组织机构是否存在
pubOrgService.PubOrgExist(req.getOrgId());
List<Cabinet> cabinets = new ArrayList<>(); List<Cabinet> cabinets = new ArrayList<>();
List<CabinetDto> cabinetList=new ArrayList<>(); List<CabinetDto> cabinetList=new ArrayList<>();
List<CabinetBoxDto> cabinetBoxList=new ArrayList<>(); List<CabinetBoxDto> cabinetBoxList=new ArrayList<>();
...@@ -222,7 +213,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -222,7 +213,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
} }
//分两种情况,如果说是本级及下级(全部)所有的单警柜信息,则incluLowerLevel为true,如果是查询本级的单警柜信息则为false //分两种情况,如果说是本级及下级(全部)所有的单警柜信息,则incluLowerLevel为true,如果是查询本级的单警柜信息则为false
if (req.getIncludeLowerLevel().equals("true") || req.getIncludeLowerLevel().equals("false")) { if (req.getIncludeLowerLevel().equals("true") || req.getIncludeLowerLevel().equals("false")) {
List<String> allOrgId = getAllOrgId(req, req.getIncludeLowerLevel()); List<Long> allOrgId = getAllOrgId(req, req.getIncludeLowerLevel());
if (allOrgId.size()==0) { if (allOrgId.size()==0) {
//抛出组织机构不存在异常 //抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST); throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
...@@ -259,11 +250,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -259,11 +250,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Override @Override
public CabinetDto showOneCabinet(CabinetReq req) { public CabinetDto showOneCabinet(CabinetReq req) {
//查询单警柜信息 //查询单警柜信息
Cabinet one = getOne(new LambdaQueryWrapper<Cabinet>() Cabinet cabinet = CabinetExist(req.getId());
.eq(ObjectUtil.isNotEmpty(req.getId()), Cabinet::getId, req.getId()));
if (ObjectUtil.isNull(one)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
//查询单警柜的箱门信息 //查询单警柜的箱门信息
List<CabinetBox> list = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>() List<CabinetBox> list = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>()
.eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getCabinetId, req.getId())); .eq(ObjectUtil.isNotEmpty(req.getId()), CabinetBox::getCabinetId, req.getId()));
...@@ -275,7 +262,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -275,7 +262,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
} }
//将单警柜的信息和它的箱门信息返回 //将单警柜的信息和它的箱门信息返回
CabinetDto cabinetDto = new CabinetDto(); CabinetDto cabinetDto = new CabinetDto();
BeanPlusUtil.copyProperties(one,cabinetDto); BeanPlusUtil.copyProperties(cabinet,cabinetDto);
cabinetDto.setCabinetBoxList(boxList); cabinetDto.setCabinetBoxList(boxList);
return cabinetDto; return cabinetDto;
} }
...@@ -289,15 +276,10 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -289,15 +276,10 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Override @Override
public boolean updateCabinetInfo(UpdateCabinetReq req) { public boolean updateCabinetInfo(UpdateCabinetReq req) {
//查询传入的组织机构id是否存在 //查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>() pubOrgService.PubOrgExist(req.getOrgId());
.eq(ObjectUtil.isNotEmpty(req.getOrgId()),PubOrg::getOrgId,req.getOrgId()));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
}
//查询是否有重复的单警柜编号 //查询是否有重复的单警柜编号
List<Cabinet> list = this.list(new LambdaQueryWrapper<Cabinet>() List<Cabinet> list = this.list(new LambdaQueryWrapper<Cabinet>()
.eq(ObjectUtil.isNotEmpty(req.getCabinetNum()),Cabinet::getCabinetNum,req.getCabinetNum())); .eq(Cabinet::getCabinetNum,req.getCabinetNum()));
if (list.size()>0) { if (list.size()>0) {
//判断是否是本身,如果是则不抛出异常(根据单警柜id进行比较) //判断是否是本身,如果是则不抛出异常(根据单警柜id进行比较)
Cabinet cabinet = list.get(0); Cabinet cabinet = list.get(0);
...@@ -363,11 +345,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -363,11 +345,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean ChangeCabinetState(UpdateCabinetReq req) { public boolean ChangeCabinetState(UpdateCabinetReq req) {
//查询单警柜是否存在 //查询单警柜是否存在
Cabinet cabinet = getOne(new LambdaQueryWrapper<Cabinet>() CabinetExist(req.getId());
.eq(Cabinet::getId, req.getId()));
if (ObjectUtil.isNull(cabinet)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
List<UpdateCabinetBoxReq> cabinetBoxList = req.getCabinetBoxList(); List<UpdateCabinetBoxReq> cabinetBoxList = req.getCabinetBoxList();
List<CabinetBox> list =new ArrayList<>(); List<CabinetBox> list =new ArrayList<>();
for (UpdateCabinetBoxReq updateCabinet:cabinetBoxList) { for (UpdateCabinetBoxReq updateCabinet:cabinetBoxList) {
...@@ -378,25 +356,21 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -378,25 +356,21 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
return cabinetBoxService.updateBatchById(list); return cabinetBoxService.updateBatchById(list);
} }
//根据单警柜id查询出组织机构id
@Override @Override
public Long SearchOrgId(String id) { public Long SearchOrgId(CabinetReq req) {
Cabinet cabinet = CabinetExist(req.getId());
return cabinet.getOrgId();
}
//根据单警柜id判断单警柜是否存在
@Override
public Cabinet CabinetExist(String id) {
Cabinet one = getOne(new LambdaQueryWrapper<Cabinet>().eq(Cabinet::getId, id)); Cabinet one = getOne(new LambdaQueryWrapper<Cabinet>().eq(Cabinet::getId, id));
if (ObjectUtil.isNull(one)){ if (ObjectUtil.isNull(one)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS); throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
} }
return one.getOrgId(); return one;
} }
//查询机构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;
}
} }
\ No newline at end of file
...@@ -35,10 +35,9 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -35,10 +35,9 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
//新增指纹信息 //新增指纹信息
@Override @Override
public boolean addFingerInfo(UpdatePoliceFingerReq req) { public Integer addFingerInfo(UpdatePoliceFingerReq req) {
//判断警员是否存在 //判断警员是否存在
PoliceExist(req.getPoliceId()); policemanService.PoliceExist(req.getPoliceId());
PoliceFinger policeFinger = getOne(new LambdaQueryWrapper<PoliceFinger>() PoliceFinger policeFinger = getOne(new LambdaQueryWrapper<PoliceFinger>()
.eq(ObjectUtil.isNotEmpty(req.getPoliceId()),PoliceFinger::getPoliceId,req.getPoliceId()) .eq(ObjectUtil.isNotEmpty(req.getPoliceId()),PoliceFinger::getPoliceId,req.getPoliceId())
.eq(ObjectUtil.isNotEmpty(req.getFingerInfo()),PoliceFinger::getFingerInfo,req.getFingerInfo())); .eq(ObjectUtil.isNotEmpty(req.getFingerInfo()),PoliceFinger::getFingerInfo,req.getFingerInfo()));
...@@ -48,7 +47,8 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -48,7 +47,8 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
} }
PoliceFinger policeFinger1=new PoliceFinger(); PoliceFinger policeFinger1=new PoliceFinger();
BeanPlusUtil.copyProperties(req, policeFinger1); BeanPlusUtil.copyProperties(req, policeFinger1);
return this.save(policeFinger1); save(policeFinger1);
return policeFinger1.getId();
} }
//修改指纹信息 //修改指纹信息
...@@ -62,6 +62,7 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -62,6 +62,7 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
//查询指纹信息 //查询指纹信息
@Override @Override
public List<PoliceFinger> searchFingerInfo(PolicemanFingerReq req) { public List<PoliceFinger> searchFingerInfo(PolicemanFingerReq req) {
policemanService.PoliceExist(req.getPoliceId());
LambdaQueryWrapper<PoliceFinger> wrapper = createWrapper(req); LambdaQueryWrapper<PoliceFinger> wrapper = createWrapper(req);
return this.list(wrapper); return this.list(wrapper);
} }
...@@ -71,7 +72,7 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -71,7 +72,7 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
@Override @Override
public boolean deleteFinger(UpdatePoliceFingerReq req) { public boolean deleteFinger(UpdatePoliceFingerReq req) {
//判断警员是否存在 //判断警员是否存在
PoliceExist(req.getPoliceId()); policemanService.PoliceExist(req.getPoliceId());
PoliceFinger policeFinger = PolicemanFingerExist(req.getId(), req.getPoliceId()); PoliceFinger policeFinger = PolicemanFingerExist(req.getId(), req.getPoliceId());
return removeById(policeFinger); return removeById(policeFinger);
} }
...@@ -107,15 +108,6 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol ...@@ -107,15 +108,6 @@ public class PoliceFingerServiceImpl extends ServiceImpl<PoliceFingerMapper, Pol
return wrapper; return wrapper;
} }
//判断警员是否存在
public boolean PoliceExist(String id){
Policeman one = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getId, id));
if (ObjectUtil.isNull(one)){
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
return true;
}
//判断指纹信息是否存在 //判断指纹信息是否存在
public PoliceFinger PolicemanFingerExist(Integer fingerId,String policeId){ public PoliceFinger PolicemanFingerExist(Integer fingerId,String policeId){
PoliceFinger one = getOne(new LambdaQueryWrapper<PoliceFinger>() PoliceFinger one = getOne(new LambdaQueryWrapper<PoliceFinger>()
......
...@@ -39,17 +39,6 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -39,17 +39,6 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Resource @Resource
private PolicemanMapper policemanMapper; private PolicemanMapper policemanMapper;
@Resource
private PoliceFingerMapper policeFingerMapper;
@Resource
private CabinetBoxMapper cabinetBoxMapper;
@Resource
private CabinetMapper cabinetMapper;
@Resource
private PubOrgMapper pubOrgMapper;
@Resource @Resource
private PubOrgService pubOrgService; private PubOrgService pubOrgService;
...@@ -58,9 +47,6 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -58,9 +47,6 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
private CabinetService cabinetService; private CabinetService cabinetService;
@Resource @Resource
private PolicemanService policemanService;
@Resource
private CabinetBoxService cabinetBoxService; private CabinetBoxService cabinetBoxService;
@Resource @Resource
...@@ -82,14 +68,9 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -82,14 +68,9 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Override @Override
public String AddPoliceman(UpdatePolicemanReq req) { public String AddPoliceman(UpdatePolicemanReq req) {
//查询传入的组织机构id是否存在 //查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>() pubOrgService.PubOrgExist(req.getOrgId());
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), PubOrg::getOrgId, req.getOrgId()));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
}
//查询是否有重复的policeCode //查询是否有重复的policeCode
List<Policeman> list = policemanService.list(new LambdaQueryWrapper<Policeman>() List<Policeman> list = list(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(req.getPoliceCode()), Policeman::getPoliceCode, req.getPoliceCode())); .eq(ObjectUtil.isNotEmpty(req.getPoliceCode()), Policeman::getPoliceCode, req.getPoliceCode()));
if (list.size() > 0) { if (list.size() > 0) {
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS); throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
...@@ -97,7 +78,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -97,7 +78,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
Policeman policeman = new Policeman(); Policeman policeman = new Policeman();
BeanPlusUtil.copyProperties(req, policeman); BeanPlusUtil.copyProperties(req, policeman);
//添加警员绑定用户信息 //添加警员绑定用户信息
policemanService.save(policeman); save(policeman);
return policeman.getId(); return policeman.getId();
} }
...@@ -143,11 +124,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -143,11 +124,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
*/ */
@Override @Override
public PolicemanDto GetOnePolice(PolicemanReq req) { public PolicemanDto GetOnePolice(PolicemanReq req) {
Policeman one = getOne(new LambdaQueryWrapper<Policeman>() Policeman one = PoliceExist(req.getId());
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
if (ObjectUtil.isNull(one)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
PolicemanDto policemanDto = new PolicemanDto(); PolicemanDto policemanDto = new PolicemanDto();
BeanPlusUtil.copyProperties(one, policemanDto); BeanPlusUtil.copyProperties(one, policemanDto);
//将警员的指纹信息查询出来 //将警员的指纹信息查询出来
...@@ -174,12 +151,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -174,12 +151,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Override @Override
public boolean DeletePolice(UpdatePolicemanReq req) { public boolean DeletePolice(UpdatePolicemanReq req) {
//通过警员id查询警员信息 //通过警员id查询警员信息
Policeman policeman = policemanService.getOne(new LambdaQueryWrapper<Policeman>() Policeman policeman = PoliceExist(req.getId());
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
//查询不到警员信息则抛异常
if (ObjectUtil.isNull(policeman)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
//如果查询出来的警员信息中没有绑定箱门而参数传递了箱门id,则抛出异常警员绑定箱门错误 //如果查询出来的警员信息中没有绑定箱门而参数传递了箱门id,则抛出异常警员绑定箱门错误
//如果传递的箱门id参数与查询出来的箱门id不一致,则抛出异常警员绑定的箱门与实际绑定不符合 //如果传递的箱门id参数与查询出来的箱门id不一致,则抛出异常警员绑定的箱门与实际绑定不符合
if ((ObjectUtil.isNull(policeman.getCabinetBoxId()) && ObjectUtil.isNotNull(req.getCabinetBoxId()))) { if ((ObjectUtil.isNull(policeman.getCabinetBoxId()) && ObjectUtil.isNotNull(req.getCabinetBoxId()))) {
...@@ -188,7 +160,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -188,7 +160,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//通过警员信息中的userId对账号进行删除 //通过警员信息中的userId对账号进行删除
sysUserService.remove(new LambdaQueryWrapper<User>() sysUserService.remove(new LambdaQueryWrapper<User>()
.eq(User::getUserId, policeman.getUserId())); .eq(User::getUserId, policeman.getUserId()));
return policemanService.removeById(policeman); return removeById(policeman);
} }
...@@ -204,17 +176,14 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -204,17 +176,14 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
Policeman policeman = new Policeman(); Policeman policeman = new Policeman();
BeanPlusUtil.copyProperties(req, policeman); BeanPlusUtil.copyProperties(req, policeman);
//查询传入的组织机构id是否存在 //查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>() pubOrgService.PubOrgExist(req.getOrgId());
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), PubOrg::getOrgId, req.getOrgId()));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
}
//判断传入的修改的警员编号与本身编号一致,如果一致则无所谓,如果不一致则需要判断修改的警员编号是否已经存在 //判断传入的修改的警员编号与本身编号一致,如果一致则无所谓,如果不一致则需要判断修改的警员编号是否已经存在
Policeman one = policemanService.getOne(new LambdaQueryWrapper<Policeman>() Policeman one = getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId())); .eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
//判断警员是否存在
if (!req.getPoliceCode().equals(one.getPoliceCode())) { if (!req.getPoliceCode().equals(one.getPoliceCode())) {
Policeman one1 = policemanService.getOne(new LambdaQueryWrapper<Policeman>() Policeman one1 = getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotNull(req.getPoliceCode()), Policeman::getPoliceCode, req.getPoliceCode())); .eq(ObjectUtil.isNotNull(req.getPoliceCode()), Policeman::getPoliceCode, req.getPoliceCode()));
if (ObjectUtil.isNotNull(one1)) { if (ObjectUtil.isNotNull(one1)) {
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS); throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
...@@ -228,7 +197,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -228,7 +197,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS); throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
} }
policeman.setUpdateTime(DateTimeUtil.getCurrentDateTime()); policeman.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return policemanService.updateById(policeman); return updateById(policeman);
} }
...@@ -241,13 +210,9 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -241,13 +210,9 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Override @Override
public boolean ChangePoliceState(UpdatePolicemanReq req) { public boolean ChangePoliceState(UpdatePolicemanReq req) {
//通过警员id查询出警员信息 //通过警员id查询出警员信息
Policeman one = getOne(new LambdaQueryWrapper<Policeman>() Policeman one = PoliceExist(req.getId());
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
if (ObjectUtil.isNull(one)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
one.setState(req.getState()); one.setState(req.getState());
return policemanService.updateById(one); return updateById(one);
} }
...@@ -287,12 +252,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -287,12 +252,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Override @Override
public PoliceDto GetAllPolicemanList(Long orgId) { public PoliceDto GetAllPolicemanList(Long orgId) {
//查询传入的组织机构id是否存在 //查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>() PubOrg pubOrg = pubOrgService.PubOrgExist(orgId);
.eq(ObjectUtil.isNotEmpty(orgId), PubOrg::getOrgId, orgId));
if (ObjectUtil.isNull(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
}
//查询出组织机构下的所有警员信息 //查询出组织机构下的所有警员信息
List<Policeman> list = list(new LambdaQueryWrapper<Policeman>() List<Policeman> list = list(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(orgId), Policeman::getOrgId, orgId) .eq(ObjectUtil.isNotEmpty(orgId), Policeman::getOrgId, orgId)
...@@ -317,7 +277,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -317,7 +277,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
PoliceDto policeDto = new PoliceDto(); PoliceDto policeDto = new PoliceDto();
policeDto.setPolicemanlist(policeList); policeDto.setPolicemanlist(policeList);
//设置组织机构名 //设置组织机构名
policeDto.setOrgName(puborg.getOrgName()); policeDto.setOrgName(pubOrg.getOrgName());
policeDto.setOrgId(orgId); policeDto.setOrgId(orgId);
return policeDto; return policeDto;
} }
...@@ -329,11 +289,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -329,11 +289,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
public PoliceDto GetPoliceData(String id) { public PoliceDto GetPoliceData(String id) {
PoliceDto policeDto = new PoliceDto(); PoliceDto policeDto = new PoliceDto();
//判断单警柜id是否正确 //判断单警柜id是否正确
Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>() Cabinet cabinet = cabinetService.CabinetExist(id);
.eq(Cabinet::getId, id));
if (ObjectUtil.isNull(cabinet)) {
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
//通过箱门id查询出警员 //通过箱门id查询出警员
List<Policeman> policemenList = policemanMapper.SearchPoliceList(id); List<Policeman> policemenList = policemanMapper.SearchPoliceList(id);
List<PolicemanDto> list = new ArrayList<>(); List<PolicemanDto> list = new ArrayList<>();
...@@ -369,14 +325,10 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -369,14 +325,10 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
if (ObjectUtil.isNull(req.getFaceInfo()) || ObjectUtil.isEmpty(req.getFaceInfo())) { if (ObjectUtil.isNull(req.getFaceInfo()) || ObjectUtil.isEmpty(req.getFaceInfo())) {
return false; return false;
} }
Policeman police = getOne(new LambdaQueryWrapper<Policeman>() Policeman police = PoliceExist(req.getId());
.eq(ObjectUtil.isNotEmpty(req.getId()), Policeman::getId, req.getId()));
if (ObjectUtil.isNull(police)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
police.setFaceInfo(req.getFaceInfo()); police.setFaceInfo(req.getFaceInfo());
police.setUpdateTime(DateTimeUtil.getCurrentDateTime()); police.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return policemanService.updateById(police); return updateById(police);
} }
/** /**
...@@ -389,15 +341,10 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -389,15 +341,10 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
**/ **/
@Override @Override
public boolean UpdateFaceInfo(UpdatePolicemanReq req) { public boolean UpdateFaceInfo(UpdatePolicemanReq req) {
//警员id不能为空 Policeman police = PoliceExist(req.getId());
if (ObjectUtil.isEmpty(req.getId()) || ObjectUtil.isNull(req.getId())) {
return false;
}
Policeman police = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(req.getId()), Policeman::getId, req.getId()));
police.setFaceInfo(req.getFaceInfo()); police.setFaceInfo(req.getFaceInfo());
police.setUpdateTime(DateTimeUtil.getCurrentDateTime()); police.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return policemanService.updateById(police); return updateById(police);
} }
...@@ -410,15 +357,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -410,15 +357,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
**/ **/
@Override @Override
public Policeman SearchFaceInfo(PolicemanReq req) { public Policeman SearchFaceInfo(PolicemanReq req) {
//警员id不能为空 Policeman policeman = PoliceExist(req.getId());
if (ObjectUtil.isEmpty(req.getId()) || ObjectUtil.isNull(req.getId())) {
return null;
}
Policeman policeman = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(req.getId()), Policeman::getId, req.getId()));
if (ObjectUtil.isNull(policeman)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
return policeman; return policeman;
} }
...@@ -434,7 +373,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -434,7 +373,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
public boolean PoliceBindUser(PolicemanReq req) { public boolean PoliceBindUser(PolicemanReq req) {
User user = new User(); User user = new User();
BeanPlusUtil.copyProperties(req, user); BeanPlusUtil.copyProperties(req, user);
//密码加密,依赖注入错误 //密码加密,bcrypt加密方式
BcryptPasswordStoredEncrypt passwordStoredEncrypt = new BcryptPasswordStoredEncrypt(); BcryptPasswordStoredEncrypt passwordStoredEncrypt = new BcryptPasswordStoredEncrypt();
String encrypt = passwordStoredEncrypt.encrypt(req.getPassword()); String encrypt = passwordStoredEncrypt.encrypt(req.getPassword());
user.setPassword(encrypt); user.setPassword(encrypt);
...@@ -447,36 +386,46 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -447,36 +386,46 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
} }
user.setRealName(req.getName()); user.setRealName(req.getName());
user.setNickName(req.getName()); user.setNickName(req.getName());
System.out.println("user = " + user);
sysUserService.save(user); sysUserService.save(user);
//判断警员是否存在
Policeman policeman = PoliceExist(req.getId());
//通过警员id将查询到的警员信息进行修改设置 //通过警员id将查询到的警员信息进行修改设置
Policeman policeman = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getId, req.getId()));
if (ObjectUtil.isNull(policeman)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
policeman.setUserId(user.getUserId()); policeman.setUserId(user.getUserId());
policeman.setIsCreatedAccount(true); policeman.setIsCreatedAccount(true);
policeman.setPassword(encrypt); policeman.setPassword(encrypt);
return policemanService.updateById(policeman); return updateById(policeman);
} }
//人员绑定箱门 //人员绑定箱门
@Override @Override
public boolean PoliceBindBox(PolicemanReq req) { public boolean PoliceBindBox(PolicemanReq req) {
Policeman policeman = new Policeman(); Policeman policeman = PoliceExist(req.getId());
BeanPlusUtil.copyProperties(req, policeman); BeanPlusUtil.copyProperties(req, policeman);
Policeman one = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getId, req.getId()));
if (ObjectUtil.isNull(one)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
//判断箱子是否存在 //判断箱子是否存在
CabinetBox cabinetBox = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>() CabinetBox cabinetBox = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getId, req.getCabinetBoxId())); .eq(CabinetBox::getId, req.getCabinetBoxId()));
if (ObjectUtil.isNull(cabinetBox)) { if (ObjectUtil.isNull(cabinetBox)) {
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS); throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
} }
return policemanService.updateById(policeman); return updateById(policeman);
} }
/**
* 通过警员id判断警员是否存在,不存在则抛出异常
*/
@Override
public Policeman PoliceExist(String policeId) {
Policeman policeman = getOne(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getId,policeId));
if (ObjectUtil.isNull(policeman)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
return policeman;
}
} }
...@@ -11,6 +11,7 @@ import com.junmp.jyzb.api.bean.req.UpdateOrgReq; ...@@ -11,6 +11,7 @@ import com.junmp.jyzb.api.bean.req.UpdateOrgReq;
import com.junmp.jyzb.api.exception.JYZBAppException; import com.junmp.jyzb.api.exception.JYZBAppException;
import com.junmp.jyzb.api.exception.enums.EquipmentTypeExceptionEnum; import com.junmp.jyzb.api.exception.enums.EquipmentTypeExceptionEnum;
import com.junmp.jyzb.api.exception.enums.OrgExceptionEnum; import com.junmp.jyzb.api.exception.enums.OrgExceptionEnum;
import com.junmp.jyzb.api.exception.enums.PubOrgExceptionEnum;
import com.junmp.jyzb.entity.EquipmentType; import com.junmp.jyzb.entity.EquipmentType;
import com.junmp.jyzb.entity.PubOrg; import com.junmp.jyzb.entity.PubOrg;
import com.junmp.jyzb.entity.Supplier; import com.junmp.jyzb.entity.Supplier;
...@@ -18,6 +19,7 @@ import com.junmp.jyzb.utils.HttpStatus; ...@@ -18,6 +19,7 @@ import com.junmp.jyzb.utils.HttpStatus;
import com.junmp.jyzb.utils.RedisUtils; import com.junmp.jyzb.utils.RedisUtils;
import com.junmp.jyzb.utils.ResponseResult; import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.jyzb.utils.ReturnMsg; import com.junmp.jyzb.utils.ReturnMsg;
import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil; import com.junmp.v2.common.util.BeanPlusUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -52,7 +54,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -52,7 +54,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
@Override @Override
public List<String> getLowerOrg(String orgId) { public List<Long> getLowerOrg(Long orgId) {
//构建 Redis 缓存� //构建 Redis 缓存�
String redisKey = "getLowerOrg"; String redisKey = "getLowerOrg";
...@@ -66,40 +68,40 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -66,40 +68,40 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
redisUtils.set(redisKey, menuList); redisUtils.set(redisKey, menuList);
} }
List<String> resultList = new ArrayList<>(); // 存储最终的菜单树结果 List<Long> resultList = new ArrayList<>(); // 存储最终的菜单树结果
Map<String, List<String>> childrenMap = new HashMap<>(); // 存储每个菜单项的子菜单映射 Map<String, List<Long>> childrenMap = new HashMap<>(); // 存储每个菜单项的子菜单映射
resultList.add(orgId); //将自己加入到返回的List中 resultList.add(orgId); //将自己加入到返回的List中
// 构建子菜单映射表 // 构建子菜单映射表
for (PubOrg menu : menuList) { for (PubOrg menu : menuList) {
String org = menu.getOrgId().toString(); Long org = menu.getOrgId();
if (!childrenMap.containsKey(menu.getOrgParentId().toString())) { // 如果父菜单还不存在于映射表中 if (!childrenMap.containsKey(menu.getOrgParentId().toString())) { // 如果父菜单还不存在于映射表中
childrenMap.put(menu.getOrgParentId().toString(), new ArrayList<>()); // 创建一个新的子菜单列表 childrenMap.put(menu.getOrgParentId().toString(), new ArrayList<>()); // 创建一个新的子菜单列表
} }
childrenMap.get(menu.getOrgParentId().toString()).add(org); // 将当前菜单项放入对应的子菜单列表中 childrenMap.get(menu.getOrgParentId()).add(org); // 将当前菜单项放入对应的子菜单列表中
} }
Long orgInfo = Long.valueOf(orgId);//获取输入的组织机构id信息 Long orgInfo = Long.valueOf(orgId);//获取输入的组织机构id信息
//Long orgInfo = new BigInteger(orgId); // 获取顶级菜单的标识符 //Long orgInfo = new BigInteger(orgId); // 获取顶级菜单的标识符
// 获取顶级菜单 // 获取顶级菜单
List<String> topMenus = childrenMap.get(orgId); List<Long> topMenus = childrenMap.get(orgId);
// 迭代构建菜单树 // 迭代构建菜单树
if (topMenus != null) { if (topMenus != null) {
for (String topMenu : topMenus) { for (Long topMenu : topMenus) {
Stack<String> stack = new Stack<>(); // 使用栈结构辅助构建菜单树 Stack<Long> stack = new Stack<>(); // 使用栈结构辅助构建菜单树
stack.push(topMenu); // 将当前顶级菜单项放入栈中 stack.push(topMenu); // 将当前顶级菜单项放入栈中
while (!stack.isEmpty()) { while (!stack.isEmpty()) {
String currentMenu = stack.pop(); // 取出队首的当前菜单项 Long currentMenu = stack.pop(); // 取出队首的当前菜单项
//Long currentMenuId = currentMenu; // 获取当前菜单项的标识符 //Long currentMenuId = currentMenu; // 获取当前菜单项的标识符
if (childrenMap.containsKey(currentMenu)) { // 如果当前菜单项有子菜单 if (childrenMap.containsKey(currentMenu)) { // 如果当前菜单项有子菜单
List<String> children = childrenMap.get(currentMenu); // 获取子菜单列表 List<Long> children = childrenMap.get(currentMenu); // 获取子菜单列表
for (int i = children.size() - 1; i >= 0; i--) { for (int i = children.size() - 1; i >= 0; i--) {
stack.push(children.get(i)); stack.push(children.get(i));
...@@ -244,6 +246,8 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -244,6 +246,8 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
} }
} }
public List<String> CheckOrgList(List<String> req){ public List<String> CheckOrgList(List<String> req){
LambdaQueryWrapper<PubOrg> wp = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PubOrg> wp = new LambdaQueryWrapper<>();
wp.in(ObjectUtil.isNotEmpty(req), PubOrg::getOrgId, req); wp.in(ObjectUtil.isNotEmpty(req), PubOrg::getOrgId, req);
...@@ -359,6 +363,18 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem ...@@ -359,6 +363,18 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
return wrapper; return wrapper;
} }
//根据组织机构id查询出组织机构是否存在
@Override
public PubOrg PubOrgExist(Long id) {
PubOrg puborg = getOne(new LambdaQueryWrapper<PubOrg>()
.eq(PubOrg::getOrgId,id));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
}
return puborg;
}
} }
......
...@@ -48,16 +48,12 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse> ...@@ -48,16 +48,12 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
@Override @Override
public WarehouseDto getOneWarehouse(WarehouseReq req) { public WarehouseDto getOneWarehouse(WarehouseReq req) {
Warehouse warehouseMsg=this.getById(req.getId()); Warehouse warehouse = WarehoustExist(req.getId());
if (ObjectUtil.isNull(warehouseMsg)){
throw new ServiceException(WarehouseExceptionEnum.WAREHOUSE_NOT_EXIST);
}
WarehouseDto warehouseDto = new WarehouseDto(); WarehouseDto warehouseDto = new WarehouseDto();
BeanPlusUtil.copyProperties(warehouseMsg,warehouseDto); BeanPlusUtil.copyProperties(warehouse,warehouseDto);
//获取组织机构名称 //获取组织机构名称
PubOrg one = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>() PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
.eq(PubOrg::getOrgId, warehouseMsg.getOrgId())); warehouseDto.setOrgName(pubOrg.getOrgName());
warehouseDto.setOrgName(one.getOrgName());
return warehouseDto; return warehouseDto;
} }
...@@ -88,13 +84,9 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse> ...@@ -88,13 +84,9 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
List<Warehouse> allWarehouse=new ArrayList<>(); List<Warehouse> allWarehouse=new ArrayList<>();
List<WarehouseDto> warehouseDtoList=new ArrayList<>(); List<WarehouseDto> warehouseDtoList=new ArrayList<>();
//判断组织机构是否存在 //判断组织机构是否存在
PubOrg one = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>() PubOrg pubOrg = pubOrgService.PubOrgExist(msg.getOrgId());
.eq(PubOrg::getOrgId, msg.getOrgId()));
if (ObjectUtil.isNull(one)){
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
}
//根据组织机构id查询组织机构名称 //根据组织机构id查询组织机构名称
String orgName = one.getOrgName(); String orgName = pubOrg.getOrgName();
//如果组织机构是浙江省公安厅 //如果组织机构是浙江省公安厅
if (msg.getOrgId().equals(1369509498032808905L) && msg.getIncludeLowerLevel().equals("true")){ if (msg.getOrgId().equals(1369509498032808905L) && msg.getIncludeLowerLevel().equals("true")){
allWarehouse = this.list(); allWarehouse = this.list();
...@@ -108,7 +100,7 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse> ...@@ -108,7 +100,7 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
} }
//获取组织机构Id //获取组织机构Id
List<String> allOrgId =getAllOrgId(msg); List<Long> allOrgId =getAllOrgId(msg);
allWarehouse = getAllWarehouseByOrg(allOrgId); allWarehouse = getAllWarehouseByOrg(allOrgId);
...@@ -122,18 +114,18 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse> ...@@ -122,18 +114,18 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
} }
private List<String> getAllOrgId(WarehouseReq msg) { private List<Long> getAllOrgId(WarehouseReq msg) {
List<String> allOrg = new ArrayList<>(); List<Long> allOrg = new ArrayList<>();
if (msg.getIncludeLowerLevel().equals("false")){ if (msg.getIncludeLowerLevel().equals("false")){
allOrg.add(msg.getOrgId().toString()); allOrg.add(msg.getOrgId());
}else if(msg.getIncludeLowerLevel().equals("true")){ }else if(msg.getIncludeLowerLevel().equals("true")){
//查询某组织机构的本级及下级 //查询某组织机构的本级及下级
allOrg = pubOrgService.getLowerOrg(msg.getOrgId().toString()); allOrg = pubOrgService.getLowerOrg(msg.getOrgId());
} }
return allOrg; return allOrg;
} }
private List<Warehouse> getAllWarehouseByOrg(List<String> allOrgId) { private List<Warehouse> getAllWarehouseByOrg(List<Long> allOrgId) {
List<Warehouse> allWarehouse = new ArrayList<>(); List<Warehouse> allWarehouse = new ArrayList<>();
LambdaQueryWrapper<Warehouse> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Warehouse> queryWrapper = new LambdaQueryWrapper<>();
...@@ -171,24 +163,21 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse> ...@@ -171,24 +163,21 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS); return new ResponseResult(HttpStatus.SUCCESS, ReturnMsg.PASS);
} }
private Warehouse queryWarehouse(WarehouseReq req) { private Warehouse queryWarehouse(WarehouseReq req) {
Warehouse app = this.getById(req.getId()); Warehouse warehouse = WarehoustExist(req.getId());
if (ObjectUtil.isNull(app)) { return warehouse;
throw new ServiceException(WarehouseExceptionEnum.WAREHOUSE_NOT_EXIST);
}
return app;
} }
private LambdaQueryWrapper<Product> createWrapper(ProductReq req) { //判断仓库是否存在
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>(); @Override
if (ObjectUtil.isEmpty(req)) { public Warehouse WarehoustExist(String id) {
return wrapper; Warehouse warehouseMsg=this.getById(id);
if (ObjectUtil.isNull(warehouseMsg)){
throw new ServiceException(WarehouseExceptionEnum.WAREHOUSE_NOT_EXIST);
} }
//根据业务编码查询 return warehouseMsg;
wrapper.like(ObjectUtil.isNotEmpty(req.getProductCode()), Product::getProductCode, req.getProductCode());
//根据企业名称模糊查询
wrapper.like(ObjectUtil.isNotEmpty(req.getName()), Product::getName, req.getName());
wrapper.orderByDesc(Product::getUpdateTime);
return wrapper;
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论