Commit 5344d7cf by 赵剑炜

新增单警柜接口

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