物资管理大屏仓库实时监控接口优化
This commit is contained in:
@ -1,24 +1,17 @@
|
||||
package org.dromara.bigscreen.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo;
|
||||
import org.dromara.bigscreen.domain.vo.designAndArrivalComparisonVo;
|
||||
import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo;
|
||||
import org.dromara.bigscreen.domain.vo.xhqsdbVo;
|
||||
import org.dromara.bigscreen.domain.vo.*;
|
||||
import org.dromara.bigscreen.service.IMaterialsManagementService;
|
||||
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
|
||||
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
|
||||
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
|
||||
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
|
||||
import org.dromara.manager.ys7manager.Ys7Manager;
|
||||
import org.dromara.materials.domain.vo.materials.MatMaterialsUseDetailVo;
|
||||
import org.dromara.materials.service.IMatMaterialsService;
|
||||
import org.dromara.project.domain.vo.project.BusProjectGisVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -45,6 +38,8 @@ public class MaterialsManagementController extends BaseController {
|
||||
private IBusMrpBaseService busMrpBaseService;
|
||||
@Autowired
|
||||
private IMatMaterialsService materialsService;
|
||||
@Resource
|
||||
private Ys7Manager ys7Manager;
|
||||
|
||||
/**
|
||||
* 库存结构分析
|
||||
@ -111,4 +106,28 @@ public class MaterialsManagementController extends BaseController {
|
||||
return R.ok(materialsService.listUseDetail(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓库实时监控
|
||||
*/
|
||||
@GetMapping("/warehouseMonitoring")
|
||||
public R<List<WarehouseMonitoringVo>> warehouseMonitoring(Long projectId) {
|
||||
return R.ok(materialsManagementService.warehouseMonitoring(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控以及仓库出入库详情
|
||||
*/
|
||||
@GetMapping("/warehouseInAndOutDetail")
|
||||
public R<List<StockInAndStockOutRecordVo>> warehouseInAndOutDetail(Long projectId, Long warehouseId) {
|
||||
return R.ok(materialsManagementService.warehouseInAndOutDetail(projectId, warehouseId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取YS7摄像头token
|
||||
*/
|
||||
@GetMapping("/get/token")
|
||||
public R<String> getToken() {
|
||||
return R.ok("操作成功", ys7Manager.getToken());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package org.dromara.bigscreen.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 仓库出入库列表
|
||||
*/
|
||||
@Data
|
||||
public class StockInAndStockOutRecordVo implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
public Long id;
|
||||
|
||||
/**
|
||||
* 材料名称
|
||||
*/
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
public Long inventoryNumber;
|
||||
/**
|
||||
* 出入库数量
|
||||
*/
|
||||
public Long inAndOutNumber;
|
||||
/**
|
||||
* 出入库类型(0、入库,1、出库)
|
||||
*/
|
||||
public String type;
|
||||
/**
|
||||
* 出入库时间
|
||||
*/
|
||||
public Date time;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
public String operator;
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package org.dromara.bigscreen.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 物资需求与实际到货对比vo
|
||||
*/
|
||||
@Data
|
||||
public class WarehouseMonitoringVo implements Serializable {
|
||||
|
||||
/**
|
||||
* 摄像头id
|
||||
*/
|
||||
public Long cameraId;
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
public Long warehouseId;
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* 摄像头序列号
|
||||
*/
|
||||
public String cameraSerial;
|
||||
|
||||
/**
|
||||
* 摄像头名称
|
||||
*/
|
||||
public String cameraName;
|
||||
|
||||
/**
|
||||
* 设备在线状态(0离线 1在线)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 状态:0-关闭,1-开启
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 摄像头最后一张抓图地址
|
||||
*/
|
||||
public String imgUrl;
|
||||
|
||||
}
|
||||
@ -2,9 +2,9 @@ package org.dromara.bigscreen.service;
|
||||
|
||||
|
||||
import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo;
|
||||
import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo;
|
||||
import org.dromara.bigscreen.domain.vo.StockInAndStockOutRecordVo;
|
||||
import org.dromara.bigscreen.domain.vo.WarehouseMonitoringVo;
|
||||
import org.dromara.bigscreen.domain.vo.xhqsdbVo;
|
||||
import org.dromara.project.domain.vo.project.BusProjectGisVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -26,4 +26,20 @@ public interface IMaterialsManagementService {
|
||||
* @return
|
||||
*/
|
||||
List<xhqsdbVo> xhqsdb(Long projectId);
|
||||
|
||||
/**
|
||||
* 仓库实时监控
|
||||
* @param projectId
|
||||
* @return
|
||||
*/
|
||||
List<WarehouseMonitoringVo> warehouseMonitoring(Long projectId);
|
||||
|
||||
/**
|
||||
* 仓库出入库详情
|
||||
*
|
||||
* @param projectId
|
||||
* @param warehouseId
|
||||
* @return
|
||||
*/
|
||||
List<StockInAndStockOutRecordVo> warehouseInAndOutDetail(Long projectId, Long warehouseId);
|
||||
}
|
||||
|
||||
@ -5,13 +5,17 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.bigscreen.domain.vo.InventoryStructureAnalysisVo;
|
||||
import org.dromara.bigscreen.domain.vo.wzxqysjdhdbVo;
|
||||
import org.dromara.bigscreen.domain.vo.StockInAndStockOutRecordVo;
|
||||
import org.dromara.bigscreen.domain.vo.WarehouseMonitoringVo;
|
||||
import org.dromara.bigscreen.domain.vo.xhqsdbVo;
|
||||
import org.dromara.bigscreen.enums.WuZhiEnum;
|
||||
import org.dromara.bigscreen.service.IMaterialsManagementService;
|
||||
import org.dromara.materials.domain.*;
|
||||
import org.dromara.materials.service.*;
|
||||
import org.dromara.project.domain.vo.project.BusProjectGisVo;
|
||||
import org.dromara.other.domain.OthYs7Device;
|
||||
import org.dromara.other.domain.OthYs7DeviceImg;
|
||||
import org.dromara.other.service.IOthYs7DeviceImgService;
|
||||
import org.dromara.other.service.IOthYs7DeviceService;
|
||||
import org.dromara.tender.domain.BusBillofquantitiesLimitList;
|
||||
import org.dromara.tender.service.IBusBillofquantitiesLimitListService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -46,6 +50,24 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
|
||||
@Lazy
|
||||
@Resource
|
||||
private IMatMaterialsUseRecordService matMaterialsUseRecordService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IMatMaterialIssueService materialIssueService;
|
||||
|
||||
@Resource
|
||||
private IMatWarehouseService warehouseService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IMatWarehouseCameraService warehouseCameraService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IOthYs7DeviceService othYs7DeviceService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IOthYs7DeviceImgService ys7DeviceImgService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IMatMaterialReceiveService materialReceiveService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -224,13 +246,36 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
|
||||
@Override
|
||||
public List<xhqsdbVo> xhqsdb(Long projectId) {
|
||||
List<xhqsdbVo> list = new ArrayList<>();
|
||||
//获取出库记录
|
||||
List<MatMaterialIssue> issuesList = materialIssueService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<MatMaterialIssue>()
|
||||
.eq(MatMaterialIssue::getProjectId, projectId)
|
||||
.eq(MatMaterialIssue::getMaterialSource, "1"));
|
||||
if (CollUtil.isEmpty(issuesList)) {
|
||||
return List.of();
|
||||
}
|
||||
Set<Long> issueIds = issuesList.stream().map(MatMaterialIssue::getId).collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(issueIds)){
|
||||
return List.of();
|
||||
}
|
||||
//获取领料明细列表
|
||||
List<MatMaterialIssueItem> issueItems = materialIssueItemService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterialIssueItem>()
|
||||
.in(MatMaterialIssueItem::getIssueId, issueIds));
|
||||
if (CollUtil.isEmpty(issueItems)){
|
||||
return List.of();
|
||||
}
|
||||
Set<Long> iIds = issueItems.stream().filter(item -> item.getInventoryId() != null).map(MatMaterialIssueItem::getInventoryId).collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(iIds)){
|
||||
return List.of();
|
||||
}
|
||||
//获取出入库表中出库记录
|
||||
List<MatMaterialsInventory> inventories = materialsInventoryService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<MatMaterialsInventory>()
|
||||
.eq(MatMaterialsInventory::getProjectId, projectId)
|
||||
.eq(MatMaterialsInventory::getOutPut, "2"));
|
||||
.in(MatMaterialsInventory::getId, iIds));
|
||||
if (CollUtil.isEmpty(inventories)) {
|
||||
return List.of();
|
||||
}
|
||||
//获取每个材料的库存数量
|
||||
HashMap<Long, BigDecimal> inventoryHashMap = new HashMap<>();
|
||||
inventories.forEach(item -> {
|
||||
if (inventoryHashMap.containsKey(item.getMaterialsId())){
|
||||
@ -243,27 +288,28 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
|
||||
if (CollUtil.isEmpty(mids)){
|
||||
return List.of();
|
||||
}
|
||||
//获取材料名称列表
|
||||
List<MatMaterials> materials = materialsService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterials>()
|
||||
.eq(MatMaterials::getProjectId, projectId)
|
||||
.in(MatMaterials::getId, mids));
|
||||
if (CollUtil.isEmpty(materials)) {
|
||||
return List.of();
|
||||
}
|
||||
//获取材料名称
|
||||
Map<Long, String> map1 = materials.stream()
|
||||
.collect(Collectors.toMap(MatMaterials::getId, MatMaterials::getMaterialsName));
|
||||
//获取所有出入库记录id
|
||||
Set<Long> ids = inventories.stream()
|
||||
.map(MatMaterialsInventory::getId)
|
||||
.collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return List.of();
|
||||
}
|
||||
//根据出入库id获取使用记录
|
||||
List<MatMaterialsUseRecord> useRecords = matMaterialsUseRecordService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<MatMaterialsUseRecord>()
|
||||
.eq(MatMaterialsUseRecord::getProjectId, projectId)
|
||||
.in(MatMaterialsUseRecord::getInventoryId, ids));
|
||||
if (CollUtil.isEmpty(useRecords)) {
|
||||
return List.of();
|
||||
}
|
||||
Map<Long, BigDecimal> map = useRecords.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
MatMaterialsUseRecord::getInventoryId,
|
||||
@ -278,4 +324,108 @@ public class MaterialsManagementServiceImpl implements IMaterialsManagementServi
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WarehouseMonitoringVo> warehouseMonitoring(Long projectId) {
|
||||
List<WarehouseMonitoringVo> list = new ArrayList<>();
|
||||
//根据项目id获取仓库列表
|
||||
List<MatWarehouse> warehouseList = warehouseService.getBaseMapper().selectList(new LambdaQueryWrapper<MatWarehouse>()
|
||||
.eq(MatWarehouse::getProjectId, projectId));
|
||||
//构建仓库id与仓库对象映射
|
||||
if (CollUtil.isEmpty(warehouseList)){
|
||||
return list;
|
||||
}
|
||||
Map<Long, MatWarehouse> warehouseMap = warehouseList.stream().collect(Collectors.toMap(MatWarehouse::getId, item -> item));
|
||||
//根据仓库列表获取仓库id
|
||||
Set<Long> warehouseIds = warehouseList.stream().map(MatWarehouse::getId).collect(Collectors.toSet());
|
||||
//根据仓库id获取摄像头id列表
|
||||
List<MatWarehouseCamera> warehouseCameraList = warehouseCameraService.getBaseMapper().selectList(new LambdaQueryWrapper<MatWarehouseCamera>()
|
||||
.in(MatWarehouseCamera::getWarehouseId, warehouseIds));
|
||||
if (CollUtil.isEmpty(warehouseCameraList)){
|
||||
return list;
|
||||
}
|
||||
Set<Long> cameraIds = warehouseCameraList.stream().map(MatWarehouseCamera::getCameraId).collect(Collectors.toSet());
|
||||
//生成摄像头与仓库关系
|
||||
Map<Long, Long> warehouseCameraMap = warehouseCameraList.stream().collect(Collectors.toMap(MatWarehouseCamera::getCameraId, MatWarehouseCamera::getWarehouseId));
|
||||
//根据摄像头id列表获取摄像头列表
|
||||
List<OthYs7Device> cameraList = othYs7DeviceService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<OthYs7Device>()
|
||||
.in(OthYs7Device::getId, cameraIds));
|
||||
if (CollUtil.isEmpty(cameraList)){
|
||||
return list;
|
||||
}
|
||||
//获取摄像头最后一张抓拍图片
|
||||
Set<String> deviceSerialSet = cameraList.stream().map(OthYs7Device::getDeviceSerial).collect(Collectors.toSet());
|
||||
List<OthYs7DeviceImg> deviceImgs = ys7DeviceImgService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<OthYs7DeviceImg>()
|
||||
.in(OthYs7DeviceImg::getDeviceSerial, deviceSerialSet));
|
||||
Map<String, String> deviceImgMap = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(deviceImgs)){
|
||||
//构建摄像头与图片关系
|
||||
deviceImgMap = deviceImgs.stream().collect(Collectors.toMap(OthYs7DeviceImg::getDeviceSerial, OthYs7DeviceImg::getUrl));
|
||||
}
|
||||
//遍历摄像头列表组装返回数据
|
||||
for (OthYs7Device item : cameraList) {
|
||||
WarehouseMonitoringVo vo = new WarehouseMonitoringVo();
|
||||
vo.setCameraId(item.getId());
|
||||
vo.setWarehouseId(warehouseCameraMap.get(item.getId()));
|
||||
vo.setCameraSerial(item.getDeviceSerial());
|
||||
vo.setCameraName(item.getDeviceName());
|
||||
vo.setStatus(item.getStatus());
|
||||
vo.setEnable(item.getEnable());
|
||||
vo.setName(warehouseMap.get(vo.getWarehouseId()).getWarehouseName());
|
||||
vo.setImgUrl(deviceImgMap.get(item.getDeviceSerial()) != null ? deviceImgMap.get(item.getDeviceSerial()) : "");
|
||||
list.add(vo);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓库出入库明细
|
||||
*
|
||||
* @param projectId
|
||||
* @param warehouseId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StockInAndStockOutRecordVo> warehouseInAndOutDetail(Long projectId, Long warehouseId) {
|
||||
List<StockInAndStockOutRecordVo> list = new ArrayList<>();
|
||||
//根据项目id和仓库id获取入库列表
|
||||
List<MatMaterials> matMaterials = materialsService.getBaseMapper().selectList(new LambdaQueryWrapper<MatMaterials>()
|
||||
.eq(MatMaterials::getProjectId, projectId)
|
||||
.eq(MatMaterials::getWarehouseId, warehouseId));
|
||||
if (CollUtil.isEmpty(matMaterials)) {
|
||||
return list;
|
||||
}
|
||||
//生成材料id与材料名称关系
|
||||
Map<Long, String> map1 = matMaterials.stream().collect(Collectors.toMap(MatMaterials::getId, MatMaterials::getMaterialsName));
|
||||
//获取入库的材料id列表
|
||||
Set<Long> mIds = matMaterials.stream()
|
||||
.map(MatMaterials::getId)
|
||||
.collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(mIds)){
|
||||
return list;
|
||||
}
|
||||
//根据材料id列表查询出入库记录表,获取到所有材料的出入库记录
|
||||
List<MatMaterialsInventory> materialsInventoryList = materialsInventoryService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<MatMaterialsInventory>()
|
||||
.in(MatMaterialsInventory::getMaterialsId, mIds)
|
||||
.orderByDesc(MatMaterialsInventory::getCreateTime));
|
||||
if (CollUtil.isEmpty(materialsInventoryList)){
|
||||
return list;
|
||||
}
|
||||
//遍历出入库记录列表,组装返回数据
|
||||
for (MatMaterialsInventory item : materialsInventoryList) {
|
||||
StockInAndStockOutRecordVo vo = new StockInAndStockOutRecordVo();
|
||||
vo.setId(item.getId());
|
||||
vo.setName(map1.get(item.getMaterialsId()));
|
||||
vo.setInventoryNumber(item.getResidue());
|
||||
vo.setInAndOutNumber(item.getNumber());
|
||||
vo.setType(item.getOutPut());
|
||||
vo.setTime(item.getOutPutTime());
|
||||
vo.setOperator(item.getOperator());
|
||||
list.add(vo);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.cailiaoshebei.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -410,6 +411,9 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
Set<Long> planIds = matMaterialReceiveItems.stream()
|
||||
.map(MatMaterialReceiveItem::getPlanId)
|
||||
.collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(planIds)){
|
||||
return new HashMap<>();
|
||||
}
|
||||
Map<Long, BigDecimal> planMap = matMaterialReceiveItems.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
MatMaterialReceiveItem::getPlanId,
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package org.dromara.materials.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -18,6 +20,8 @@ import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.materials.domain.bo.MatWarehouseBo;
|
||||
import org.dromara.materials.domain.vo.MatWarehouseVo;
|
||||
import org.dromara.materials.service.IMatWarehouseService;
|
||||
import org.dromara.other.domain.vo.ys7device.OthYs7DeviceVo;
|
||||
import org.dromara.other.service.IOthYs7DeviceService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -37,6 +41,19 @@ public class MatWarehouseController extends BaseController {
|
||||
|
||||
private final IMatWarehouseService matWarehouseService;
|
||||
|
||||
@Resource
|
||||
private IOthYs7DeviceService othYs7DeviceService;
|
||||
|
||||
|
||||
/**
|
||||
* 根据项目查询萤石摄像头列表
|
||||
*/
|
||||
@SaCheckPermission( value = {"materials:warehouse:list","materials:warehouse:add","materials:warehouse:edit"}, mode = SaMode.OR)
|
||||
@GetMapping("/device/project")
|
||||
public TableDataInfo<OthYs7DeviceVo> listByProject(Long projectId, PageQuery pageQuery) {
|
||||
return othYs7DeviceService.queryPageListByProject(projectId, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物资仓库列表
|
||||
*/
|
||||
|
||||
@ -84,4 +84,9 @@ public class MatMaterialReceiveItem extends BaseEntity {
|
||||
*/
|
||||
private Long planId;
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
private Long warehouseId;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package org.dromara.materials.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 物资仓库与摄像头绑定对象 mat_warehouse_camera
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Data
|
||||
@TableName("mat_warehouse_camera")
|
||||
public class MatWarehouseCamera implements Serializable{
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
@TableId(value = "warehouse_id")
|
||||
private Long warehouseId;
|
||||
|
||||
/**
|
||||
* 摄像头id
|
||||
*/
|
||||
private Long cameraId;
|
||||
|
||||
|
||||
}
|
||||
@ -10,6 +10,8 @@ import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.materials.domain.MatWarehouse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物资仓库业务对象 mat_warehouse
|
||||
*
|
||||
@ -91,4 +93,9 @@ public class MatWarehouseBo extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 萤石设备id
|
||||
*/
|
||||
private List<Long> ys7DeviceIds;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
package org.dromara.materials.domain.bo;
|
||||
|
||||
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 物资仓库与摄像头绑定业务对象 mat_warehouse_camera
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Data
|
||||
public class MatWarehouseCameraBo implements Serializable {
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
@NotNull(message = "仓库id不能为空", groups = { EditGroup.class })
|
||||
private Long warehouseId;
|
||||
|
||||
/**
|
||||
* 摄像头id
|
||||
*/
|
||||
@NotNull(message = "摄像头id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long cameraId;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package org.dromara.materials.domain.vo;
|
||||
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.materials.domain.MatWarehouseCamera;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 物资仓库与摄像头绑定视图对象 mat_warehouse_camera
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = MatWarehouseCamera.class)
|
||||
public class MatWarehouseCameraVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
@ExcelProperty(value = "仓库id")
|
||||
private Long warehouseId;
|
||||
|
||||
/**
|
||||
* 摄像头id
|
||||
*/
|
||||
@ExcelProperty(value = "摄像头id")
|
||||
private Long cameraId;
|
||||
|
||||
|
||||
}
|
||||
@ -7,9 +7,12 @@ import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.materials.domain.MatWarehouse;
|
||||
import org.dromara.other.domain.OthYs7Device;
|
||||
import org.dromara.other.domain.vo.ys7device.OthYs7DeviceVo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -105,4 +108,14 @@ public class MatWarehouseVo implements Serializable {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 萤石设备id
|
||||
*/
|
||||
private List<Long> ys7DeviceIds;
|
||||
|
||||
/**
|
||||
* 萤石摄像头信息
|
||||
*/
|
||||
private List<OthYs7Device> ys7DeviceList;
|
||||
|
||||
}
|
||||
|
||||
@ -77,4 +77,9 @@ public class MatMaterialReceiveItemVo implements Serializable {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
private Long warehouseId;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package org.dromara.materials.mapper;
|
||||
|
||||
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.materials.domain.MatWarehouseCamera;
|
||||
import org.dromara.materials.domain.vo.MatWarehouseCameraVo;
|
||||
|
||||
/**
|
||||
* 物资仓库与摄像头绑定Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
public interface MatWarehouseCameraMapper extends BaseMapperPlus<MatWarehouseCamera, MatWarehouseCameraVo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package org.dromara.materials.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.materials.domain.MatWarehouseCamera;
|
||||
import org.dromara.materials.domain.bo.MatWarehouseCameraBo;
|
||||
import org.dromara.materials.domain.vo.MatWarehouseCameraVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物资仓库与摄像头绑定Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
public interface IMatWarehouseCameraService extends IService<MatWarehouseCamera>{
|
||||
|
||||
/**
|
||||
* 查询物资仓库与摄像头绑定
|
||||
*
|
||||
* @param warehouseId 主键
|
||||
* @return 物资仓库与摄像头绑定
|
||||
*/
|
||||
MatWarehouseCameraVo queryById(Long warehouseId);
|
||||
|
||||
/**
|
||||
* 分页查询物资仓库与摄像头绑定列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 物资仓库与摄像头绑定分页列表
|
||||
*/
|
||||
TableDataInfo<MatWarehouseCameraVo> queryPageList(MatWarehouseCameraBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的物资仓库与摄像头绑定列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物资仓库与摄像头绑定列表
|
||||
*/
|
||||
List<MatWarehouseCameraVo> queryList(MatWarehouseCameraBo bo);
|
||||
|
||||
/**
|
||||
* 新增物资仓库与摄像头绑定
|
||||
*
|
||||
* @param bo 物资仓库与摄像头绑定
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(MatWarehouseCameraBo bo);
|
||||
|
||||
/**
|
||||
* 修改物资仓库与摄像头绑定
|
||||
*
|
||||
* @param bo 物资仓库与摄像头绑定
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(MatWarehouseCameraBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除物资仓库与摄像头绑定信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -253,18 +253,6 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
|
||||
List<MatMaterialIssueItemDto> itemList = req.getItemList();
|
||||
if (CollUtil.isNotEmpty(itemList)) {
|
||||
List<MatMaterialIssueItem> materialIssueItemList = itemList.stream().map(item -> {
|
||||
MatMaterialIssueItem materialIssueItem = new MatMaterialIssueItem();
|
||||
BeanUtils.copyProperties(item, materialIssueItem);
|
||||
materialIssueItem.setIssueId(materialIssue.getId());
|
||||
materialIssueItem.setProjectId(materialIssue.getProjectId());
|
||||
return materialIssueItem;
|
||||
}).toList();
|
||||
boolean result = materialIssueItemService.saveBatch(materialIssueItemList);
|
||||
if (!result) {
|
||||
throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR);
|
||||
}
|
||||
// 创建设备材料出库记录
|
||||
List<MatMaterialsInventory> inventoryList = itemList.stream().map(item -> {
|
||||
MatMaterialsInventory inventory = new MatMaterialsInventory();
|
||||
inventory.setNumber(item.getIssuedQuantity().longValue());
|
||||
inventory.setOutPutTime(new Date());
|
||||
@ -278,12 +266,30 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
|
||||
inventory.setProjectId(materialIssue.getProjectId());
|
||||
inventory.setOutPut(MatMaterialsInventoryOutPutEnum.OUT.getValue());
|
||||
inventory.setRemark(item.getRemark());
|
||||
return inventory;
|
||||
boolean saved = materialsInventoryService.save(inventory);
|
||||
if (!saved) {
|
||||
throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
|
||||
}
|
||||
MatMaterialIssueItem materialIssueItem = new MatMaterialIssueItem();
|
||||
BeanUtils.copyProperties(item, materialIssueItem);
|
||||
materialIssueItem.setIssueId(materialIssue.getId());
|
||||
materialIssueItem.setProjectId(materialIssue.getProjectId());
|
||||
materialIssueItem.setInventoryId(inventory.getId());
|
||||
return materialIssueItem;
|
||||
}).toList();
|
||||
boolean saved = materialsInventoryService.saveBatch(inventoryList);
|
||||
if (!saved) {
|
||||
throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
|
||||
boolean result = materialIssueItemService.saveBatch(materialIssueItemList);
|
||||
if (!result) {
|
||||
throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR);
|
||||
}
|
||||
// // 创建设备材料出库记录
|
||||
// List<MatMaterialsInventory> inventoryList = itemList.stream().map(item -> {
|
||||
//
|
||||
// return inventory;
|
||||
// }).toList();
|
||||
// boolean saved = materialsInventoryService.saveBatch(inventoryList);
|
||||
// if (!saved) {
|
||||
// throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
|
||||
// }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -0,0 +1,129 @@
|
||||
package org.dromara.materials.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.materials.domain.MatWarehouseCamera;
|
||||
import org.dromara.materials.domain.bo.MatWarehouseCameraBo;
|
||||
import org.dromara.materials.domain.vo.MatWarehouseCameraVo;
|
||||
import org.dromara.materials.mapper.MatWarehouseCameraMapper;
|
||||
import org.dromara.materials.service.IMatWarehouseCameraService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 物资仓库与摄像头绑定Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class MatWarehouseCameraServiceImpl extends ServiceImpl<MatWarehouseCameraMapper, MatWarehouseCamera> implements IMatWarehouseCameraService {
|
||||
|
||||
private final MatWarehouseCameraMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询物资仓库与摄像头绑定
|
||||
*
|
||||
* @param warehouseId 主键
|
||||
* @return 物资仓库与摄像头绑定
|
||||
*/
|
||||
@Override
|
||||
public MatWarehouseCameraVo queryById(Long warehouseId){
|
||||
return baseMapper.selectVoById(warehouseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询物资仓库与摄像头绑定列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 物资仓库与摄像头绑定分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<MatWarehouseCameraVo> queryPageList(MatWarehouseCameraBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<MatWarehouseCamera> lqw = buildQueryWrapper(bo);
|
||||
Page<MatWarehouseCameraVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的物资仓库与摄像头绑定列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 物资仓库与摄像头绑定列表
|
||||
*/
|
||||
@Override
|
||||
public List<MatWarehouseCameraVo> queryList(MatWarehouseCameraBo bo) {
|
||||
LambdaQueryWrapper<MatWarehouseCamera> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<MatWarehouseCamera> buildQueryWrapper(MatWarehouseCameraBo bo) {
|
||||
LambdaQueryWrapper<MatWarehouseCamera> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(MatWarehouseCamera::getWarehouseId);
|
||||
lqw.eq(bo.getCameraId() != null, MatWarehouseCamera::getCameraId, bo.getCameraId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物资仓库与摄像头绑定
|
||||
*
|
||||
* @param bo 物资仓库与摄像头绑定
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(MatWarehouseCameraBo bo) {
|
||||
MatWarehouseCamera add = MapstructUtils.convert(bo, MatWarehouseCamera.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setWarehouseId(add.getWarehouseId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物资仓库与摄像头绑定
|
||||
*
|
||||
* @param bo 物资仓库与摄像头绑定
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(MatWarehouseCameraBo bo) {
|
||||
MatWarehouseCamera update = MapstructUtils.convert(bo, MatWarehouseCamera.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(MatWarehouseCamera entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除物资仓库与摄像头绑定信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -4,21 +4,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.materials.domain.MatWarehouse;
|
||||
import org.dromara.materials.domain.MatWarehouseCamera;
|
||||
import org.dromara.materials.domain.bo.MatWarehouseBo;
|
||||
import org.dromara.materials.domain.vo.MatWarehouseVo;
|
||||
import org.dromara.materials.mapper.MatWarehouseMapper;
|
||||
import org.dromara.materials.service.IMatWarehouseCameraService;
|
||||
import org.dromara.materials.service.IMatWarehouseService;
|
||||
import org.dromara.other.domain.OthYs7Device;
|
||||
import org.dromara.other.service.IOthYs7DeviceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 物资仓库Service业务层处理
|
||||
@ -31,6 +35,12 @@ import java.util.Map;
|
||||
public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, MatWarehouse>
|
||||
implements IMatWarehouseService {
|
||||
|
||||
@Resource
|
||||
private IMatWarehouseCameraService matWarehouseCameraService;
|
||||
|
||||
@Resource
|
||||
private IOthYs7DeviceService othYs7DeviceService;
|
||||
|
||||
/**
|
||||
* 查询物资仓库
|
||||
*
|
||||
@ -39,7 +49,22 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
|
||||
*/
|
||||
@Override
|
||||
public MatWarehouseVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
MatWarehouseVo vo = baseMapper.selectVoById(id);
|
||||
if (vo !=null){
|
||||
List<MatWarehouseCamera> list = matWarehouseCameraService.getBaseMapper().selectList(new LambdaQueryWrapper<MatWarehouseCamera>().eq(MatWarehouseCamera::getWarehouseId, id));
|
||||
if (list != null && !list.isEmpty()){
|
||||
Set<Long> cameraIds = new HashSet<>();
|
||||
for (MatWarehouseCamera item : list) {
|
||||
cameraIds.add(item.getCameraId());
|
||||
}
|
||||
List<OthYs7Device> ys7DeviceList = othYs7DeviceService.getBaseMapper().selectList(new LambdaQueryWrapper<OthYs7Device>().in(OthYs7Device::getId, cameraIds));
|
||||
if (ys7DeviceList != null && !ys7DeviceList.isEmpty()){
|
||||
vo.setYs7DeviceList(ys7DeviceList);
|
||||
}
|
||||
vo.setYs7DeviceIds(cameraIds.stream().toList());
|
||||
}
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,12 +118,29 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(MatWarehouseBo bo) {
|
||||
MatWarehouse add = MapstructUtils.convert(bo, MatWarehouse.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
if (bo.getYs7DeviceIds() != null){
|
||||
Long count = matWarehouseCameraService.getBaseMapper()
|
||||
.selectCount(new LambdaQueryWrapper<MatWarehouseCamera>()
|
||||
.in(MatWarehouseCamera::getCameraId, bo.getYs7DeviceIds()));
|
||||
if (count > 0){
|
||||
throw new RuntimeException("摄像头已与仓库绑定请重新选择摄像头");
|
||||
}
|
||||
List<MatWarehouseCamera> list = new ArrayList<>();
|
||||
for (Long item : bo.getYs7DeviceIds()) {
|
||||
MatWarehouseCamera matWarehouseCamera = new MatWarehouseCamera();
|
||||
matWarehouseCamera.setWarehouseId(add.getId());
|
||||
matWarehouseCamera.setCameraId(item);
|
||||
list.add(matWarehouseCamera);
|
||||
}
|
||||
matWarehouseCameraService.saveBatch(list);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@ -110,9 +152,27 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(MatWarehouseBo bo) {
|
||||
MatWarehouse update = MapstructUtils.convert(bo, MatWarehouse.class);
|
||||
validEntityBeforeSave(update);
|
||||
matWarehouseCameraService.remove(new LambdaQueryWrapper<MatWarehouseCamera>().eq(MatWarehouseCamera::getWarehouseId, bo.getId()));
|
||||
if (bo.getYs7DeviceIds() != null){
|
||||
Long count = matWarehouseCameraService.getBaseMapper()
|
||||
.selectCount(new LambdaQueryWrapper<MatWarehouseCamera>()
|
||||
.in(MatWarehouseCamera::getCameraId, bo.getYs7DeviceIds()));
|
||||
if (count > 0){
|
||||
throw new RuntimeException("摄像头已与仓库绑定请重新选择摄像头");
|
||||
}
|
||||
List<MatWarehouseCamera> list = new ArrayList<>();
|
||||
for (Long item : bo.getYs7DeviceIds()) {
|
||||
MatWarehouseCamera matWarehouseCamera = new MatWarehouseCamera();
|
||||
matWarehouseCamera.setWarehouseId(bo.getId());
|
||||
matWarehouseCamera.setCameraId(item);
|
||||
list.add(matWarehouseCamera);
|
||||
}
|
||||
matWarehouseCameraService.saveBatch(list);
|
||||
}
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@ -135,6 +195,7 @@ public class MatWarehouseServiceImpl extends ServiceImpl<MatWarehouseMapper, Mat
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
matWarehouseCameraService.remove(new LambdaQueryWrapper<MatWarehouseCamera>().in(MatWarehouseCamera::getWarehouseId, ids));
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,10 +88,7 @@ public class BigScreenWebSocketServer {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
//todo 填充不同类型大屏获取基础数据的方法判断
|
||||
IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class);
|
||||
IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class);
|
||||
IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class);
|
||||
IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class);
|
||||
|
||||
BusAttendanceServiceImpl busAttendanceService = SpringUtils.getBean(BusAttendanceServiceImpl.class);
|
||||
// 大屏-质安管理
|
||||
DpzaglService dpzaglService = SpringUtils.getBean(DpzaglService.class);
|
||||
@ -126,6 +123,10 @@ public class BigScreenWebSocketServer {
|
||||
break;
|
||||
case 5:
|
||||
//物资管理大屏
|
||||
IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class);
|
||||
IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class);
|
||||
IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class);
|
||||
IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class);
|
||||
generateLargeScreenData(materialsService, managementService, projectId, maps, purchaseDocService, mrpBaseService);
|
||||
break;
|
||||
case 6:
|
||||
@ -155,67 +156,6 @@ public class BigScreenWebSocketServer {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物资管理大屏数据
|
||||
*/
|
||||
private static void generateLargeScreenData(IMatMaterialsService materialsService, IMaterialsManagementService managementService, Long projectId, List<Map<String, String>> maps, IBusPurchaseDocService purchaseDocService, IBusMrpBaseService mrpBaseService) {
|
||||
if (materialsService != null) {
|
||||
//库存结构分析
|
||||
InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId);
|
||||
if (vo != null) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "inventoryStructureAnalysis");
|
||||
map.put("data", JSONUtil.toJsonStr(vo));
|
||||
maps.add(map);
|
||||
}
|
||||
//消耗趋势对比
|
||||
List<xhqsdbVo> xhqsdb = managementService.xhqsdb(projectId);
|
||||
if (xhqsdb != null && !xhqsdb.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "xhqsdb");
|
||||
map.put("data", JSONUtil.toJsonStr(xhqsdb));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
if (purchaseDocService != null) {
|
||||
//采购单
|
||||
List<BusPurchaseDocVo> purchaseDocVos = purchaseDocService.purchaseNote(projectId);
|
||||
if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "purchaseNote");
|
||||
map.put("data", JSONUtil.toJsonStr(purchaseDocVos));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
if (mrpBaseService != null) {
|
||||
//设计量与到货量对比
|
||||
List<designAndArrivalComparisonVo> designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId);
|
||||
if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "designAndArrivalComparison");
|
||||
map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos));
|
||||
maps.add(map);
|
||||
}
|
||||
//物资需求与实际到货对比
|
||||
List<wzxqysjdhdbVo> wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId);
|
||||
if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "wzxqysjdhdb");
|
||||
map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
if (materialsService != null) {
|
||||
//物资跟踪管理台账
|
||||
List<MatMaterialsUseDetailVo> useDetailVos = materialsService.listUseDetail(projectId);
|
||||
if (useDetailVos != null && !useDetailVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "listUseDetail");
|
||||
map.put("data", JSONUtil.toJsonStr(useDetailVos));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端消息
|
||||
@ -263,6 +203,11 @@ public class BigScreenWebSocketServer {
|
||||
break;
|
||||
case 5:
|
||||
//物资管理大屏
|
||||
IMaterialsManagementService managementService = SpringUtils.getBean(IMaterialsManagementService.class);
|
||||
IBusPurchaseDocService purchaseDocService = SpringUtils.getBean(IBusPurchaseDocService.class);
|
||||
IBusMrpBaseService mrpBaseService = SpringUtils.getBean(IBusMrpBaseService.class);
|
||||
IMatMaterialsService materialsService = SpringUtils.getBean(IMatMaterialsService.class);
|
||||
generateLargeScreenData(materialsService, managementService, projectId, maps, purchaseDocService, mrpBaseService);
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
@ -540,5 +485,76 @@ public class BigScreenWebSocketServer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物资管理大屏数据
|
||||
*/
|
||||
private static void generateLargeScreenData(IMatMaterialsService materialsService, IMaterialsManagementService managementService, Long projectId, List<Map<String, String>> maps, IBusPurchaseDocService purchaseDocService, IBusMrpBaseService mrpBaseService) {
|
||||
if (materialsService != null) {
|
||||
//库存结构分析
|
||||
InventoryStructureAnalysisVo vo = managementService.inventoryStructureAnalysis(projectId);
|
||||
if (vo != null) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "inventoryStructureAnalysis");
|
||||
map.put("data", JSONUtil.toJsonStr(vo));
|
||||
maps.add(map);
|
||||
}
|
||||
//消耗趋势对比
|
||||
List<xhqsdbVo> xhqsdb = managementService.xhqsdb(projectId);
|
||||
if (xhqsdb != null && !xhqsdb.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "xhqsdb");
|
||||
map.put("data", JSONUtil.toJsonStr(xhqsdb));
|
||||
maps.add(map);
|
||||
}
|
||||
//仓库监控
|
||||
List<WarehouseMonitoringVo> warehouseMonitoringVos = managementService.warehouseMonitoring(projectId);
|
||||
if (warehouseMonitoringVos != null && !warehouseMonitoringVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "warehouseMonitoring");
|
||||
map.put("data", JSONUtil.toJsonStr(warehouseMonitoringVos));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
if (purchaseDocService != null) {
|
||||
//采购单
|
||||
List<BusPurchaseDocVo> purchaseDocVos = purchaseDocService.purchaseNote(projectId);
|
||||
if (purchaseDocVos != null && !purchaseDocVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "purchaseNote");
|
||||
map.put("data", JSONUtil.toJsonStr(purchaseDocVos));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
if (mrpBaseService != null) {
|
||||
//设计量与到货量对比
|
||||
List<designAndArrivalComparisonVo> designAndArrivalComparisonVos = mrpBaseService.designAndArrivalComparison(projectId);
|
||||
if (designAndArrivalComparisonVos != null && !designAndArrivalComparisonVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "designAndArrivalComparison");
|
||||
map.put("data", JSONUtil.toJsonStr(designAndArrivalComparisonVos));
|
||||
maps.add(map);
|
||||
}
|
||||
//物资需求与实际到货对比
|
||||
List<wzxqysjdhdbVo> wzxqysjdhdbVos = mrpBaseService.wzxqysjdhdb(projectId);
|
||||
if (wzxqysjdhdbVos != null && !wzxqysjdhdbVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "wzxqysjdhdb");
|
||||
map.put("data", JSONUtil.toJsonStr(wzxqysjdhdbVos));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
if (materialsService != null) {
|
||||
//物资跟踪管理台账
|
||||
List<MatMaterialsUseDetailVo> useDetailVos = materialsService.listUseDetail(projectId);
|
||||
if (useDetailVos != null && !useDetailVos.isEmpty()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "listUseDetail");
|
||||
map.put("data", JSONUtil.toJsonStr(useDetailVos));
|
||||
maps.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.materials.mapper.MatWarehouseCameraMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user