Commit 9a100cd1 by 李小惠

Merge branch 'develop' of http://gitlab.sothing.top/843502640/jyzb_platformV2 into develop-lxh

parents 8fa04ff9 5344d7cf
...@@ -17,7 +17,7 @@ public class CabinetBoxDto implements Serializable { ...@@ -17,7 +17,7 @@ public class CabinetBoxDto implements Serializable {
* 箱号 * 箱号
*/ */
@ApiModelProperty(value = "箱门号") @ApiModelProperty(value = "箱门号")
private Integer BoxNum; private Integer num;
/** /**
* 异常状态:1正常/0异常 * 异常状态:1正常/0异常
...@@ -31,6 +31,7 @@ public class CabinetBoxDto implements Serializable { ...@@ -31,6 +31,7 @@ public class CabinetBoxDto implements Serializable {
@ApiModelProperty(value = "异常原因") @ApiModelProperty(value = "异常原因")
private String errorMsg; private String errorMsg;
/** /**
* 箱门绑定警员id * 箱门绑定警员id
*/ */
...@@ -41,4 +42,10 @@ public class CabinetBoxDto implements Serializable { ...@@ -41,4 +42,10 @@ public class CabinetBoxDto implements Serializable {
*/ */
private String policeName; private String policeName;
/**
* 箱门类型:1单警柜,2公共柜
*/
@ApiModelProperty(value = "箱门类型:1单警柜,2公共柜")
private Integer boxType;
} }
...@@ -47,9 +47,18 @@ public class CabinetDto implements Serializable{ ...@@ -47,9 +47,18 @@ public class CabinetDto implements Serializable{
*/ */
@ApiModelProperty(value = "位置信息") @ApiModelProperty(value = "位置信息")
private String location; private String location;
/**
* 单警柜号
*/
@ApiModelProperty(value = "单警柜号")
private String serverNum;
private Integer state; private Integer state;
/**
* 在线状态
*/
@ApiModelProperty(value = "在线状态")
private Integer onlineState;
private List<CabinetBoxDto> cabinetBoxList; private List<CabinetBoxDto> cabinetBoxList;
......
...@@ -15,15 +15,16 @@ public class CabinetReq extends BaseRequest { ...@@ -15,15 +15,16 @@ public class CabinetReq extends BaseRequest {
/** /**
* 单警柜ID * 单警柜ID
*/ */
@NotNull(message = "单警柜ID主键不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "单警柜ID") @ApiModelProperty(value = "单警柜ID")
private String id; private String id;
/** /**
* 单警柜编号 * 单警柜编号
*/ */
@NotNull(message = "单警柜ID主键不能为空", groups = {edit.class, delete.class, detail.class})
@ApiModelProperty(value = "单警柜编号") @ApiModelProperty(value = "单警柜编号")
private String cabinetNum; private String serialNum;
/** /**
* 箱数 * 箱数
...@@ -32,6 +33,11 @@ public class CabinetReq extends BaseRequest { ...@@ -32,6 +33,11 @@ public class CabinetReq extends BaseRequest {
private Integer num; private Integer num;
/** /**
* 类型
*/
@ApiModelProperty(value = "类型")
private String containType;
/**
* 单警柜名称 * 单警柜名称
*/ */
@ApiModelProperty(value = "单警柜名称") @ApiModelProperty(value = "单警柜名称")
......
...@@ -7,20 +7,22 @@ import lombok.EqualsAndHashCode; ...@@ -7,20 +7,22 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class UpdateCabinetBoxReq extends BaseRequest { public class UpdateCabinetBoxReq extends BaseRequest {
@NotBlank(message = "箱门id不能为空",groups = {add.class,edit.class}) // @NotBlank(message = "箱门id不能为空",groups = {add.class,edit.class})
private String id; private String id;
@NotNull(message = "箱门状态不能为空",groups = {edit.class})
private Integer state; private Integer state;
private String errorMsg; private String errorMsg;
private String boxName;
//单警柜编号 private String equipmentConfig;
@NotBlank(message = "单警柜编号不能为空",groups = {add.class}) private String boxType;
private String cabinetNum; private String power;
private List<String> boxNum;
private Integer num; private Integer num;
} }
...@@ -25,13 +25,7 @@ public class UpdateCabinetReq extends BaseRequest { ...@@ -25,13 +25,7 @@ public class UpdateCabinetReq extends BaseRequest {
*/ */
@NotBlank(message = "单警柜编号不能为空", groups = {add.class,edit.class, detail.class}) @NotBlank(message = "单警柜编号不能为空", groups = {add.class,edit.class, detail.class})
@ApiModelProperty(value = "单警柜编号") @ApiModelProperty(value = "单警柜编号")
private String cabinetNum; private String serialNum;
/**
* 箱数
*/
@ApiModelProperty(value = "箱数")
private Integer num;
/** /**
* 单警柜名称 * 单警柜名称
...@@ -39,6 +33,11 @@ public class UpdateCabinetReq extends BaseRequest { ...@@ -39,6 +33,11 @@ public class UpdateCabinetReq extends BaseRequest {
@NotBlank(message = "单警柜名称不能为空", groups = {add.class,edit.class, detail.class}) @NotBlank(message = "单警柜名称不能为空", groups = {add.class,edit.class, detail.class})
@ApiModelProperty(value = "单警柜名称") @ApiModelProperty(value = "单警柜名称")
private String name; private String name;
/**
* 单警柜名称
*/
@ApiModelProperty(value = "动作来源")
private String actionFrom;
/** /**
* 组织机构号 * 组织机构号
...@@ -50,7 +49,7 @@ public class UpdateCabinetReq extends BaseRequest { ...@@ -50,7 +49,7 @@ public class UpdateCabinetReq extends BaseRequest {
/** /**
* 位置信息 * 位置信息
*/ */
@NotBlank(message = "位置信息不能为空", groups = {add.class, edit.class})
@ApiModelProperty(value = "位置信息") @ApiModelProperty(value = "位置信息")
private String location; private String location;
...@@ -88,6 +87,8 @@ public class UpdateCabinetReq extends BaseRequest { ...@@ -88,6 +87,8 @@ public class UpdateCabinetReq extends BaseRequest {
//箱门信息列表 //箱门信息列表
private List<UpdateCabinetBoxReq> cabinetBoxList; private List<UpdateCabinetBoxReq> cabinetBoxList;
//箱门信息列表
private List<String> numList;
//单警柜id列表 //单警柜id列表
private List<String> cabinetList; private List<String> cabinetList;
......
package com.junmp.jyzb.controller; package com.junmp.jyzb.controller;
import com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq; import com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq;
import com.junmp.jyzb.api.bean.req.UpdateCabinetReq;
import com.junmp.jyzb.service.CabinetBoxService; import com.junmp.jyzb.service.CabinetBoxService;
import com.junmp.v2.common.bean.request.ValidationApi; import com.junmp.v2.common.bean.request.ValidationApi;
import com.junmp.v2.common.bean.response.ApiRes; import com.junmp.v2.common.bean.response.ApiRes;
...@@ -25,7 +26,14 @@ public class CabinetBoxController { ...@@ -25,7 +26,14 @@ public class CabinetBoxController {
//添加箱门信息 //添加箱门信息
@PostMapping("/AddBoxInfo") @PostMapping("/AddBoxInfo")
@ApiOperation("添加箱门信息") @ApiOperation("添加箱门信息")
public ApiRes<String> AddBoxInfo(@RequestBody @Validated(ValidationApi.add.class) UpdateCabinetBoxReq req){ public ApiRes<String> AddOrUpdateBoxInfo(@RequestBody UpdateCabinetReq req){
return ApiRes.success(cabinetBoxService.AddBoxInfo(req)); return ApiRes.success(cabinetBoxService.AddOrUpdateBoxInfo(req));
}
//添加箱门信息
@PostMapping("/DeleteBox")
@ApiOperation("删除箱门")
public ApiRes<String> DeleteBox(@RequestBody @Validated(ValidationApi.delete.class) UpdateCabinetReq req){
return ApiRes.success(cabinetBoxService.DeleteBox(req));
} }
} }
...@@ -59,9 +59,9 @@ public class CabinetController { ...@@ -59,9 +59,9 @@ public class CabinetController {
return ApiRes.success(cabinetService.deleteCabinetInfo(req)); return ApiRes.success(cabinetService.deleteCabinetInfo(req));
} }
@PostMapping("/UpdateCabinetInfo") @PostMapping("/UpdateCabinetServer")
@ApiOperation("修改单警柜信息") @ApiOperation("修改单警柜信息,平台使用")
public ApiRes<Boolean> updateCabinetInfo(@RequestBody UpdateCabinetReq req) { public ApiRes<Boolean> UpdateCabinetServer(@RequestBody UpdateCabinetReq req) {
boolean result = cabinetService.updateCabinetInfo(req); boolean result = cabinetService.updateCabinetInfo(req);
if (!result){ if (!result){
return ApiRes.failure("操作失败"); return ApiRes.failure("操作失败");
...@@ -69,7 +69,15 @@ public class CabinetController { ...@@ -69,7 +69,15 @@ public class CabinetController {
return ApiRes.success(result); return ApiRes.success(result);
} }
@PostMapping("/UpdateCabinetClient")
@ApiOperation("修改单警柜信息,警柜使用")
public ApiRes<Boolean> UpdateCabinetClient(@RequestBody UpdateCabinetReq req) {
boolean result = cabinetService.updateCabinetInfo(req);
if (!result){
return ApiRes.failure("操作失败");
}
return ApiRes.success(result);
}
//通过单警柜id查询单个箱门及其箱门信息 //通过单警柜id查询单个箱门及其箱门信息
@PostMapping("/ShowOneCabinet") @PostMapping("/ShowOneCabinet")
......
...@@ -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;
/** /**
...@@ -62,7 +62,12 @@ public class Cabinet implements Serializable { ...@@ -62,7 +62,12 @@ public class Cabinet implements Serializable {
*/ */
@ApiModelProperty(value = "单警柜当前状态,0正常,1异常") @ApiModelProperty(value = "单警柜当前状态,0正常,1异常")
private Integer state; private Integer state;
/**
* 单警柜在线状态,0正常,1异常
*/
@ApiModelProperty(value = "单警柜在线状态,0离线,1在线")
@TableField("online_state")
private Integer onlineState;
/** /**
* 装备总数 * 装备总数
*/ */
...@@ -90,20 +95,13 @@ public class Cabinet implements Serializable { ...@@ -90,20 +95,13 @@ public class Cabinet implements Serializable {
@TableField("price_total") @TableField("price_total")
private BigDecimal priceTotal; private BigDecimal priceTotal;
/** @TableField(fill = FieldFill.INSERT_UPDATE, value = "create_time")
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@TableField(value="create_time")
private Date createTime; private Date createTime;
/** @TableField(fill = FieldFill.INSERT_UPDATE, value = "update_time")
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
@TableField(value = "update_time")
private Date updateTime; private Date updateTime;
/** /**
* 新增人员 * 新增人员
*/ */
......
package com.junmp.jyzb.entity; package com.junmp.jyzb.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -38,6 +37,19 @@ public class CabinetBox implements Serializable { ...@@ -38,6 +37,19 @@ public class CabinetBox implements Serializable {
private Integer num; private Integer num;
/** /**
* 装备配置信息
*/
@ApiModelProperty(value = "装备配置信息")
@TableField("equipment_config")
private String equipmentConfig;
/**
* 功率
*/
@ApiModelProperty(value = "power")
@TableField("power")
private String power;
/**
* 异常状态:1正常/0异常 * 异常状态:1正常/0异常
*/ */
@ApiModelProperty(value = "异常状态:1正常/0异常") @ApiModelProperty(value = "异常状态:1正常/0异常")
...@@ -49,7 +61,18 @@ public class CabinetBox implements Serializable { ...@@ -49,7 +61,18 @@ public class CabinetBox implements Serializable {
@ApiModelProperty(value = "异常原因") @ApiModelProperty(value = "异常原因")
@TableField("error_msg") @TableField("error_msg")
private String errorMsg; private String errorMsg;
/**
* 别名
*/
@ApiModelProperty(value = "别名")
@TableField("box_name")
private String boxName;
/**
* 箱门类型:1单警柜,2公共柜
*/
@ApiModelProperty(value = "箱门类型:1单警柜,2公共柜")
@TableField("box_type")
private String boxType;
/** /**
* 使用日志存储位置信息 * 使用日志存储位置信息
*/ */
...@@ -66,4 +89,10 @@ public class CabinetBox implements Serializable { ...@@ -66,4 +89,10 @@ public class CabinetBox implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableField(fill = FieldFill.INSERT_UPDATE, value = "create_time")
private Date createTime;
@TableField(fill = FieldFill.INSERT_UPDATE, value = "update_time")
private Date updateTime;
} }
\ No newline at end of file
...@@ -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; ...@@ -3,6 +3,7 @@ package com.junmp.jyzb.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.junmp.jyzb.api.bean.query.CabinetReq; import com.junmp.jyzb.api.bean.query.CabinetReq;
import com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq; import com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq;
import com.junmp.jyzb.api.bean.req.UpdateCabinetReq;
import com.junmp.jyzb.entity.CabinetBox; import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.jyzb.entity.Policeman; import com.junmp.jyzb.entity.Policeman;
...@@ -13,8 +14,9 @@ public interface CabinetBoxService extends IService<CabinetBox> { ...@@ -13,8 +14,9 @@ public interface CabinetBoxService extends IService<CabinetBox> {
//添加箱门信息 //添加箱门信息
String AddBoxInfo(UpdateCabinetBoxReq req); String AddOrUpdateBoxInfo(UpdateCabinetReq req);
//添加箱门信息
String DeleteBox(UpdateCabinetReq req);
//判断箱门信息是否存在 //判断箱门信息是否存在
CabinetBox CabinetBoxExist(String id); CabinetBox CabinetBoxExist(String id);
} }
...@@ -46,13 +46,19 @@ public interface CabinetService extends IService<Cabinet> { ...@@ -46,13 +46,19 @@ public interface CabinetService extends IService<Cabinet> {
CabinetDto showOneCabinet(CabinetReq req); CabinetDto showOneCabinet(CabinetReq req);
/** /**
* 修改单警柜信息 * 修改单警柜信息,平台使用
* @param req * @param req
* @return * @return
*/ */
boolean updateCabinetInfo(UpdateCabinetReq req); boolean updateCabinetInfo(UpdateCabinetReq req);
/** /**
* 修改单警柜信息,警柜使用
* @param req
* @return
*/
boolean updateCabinetClient(UpdateCabinetReq req);
/**
* 箱门绑定人员 * 箱门绑定人员
* @param req * @param req
* @return * @return
......
...@@ -5,23 +5,32 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -5,23 +5,32 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.query.CabinetReq; import com.junmp.jyzb.api.bean.query.CabinetReq;
import com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq; import com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq;
import com.junmp.jyzb.api.bean.req.UpdateCabinetReq;
import com.junmp.jyzb.entity.Cabinet; import com.junmp.jyzb.entity.Cabinet;
import com.junmp.jyzb.entity.CabinetBox; import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.jyzb.api.exception.enums.CabinetBoxExceptionEnum; import com.junmp.jyzb.api.exception.enums.CabinetBoxExceptionEnum;
import com.junmp.jyzb.api.exception.enums.CabinetExceptionEnum; import com.junmp.jyzb.api.exception.enums.CabinetExceptionEnum;
import com.junmp.jyzb.entity.ES.Blog;
import com.junmp.jyzb.mapper.CabinetBoxMapper; import com.junmp.jyzb.mapper.CabinetBoxMapper;
import com.junmp.jyzb.mapper.PoliceFingerMapper; import com.junmp.jyzb.mapper.PoliceFingerMapper;
import com.junmp.jyzb.mapper.PolicemanMapper; import com.junmp.jyzb.mapper.PolicemanMapper;
import com.junmp.jyzb.service.CabinetBoxService; import com.junmp.jyzb.service.CabinetBoxService;
import com.junmp.jyzb.service.CabinetService; import com.junmp.jyzb.service.CabinetService;
import com.junmp.jyzb.utils.RabbitMQSendMsg;
import com.junmp.v2.common.exception.base.ServiceException; import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil; import com.junmp.v2.common.util.BeanPlusUtil;
import org.apache.poi.ss.formula.functions.Now;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service @Service
public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, CabinetBox> implements CabinetBoxService { public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, CabinetBox> implements CabinetBoxService {
...@@ -29,15 +38,77 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet ...@@ -29,15 +38,77 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
@Resource @Resource
private CabinetService cabinetService; private CabinetService cabinetService;
@Autowired
private RabbitMQSendMsg MQ;
//添加箱门信息 //添加箱门信息
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String AddBoxInfo(UpdateCabinetBoxReq req) { public String AddOrUpdateBoxInfo(UpdateCabinetReq req) {
Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getCabinetNum, req.getSerialNum()));
if (ObjectUtil.isNull(cabinet)) {
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
List<UpdateCabinetBoxReq> addList = req.getCabinetBoxList();
List<CabinetBox> existingBoxes = list(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getCabinetId, cabinet.getId()));
Map<Integer, CabinetBox> existingBoxMap = existingBoxes.stream()
.collect(Collectors.toMap(CabinetBox::getNum, Function.identity()));
List<CabinetBox> boxListAdd = new ArrayList<>();
for (UpdateCabinetBoxReq boxReq : addList) {
CabinetBox box = new CabinetBox();
box.setCabinetId(cabinet.getId());
box.setPower(boxReq.getPower());
box.setEquipmentConfig(boxReq.getEquipmentConfig());
box.setBoxType(boxReq.getBoxType());
box.setState(0);
box.setBoxName(boxReq.getBoxName());
box.setNum(boxReq.getNum());
box.setUpdateTime(new Date());
// 在内存中比较是否存在相同 SerialNum 和相同 num 的数据
CabinetBox existingBox = existingBoxMap.get(boxReq.getNum());
if (existingBox != null) {
// 如果存在,则更新数据
box.setId(existingBox.getId());
updateById(box);
} else {
// 如果不存在,则新增数据
boxListAdd.add(box);
}
}
Integer num = cabinet.getNum();//获取当前柜的总数量
if (num == null) {
num = 0;
}
// 更新 Cabinet 实体
cabinet.setNum(num + addList.size());
cabinetService.updateById(cabinet);
if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送
{
MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange");
}
// 批量保存新增的数据
saveBatch(boxListAdd);
return cabinet.getId();
}
//删除箱门
@Override
@Transactional(rollbackFor = Exception.class)
public String DeleteBox(UpdateCabinetReq req) {
Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>() Cabinet cabinet = cabinetService.getOne(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getCabinetNum, req.getCabinetNum())); .eq(Cabinet::getCabinetNum, req.getSerialNum()));
if (ObjectUtil.isNull(cabinet)){ if (ObjectUtil.isNull(cabinet)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS); throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
} }
...@@ -47,26 +118,24 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet ...@@ -47,26 +118,24 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
if (ObjectUtil.isNotNull(one)){ if (ObjectUtil.isNotNull(one)){
throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_IS_EXISTS); throw new ServiceException(CabinetBoxExceptionEnum.CABINETBOX_IS_EXISTS);
} }
CabinetBoxExist(req.getId());
CabinetBox cabinetBox = new CabinetBox();
BeanPlusUtil.copyProperties(req,cabinetBox);
//添加单警柜箱门信息默认状态为0正常 //添加单警柜箱门信息默认状态为0正常
cabinetBox.setState(0); List<String> boxNumList = req.getNumList();
cabinetBox.setCabinetId(cabinet.getId()); remove(new LambdaQueryWrapper<CabinetBox>()
Integer num = cabinet.getNum(); .eq(CabinetBox::getCabinetId, cabinet.getId())
if (num==null){ .in(CabinetBox::getNum, boxNumList));
num=1;
cabinet.setNum(num); // 更新 Cabinet 实体的 num 字段
cabinetBox.setNum(num); Integer cabinetNum = cabinet.getNum();
}else { if (cabinetNum != null) {
cabinet.setNum(num+1); cabinet.setNum(cabinetNum - boxNumList.size());
cabinetBox.setNum(num+1);
}
cabinetService.updateById(cabinet); cabinetService.updateById(cabinet);
save(cabinetBox);
return cabinetBox.getId();
} }
if (req.getActionFrom().equals("platform"))//请求来源于平台,则进行推送
{
MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange");
}
return cabinet.getId();
}
//判断箱子信息是否存在 //判断箱子信息是否存在
@Override @Override
public CabinetBox CabinetBoxExist(String id) { public CabinetBox CabinetBoxExist(String id) {
......
package com.junmp.jyzb.service.impl; package com.junmp.jyzb.service.impl;
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;
...@@ -21,12 +23,14 @@ import com.junmp.v2.common.util.BeanPlusUtil; ...@@ -21,12 +23,14 @@ import com.junmp.v2.common.util.BeanPlusUtil;
import com.junmp.v2.db.api.factory.PageFactory; import com.junmp.v2.db.api.factory.PageFactory;
import com.junmp.v2.db.api.factory.PageResultFactory; import com.junmp.v2.db.api.factory.PageResultFactory;
import com.junmp.v2.db.api.page.PageResult; import com.junmp.v2.db.api.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
...@@ -35,18 +39,14 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -35,18 +39,14 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Resource @Resource
private CabinetMapper cabinetMapper; private CabinetMapper cabinetMapper;
@Resource @Resource
private PubOrgService pubOrgService; private PubOrgService pubOrgService;
@Resource @Resource
private CabinetBoxService cabinetBoxService; private CabinetBoxService cabinetBoxService;
@Resource @Resource
private PolicemanService policemanService; private PolicemanService policemanService;
@Autowired
@Resource private RabbitMQSendMsg MQ;
private OrderMainService orderMainService;
private List<Long> getAllOrgId(CabinetReq req, String includeLowerLevel) { private List<Long> getAllOrgId(CabinetReq req, String includeLowerLevel) {
List<Long> allOrg = new ArrayList<>(); List<Long> allOrg = new ArrayList<>();
...@@ -76,34 +76,39 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -76,34 +76,39 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Override @Override
public String addCabinetInfo(UpdateCabinetReq req) { public String addCabinetInfo(UpdateCabinetReq req) {
Cabinet cabinet = new Cabinet(); Cabinet cabinet = new Cabinet();
//查询传入的组织机构id是否存在 // 查询传入的组织机构id是否存在
pubOrgService.PubOrgExist(req.getOrgId()); pubOrgService.PubOrgExist(req.getOrgId());
//查询是否有重复的单警柜编号 // 查询是否有重复的单警柜编号
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.getSerialNum()), Cabinet::getCabinetNum, req.getSerialNum()));
if (list.size()>0) { if (list.size() > 0) {
//抛出单警柜重复异常 // 抛出单警柜重复异常
throw new ServiceException(CabinetExceptionEnum.CABINETID_IS_EXISTS); throw new ServiceException(CabinetExceptionEnum.CABINETID_IS_EXISTS);
} }
BeanPlusUtil.copyProperties(req, cabinet); BeanPlusUtil.copyProperties(req, cabinet);
cabinet.setCreateTime(DateTimeUtil.getCurrentDateTime()); cabinet.setCabinetNum(req.getSerialNum());
cabinet.setUpdateTime(DateTimeUtil.getCurrentDateTime()); cabinet.setNum(req.getCabinetBoxList().size());
//添加单警柜 cabinet.setOnlineState(1);//新增后设置离线
cabinet.setUpdateTime(new Date());
cabinet.setCreateTime(new Date());
// 添加或更新单警柜
save(cabinet); save(cabinet);
List<CabinetBox> objects = new ArrayList<>();
//判断num值是否传递,如果没有不做操作 // 处理箱门信息
if (ObjectUtil.isNotNull(req.getNum()) && req.getNum().intValue()>=1){ if (CollectionUtil.isNotEmpty(req.getCabinetBoxList())) {
for (int i = 1; i <= req.getNum(); i++) { List<CabinetBox> boxList = req.getCabinetBoxList().stream()
CabinetBox cabinetBox = new CabinetBox(); .map(boxReq -> {
cabinetBox.setCabinetId(cabinet.getId()); CabinetBox box = new CabinetBox();
cabinetBox.setState(0); box.setCabinetId(cabinet.getId());
cabinetBox.setNum(i); box.setPower(boxReq.getPower());
//添加到列表进行批量增加 box.setEquipmentConfig(boxReq.getEquipmentConfig());
objects.add(cabinetBox); box.setBoxType(boxReq.getBoxType());
} box.setState(0);
cabinetBoxService.saveBatch(objects); box.setNum(boxReq.getNum());
}else if (ObjectUtil.isNotNull(req.getNum()) && req.getNum().intValue()<1){ return box;
throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR); })
.collect(Collectors.toList());
cabinetBoxService.saveOrUpdateBatch(boxList);
} }
return cabinet.getId(); return cabinet.getId();
...@@ -174,90 +179,66 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -174,90 +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);
List<CabinetBox> list1 = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getCabinetId, cabinet.getId()));
List<CabinetBoxDto> cabinetBoxList=new ArrayList<>();
for (CabinetBox cabinetBox:list1) {
CabinetBoxDto cabinetBoxDto = new CabinetBoxDto();
BeanPlusUtil.copyProperties(cabinetBox,cabinetBoxDto);
//查询箱门绑定的警员id和姓名
List<Policeman> policeList = policemanService.list(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getCabinetBoxId, cabinetBox.getId()));
if (policeList.size()!=0){
Policeman policeman = policeList.get(0);
cabinetBoxDto.setPoliceId(policeman.getId());
cabinetBoxDto.setPoliceName(policeman.getName());
}
cabinetBoxDto.setBoxNum(cabinetBox.getNum());
cabinetBoxList.add(cabinetBoxDto);
}
cabinetDto.setCabinetBoxList(cabinetBoxList);
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.getCabinetNum()),Cabinet::getCabinetNum,req.getCabinetNum()); .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);
List<CabinetBox> list1 = cabinetBoxService.list(new LambdaQueryWrapper<CabinetBox>()
.eq(CabinetBox::getCabinetId, cabinet.getId())
.orderByAsc(CabinetBox::getNum));
List<CabinetBoxDto> cabinetBoxList=new ArrayList<>();
for (CabinetBox cabinetBox:list1) {
CabinetBoxDto cabinetBoxDto = new CabinetBoxDto();
BeanPlusUtil.copyProperties(cabinetBox,cabinetBoxDto);
//查询箱门绑定的警员id和姓名
List<Policeman> policeList = policemanService.list(new LambdaQueryWrapper<Policeman>()
.eq(Policeman::getCabinetBoxId, cabinetBox.getId()));
if (policeList.size()!=0){
Policeman policeman = policeList.get(0);
cabinetBoxDto.setPoliceId(policeman.getId());
cabinetBoxDto.setPoliceName(policeman.getName());
}
cabinetBoxDto.setBoxNum(cabinetBox.getNum());
cabinetBoxList.add(cabinetBoxDto);
}
cabinetDto.setCabinetBoxList(cabinetBoxList);
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;
} }
/** /**
...@@ -268,21 +249,27 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -268,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 = CabinetExist(req.getId()); Cabinet cabinet = CabinetExistByNum(req.getSerialNum());
//查询单警柜的箱门信息
// 查询单警柜的箱门信息
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(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;
} }
...@@ -299,26 +286,44 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -299,26 +286,44 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
Cabinet one = getById(req.getId()); Cabinet one = getById(req.getId());
//查询是否有重复的单警柜编号 //查询是否有重复的单警柜编号
List<Cabinet> list = this.list(new LambdaQueryWrapper<Cabinet>() List<Cabinet> list = this.list(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getCabinetNum,req.getCabinetNum())); .eq(Cabinet::getCabinetNum,req.getSerialNum()));
if (list.size()>0 && !list.get(0).getCabinetNum().equals(one.getCabinetNum())) { if (list.size()>0 && !list.get(0).getCabinetNum().equals(one.getCabinetNum())) {
//抛出单警柜重复异常 //抛出单警柜重复异常
throw new ServiceException(CabinetExceptionEnum.CABINETID_IS_EXISTS); throw new ServiceException(CabinetExceptionEnum.CABINETID_IS_EXISTS);
} }
Cabinet cabinet = new Cabinet(); Cabinet cabinet = new Cabinet();
BeanPlusUtil.copyProperties(req, cabinet); BeanPlusUtil.copyProperties(req, cabinet);
//判断传递的箱数是否相同,如果相同则表示没有新增箱门数量,否则添加箱门信息 //后面还要进行消息推送
List<CabinetBox> cabinetBoxList=new ArrayList<>(); MQ.SendMsg("cabinetMsg",req.getSerialNum(),"cabinetChange");
if(req.getNum() != one.getNum()){ return this.updateById(cabinet);
int startNum = (one.getNum() != null) ? one.getNum() + 1 : 0; }
for(int i=startNum+1;i<=req.getNum();i++){ /**
CabinetBox cabinetBox = new CabinetBox(); * 修改单警柜信息,警柜使用
cabinetBox.setNum(i); * 新增箱数
cabinetBox.setCabinetId(req.getId()); * @param req
cabinetBox.setState(0); * @return
cabinetBoxList.add(cabinetBox); */
@Override
public boolean updateCabinetClient(UpdateCabinetReq req) {
//查询传入的组织机构id是否存在
pubOrgService.PubOrgExist(req.getOrgId());
Cabinet one = getOne(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getCabinetNum,req.getSerialNum()));
if (one==null)
{
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
} }
//查询是否有重复的单警柜编号
List<Cabinet> list = this.list(new LambdaQueryWrapper<Cabinet>()
.eq(Cabinet::getCabinetNum,req.getSerialNum()));
if (list.size()>0 && !list.get(0).getCabinetNum().equals(one.getCabinetNum())) {
//抛出单警柜重复异常
throw new ServiceException(CabinetExceptionEnum.CABINETID_IS_EXISTS);
} }
cabinetBoxService.saveBatch(cabinetBoxList); Cabinet cabinet = new Cabinet();
BeanPlusUtil.copyProperties(req, cabinet);
//后面还要进行消息推送
return this.updateById(cabinet); return this.updateById(cabinet);
} }
...@@ -346,7 +351,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -346,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()));
...@@ -372,7 +377,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -372,7 +377,7 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
@Override @Override
public boolean ChangeCabinetState(UpdateCabinetReq req) { public boolean ChangeCabinetState(UpdateCabinetReq req) {
//查询单警柜是否存在 //查询单警柜是否存在
CabinetExist(req.getId()); CabinetExistByNum(req.getSerialNum());
if (ObjectUtil.isNull(req.getCabinetBoxList()) || req.getCabinetBoxList().size()==0){ if (ObjectUtil.isNull(req.getCabinetBoxList()) || req.getCabinetBoxList().size()==0){
throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR); throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
} }
...@@ -389,8 +394,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -389,8 +394,8 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
//根据单警柜id查询出组织机构id //根据单警柜id查询出组织机构id
@Override @Override
public Long SearchOrgId(CabinetReq req) { public Long SearchOrgId(CabinetReq req) {
Cabinet cabinet = CabinetExist(req.getId()); Cabinet cabinet = CabinetExistByNum(req.getSerialNum());
return cabinet.getOrgId(); return cabinet.getOrgIdInt();
} }
//根据单警柜id判断单警柜是否存在 //根据单警柜id判断单警柜是否存在
...@@ -402,7 +407,15 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl ...@@ -402,7 +407,15 @@ public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> impl
} }
return one; return one;
} }
//根据单警柜id判断单警柜是否存在
public Cabinet CabinetExistByNum(String serverNum) {
Cabinet one = getOne(new LambdaQueryWrapper<Cabinet>()
.eq(ObjectUtil.isNotEmpty(serverNum), Cabinet::getCabinetNum, serverNum));
if (ObjectUtil.isNull(one)){
throw new ServiceException(CabinetExceptionEnum.CABINET_ISNOT_EXISTS);
}
return one;
}
//设置单警柜库存数量信息 //设置单警柜库存数量信息
@Override @Override
public boolean SetInventoryInfo(String id) { public boolean SetInventoryInfo(String id) {
......
...@@ -21,6 +21,8 @@ import com.junmp.jyzb.entity.*; ...@@ -21,6 +21,8 @@ import com.junmp.jyzb.entity.*;
import com.junmp.jyzb.mapper.OrderMainMapper; import com.junmp.jyzb.mapper.OrderMainMapper;
import com.junmp.jyzb.service.*; import com.junmp.jyzb.service.*;
import com.junmp.jyzb.utils.DateTimeUtil; import com.junmp.jyzb.utils.DateTimeUtil;
import com.junmp.jyzb.utils.RabbitMQSendMsg;
import com.junmp.jyzb.utils.RedisUtils;
import com.junmp.v2.common.bean.response.ApiRes; import com.junmp.v2.common.bean.response.ApiRes;
import com.junmp.v2.common.exception.base.ServiceException; import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.exception.enums.DefaultBizExceptionEnum; import com.junmp.v2.common.exception.enums.DefaultBizExceptionEnum;
...@@ -41,6 +43,7 @@ import org.springframework.amqp.core.Queue; ...@@ -41,6 +43,7 @@ import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.core.*; import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -108,6 +111,8 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -108,6 +111,8 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
@Resource @Resource
protected TaskService taskService; protected TaskService taskService;
@Autowired
private RabbitMQSendMsg MQ;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -285,29 +290,13 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -285,29 +290,13 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
} }
//将完成的任务单直接推送到消息队列rabbitmq中(需要判断是入库单还是出库单,入库单传发物单位id,出库单传收物单位id) //将完成的任务单直接推送到消息队列rabbitmq中(需要判断是入库单还是出库单,入库单传发物单位id,出库单传收物单位id)
//方法1:一个交换机,一个队列。通过中间对象,object存储对象,type表标识
// if(req.getOrderType().equals("in")){
// rabbitTemplate.convertAndSend("OrderExchange","OrderRouting",new MessageWrapper(req,req.getStartOrgId()));
// }else {
// rabbitTemplate.convertAndSend("OrderExchange","OrderRouting",new MessageWrapper(req,req.getEndOrgId()));
// }
//方法2:一个交换机,多个队列。动态创建队列 //方法2:一个交换机,多个队列。动态创建队列
String exchangeName="orderExchange"; String exchangeName="orderExchange";
//需要判断是入库单还是出库单,入库单传收物单位id,出库单传发物单位id //需要判断是入库单还是出库单,入库单传收物单位id,出库单传发物单位id
if(req.getOrderType().equals("in")){ if(req.getOrderType().equals("in")){
Queue queue=new Queue( req.getEndOrgId().toString(),true,false,false); MQ.SendMsg(exchangeName,req.getEndOrgId().toString(),req);
Exchange exchange = new DirectExchange(exchangeName, true, false);
rabbitAdmin.declareQueue(queue);
rabbitAdmin.declareExchange(exchange);
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with(req.getEndOrgId().toString()).noargs());
rabbitTemplate.convertAndSend(exchangeName, req.getEndOrgId().toString(), req);
}else { }else {
Queue queue = new Queue(req.getStartOrgId().toString(), true, false, false); MQ.SendMsg(exchangeName,req.getStartOrgId().toString(),req);
Exchange exchange = new DirectExchange(exchangeName, true, false);
rabbitAdmin.declareQueue(queue);
rabbitAdmin.declareExchange(exchange);
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with(req.getStartOrgId().toString()).noargs());
rabbitTemplate.convertAndSend(exchangeName, req.getStartOrgId().toString(), req);
} }
return req.getId(); return req.getId();
} }
......
...@@ -520,7 +520,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -520,7 +520,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<>();
...@@ -550,7 +550,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -550,7 +550,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());
......
package com.junmp.jyzb.utils;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class RabbitMQSendMsg {
@Resource
private RabbitTemplate rabbitTemplate;
@Resource
private RabbitAdmin rabbitAdmin;
public void SendMsg(String exchangeName,String name,Object msg)
{
Queue queue=new Queue(name,true,false,false);
Exchange exchange = new DirectExchange(exchangeName, true, false);
rabbitAdmin.declareQueue(queue);
rabbitAdmin.declareExchange(exchange);
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with(name).noargs());
rabbitTemplate.convertAndSend(exchangeName, name, msg);
}
}
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论