Commit 708a69d6 by 李小惠

测试异常的代码进行修改

parent 73ce52ca
package com.junmp.jyzb.api.bean.query;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.junmp.v2.common.bean.request.BaseRequest;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
public class WarehouseReq extends BaseRequest {
@NotBlank(message = "仓库主键不能为空", groups = {edit.class, delete.class, detail.class})
@NotBlank(message = "仓库主键不能为空", groups = {updateStatus.class, delete.class, detail.class})
private String id;
private Long departmentId;
......@@ -38,7 +32,7 @@ public class WarehouseReq extends BaseRequest {
private String updateUser;
@JsonProperty(value = "orgId")
@NotNull(message = "组织机构id不能为空", groups = {edit.class})
private Long orgId;
private Boolean isLocked;
......@@ -51,11 +45,11 @@ public class WarehouseReq extends BaseRequest {
private BigDecimal priceTotal;
@NotNull(message = "仓库状态不能为空", groups = {edit.class})
@NotNull(message = "仓库状态不能为空", groups = {updateStatus.class})
private Integer state;
private Long orderId;
@JsonProperty(value = "IncludeLowerLevel")
@NotBlank(message = "IncludeLowerLevel不能为空", groups = {edit.class})
private String IncludeLowerLevel;
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ import javax.validation.constraints.NotNull;
public class UpdateCabinetBoxReq extends BaseRequest {
@NotBlank(message = "箱门id不能为空",groups = {add.class,edit.class})
private String id;
@NotBlank(message = "箱门状态不能为空",groups = {edit.class})
@NotNull(message = "箱门状态不能为空",groups = {edit.class})
private Integer state;
private String errorMsg;
......
......@@ -11,7 +11,7 @@ import java.util.Date;
@EqualsAndHashCode(callSuper = true)
public class UpdatePolicemanReq extends BaseRequest {
@NotNull(message = "警员主键不能为空", groups = {add.class,edit.class, delete.class, detail.class})
@NotNull(message = "警员主键不能为空", groups = {edit.class, delete.class, detail.class})
private String id;
@NotNull(message = "警员名字不能为空", groups = {add.class,edit.class})
......
......@@ -14,32 +14,29 @@ import java.util.List;
@Data
public class UpdateWarehouseReq extends BaseRequest {
@NotBlank(message = "仓库主键不能为空", groups = {edit.class, delete.class, detail.class})
@NotBlank(message = "仓库主键不能为空", groups = {edit.class, detail.class})
private String id;
private Long departmentId;
@NotBlank(message = "仓库名称不能为空", groups = {add.class,edit.class, delete.class, detail.class})
@NotBlank(message = "仓库名称不能为空", groups = {add.class,edit.class, detail.class})
private String name;
@NotBlank(message = "仓库地点不能为空", groups = {add.class,edit.class, delete.class, detail.class})
@NotBlank(message = "仓库地点不能为空", groups = {add.class,edit.class, detail.class})
private String location;
@NotBlank(message = "联系方式不能为空", groups = {add.class,edit.class, delete.class, detail.class})
@NotBlank(message = "联系方式不能为空", groups = {add.class,edit.class, detail.class})
private String phone;
private String video;
@TableField(value = "create_time",fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_time",fill = FieldFill.UPDATE)
private Date updateTime;
private String updateUser;
@JsonProperty(value = "orgId")
@NotNull(message = "组织机构id不能为空", groups = {add.class,edit.class, delete.class, detail.class})
@NotNull(message = "组织机构id不能为空", groups = {add.class,edit.class, detail.class})
private Long orgId;
private Boolean isLocked;
......
......@@ -72,8 +72,8 @@ public class PoliceController {
//根据组织机构id查询,只查询本级,不包含下级
@PostMapping("/ShowPoliceList")
@ApiOperation("查询某个组织机构下的所有警员信息")
public ApiRes<PoliceDto> GetAllPolicemanList(PolicemanReq req){
PoliceDto policeDto = policemanService.GetAllPolicemanList(req.getOrgId());
public ApiRes<PoliceDto> GetAllPolicemanList(@RequestBody PolicemanReq req){
PoliceDto policeDto = policemanService.GetAllPolicemanList(req);
return ApiRes.success(policeDto);
}
......@@ -98,9 +98,9 @@ public class PoliceController {
*/
@PostMapping("/GetPoliceData")
@ApiOperation("查询与单警柜绑定的警员信息") //根据单警柜id查询
public ApiRes<PoliceDto> GetPoliceData(CabinetReq req){
public ApiRes<PoliceDto> GetPoliceData(@RequestBody CabinetReq req){
//获取该组织机构下所有警员的id
PoliceDto policeDto = policemanService.GetPoliceData(req.getId());
PoliceDto policeDto = policemanService.GetPoliceData(req);
return ApiRes.success(policeDto);
}
......
......@@ -55,16 +55,22 @@ public class WarehouseController {
@PostMapping("/ChangeWarehouseState")
@ApiOperation("禁用/启用仓库")
public ApiRes<Boolean> changeWarehouseState(@RequestBody @Validated(WarehouseReq.edit.class) WarehouseReq req) {
public ApiRes<Boolean> changeWarehouseState(@RequestBody @Validated(ValidationApi.updateStatus.class) WarehouseReq req) {
return ApiRes.success(warehouseService.changeWarehouseState(req));
}
/**
* 通过组织机构id获取仓库列表
* @param req
* @return
*/
@PostMapping("/ShowWarehouse")
@ApiOperation("查询仓库列表")
public ApiRes<List<WarehouseDto>> getAllWarehouse(@RequestBody WarehouseReq req){
public ApiRes<List<WarehouseDto>> getAllWarehouse(@RequestBody @Validated(ValidationApi.edit.class) WarehouseReq req){
return ApiRes.success(warehouseService.getAllWarehouse(req));
}
//通过仓库id查询列表
@PostMapping("/GetWarehouseDetail")
@ApiOperation("查询单个仓库信息")
public ApiRes<WarehouseDto> getOneWarehouse(@RequestBody @Validated(WarehouseReq.detail.class)WarehouseReq req) {
......@@ -73,7 +79,7 @@ public class WarehouseController {
@PostMapping("/UpdateWarehouse")
@ApiOperation("修改仓库信息")
public ApiRes<Boolean> updateWarehouse(@RequestBody @Validated(WarehouseReq.edit.class) UpdateWarehouseReq req) {
public ApiRes<Boolean> updateWarehouse(@RequestBody @Validated(ValidationApi.edit.class) UpdateWarehouseReq req) {
return ApiRes.success(warehouseService.updateWarehouse(req));
}
......@@ -104,7 +110,7 @@ public class WarehouseController {
@PostMapping("/AddShelf")
@ApiOperation("添加货架")
public ApiRes<Boolean> AddShelf(@RequestBody @Validated(ValidationApi.add.class) UpdateShelfReq req) {
public ApiRes<String> AddShelf(@RequestBody @Validated(ValidationApi.add.class) UpdateShelfReq req) {
return ApiRes.success(shelfService.AddShelf(req));
}
......
......@@ -44,14 +44,11 @@ public class Warehouse implements Serializable {
private String updateUser;
@TableField("org_id_int")
private Long orgIdInt;
private Long orgId;
@TableField("is_locked")
private Boolean isLocked;
@TableField("org_id")
private String orgId;
@TableField("sum")
private Integer sum;
......
......@@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
@TableName("base_warehouse_area")
public class WarehouseArea implements Serializable {
@TableId(value = "area_id", type = IdType.ASSIGN_UUID)
private String id;
private String areaId;
@TableField("area_name")
private String areaName;
......
......@@ -16,4 +16,7 @@ public interface CabinetBoxService extends IService<CabinetBox> {
//添加箱门信息
boolean AddBoxInfo(UpdateCabinetBoxReq req);
//判断箱门信息是否存在
CabinetBox CabinetBoxExist(String id);
}
......@@ -3,6 +3,7 @@ package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.dto.PoliceDto;
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.req.UpdatePolicemanReq;
import com.junmp.jyzb.entity.Policeman;
......@@ -34,11 +35,11 @@ public interface PolicemanService extends IService<Policeman> {
//通过组织机构id查询警员列表
PoliceDto GetAllPolicemanList(Long orgId);
PoliceDto GetAllPolicemanList(PolicemanReq req);
//根据单警柜id查询警员列表
PoliceDto GetPoliceData(String id);
PoliceDto GetPoliceData(CabinetReq req);
boolean UpdateFaceInfo(UpdatePolicemanReq req);
......
......@@ -9,7 +9,7 @@ import com.junmp.jyzb.entity.Shelf;
import java.util.List;
public interface ShelfService extends IService<Shelf> {
boolean AddShelf(UpdateShelfReq req);
String AddShelf(UpdateShelfReq req);
boolean UpdateShelf(UpdateShelfReq req);
......
......@@ -49,15 +49,22 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
@Override
@Transactional(rollbackFor = Exception.class)
public boolean AddBoxInfo(UpdateCabinetBoxReq req) {
CabinetBox cabinetBox = new CabinetBox();
BeanPlusUtil.copyProperties(req,cabinetBox);
//添加单警柜箱门信息默认状态为1
cabinetBox.setState(1);
Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getCabinetNum, req.getCabinetNum()));
if (ObjectUtil.isNull(cabinet)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
//判断传递的箱号是否存在
CabinetBox one = getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getCabinetId, cabinet.getId())
.eq(CabinetBox::getNum, req.getNum()));
if (ObjectUtil.isNull(one)){
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_IS_EXISTS);
}
CabinetBox cabinetBox = new CabinetBox();
BeanPlusUtil.copyProperties(req,cabinetBox);
//添加单警柜箱门信息默认状态为1
cabinetBox.setState(1);
cabinetBox.setCabinetId(cabinet.getId());
Integer num = cabinet.getNum();
if (num==null){
......@@ -70,4 +77,15 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
return save(cabinetBox);
}
//判断箱子信息是否存在
@Override
public CabinetBox CabinetBoxExist(String id) {
CabinetBox cabinetBox = getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getId,id));
if (ObjectUtil.isNull(cabinetBox)) {
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
}
return cabinetBox;
}
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.PoliceDto;
import com.junmp.jyzb.api.bean.dto.PoliceFingerDto;
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.req.UpdatePolicemanReq;
import com.junmp.jyzb.entity.*;
......@@ -178,10 +179,8 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//查询传入的组织机构id是否存在
pubOrgService.PubOrgExist(req.getOrgId());
//判断传入的修改的警员编号与本身编号一致,如果一致则无所谓,如果不一致则需要判断修改的警员编号是否已经存在
Policeman one = getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotNull(req.getId()), Policeman::getId, req.getId()));
//判断警员是否存在
Policeman one = PoliceExist(req.getId());
if (!req.getPoliceCode().equals(one.getPoliceCode())) {
Policeman one1 = getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotNull(req.getPoliceCode()), Policeman::getPoliceCode, req.getPoliceCode()));
......@@ -189,12 +188,10 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
}
}
//判断是否传递了箱子id,如果传了则判断箱子是否存在
if (ObjectUtil.isNotEmpty(req.getCabinetBoxId())||!req.getCabinetBoxId().equals("")){
//查询单警柜箱号是否存在,箱门不存在抛异常
CabinetBox cabinetBox = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getId, req.getCabinetBoxId()));
if (ObjectUtil.isNull(cabinetBox)) {
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
cabinetBoxService.CabinetBoxExist(req.getCabinetBoxId());
}
policeman.setUpdateTime(DateTimeUtil.getCurrentDateTime());
return updateById(policeman);
......@@ -247,15 +244,15 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
/**
* 通过组织机构id查询警员列表
*
* @param orgId
* @param
*/
@Override
public PoliceDto GetAllPolicemanList(Long orgId) {
public PoliceDto GetAllPolicemanList(PolicemanReq req) {
//查询传入的组织机构id是否存在
PubOrg pubOrg = pubOrgService.PubOrgExist(orgId);
PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
//查询出组织机构下的所有警员信息
List<Policeman> list = list(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(orgId), Policeman::getOrgId, orgId)
.eq(ObjectUtil.isNotEmpty(req.getOrgId()), Policeman::getOrgId, req.getOrgId())
.eq(Policeman::getState, 1));
List<PolicemanDto> policeList = new ArrayList<>();
//查询出警员信息下的指纹列表信息
......@@ -278,7 +275,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
policeDto.setPolicemanlist(policeList);
//设置组织机构名
policeDto.setOrgName(pubOrg.getOrgName());
policeDto.setOrgId(orgId);
policeDto.setOrgId(req.getOrgId());
return policeDto;
}
......@@ -286,12 +283,12 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//根据单警柜id查询警员信息
@Override
public PoliceDto GetPoliceData(String id) {
public PoliceDto GetPoliceData(CabinetReq req) {
PoliceDto policeDto = new PoliceDto();
//判断单警柜id是否正确
Cabinet cabinet = cabinetService.CabinetExist(id);
Cabinet cabinet = cabinetService.CabinetExist(req.getId());
//通过箱门id查询出警员
List<Policeman> policemenList = policemanMapper.SearchPoliceList(id);
List<Policeman> policemenList = policemanMapper.SearchPoliceList(req.getId());
List<PolicemanDto> list = new ArrayList<>();
for (Policeman policeman : policemenList) {
PolicemanDto policemanDto = new PolicemanDto();
......@@ -403,11 +400,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
Policeman policeman = PoliceExist(req.getId());
BeanPlusUtil.copyProperties(req, policeman);
//判断箱子是否存在
CabinetBox cabinetBox = cabinetBoxService.getOne(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getId, req.getCabinetBoxId()));
if (ObjectUtil.isNull(cabinetBox)) {
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_ISNOT_EXISTS);
}
cabinetBoxService.CabinetBoxExist(req.getCabinetBoxId());
return updateById(policeman);
}
......
......@@ -28,10 +28,13 @@ public class ShelfServiceImpl extends ServiceImpl<ShelfMapper, Shelf> implements
private WarehouseService warehouseService;
@Override
public boolean AddShelf(UpdateShelfReq req) {
public String AddShelf(UpdateShelfReq req) {
//判断仓库是否存在
warehouseService.WarehoustExist(req.getWarehouseId());
Shelf shelf = new Shelf();
BeanPlusUtil.copyProperties(req,shelf);
return this.save(shelf);
save(shelf);
return shelf.getShelfId();
}
@Override
......@@ -51,13 +54,9 @@ public class ShelfServiceImpl extends ServiceImpl<ShelfMapper, Shelf> implements
@Override
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);
List<Shelf> list = list(wrapper);
warehouseService.WarehoustExist(req.getWarehouseId());
List<Shelf> list = list(new LambdaQueryWrapper<Shelf>()
.eq(Shelf::getWarehouseId,req.getWarehouseId()));
List<ShelfDto> shelfDtoList=new ArrayList<>();
for (Shelf shelf:list) {
ShelfDto shelfDto = new ShelfDto();
......@@ -80,17 +79,4 @@ public class ShelfServiceImpl extends ServiceImpl<ShelfMapper, Shelf> implements
return shelf;
}
private LambdaQueryWrapper<Shelf> createWrapper(ShelfReq req) {
LambdaQueryWrapper<Shelf> wrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isEmpty(req)) {
return wrapper;
}
//根据货架id查询
wrapper.eq(ObjectUtil.isNotEmpty(req.getShelfId()), Shelf::getShelfId, req.getShelfId());
//根据货架名称、货架编号模糊查询
wrapper.like(ObjectUtil.isNotEmpty(req.getShelfName()), Shelf::getCode, req.getShelfName());
wrapper.orderByDesc(Shelf::getCreateTime);
return wrapper;
}
}
......@@ -65,7 +65,7 @@ public class WarehouseAreaServiceImpl extends ServiceImpl<WarehouseAreaMapper, W
WarehouseAreaExist(req.getAreaId());
WarehouseArea warehouseArea = new WarehouseArea();
BeanPlusUtil.copyProperties(req,warehouseArea);
return this.removeById(warehouseArea.getId());
return this.removeById(warehouseArea);
}
@Override
......
package com.junmp.jyzb.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -18,6 +19,7 @@ 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 org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -52,7 +54,7 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
WarehouseDto warehouseDto = new WarehouseDto();
BeanPlusUtil.copyProperties(warehouse,warehouseDto);
//获取组织机构名称
PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
PubOrg pubOrg = pubOrgService.PubOrgExist(warehouse.getOrgId());
warehouseDto.setOrgName(pubOrg.getOrgName());
return warehouseDto;
}
......@@ -129,7 +131,7 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper,Warehouse>
List<Warehouse> allWarehouse = new ArrayList<>();
LambdaQueryWrapper<Warehouse> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(Warehouse::getOrgIdInt, allOrgId);
queryWrapper.in(Warehouse::getOrgId, allOrgId);
allWarehouse = warehouseMapper.selectList(queryWrapper);
return allWarehouse;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论