Commit 5344d7cf by 赵剑炜

新增单警柜接口

parent c0b8da71
......@@ -33,6 +33,11 @@ public class CabinetReq extends BaseRequest {
private Integer num;
/**
* 类型
*/
@ApiModelProperty(value = "类型")
private String containType;
/**
* 单警柜名称
*/
@ApiModelProperty(value = "单警柜名称")
......
......@@ -42,7 +42,7 @@ public class Cabinet implements Serializable {
*/
@ApiModelProperty(value = "新版本组织机构号")
@TableField("org_id_int")
private Long orgId;
private Long orgIdInt;
/**
......
......@@ -13,7 +13,7 @@ import java.util.Map;
public interface CabinetMapper extends BaseMapper<Cabinet> {
List<Cabinet> getAllCabinetByOrgList(@Param("list") List<Long> allOrgId);
List<Cabinet> getAllCabinetsWithSingleCabinet(@Param("orgId")String id, @Param("boxType") String boxType);
boolean SetInventoryInfo(String id);
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.junmp.jyzb.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.CabinetDto;
......@@ -178,53 +179,66 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
*/
@Override
public List<CabinetDto> getAllCabinetList(CabinetReq req) {
//判断组织机构是否存在
// 判断组织机构是否存在
PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
List<CabinetDto> cabinetList=new ArrayList<>();
List<Cabinet> list = list(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getOrgId, req.getOrgId()));
if (list.size()==0){
List<CabinetDto> cabinetList = new ArrayList<>();
List<Cabinet> list = cabinetMapper.getAllCabinetsWithSingleCabinet(String.valueOf(req.getOrgId()),req.getContainType());
if (list.size() == 0) {
return new ArrayList<>();
}
for (Cabinet cabinet:list) {
for (Cabinet cabinet : list) {
CabinetDto cabinetDto = new CabinetDto();
BeanPlusUtil.copyProperties(cabinet,cabinetDto);
BeanPlusUtil.copyProperties(cabinet, cabinetDto);
cabinetDto.setOrgName(pubOrg.getOrgName());
cabinetList.add(cabinetDto);
}
return cabinetList;
}
//根据组织机构id查询出单警柜的详细信息(page)
@Override
public PageResult<CabinetDto> ShowCabinetPage(CabinetReq req) {
//判断组织机构是否存在
// 判断组织机构是否存在
PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
List<CabinetDto> cabinetList=new ArrayList<>();
LambdaQueryWrapper<Cabinet> eq = new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getOrgId, req.getOrgId())
.like(ObjectUtil.isNotNull(req.getName()),Cabinet::getName,req.getName())
.like(ObjectUtil.isNotNull(req.getSerialNum()),Cabinet::getCabinetNum,req.getSerialNum());
List<Cabinet> list = list(eq);
long size = list.size();
if (list.size()==0){
Page<CabinetDto> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
page.setRecords(cabinetList);
page.setTotal(cabinetList.size());
return PageResultFactory.createPageResult(page);
}
Page<Cabinet> page = page(PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()), eq);
List<Cabinet> records = page.getRecords();
for (Cabinet cabinet:records) {
.eq(Cabinet::getOrgIdInt, req.getOrgId())
.like(ObjectUtil.isNotNull(req.getName()), Cabinet::getName, req.getName())
.like(ObjectUtil.isNotNull(req.getSerialNum()), Cabinet::getCabinetNum, req.getSerialNum());
// 使用 PageHelper 开始分页
Page<Cabinet> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
// 执行分页查询
IPage<Cabinet> cabinetPage = page(page, eq);
// 获取查询结果列表
List<Cabinet> records = cabinetPage.getRecords();
// 将 Cabinet 转换为 CabinetDto
List<CabinetDto> cabinetList = records.stream()
.map(cabinet -> {
CabinetDto cabinetDto = new CabinetDto();
BeanPlusUtil.copyProperties(cabinet,cabinetDto);
BeanPlusUtil.copyProperties(cabinet, cabinetDto);
cabinetDto.setOrgName(pubOrg.getOrgName());
cabinetList.add(cabinetDto);
}
Page<CabinetDto> page1 = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
page1.setRecords(cabinetList);
page1.setTotal(size);
return PageResultFactory.createPageResult(page1);
return cabinetDto;
})
.collect(Collectors.toList());
// 构造一个新的 Page 对象,将 cabinetPage 的数据拷贝到新的对象中
Page<CabinetDto> newPage = new Page<>(cabinetPage.getCurrent(), cabinetPage.getSize(), cabinetPage.getTotal());
newPage.setRecords(cabinetList);
// 使用新的 Page 对象构造返回的 PageResult 对象
PageResult<CabinetDto> result = PageResultFactory.createPageResult(newPage);
return result;
}
/**
......@@ -235,21 +249,27 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
*/
@Override
public CabinetDto showOneCabinet(CabinetReq req) {
//查询单警柜信息
// 查询单警柜信息
Cabinet cabinet = CabinetExistByNum(req.getSerialNum());
//查询单警柜的箱门信息
// 查询单警柜的箱门信息
List<CabinetBox> list = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>()
.eq(ObjectUtil.isNotEmpty(cabinet.getId()), CabinetBox::getCabinetId, cabinet.getId()));
List<CabinetBoxDto> boxList=new ArrayList<>();
for (CabinetBox cabinetBox: list) {
.eq(ObjectUtil.isNotEmpty(cabinet.getId()), CabinetBox::getCabinetId, cabinet.getId())
.eq(ObjectUtil.isNotEmpty(req.getContainType()), CabinetBox::getBoxType, req.getContainType()));
List<CabinetBoxDto> boxList = list.stream()
.map(cabinetBox -> {
CabinetBoxDto cabinetBoxDto = new CabinetBoxDto();
BeanPlusUtil.copyProperties(cabinetBox,cabinetBoxDto);
boxList.add(cabinetBoxDto);
}
//将单警柜的信息和它的箱门信息返回
BeanPlusUtil.copyProperties(cabinetBox, cabinetBoxDto);
return cabinetBoxDto;
})
.collect(Collectors.toList());
// 将单警柜的信息和它的箱门信息返回
CabinetDto cabinetDto = new CabinetDto();
BeanPlusUtil.copyProperties(cabinet,cabinetDto);
BeanPlusUtil.copyProperties(cabinet, cabinetDto);
cabinetDto.setCabinetBoxList(boxList);
return cabinetDto;
}
......@@ -331,7 +351,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
//单警柜不存在异常
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
long orgId = one1.getOrgId();
long orgId = one1.getOrgIdInt();
//通过警员id获取警员所在的机构id
Policeman one2 = policemanService.getOne(new LambdaQueryWrapper<Policeman>()
.eq(ObjectUtil.isNotEmpty(req.getPoliceId()), Policeman::getId, req.getPoliceId()));
......@@ -375,7 +395,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Override
public Long SearchOrgId(CabinetReq req) {
Cabinet cabinet = CabinetExistByNum(req.getSerialNum());
return cabinet.getOrgId();
return cabinet.getOrgIdInt();
}
//根据单警柜id判断单警柜是否存在
......
......@@ -511,7 +511,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//判断单警柜id是否正确
Cabinet cabinet = cabinetService.CabinetExist(req.getId());
PubOrg pubOrg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>()
.eq(PubOrg::getOrgId, cabinet.getOrgId()));
.eq(PubOrg::getOrgId, cabinet.getOrgIdInt()));
//通过箱门id查询出警员
List<Policeman> policemenList = policemanMapper.SearchPoliceList(req.getId());
List<PolicemanDto> list = new ArrayList<>();
......@@ -541,7 +541,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
//判断单警柜id是否正确
Cabinet cabinet = cabinetService.CabinetExist(req.getId());
PubOrg pubOrg = pubOrgService.getOne(new LambdaQueryWrapper<PubOrg>()
.eq(PubOrg::getOrgId, cabinet.getOrgId()));
.eq(PubOrg::getOrgId, cabinet.getOrgIdInt()));
//通过箱门id查询出警员
Page<Policeman> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
long size = policemanMapper.SearchPoliceSize(req.getId());
......
......@@ -5,7 +5,7 @@
<id property="id" column="id" />
<result property="cabinetNum" column="cabinet_num" />
<result property="name" column="name" />
<result property="orgId" column="org_id_int" />
<result property="orgIdInt" column="org_id_int" />
<result property="departmentId" column="department_id" />
<result property="location" column="location" />
<result property="state" column="state" />
......@@ -72,6 +72,18 @@
#{item}
</foreach>
</select>
<select id="getAllCabinetsWithSingleCabinet" resultType="com.junmp.jyzb.entity.Cabinet">
SELECT c.*
FROM base_cabinet c
JOIN pub_org o ON c.org_id_int = o.org_id
WHERE c.org_id_int = #{orgId}
AND (#{boxType} IS NULL OR #{boxType} = '' OR EXISTS (
SELECT 1
FROM base_cabinet_box cb
WHERE cb.cabinet_id = c.id
AND cb.box_type = #{boxType}
))
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论