Commit 938b67a2 by 李小惠

合并

parent 0fd20fdc
package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class ShelfDto implements Serializable {
private String shelfId;
private String shelfName;
private String code;
private String type;
private Integer shelfRows;
private Integer shelfColumns;
private Integer shelfRanges;
private String url;
private String sizeInfo;
}
package com.junmp.jyzb.api.bean.query;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.junmp.v2.common.bean.request.BaseRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import javax.validation.constraints.NotBlank;
@Data
@EqualsAndHashCode(callSuper = true)
public class ShelfReq extends BaseRequest {
private String shelfId;
private Long areaId;
......@@ -21,6 +20,7 @@ public class ShelfReq extends BaseRequest {
private String type;
@NotBlank(message = "仓库id不能为空",groups = {detail.class})
private String warehouseId;
private Integer shelfRows;
......
package com.junmp.jyzb.controller;
import com.junmp.jyzb.api.bean.dto.ShelfDto;
import com.junmp.jyzb.api.bean.dto.WarehouseAreaDto;
import com.junmp.jyzb.api.bean.dto.WarehouseDto;
import com.junmp.jyzb.api.bean.query.ShelfReq;
......@@ -121,7 +122,7 @@ public class WarehouseController {
@PostMapping("/GetShelfList")
@ApiOperation("查询货架信息")
public ApiRes<List<Shelf>> getShelfList(@RequestBody ShelfReq req){
return ApiRes.success(shelfService.getShelfList(req));
public ApiRes<List<ShelfDto>> GetShelfList(@RequestBody @Validated(ValidationApi.detail.class) ShelfReq req){
return ApiRes.success(shelfService.GetShelfList(req));
}
}
......@@ -6,21 +6,21 @@ import com.junmp.jyzb.api.bean.dto.PolicemanDto;
import com.junmp.jyzb.api.bean.query.PolicemanReq;
import com.junmp.jyzb.api.bean.req.UpdatePolicemanReq;
import com.junmp.jyzb.entity.Policeman;
import com.junmp.jyzb.utils.ResponseResult;
import java.util.List;
import java.util.Map;
public interface PolicemanService extends IService<Policeman> {
//获取单个警员信息
PolicemanDto GetOnePolice(PolicemanReq req);
//添加警员
String AddPoliceman(UpdatePolicemanReq req);
//获取单个警员信息
PolicemanDto GetOnePolice(PolicemanReq req);
//删除警员
boolean DeletePolice(UpdatePolicemanReq req);
//修改警员信息
boolean UpdatePolice(UpdatePolicemanReq req);
......@@ -51,14 +51,3 @@ public interface PolicemanService extends IService<Policeman> {
}
Policeman SearchFaceInfo(PolicemanReq req);
boolean PoliceBindUser(PolicemanReq req);
boolean PoliceBindBox(PolicemanReq req);
}
package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.dto.ShelfDto;
import com.junmp.jyzb.api.bean.query.ShelfReq;
import com.junmp.jyzb.api.bean.req.UpdateShelfReq;
import com.junmp.jyzb.entity.Shelf;
......@@ -8,11 +9,11 @@ import com.junmp.jyzb.entity.Shelf;
import java.util.List;
public interface ShelfService extends IService<Shelf> {
boolean AddShelf(UpdateShelfReq msg);
boolean AddShelf(UpdateShelfReq req);
boolean UpdateShelf(UpdateShelfReq msg);
boolean UpdateShelf(UpdateShelfReq req);
boolean DeleteShelf(UpdateShelfReq msg);
boolean DeleteShelf(UpdateShelfReq req);
List<Shelf> getShelfList(ShelfReq msg);
List<ShelfDto> GetShelfList(ShelfReq req);
}
......@@ -75,6 +75,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
/**
* 添加警员信息
*
* @param req
* @return
*/
......@@ -82,7 +83,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
public String AddPoliceman(UpdatePolicemanReq req) {
//查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>()
.eq(ObjectUtil.isNotEmpty(req.getOrgId()),PubOrg::getOrgId,req.getOrgId()));
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), PubOrg::getOrgId, req.getOrgId()));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
......@@ -90,11 +91,11 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//查询是否有重复的policeCode
List<Policeman> list = policemanService.list(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(req.getPoliceCode()), Policeman::getPoliceCode, req.getPoliceCode()));
if (list.size()>0){
if (list.size() > 0) {
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
}
Policeman policeman = new Policeman();
BeanPlusUtil.copyProperties(req,policeman);
BeanPlusUtil.copyProperties(req, policeman);
//添加警员绑定用户信息
policemanService.save(policeman);
return policeman.getId();
......@@ -115,17 +116,17 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
if (cachedDataFalse == null && cachedDataTrue == null) {
//getAllPoliceId(Map.of("IncludeLowerLevel", false, "orgId", orgId));
return;
}else if(cachedDataFalse!=null){
} else if (cachedDataFalse != null) {
cachedDataFalse.add(newPoliceId);
redisUtils.set(redisKeyFalse, cachedDataFalse);
}else if(cachedDataTrue!=null){
} else if (cachedDataTrue != null) {
cachedDataTrue.add(newPoliceId);
redisUtils.set(redisKeyTrue, cachedDataTrue);
}
}
//删除缓存的方法
private void deletePoliceIdCache(String orgId){
private void deletePoliceIdCache(String orgId) {
//构建 Redis 缓存键
String redisKey = "getAllPoliceId_false_" + orgId;
redisUtils.delete(redisKey);
......@@ -137,7 +138,6 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
/**
*
* @param req
* @return
*/
......@@ -145,18 +145,18 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
public PolicemanDto GetOnePolice(PolicemanReq req) {
Policeman one = getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
if (ObjectUtil.isNull(one)){
if (ObjectUtil.isNull(one)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
PolicemanDto policemanDto = new PolicemanDto();
BeanPlusUtil.copyProperties(one,policemanDto);
BeanPlusUtil.copyProperties(one, policemanDto);
//将警员的指纹信息查询出来
List<PoliceFinger> list1 = policeFingerService.list(new LambdaQueryWrapper<PoliceFinger>()
.eq(ObjectUtil.isNotNull(req.getId()), PoliceFinger::getPoliceId, req.getId()));
List<PoliceFingerDto> fingerDtoList=new ArrayList<>();
for (PoliceFinger policeFinger:list1) {
List<PoliceFingerDto> fingerDtoList = new ArrayList<>();
for (PoliceFinger policeFinger : list1) {
PoliceFingerDto policeFingerDto = new PoliceFingerDto();
BeanPlusUtil.copyProperties(policeFinger,policeFingerDto);
BeanPlusUtil.copyProperties(policeFinger, policeFingerDto);
fingerDtoList.add(policeFingerDto);
}
policemanDto.setFingersList(fingerDtoList);
......@@ -166,6 +166,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
/**
* 删除警员信息
*
* @param req
* @return
*/
......@@ -176,34 +177,35 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
Policeman policeman = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
//查询不到警员信息则抛异常
if (ObjectUtil.isNull(policeman)){
if (ObjectUtil.isNull(policeman)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
//如果查询出来的警员信息中没有绑定箱门而参数传递了箱门id,则抛出异常警员绑定箱门错误
//如果传递的箱门id参数与查询出来的箱门id不一致,则抛出异常警员绑定的箱门与实际绑定不符合
if ((ObjectUtil.isNull(policeman.getCabinetBoxId()) && ObjectUtil.isNotNull(req.getCabinetBoxId()))){
if ((ObjectUtil.isNull(policeman.getCabinetBoxId()) && ObjectUtil.isNotNull(req.getCabinetBoxId()))) {
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
}
//通过警员信息中的userId对账号进行删除
sysUserService.remove(new LambdaQueryWrapper<User>()
.eq(User::getUserId,policeman.getUserId()));
return policemanService.removeById(policeman);
.eq(User::getUserId, policeman.getUserId()));
return policemanService.removeById(policeman);
}
/**
* 修改警员信息
*
* @param req
* @return
*/
@Override
public boolean UpdatePolice(UpdatePolicemanReq req) {
Policeman policeman = new Policeman();
BeanPlusUtil.copyProperties(req,policeman);
BeanPlusUtil.copyProperties(req, policeman);
//查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>()
.eq(ObjectUtil.isNotEmpty(req.getOrgId()),PubOrg::getOrgId,req.getOrgId()));
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), PubOrg::getOrgId, req.getOrgId()));
if (ObjectUtil.isEmpty(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
......@@ -211,10 +213,10 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//判断传入的修改的警员编号与本身编号一致,如果一致则无所谓,如果不一致则需要判断修改的警员编号是否已经存在
Policeman one = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.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>()
.eq(ObjectUtil.isNotNull(req.getPoliceCode()), Policeman::getPoliceCode, req.getPoliceCode()));
if (ObjectUtil.isNotNull(one1)){
if (ObjectUtil.isNotNull(one1)) {
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
}
}
......@@ -222,7 +224,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//查询单警柜箱号是否存在,箱门不存在抛异常
CabinetBox cabinetBox = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getId, req.getCabinetBoxId()));
if (ObjectUtil.isNull(cabinetBox)){
if (ObjectUtil.isNull(cabinetBox)) {
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
}
policeman.setUpdateTime(DateTimeUtil.getCurrentDateTime());
......@@ -230,11 +232,9 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
}
/**
* 修改警员状态
*
* @param req
* @return
*/
......@@ -243,7 +243,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//通过警员id查询出警员信息
Policeman one = getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
if (ObjectUtil.isNull(one)){
if (ObjectUtil.isNull(one)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
one.setState(req.getState());
......@@ -251,15 +251,15 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
}
public List<Map<String, Object>> getAllPolicemanMsg(Map<String, Object> msg,List<String> allPoliceId) {
public List<Map<String, Object>> getAllPolicemanMsg(Map<String, Object> msg, List<String> allPoliceId) {
List<Map<String, Object>> allPoliceman = new ArrayList<>();
// 构建 Redis 缓存键
String redisKey = REDIS_ORG + msg.get("IncludeLowerLevel").toString() +'_'+ msg.get("orgId").toString();
String redisKey = REDIS_ORG + msg.get("IncludeLowerLevel").toString() + '_' + msg.get("orgId").toString();
// 从 Redis 中获取数据
List<Map<String, Object>> cachedData = redisUtils.findCachedData(redisKey);
if (cachedData != null) {
//将Long类型的数据转化为Date
for (Map<String,Object> one:cachedData){
for (Map<String, Object> one : cachedData) {
Long dataMsg = (Long) one.get("updateTime");
one.put("updateTime", redisUtils.getDate(dataMsg));
allPoliceman.add(one);
......@@ -281,13 +281,14 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
/**
* 通过组织机构id查询警员列表
*
* @param orgId
*/
@Override
public PoliceDto GetAllPolicemanList(Long orgId) {
//查询传入的组织机构id是否存在
PubOrg puborg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>()
.eq(ObjectUtil.isNotEmpty(orgId),PubOrg::getOrgId,orgId));
.eq(ObjectUtil.isNotEmpty(orgId), PubOrg::getOrgId, orgId));
if (ObjectUtil.isNull(puborg)) {
//抛出组织机构不存在异常
throw new ServiceException(PubOrgExceptionEnum.PUBORG_NOT_EXIST);
......@@ -295,18 +296,18 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//查询出组织机构下的所有警员信息
List<Policeman> list = list(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(orgId), Policeman::getOrgId, orgId)
.eq(Policeman::getState,1));
List<PolicemanDto> policeList=new ArrayList<>();
.eq(Policeman::getState, 1));
List<PolicemanDto> policeList = new ArrayList<>();
//查询出警员信息下的指纹列表信息
for (Policeman p:list) {
for (Policeman p : list) {
PolicemanDto policemanDto = new PolicemanDto();
BeanPlusUtil.copyProperties(p,policemanDto);
BeanPlusUtil.copyProperties(p, policemanDto);
List<PoliceFinger> list1 = policeFingerService.list(new LambdaQueryWrapper<PoliceFinger>()
.eq(ObjectUtil.isNotNull(p.getId()), PoliceFinger::getPoliceId, p.getId()));
List<PoliceFingerDto> policeFingerDtoList=new ArrayList<>();
for (PoliceFinger policeFinger:list1) {
List<PoliceFingerDto> policeFingerDtoList = new ArrayList<>();
for (PoliceFinger policeFinger : list1) {
PoliceFingerDto policeFingerDto = new PoliceFingerDto();
BeanPlusUtil.copyProperties(policeFinger,policeFingerDto);
BeanPlusUtil.copyProperties(policeFinger, policeFingerDto);
policeFingerDtoList.add(policeFingerDto);
}
policemanDto.setFingersList(policeFingerDtoList);
......@@ -321,22 +322,6 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
return policeDto;
}
private List<Map<String, Object>> getAllPolicemanByOrg(Map<String, Object> msg, List<String> allOrgId) {
List<Map<String, Object>> allPoliceman = new ArrayList<>();
allPoliceman = policemanMapper.getAllPolicemanByOrgList(allOrgId);
return allPoliceman;
}
private List<String> getAllOrgId(Map<String, Object> msg) {
List<String> allOrg = new ArrayList<>();
if (msg.get("IncludeLowerLevel").equals("false")){
allOrg.add((String) msg.get("orgId"));
}else if(msg.get("IncludeLowerLevel").equals("true")){
//查询某组织机构的本级及下级
allOrg = pubOrgService.getLowerOrg(msg.get("orgId").toString());
}
return allOrg;
}
//根据单警柜id查询警员信息
......@@ -346,22 +331,22 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//判断单警柜id是否正确
Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getId, id));
if (ObjectUtil.isNull(cabinet)){
if (ObjectUtil.isNull(cabinet)) {
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
//通过箱门id查询出警员
List<Policeman> policemenList = policemanMapper.SearchPoliceList(id);
List<PolicemanDto> list = new ArrayList<>();
for (Policeman policeman:policemenList) {
for (Policeman policeman : policemenList) {
PolicemanDto policemanDto = new PolicemanDto();
BeanPlusUtil.copyProperties(policeman,policemanDto);
BeanPlusUtil.copyProperties(policeman, policemanDto);
//指纹信息查找
List<PoliceFinger> fingerList = policeFingerService.list(new LambdaQueryWrapper<PoliceFinger>()
.eq(PoliceFinger::getPoliceId, policeman.getId()));
List<PoliceFingerDto> fingerDtoList=new ArrayList<>();
for (PoliceFinger policeFinger:fingerList) {
List<PoliceFingerDto> fingerDtoList = new ArrayList<>();
for (PoliceFinger policeFinger : fingerList) {
PoliceFingerDto policeFingerDto = new PoliceFingerDto();
BeanPlusUtil.copyProperties(policeFinger,policeFingerDto);
BeanPlusUtil.copyProperties(policeFinger, policeFingerDto);
fingerDtoList.add(policeFingerDto);
}
policemanDto.setFingersList(fingerDtoList);
......@@ -381,12 +366,12 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Override
public boolean AddFaceInfo(UpdatePolicemanReq req) {
//面部信息为null或者为空
if (ObjectUtil.isNull(req.getFaceInfo()) || ObjectUtil.isEmpty(req.getFaceInfo())){
if (ObjectUtil.isNull(req.getFaceInfo()) || ObjectUtil.isEmpty(req.getFaceInfo())) {
return false;
}
Policeman police = getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(req.getId()),Policeman::getId,req.getId()));
if (ObjectUtil.isNull(police)){
.eq(ObjectUtil.isNotEmpty(req.getId()), Policeman::getId, req.getId()));
if (ObjectUtil.isNull(police)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
police.setFaceInfo(req.getFaceInfo());
......@@ -395,17 +380,17 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
}
/**
* @author lxh
* @description 更新人脸信息\删除人脸信息
* 删除时:传一个null的人脸信息即可
* @since 2023/7/18 15:02
* @param
* @return
**/
* @param
* @return
* @author lxh
* @description 更新人脸信息\删除人脸信息
* 删除时:传一个null的人脸信息即可
* @since 2023/7/18 15:02
**/
@Override
public boolean UpdateFaceInfo(UpdatePolicemanReq req) {
//警员id不能为空
if (ObjectUtil.isEmpty(req.getId()) || ObjectUtil.isNull(req.getId())){
if (ObjectUtil.isEmpty(req.getId()) || ObjectUtil.isNull(req.getId())) {
return false;
}
Policeman police = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
......@@ -417,103 +402,21 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
}
/**
* @author lxh
* @description 查询人脸信息
* @since 2023/7/18 15:02
* @param
* @return
**/
@Override
public Policeman SearchFaceInfo(PolicemanReq req) {
//警员id不能为空
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;
}
/**
* 警员绑定账号
* @param req
* @param
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean PoliceBindUser(PolicemanReq req) {
User user = new User();
BeanPlusUtil.copyProperties(req,user);
//密码加密,依赖注入错误
BcryptPasswordStoredEncrypt passwordStoredEncrypt = new BcryptPasswordStoredEncrypt();
String encrypt = passwordStoredEncrypt.encrypt(req.getPassword());
user.setPassword(encrypt);
//存储到数据库
//判断传入的sex是什么,需要做处理
if (req.getSex().equals("男")){
user.setSex("M");
}else{
user.setSex("F");
}
user.setRealName(req.getName());
user.setNickName(req.getName());
sysUserService.save(user);
//通过警员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.setIsCreatedAccount(true);
policeman.setPassword(encrypt);
return policemanService.updateById(policeman);
}
//人员绑定箱门
@Override
public boolean PoliceBindBox(PolicemanReq req) {
Policeman policeman = new 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>()
.eq(CabinetBox::getId, req.getCabinetBoxId()));
if (ObjectUtil.isNull(cabinetBox)){
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
}
return policemanService.updateById(policeman);
}
}
}
/**
* @author lxh
* @description 查询人脸信息
* @since 2023/7/18 15:02
* @param
* @return
**/
* @author lxh
* @description 查询人脸信息
* @since 2023/7/18 15:02
**/
@Override
public Policeman SearchFaceInfo(PolicemanReq req) {
//警员id不能为空
if (ObjectUtil.isEmpty(req.getId()) || ObjectUtil.isNull(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)){
if (ObjectUtil.isNull(policeman)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
return policeman;
......@@ -522,6 +425,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
/**
* 警员绑定账号
*
* @param req
* @return
*/
......@@ -529,16 +433,16 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Override
public boolean PoliceBindUser(PolicemanReq req) {
User user = new User();
BeanPlusUtil.copyProperties(req,user);
BeanPlusUtil.copyProperties(req, user);
//密码加密,依赖注入错误
BcryptPasswordStoredEncrypt passwordStoredEncrypt = new BcryptPasswordStoredEncrypt();
String encrypt = passwordStoredEncrypt.encrypt(req.getPassword());
user.setPassword(encrypt);
//存储到数据库
//判断传入的sex是什么,需要做处理
if (req.getSex().equals("男")){
if (req.getSex().equals("男")) {
user.setSex("M");
}else{
} else {
user.setSex("F");
}
user.setRealName(req.getName());
......@@ -548,7 +452,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//通过警员id将查询到的警员信息进行修改设置
Policeman policeman = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getId, req.getId()));
if (ObjectUtil.isNull(policeman)){
if (ObjectUtil.isNull(policeman)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
policeman.setUserId(user.getUserId());
......@@ -561,20 +465,18 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Override
public boolean PoliceBindBox(PolicemanReq req) {
Policeman policeman = new Policeman();
BeanPlusUtil.copyProperties(req,policeman);
BeanPlusUtil.copyProperties(req, policeman);
Policeman one = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getId, req.getId()));
if (ObjectUtil.isNull(one)){
if (ObjectUtil.isNull(one)) {
throw new ServiceException(PolicemanExceptionEnum.POLICEMAN_NOT_EXIST);
}
//判断箱子是否存在
CabinetBox cabinetBox = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getId, req.getCabinetBoxId()));
if (ObjectUtil.isNull(cabinetBox)){
if (ObjectUtil.isNull(cabinetBox)) {
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
}
return policemanService.updateById(policeman);
}
}
......@@ -3,10 +3,14 @@ package com.junmp.jyzb.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.ShelfDto;
import com.junmp.jyzb.api.bean.query.ShelfReq;
import com.junmp.jyzb.api.bean.req.UpdateShelfReq;
import com.junmp.jyzb.api.exception.enums.ShelfExceptionEnum;
import com.junmp.jyzb.api.exception.enums.WarehouseExceptionEnum;
import com.junmp.jyzb.entity.Shelf;
import com.junmp.jyzb.entity.Warehouse;
import com.junmp.jyzb.service.WarehouseService;
import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil;
import org.springframework.stereotype.Service;
......@@ -14,11 +18,14 @@ import javax.annotation.Resource;
import com.junmp.jyzb.mapper.ShelfMapper;
import com.junmp.jyzb.service.ShelfService;
import java.util.ArrayList;
import java.util.List;
@Service
public class ShelfServiceImpl extends ServiceImpl<ShelfMapper, Shelf> implements ShelfService {
@Resource
private WarehouseService warehouseService;
@Override
public boolean AddShelf(UpdateShelfReq req) {
......@@ -42,9 +49,22 @@ public class ShelfServiceImpl extends ServiceImpl<ShelfMapper, Shelf> implements
}
@Override
public List<Shelf> getShelfList(ShelfReq req) {
public List<ShelfDto> GetShelfList(ShelfReq req) {
//判断仓库id是否存在
Warehouse one = warehouseService.getOne(new LambdaQueryWrapper<Warehouse>()
.eq(Warehouse::getId, req.getWarehouseId()));
if (ObjectUtil.isNull(one)){
throw new ServiceException(WarehouseExceptionEnum.WAREHOUSE_NOT_EXIST);
}
LambdaQueryWrapper<Shelf> wrapper = createWrapper(req);
return this.list(wrapper);
List<Shelf> list = list(wrapper);
List<ShelfDto> shelfDtoList=new ArrayList<>();
for (Shelf shelf:list) {
ShelfDto shelfDto = new ShelfDto();
BeanPlusUtil.copyProperties(shelf,shelfDto);
shelfDtoList.add(shelfDto);
}
return shelfDtoList;
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论