### commit message

1. 在权限相关VO中添加图标图片字段   - 在各类权限相关的响应对象中,新增图标图片字段,用于存储图标图片的路径。

2. 优化常用应用配置的批量操作逻辑
   - 合并常用应用配置的创建、编辑和删除操作为一个接口,简化批量操作流程。
   - 更新数据库操作逻辑,以支持批量创建或编辑或删除常用应用配置。

3. 修复智能工厂模块的BUG和性能优化
   - 修复智能工厂模块中与窑炉产能和摄像头数量相关的数据统计问题。 - 性能优化,仅查询必要的数据,并避免不必要的数据库操作。
This commit is contained in:
aikai 2024-09-09 19:06:31 +08:00
parent 48b64afa14
commit 2fbd8fcd0a
15 changed files with 129 additions and 27 deletions

View File

@ -36,6 +36,9 @@ public class AuthMenuRespVO {
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list") @Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
private String icon; private String icon;
@Schema(description = "图标图片", example = "/menu/list")
private String img;
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
private Boolean visible; private Boolean visible;

View File

@ -78,6 +78,9 @@ public class AuthPermissionInfoRespVO {
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list") @Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
private String icon; private String icon;
@Schema(description = "图标图片", example = "/menu/list")
private String img;
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
private Boolean visible; private Boolean visible;

View File

@ -43,11 +43,11 @@ public class CommonlyUsedController {
return success(commonlyUsedService.createCommonlyUsed(createReqVO)); return success(commonlyUsedService.createCommonlyUsed(createReqVO));
} }
@PostMapping("/batchCreate") @PostMapping("/batchCreateOrEditOrDel")
@Operation(summary = "批量创建用户常用应用配置") @Operation(summary = "批量创建编辑删除用户常用应用配置")
@PreAuthorize("@ss.hasPermission('system:commonly-used:create')") @PreAuthorize("@ss.hasPermission('system:commonly-used:create')")
public CommonResult<?> batchCreate(@Valid @RequestBody List<CommonlyUsedSaveReqVO> list) { public CommonResult<?> batchCreateOrEditOrDel(@Valid @RequestBody List<CommonlyUsedSaveReqVO> list) {
commonlyUsedService.batchCreate(list); commonlyUsedService.batchCreateOrEditOrDel(list);
return success(true); return success(true);
} }

View File

@ -1,10 +1,7 @@
package cn.iocoder.yudao.module.system.controller.admin.commonlyused.vo; package cn.iocoder.yudao.module.system.controller.admin.commonlyused.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.Data;
import java.util.*;
import javax.validation.constraints.*;
import java.util.*;
@Schema(description = "管理后台 - 用户常用应用配置新增/修改 Request VO") @Schema(description = "管理后台 - 用户常用应用配置新增/修改 Request VO")
@Data @Data
@ -13,9 +10,6 @@ public class CommonlyUsedSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18873") @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18873")
private Long id; private Long id;
@Schema(description = "用户id", example = "2072")
private Long userId;
@Schema(description = "类型 1流程 2菜单", example = "1") @Schema(description = "类型 1流程 2菜单", example = "1")
private Integer type; private Integer type;

View File

@ -43,6 +43,9 @@ public class MenuRespVO {
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list") @Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
private String icon; private String icon;
@Schema(description = "图标图片", example = "/menu/list")
private String img;
@Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index") @Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index")
@Size(max = 200, message = "组件路径不能超过255个字符") @Size(max = 200, message = "组件路径不能超过255个字符")
private String component; private String component;

View File

@ -42,6 +42,9 @@ public class MenuSaveVO {
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list") @Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
private String icon; private String icon;
@Schema(description = "图标图片", example = "/menu/list")
private String img;
@Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index") @Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index")
@Size(max = 200, message = "组件路径不能超过255个字符") @Size(max = 200, message = "组件路径不能超过255个字符")
private String component; private String component;

View File

@ -6,6 +6,7 @@ import java.time.LocalDateTime;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import org.apache.ibatis.type.JdbcType;
/** /**
* 用户常用应用配置 DO * 用户常用应用配置 DO

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -70,6 +71,12 @@ public class MenuDO extends BaseDO {
* 菜单图标 * 菜单图标
*/ */
private String icon; private String icon;
/**
* 图标图片
*/
private String img;
/** /**
* 组件路径 * 组件路径
*/ */

View File

@ -61,13 +61,6 @@ public interface CommonlyUsedService {
*/ */
CommonlyUsedVO getCommonlyUsedList(); CommonlyUsedVO getCommonlyUsedList();
/**
* 批量新增
*
* @param list
*/
void batchCreate(List<CommonlyUsedSaveReqVO> list);
/** /**
* 批量更新 * 批量更新
* *
@ -81,4 +74,11 @@ public interface CommonlyUsedService {
* @param ids * @param ids
*/ */
void batchDelete(List<Long> ids); void batchDelete(List<Long> ids);
/**
* 批量创建编辑删除
*
* @param list
*/
void batchCreateOrEditOrDel(List<CommonlyUsedSaveReqVO> list);
} }

View File

@ -142,11 +142,6 @@ public class CommonlyUsedServiceImpl implements CommonlyUsedService {
return vo; return vo;
} }
@Override
public void batchCreate(List<CommonlyUsedSaveReqVO> list) {
List<CommonlyUsedDO> saveList = BeanUtils.toBean(list, CommonlyUsedDO.class);
commonlyUsedMapper.insertBatch(saveList);
}
@Override @Override
public void batchUpdate(List<CommonlyUsedSaveReqVO> list) { public void batchUpdate(List<CommonlyUsedSaveReqVO> list) {
@ -159,4 +154,50 @@ public class CommonlyUsedServiceImpl implements CommonlyUsedService {
commonlyUsedMapper.deleteBatchIds(ids); commonlyUsedMapper.deleteBatchIds(ids);
} }
@Override
public void batchCreateOrEditOrDel(List<CommonlyUsedSaveReqVO> list) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
if (CollectionUtil.isEmpty(list)) {
commonlyUsedMapper.delete(new LambdaQueryWrapper<CommonlyUsedDO>().eq(CommonlyUsedDO::getUserId, userId));
return;
}
List<CommonlyUsedDO> oldList = commonlyUsedMapper.selectList(new LambdaQueryWrapper<CommonlyUsedDO>().eq(CommonlyUsedDO::getUserId, userId));
List<CommonlyUsedDO> newList = BeanUtils.toBean(list, CommonlyUsedDO.class);
if (CollectionUtil.isEmpty(oldList)) {
commonlyUsedMapper.insertBatch(newList);
return;
}
//根据类型和objectId 分组
Map<String, CommonlyUsedDO> oldMap = oldList.stream().collect(Collectors.toMap(a -> a.getType() + "_" + a.getObjectId(), a -> a));
Map<String, CommonlyUsedDO> newMap = newList.stream().collect(Collectors.toMap(a -> a.getType() + "_" + a.getObjectId(), a -> a));
// -- 需要删除的
List<String> delIds = new ArrayList<>(CollectionUtil.subtract(oldMap.keySet(), newMap.keySet()));
if (CollectionUtil.isNotEmpty(delIds)) {
List<Long> delIdList = new ArrayList<>();
for (String delId : delIds) {
delIdList.add(oldMap.get(delId).getId());
}
commonlyUsedMapper.deleteBatchIds(delIdList);
}
// -- 需要保存的
List<String> saveIds = new ArrayList<>(CollectionUtil.subtract(newMap.keySet(), oldMap.keySet()));
if (CollectionUtil.isNotEmpty(saveIds)) {
List<CommonlyUsedDO> saveIdList = new ArrayList<>();
for (String saveId : saveIds) {
CommonlyUsedDO commonlyUsedDO = newMap.get(saveId);
commonlyUsedDO.setUserId(userId);
saveIdList.add(newMap.get(saveId));
}
commonlyUsedMapper.insertBatch(saveIdList);
}
// -- 需要编辑的
List<String> editIds = new ArrayList<>(CollectionUtil.intersectionDistinct(newMap.keySet(), oldMap.keySet()));
if (CollectionUtil.isNotEmpty(editIds)) {
List<CommonlyUsedDO> editList = new ArrayList<>();
for (String editId : editIds) {
editList.add(newMap.get(editId));
}
commonlyUsedMapper.updateBatch(editList);
}
}
} }

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 功能描述
*
* @author: yj
* @date: 2024年03月05日 13:55
*/
@Data
public class CameraVO {
@Schema(description = "工厂id")
private Long factoryId;
@Schema(description = "工厂名称")
private String factoryName;
@Schema(description = "数量")
private Integer number;
}

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.system.api.user.vo.AdminUserRpcVO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
@ -28,6 +29,8 @@ public class DataOverviewVO {
@Schema(description = "窑炉数量") @Schema(description = "窑炉数量")
private Integer ylNum; private Integer ylNum;
@Schema(description = "窑炉产能")
private BigDecimal ylCapacity;
@Schema(description = "窑炉信息列表") @Schema(description = "窑炉信息列表")
private List<FactoryKilnVO> factoryKilnList; private List<FactoryKilnVO> factoryKilnList;
@ -55,9 +58,14 @@ public class DataOverviewVO {
@Schema(description = "绑带数") @Schema(description = "绑带数")
private Integer bdNum; private Integer bdNum;
@Schema(description = "托盘信息") @Schema(description = "绑带信息")
private List<AssetsStockVO> strapsList; private List<AssetsStockVO> strapsList;
@Schema(description = "摄像头数量")
private Integer cameraNum;
@Schema(description = "摄像头信息")
private List<CameraVO> cameraVOS;
@Schema(description = "出库") @Schema(description = "出库")
private Integer outTotalNum; private Integer outTotalNum;

View File

@ -37,8 +37,8 @@ public interface CameraDeviceMapper extends BaseMapperX<CameraDeviceDO> {
default List<CameraDeviceDO> selectListCameraByFactoryId(Long factoryId) { default List<CameraDeviceDO> selectListCameraByFactoryId(Long factoryId) {
return selectList(new LambdaQueryWrapperX<CameraDeviceDO>() return selectList(new LambdaQueryWrapperX<CameraDeviceDO>()
.eq(CameraDeviceDO::getFactoryId, factoryId) .eq(factoryId != null, CameraDeviceDO::getFactoryId, factoryId)
.eq(CameraDeviceDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) .eq(CameraDeviceDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.eq(CameraDeviceDO::getIsShow, 1)); .eq(CameraDeviceDO::getIsShow, 1));
} }
} }

View File

@ -137,6 +137,10 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
@Override @Override
public List<FactoryInfoDO> getFactoryList(Collection<Long> ids) { public List<FactoryInfoDO> getFactoryList(Collection<Long> ids) {
if (CollectionUtil.isEmpty(ids)) {
return Collections.emptyList();
}
ids = ids.stream().filter(Objects::nonNull).collect(Collectors.toList());
return factoryInfoMapper.selectList(new LambdaQueryWrapper<FactoryInfoDO>() return factoryInfoMapper.selectList(new LambdaQueryWrapper<FactoryInfoDO>()
.in(CollectionUtil.isNotEmpty(ids), FactoryInfoDO::getId, ids)); .in(CollectionUtil.isNotEmpty(ids), FactoryInfoDO::getId, ids));
} }

View File

@ -300,6 +300,7 @@ public class ScreenDataServiceImpl implements ScreenDataService {
// ---------------------------------- 窑炉 ---------------------------------- // ---------------------------------- 窑炉 ----------------------------------
List<FactoryKilnDO> factoryKilnDOS = factoryKilnService.getFactoryKilnByFactoryId(factoryId); List<FactoryKilnDO> factoryKilnDOS = factoryKilnService.getFactoryKilnByFactoryId(factoryId);
vo.setYlNum(factoryKilnDOS.size()); vo.setYlNum(factoryKilnDOS.size());
vo.setYlCapacity(factoryKilnDOS.stream().map(FactoryKilnDO::getCapacity).reduce(BigDecimal.ZERO, BigDecimal::add));
Map<Long, List<FactoryKilnDO>> factoryKilnMap = factoryKilnDOS.stream().collect(Collectors.groupingBy(FactoryKilnDO::getFactoryId)); Map<Long, List<FactoryKilnDO>> factoryKilnMap = factoryKilnDOS.stream().collect(Collectors.groupingBy(FactoryKilnDO::getFactoryId));
List<FactoryKilnVO> factoryKilnList = new ArrayList<>(); List<FactoryKilnVO> factoryKilnList = new ArrayList<>();
for (Map.Entry<Long, List<FactoryKilnDO>> entry : factoryKilnMap.entrySet()) { for (Map.Entry<Long, List<FactoryKilnDO>> entry : factoryKilnMap.entrySet()) {
@ -384,12 +385,26 @@ public class ScreenDataServiceImpl implements ScreenDataService {
vo.setTrayList(trayList); vo.setTrayList(trayList);
// ---------------------------------- 托盘 ---------------------------------- // ---------------------------------- 绑带 ----------------------------------
List<Long> strapsAssetsTypeIds = assetsTypeApi.getAssetsTypeIdsByCode(AssetsTypeCodeEnum.STRAPS).getData(); List<Long> strapsAssetsTypeIds = assetsTypeApi.getAssetsTypeIdsByCode(AssetsTypeCodeEnum.STRAPS).getData();
List<AssetsStockVO> strapsList = screenDataMapper.getAssetsNumByFactoryIdAndTypeIds(Collections.singletonList(factoryId), strapsAssetsTypeIds); List<AssetsStockVO> strapsList = screenDataMapper.getAssetsNumByFactoryIdAndTypeIds(Collections.singletonList(factoryId), strapsAssetsTypeIds);
vo.setBdNum(strapsList.stream().mapToInt(AssetsStockVO::getStock).sum()); vo.setBdNum(strapsList.stream().mapToInt(AssetsStockVO::getStock).sum());
vo.setStrapsList(strapsList); vo.setStrapsList(strapsList);
// ---------------------------------- 摄像头 ----------------------------------
List<CameraVO> cameraVOS = new ArrayList<>();
List<CameraDeviceDO> cameraDeviceDOS = cameraDeviceService.getListCameraByFactoryId(factoryId);
Map<Long, List<CameraDeviceDO>> cameraDeviceMaps = cameraDeviceDOS.stream().collect(Collectors.groupingBy(CameraDeviceDO::getFactoryId));
for (Map.Entry<Long, List<CameraDeviceDO>> entry : cameraDeviceMaps.entrySet()) {
CameraVO cameraVO = new CameraVO();
cameraVO.setFactoryId(entry.getKey());
cameraVO.setFactoryName(factoryMap.get(entry.getKey()).getName());
cameraVO.setNumber(entry.getValue().size());
cameraVOS.add(cameraVO);
}
vo.setCameraNum(cameraDeviceDOS.size());
vo.setCameraVOS(cameraVOS);
// //
// vo.setForkliftTotal(list.stream().mapToInt(FactoryDataOverviewDO::getTruckTotalNum).sum()); // vo.setForkliftTotal(list.stream().mapToInt(FactoryDataOverviewDO::getTruckTotalNum).sum());
// vo.setTruckOnNum(extras.stream().mapToInt(ScreenFactoryExtraDO::getTruckOnNum).sum()); // vo.setTruckOnNum(extras.stream().mapToInt(ScreenFactoryExtraDO::getTruckOnNum).sum());