Browse Source

Merge pull request 'master' (#27) from master into V3

Reviewed-on: http://git.lrdaiot.cn:9000/thing/thing_api/pulls/27
qingyuan_dev_new
李帅 2 years ago
parent
commit
1e7f58d443
  1. 4
      common/orm/src/main/java/com/thing/common/orm/entity/BaseTenantEntity.java
  2. 1
      common/tskv/src/main/java/com/thing/common/tskv/event/TsKvEventServiceImpl.java
  3. 2
      modules/configuration/src/main/java/com/thing/configuration/newmaterial/controller/IotNewSourceMaterialController.java
  4. 2
      modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/IotNewSourceMaterialService.java
  5. 9
      modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/impl/IotNewSourceMaterialServiceImpl.java
  6. 106
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java
  7. 8
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java
  8. 34
      modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java
  9. 10
      modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateDetailEntity.java
  10. 6
      modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateEntity.java
  11. 2
      modules/equipment/src/main/java/com/thing/eq/eqby/service/EqByTemplateDetailService.java
  12. 53
      modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java
  13. 5
      modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateDetailServiceImpl.java
  14. 33
      modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateServiceImpl.java
  15. 5
      modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqCheckStandardController.java
  16. 26
      modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqSpotCheckPlanController.java
  17. 5
      modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqCheckStandardDetailDTO.java
  18. 4
      modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqSpotCheckPlanDTO.java
  19. 10
      modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqPatrolCheckPlanEntity.java
  20. 11
      modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqSpotCheckPlanEntity.java
  21. 28
      modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckPlanServiceImpl.java
  22. 3
      modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqSpotCheckPlanServiceImpl.java
  23. 3
      modules/equipment/src/main/java/com/thing/eq/eqmanager/dto/EqScrapDTO.java
  24. 4
      modules/equipment/src/main/java/com/thing/eq/eqmanager/mapper/IotThingBaseInfoMapper.java
  25. 1
      modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/EqScrapServiceImpl.java
  26. 17
      modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingBaseInfoServiceImpl.java
  27. 46
      modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java
  28. 10
      modules/equipment/src/main/java/com/thing/eq/tree/controller/DeviceController.java
  29. 14
      modules/equipment/src/main/resources/mapper/eqmanager/IotThingBaseInfoMapper.xml
  30. 2
      modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java
  31. 4
      modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java
  32. 1
      modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java
  33. 7
      modules/visual-design/pom.xml
  34. 34
      modules/visual-design/src/main/java/com/thing/visual/component/controller/IotVisualComponentController.java
  35. 20
      modules/visual-design/src/main/java/com/thing/visual/component/dto/AdjustSortInfo.java
  36. 30
      modules/visual-design/src/main/java/com/thing/visual/component/dto/ComponentSortInfo.java
  37. 18
      modules/visual-design/src/main/java/com/thing/visual/component/dto/GroupInfo.java
  38. 12
      modules/visual-design/src/main/java/com/thing/visual/component/dto/IotVisualComponentDTO.java
  39. 2
      modules/visual-design/src/main/java/com/thing/visual/component/entity/IotVisualComponentEntity.java
  40. 19
      modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java
  41. 181
      modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java
  42. 62
      modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java
  43. 9
      modules/visual-design/src/main/java/com/thing/visual/group/dto/AdjustGroupDto.java
  44. 32
      modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupInfoFormatDTO.java
  45. 4
      modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupSortInfo.java
  46. 17
      modules/visual-design/src/main/java/com/thing/visual/group/dto/IotVisualGroupDTO.java
  47. 17
      modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java
  48. 4
      modules/visual-design/src/main/java/com/thing/visual/group/entity/IotVisualGroupEntity.java
  49. 17
      modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java
  50. 291
      modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java

4
common/orm/src/main/java/com/thing/common/orm/entity/BaseTenantEntity.java

@ -3,6 +3,8 @@ package com.thing.common.orm.entity;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@ -26,7 +28,7 @@ public class BaseTenantEntity implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1536009703312548328L; private static final long serialVersionUID = 1536009703312548328L;
@Id
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id; private Long id;
/*------------------------租户信息--------------------------------*/ /*------------------------租户信息--------------------------------*/

1
common/tskv/src/main/java/com/thing/common/tskv/event/TsKvEventServiceImpl.java

@ -1,6 +1,5 @@
package com.thing.common.tskv.event; package com.thing.common.tskv.event;
import com.alibaba.fastjson2.JSON;
import com.thing.common.data.proto.QueueProto.DataProto; import com.thing.common.data.proto.QueueProto.DataProto;
import com.thing.common.tskv.service.DBExecutor; import com.thing.common.tskv.service.DBExecutor;
import com.thing.common.tskv.service.TsKvService; import com.thing.common.tskv.service.TsKvService;

2
modules/configuration/src/main/java/com/thing/configuration/newmaterial/controller/IotNewSourceMaterialController.java

@ -127,7 +127,7 @@ public class IotNewSourceMaterialController {
@PostMapping("export") @PostMapping("export")
@Operation(summary="导出") @Operation(summary="导出")
@Parameters({ @Parameters({
@Parameter(name ="groupIds",description ="部件组id 多个以英文逗号分割"),
@Parameter(name ="groupIds",description ="素材组id 多个以英文逗号分割"),
@Parameter(name ="name",description ="素材名称"), @Parameter(name ="name",description ="素材名称"),
@Parameter(name ="type",description ="文件类型"), @Parameter(name ="type",description ="文件类型"),
@Parameter(name ="ids",description ="id数组"), @Parameter(name ="ids",description ="id数组"),

2
modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/IotNewSourceMaterialService.java

@ -32,4 +32,6 @@ public interface IotNewSourceMaterialService extends IBaseService<IotNewSourceMa
void deleteIotNewSourceMaterialDTO(Long[] ids); void deleteIotNewSourceMaterialDTO(Long[] ids);
Result saveBatch(IotNewSourceMaterialDTO[] dtos); Result saveBatch(IotNewSourceMaterialDTO[] dtos);
List<IotNewSourceMaterialEntity> getInfoByGroupIds(List<Long> groupIds);
} }

9
modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/impl/IotNewSourceMaterialServiceImpl.java

@ -24,7 +24,6 @@ import com.thing.configuration.newmaterial.mapper.IotNewSourceMaterialMapper;
import com.thing.configuration.newmaterial.service.IotNewSourceMaterialService; import com.thing.configuration.newmaterial.service.IotNewSourceMaterialService;
import com.thing.sys.biz.dto.SysUserDTO; import com.thing.sys.biz.dto.SysUserDTO;
import com.thing.sys.biz.service.SysUserService; import com.thing.sys.biz.service.SysUserService;
import com.thing.sys.oss.cloud.AbstractCloudStorageService;
import com.thing.sys.oss.cloud.OSSFactory; import com.thing.sys.oss.cloud.OSSFactory;
import com.thing.sys.security.context.TenantContext; import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.context.UserContext; import com.thing.sys.security.context.UserContext;
@ -240,4 +239,12 @@ public class IotNewSourceMaterialServiceImpl extends BaseServiceImpl<IotNewSourc
} }
return new Result().ok("批量新增成功"); return new Result().ok("批量新增成功");
} }
@Override
public List<IotNewSourceMaterialEntity> getInfoByGroupIds(List<Long> groupIds) {
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq( "group_id", groupIds);
return this.mapper.selectListByQuery(wrapper);
}
} }

106
modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java

@ -28,7 +28,6 @@ import com.thing.eq.file.service.FileService;
import com.thing.sys.biz.dto.SysDeptDTO; import com.thing.sys.biz.dto.SysDeptDTO;
import com.thing.sys.biz.dto.SysDictTypeListDTO; import com.thing.sys.biz.dto.SysDictTypeListDTO;
import com.thing.sys.biz.entity.SysDictDataEntity; import com.thing.sys.biz.entity.SysDictDataEntity;
import com.thing.sys.biz.entity.SysDictTypeEntity;
import com.thing.sys.biz.service.SysDeptService; import com.thing.sys.biz.service.SysDeptService;
import com.thing.sys.biz.service.SysDictDataService; import com.thing.sys.biz.service.SysDictDataService;
import com.thing.sys.biz.service.SysDictTypeService; import com.thing.sys.biz.service.SysDictTypeService;
@ -38,11 +37,13 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -94,7 +95,7 @@ public class EqWxPlanController {
// private IotDictTypeService iotDictTypeService; // private IotDictTypeService iotDictTypeService;
@GetMapping("page") @GetMapping("page")
@Operation(summary= "分页")
@Operation(summary = "分页")
@Parameters({ @Parameters({
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始"), @Parameter(name = Constant.PAGE, description = "当前页码,从1开始"),
@Parameter(name = Constant.LIMIT, description = "每页显示记录数"), @Parameter(name = Constant.LIMIT, description = "每页显示记录数"),
@ -128,16 +129,16 @@ public class EqWxPlanController {
EqWxInfoRes eqWxInfoRes = ConvertUtils.sourceToTarget(data, EqWxInfoRes.class); EqWxInfoRes eqWxInfoRes = ConvertUtils.sourceToTarget(data, EqWxInfoRes.class);
//调整 //调整
String userId = data.getWxUser(); String userId = data.getWxUser();
if(StringUtils.isNotBlank(userId)){
if (StringUtils.isNotBlank(userId)) {
String[] split = userId.split(","); String[] split = userId.split(",");
List<Long> longs = new ArrayList<>(); List<Long> longs = new ArrayList<>();
for (String s : split) { for (String s : split) {
longs.add(Long.parseLong(s)); longs.add(Long.parseLong(s));
} }
List<String> planUserName = sysUserService.getUserNameLists(longs); List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
String name = "";
for (String s : planUserName) { for (String s : planUserName) {
name+=s+",";
name += s + ",";
} }
name = name.substring(0, name.length() - 1); name = name.substring(0, name.length() - 1);
eqWxInfoRes.setWxUseText(name); eqWxInfoRes.setWxUseText(name);
@ -157,7 +158,7 @@ public class EqWxPlanController {
eqWxInfoRes.setBxInfo(storeEqBxMap.get(data.getEqBxId())); eqWxInfoRes.setBxInfo(storeEqBxMap.get(data.getEqBxId()));
} else { } else {
EqBxEntity eqBxEntity = null; EqBxEntity eqBxEntity = null;
if(!Objects.isNull(data.getEqBxId())){
if (!Objects.isNull(data.getEqBxId())) {
eqBxEntity = eqBxService.getById(data.getEqBxId()); eqBxEntity = eqBxService.getById(data.getEqBxId());
} }
if (!Objects.isNull(eqBxEntity)) { if (!Objects.isNull(eqBxEntity)) {
@ -177,55 +178,59 @@ public class EqWxPlanController {
} }
@GetMapping("{id}/{relationTypeId}") @GetMapping("{id}/{relationTypeId}")
@Operation(summary= "信息")
@Operation(summary = "信息")
// @RequiresPermissions("eqwxplan:eqwxplan:info") // @RequiresPermissions("eqwxplan:eqwxplan:info")
public Result<EqWxInfoRes> get(@PathVariable("id") Long id, @PathVariable(value = "relationTypeId") Long relationTypeId) { public Result<EqWxInfoRes> get(@PathVariable("id") Long id, @PathVariable(value = "relationTypeId") Long relationTypeId) {
EqWxPlanDTO data = eqWxPlanService.getByIdAs(id,EqWxPlanDTO.class);
EqWxInfoRes data = eqWxPlanService.getByIdAs(id, EqWxInfoRes.class);
if (Objects.isNull(data)) { if (Objects.isNull(data)) {
throw new SysException("维修计划不存在"); throw new SysException("维修计划不存在");
} }
EqWxInfoRes eqWxInfoRes = new EqWxInfoRes();
BeanUtils.copyProperties(data, eqWxInfoRes);
//
// EqWxInfoRes eqWxInfoRes = new EqWxInfoRes();
// BeanUtils.copyProperties(data, eqWxInfoRes);
// 查询设备信息 // 查询设备信息
ThingDTO thingDTO = new ThingDTO(); ThingDTO thingDTO = new ThingDTO();
iotThingBaseInfoService.getThingInfo(thingDTO, data.getThingId(), null, "1", String.valueOf(relationTypeId));
eqWxInfoRes.setBaseInfo(thingDTO);
ThingDTO thingInfo = iotThingBaseInfoService.getThingInfo(thingDTO, data.getThingId(), null, "1", String.valueOf(relationTypeId));
data.setBaseInfo(thingInfo);
//调整 //调整
String userId = data.getWxUser(); String userId = data.getWxUser();
String[] split = userId.split(","); String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
if (ArrayUtils.isNotEmpty(split)) {
List<Long> longs = new ArrayList<>();
for (String s : split) { for (String s : split) {
longs.add(Long.parseLong(s));
} List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
for (String s : planUserName) {
name+=s+",";
if(StringUtils.isNotBlank(s)){
longs.add(Long.parseLong(s));
}
}
if(CollectionUtil.isNotEmpty(longs)){
List<String> planUserName = sysUserService.getUserNameLists(longs);
String name = "";
for (String s : planUserName) {
name += s + ",";
}
name = name.substring(0, name.length() - 1);
data.setWxUseText(name);
}
} }
name = name.substring(0, name.length() - 1);
eqWxInfoRes.setWxUseText(name);
BxInfoDTO bxInfoDTO = new BxInfoDTO();
// 查询报修信息 // 查询报修信息
EqBxEntity eqBxEntity = eqBxService.getById(data.getEqBxId());
if (!Objects.isNull(eqBxEntity)) {
BeanUtils.copyProperties(eqBxEntity, bxInfoDTO);
eqWxInfoRes.setBxInfo(bxInfoDTO);
BxInfoDTO bxInfoDTO = eqBxService.getByIdAs(data.getEqBxId(),BxInfoDTO.class);
if (!Objects.isNull(bxInfoDTO)) {
data.setBxInfo(bxInfoDTO);
Map<String, List<EqAttacmentDTO>> document = fileService.getDocument(data.getEqBxId()); Map<String, List<EqAttacmentDTO>> document = fileService.getDocument(data.getEqBxId());
bxInfoDTO.setImageUrls(document.get("image")); bxInfoDTO.setImageUrls(document.get("image"));
bxInfoDTO.setAttachmentUrls(document.get("attachment")); bxInfoDTO.setAttachmentUrls(document.get("attachment"));
} }
// 查询维修备件信息 // 查询维修备件信息
eqWxInfoRes.setReplacements(eqWxReplacementService.getWxReplacementByWxPlanId(data.getId()));
data.setReplacements(eqWxReplacementService.getWxReplacementByWxPlanId(data.getId()));
return new Result<EqWxInfoRes>().ok(eqWxInfoRes);
return new Result<EqWxInfoRes>().ok(data);
} }
@PostMapping @PostMapping
@Operation(summary= "保存")
@Operation(summary = "保存")
@LogOperation("保存") @LogOperation("保存")
// @RequiresPermissions("equipment:maintainRecords:add") // @RequiresPermissions("equipment:maintainRecords:add")
public Result save(@RequestBody EqWxPlanAddDTO dto) { public Result save(@RequestBody EqWxPlanAddDTO dto) {
@ -254,7 +259,7 @@ public class EqWxPlanController {
} }
@PutMapping @PutMapping
@Operation(summary= "修改")
@Operation(summary = "修改")
@LogOperation("修改") @LogOperation("修改")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
// @RequiresPermissions("equipment:maintainRecords:update") // @RequiresPermissions("equipment:maintainRecords:update")
@ -278,7 +283,7 @@ public class EqWxPlanController {
} }
@DeleteMapping @DeleteMapping
@Operation(summary= "删除")
@Operation(summary = "删除")
@LogOperation("删除") @LogOperation("删除")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
// @RequiresPermissions("equipment:maintainRecords:delete") // @RequiresPermissions("equipment:maintainRecords:delete")
@ -287,7 +292,7 @@ public class EqWxPlanController {
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
for (Long id : ids) { for (Long id : ids) {
EqWxPlanDTO eqWxPlanDTO = eqWxPlanService.getByIdAs(id,EqWxPlanDTO.class);
EqWxPlanDTO eqWxPlanDTO = eqWxPlanService.getByIdAs(id, EqWxPlanDTO.class);
if (!Objects.isNull(eqWxPlanDTO) && "2".equals(eqWxPlanDTO.getWxStatus())) { if (!Objects.isNull(eqWxPlanDTO) && "2".equals(eqWxPlanDTO.getWxStatus())) {
throw new SysException("不能删除已完成的维修记录"); throw new SysException("不能删除已完成的维修记录");
} }
@ -303,7 +308,7 @@ public class EqWxPlanController {
} }
@PostMapping("export") @PostMapping("export")
@Operation(summary= "导出")
@Operation(summary = "导出")
@LogOperation("导出") @LogOperation("导出")
// @Parameters({ // @Parameters({
// @Parameter(name = "relationTypeId", description = "结构类型id", paramType = "query", required = true, dataType = "String"), // @Parameter(name = "relationTypeId", description = "结构类型id", paramType = "query", required = true, dataType = "String"),
@ -356,13 +361,14 @@ public class EqWxPlanController {
//调整 //调整
String userId = data.getWxUser(); String userId = data.getWxUser();
String[] split = userId.split(","); String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(Long.parseLong(s));
} List<String> planUserName = sysUserService.getUserNameLists(longs);
String name="";
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(Long.parseLong(s));
}
List<String> planUserName = sysUserService.getUserNameLists(longs);
String name = "";
for (String s : planUserName) { for (String s : planUserName) {
name+=s+",";
name += s + ",";
} }
name = name.substring(0, name.length() - 1); name = name.substring(0, name.length() - 1);
eqWxPlanExcel.setWxUser(name); eqWxPlanExcel.setWxUser(name);
@ -424,16 +430,16 @@ public class EqWxPlanController {
} }
List<EqWxPlanExcel> newList = new ArrayList<>(); List<EqWxPlanExcel> newList = new ArrayList<>();
List<Long> idList = new ArrayList<>(Arrays.asList(ids)); List<Long> idList = new ArrayList<>(Arrays.asList(ids));
if (CollectionUtil.isNotEmpty(idList)){
for (EqWxPlanExcel eqWxPlanExcel : excels ){
if (idList.contains(eqWxPlanExcel.getId())){
if (CollectionUtil.isNotEmpty(idList)) {
for (EqWxPlanExcel eqWxPlanExcel : excels) {
if (idList.contains(eqWxPlanExcel.getId())) {
newList.add(eqWxPlanExcel); newList.add(eqWxPlanExcel);
} }
} }
}else{
} else {
newList.addAll(excels); newList.addAll(excels);
} }
ExcelUtils.exportExcel(newList,null, "维修记录", EqWxPlanExcel.class,"维修记录.xls",response);
ExcelUtils.exportExcel(newList, null, "维修记录", EqWxPlanExcel.class, "维修记录.xls", response);
} }
@ -443,15 +449,15 @@ public class EqWxPlanController {
return ""; return "";
} }
List<SysDictDataEntity> temp = new ArrayList<>(); List<SysDictDataEntity> temp = new ArrayList<>();
Object obj = dictMap.get(dictType);
temp= JSON.parseArray(JSON.toJSONString(obj),SysDictDataEntity.class);
Object obj = dictMap.get(dictType);
temp = JSON.parseArray(JSON.toJSONString(obj), SysDictDataEntity.class);
if (CollectionUtil.isEmpty(temp)) { if (CollectionUtil.isEmpty(temp)) {
return ""; return "";
} }
Map<String, String> dictObject = new HashMap<>(); Map<String, String> dictObject = new HashMap<>();
for (SysDictDataEntity dictData:temp){
dictObject.put(dictData.getDictValue(),dictData.getDictLabel());
for (SysDictDataEntity dictData : temp) {
dictObject.put(dictData.getDictValue(), dictData.getDictLabel());
} }
// List<Map> temp = (List<Map>) dictMap.get(dictType); // List<Map> temp = (List<Map>) dictMap.get(dictType);

8
modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java

@ -28,6 +28,7 @@ import com.thing.sys.biz.mapper.SysDeptMapper;
import com.thing.sys.biz.mapper.SysUserMapper; import com.thing.sys.biz.mapper.SysUserMapper;
import com.thing.sys.biz.service.SysUserService; import com.thing.sys.biz.service.SysUserService;
import com.thing.sys.security.context.TenantContext; import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.context.UserContext;
import com.thing.sys.security.domain.SecurityUser; import com.thing.sys.security.domain.SecurityUser;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -107,7 +108,7 @@ public class EqBxServiceImpl extends BaseServiceImpl<EqBxMapper, EqBxEntity> imp
for (EqBxDTO eqBxEntity : eqBxEntities) { for (EqBxDTO eqBxEntity : eqBxEntities) {
EqBxDTO eqBxDTO = new EqBxDTO(); EqBxDTO eqBxDTO = new EqBxDTO();
BeanUtils.copyProperties(eqBxEntity, eqBxDTO); BeanUtils.copyProperties(eqBxEntity, eqBxDTO);
eqBxDTO.setCreateDate(eqBxEntity.getHappenDate());
Map<String, List<EqAttacmentDTO>> document = fileService.getDocument(eqBxDTO.getId()); Map<String, List<EqAttacmentDTO>> document = fileService.getDocument(eqBxDTO.getId());
eqBxDTO.setImageUrls(document.get("image")); eqBxDTO.setImageUrls(document.get("image"));
eqBxDTO.setAttachmentUrls(document.get("attachment")); eqBxDTO.setAttachmentUrls(document.get("attachment"));
@ -122,8 +123,7 @@ public class EqBxServiceImpl extends BaseServiceImpl<EqBxMapper, EqBxEntity> imp
eqBxDTOS.add(eqBxDTO); eqBxDTOS.add(eqBxDTO);
} }
PageData<EqBxDTO> pageData = new PageData<>(eqBxDTOS, eqBxDTOS.size());
return pageData;
return new PageData<>(eqBxDTOS, eqBxDTOS.size());
} }
@Override @Override
@ -256,7 +256,7 @@ public class EqBxServiceImpl extends BaseServiceImpl<EqBxMapper, EqBxEntity> imp
lastNo = SerialNumberUnit.generateNumber("BX", eqBxEntity.getBxNo()); lastNo = SerialNumberUnit.generateNumber("BX", eqBxEntity.getBxNo());
dto.setBxNo(lastNo); dto.setBxNo(lastNo);
dto.setTenantCode(SecurityUser.getTenantCode());
dto.setTenantCode(UserContext.getRealTenantCode());
// Long eqBxId = IdWorker.getId(); // Long eqBxId = IdWorker.getId();
// dto.setId(eqBxId); // dto.setId(eqBxId);

34
modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java

@ -1,11 +1,15 @@
package com.thing.eq.eqby.entity; package com.thing.eq.eqby.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import com.thing.common.orm.entity.BaseDateEntity;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/** /**
* 部件使用记录 * 部件使用记录
@ -16,11 +20,37 @@ import java.io.Serial;
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@Table("eq_by_plan_part") @Table("eq_by_plan_part")
public class EqByPlanPartEntity extends BaseDateEntity {
public class EqByPlanPartEntity implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id;
/*------------------------修改记录信息--------------------------------*/
/**
* 创建者
*/
private Long creator;
/**
* 创建时间
*/
private Date createDate;
/**
* 修改人
*/
private Long updater;
/**
* 修改时间
*/
private Date updateDate;
/** /**
* 更换数量 * 更换数量
*/ */

10
modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateDetailEntity.java

@ -1,10 +1,14 @@
package com.thing.eq.eqby.entity; package com.thing.eq.eqby.entity;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
@ -16,10 +20,12 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@Table("eq_by_template_detail") @Table("eq_by_template_detail")
public class EqByTemplateDetailEntity {
public class EqByTemplateDetailEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id; private Long id;
/** /**
* 保养模板id * 保养模板id

6
modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateEntity.java

@ -5,6 +5,8 @@ import com.mybatisflex.annotation.Table;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
@ -16,7 +18,9 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@Table("eq_by_template") @Table("eq_by_template")
public class EqByTemplateEntity {
public class EqByTemplateEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id

2
modules/equipment/src/main/java/com/thing/eq/eqby/service/EqByTemplateDetailService.java

@ -23,4 +23,6 @@ public interface EqByTemplateDetailService extends IBaseService<EqByTemplateDeta
void deleteByTemplateIds(Long[] ids); void deleteByTemplateIds(Long[] ids);
List<EqByTemplateDetailEntity> findByName(String name);
} }

53
modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java

@ -1,6 +1,7 @@
package com.thing.eq.eqby.service.impl; package com.thing.eq.eqby.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
@ -23,7 +24,6 @@ import com.thing.eq.utils.SerialNumberUnit;
import com.thing.sys.biz.dto.SysDictTypeListDTO; import com.thing.sys.biz.dto.SysDictTypeListDTO;
import com.thing.sys.biz.entity.SysDeptEntity; import com.thing.sys.biz.entity.SysDeptEntity;
import com.thing.sys.biz.entity.SysDictDataEntity; import com.thing.sys.biz.entity.SysDictDataEntity;
import com.thing.sys.biz.entity.SysDictTypeEntity;
import com.thing.sys.biz.entity.SysUserEntity; import com.thing.sys.biz.entity.SysUserEntity;
import com.thing.sys.biz.service.SysDeptService; import com.thing.sys.biz.service.SysDeptService;
import com.thing.sys.biz.service.SysDictDataService; import com.thing.sys.biz.service.SysDictDataService;
@ -86,24 +86,36 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla
@Override @Override
public QueryWrapper getWrapper(Map<String, Object> params) { public QueryWrapper getWrapper(Map<String, Object> params) {
QueryWrapper wrapper = new QueryWrapper(); QueryWrapper wrapper = new QueryWrapper();
wrapper.eq(EqByPlanEntity::getTenantCode,UserContext.getRealTenantCode());
String byStatus = MapUtil.getStr(params, "byStatus");
wrapper.eq(EqByPlanEntity::getByStatus, byStatus,StringUtils::isNotBlank);
String by_user = MapUtil.getStr(params, "checkUserId");
wrapper.like(EqByPlanEntity::getByUser, by_user,StringUtils::isNotBlank);
String byNo = MapUtil.getStr(params, "byNo");
wrapper.like(EqByPlanEntity::getByNo, byNo,StringUtils::isNotBlank);
if (params.get("eqIds") != null) {
String eqIds = params.get("eqIds").toString();
List<Long> eqthingIds = Arrays.stream(eqIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
wrapper.in(EqByPlanEntity::getThingsId, eqthingIds,CollectionUtil.isNotEmpty(eqthingIds));
}
Long startTime = MapUtil.getLong(params, "startTime");
Long endTime = MapUtil.getLong(params, "endTime");
String relationTypeId = MapUtil.getStr(params, "relationTypeId");
return wrapper; return wrapper;
} }
@Override @Override
public PageData<EqByPlanDTO> page(Map<String, Object> params) { public PageData<EqByPlanDTO> page(Map<String, Object> params) {
Page<EqByPlanEntity> page = getPage(params);
int pageNumber = MapUtil.getInt(params, "page",1);
int pageSize = MapUtil.getInt(params, "limit",10);
// IPage<EqByPlanEntity> thingsEntityPage = baseDao.selectPage(page, getWrapper(params));
String eqIds;
List<Long> eqthingIds = new ArrayList<>();
if (params.get("eqIds") != null) {
eqIds = params.get("eqIds").toString();
eqthingIds = Arrays.stream(eqIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
params.put("eqIdList", eqthingIds);
}
params.put("tenantCode", TenantContext.getTenantCode(SecurityUser.getUser()));
Page<EqByPlanDTO> paginate = mapper.paginateAs(new Page<>(pageNumber, pageSize), getWrapper(params),EqByPlanDTO.class);
List<EqByPlanDTO> eqByPlansDTOS = paginate.getRecords();
String relationTypeId = params.get("relationTypeId").toString(); String relationTypeId = params.get("relationTypeId").toString();
List<EqByPlanDTO> eqByPlansDTOS = eqByPlanDao.getListData(params);
for (EqByPlanDTO eqByPlansDTO : eqByPlansDTOS) { for (EqByPlanDTO eqByPlansDTO : eqByPlansDTOS) {
EqInfo thingsInfo = iotThingsService.getThingInfo(eqByPlansDTO.getThingsId(),relationTypeId); EqInfo thingsInfo = iotThingsService.getThingInfo(eqByPlansDTO.getThingsId(),relationTypeId);
if (thingsInfo != null) { if (thingsInfo != null) {
@ -160,9 +172,13 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla
for (EqByPlanPartDTO eqpart : dto.getThingParts()) { for (EqByPlanPartDTO eqpart : dto.getThingParts()) {
//调整 //调整
// eqpart.setEqByPlanId(id); // eqpart.setEqByPlanId(id);
eqpart.setCreateDate(new Date());
eqpart.setUpdateDate(new Date());
eqpart.setCreator(SecurityUser.getUserId());
eqByParts.add(eqpart); eqByParts.add(eqpart);
} }
eqByPlanPartService.saveDto(ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class));
List<EqByPlanPartEntity> eqByPlanPartEntities = ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class);
eqByPlanPartService.saveBatch(eqByPlanPartEntities);
} }
} }
} }
@ -197,13 +213,14 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla
//先删除保养计划更换部件 //先删除保养计划更换部件
eqByPlanPartService.deleteByEqByPlanId(dto.getId()); eqByPlanPartService.deleteByEqByPlanId(dto.getId());
//保存保养计划部件 //保存保养计划部件
List<EqByPlanPartDTO> eqByParts = new ArrayList<>();
List<EqByPlanPartEntity> eqByParts = new ArrayList<>();
if (CollectionUtil.isNotEmpty(dto.getThingParts())) { if (CollectionUtil.isNotEmpty(dto.getThingParts())) {
for (EqByPlanPartDTO eqpart : dto.getThingParts()) { for (EqByPlanPartDTO eqpart : dto.getThingParts()) {
eqpart.setEqByPlanId(dto.getId());
eqByParts.add(eqpart);
EqByPlanPartEntity eqByPlanPartEntity = ConvertUtils.sourceToTarget(eqpart, EqByPlanPartEntity.class);
eqByPlanPartEntity.setEqByPlanId(dto.getId());
eqByParts.add(eqByPlanPartEntity);
} }
eqByPlanPartService.saveDto(ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class));
eqByPlanPartService.saveBatch(ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class));
} }
} }
@ -235,6 +252,8 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla
if (CollectionUtil.isNotEmpty(byTemplateIds)) { if (CollectionUtil.isNotEmpty(byTemplateIds)) {
for (String byTemplateId : byTemplateIds) { for (String byTemplateId : byTemplateIds) {
EqByTemplateDTO eqByTemplateDTO = eqByTemplateService.getByIdAs(Long.parseLong(byTemplateId),EqByTemplateDTO.class); EqByTemplateDTO eqByTemplateDTO = eqByTemplateService.getByIdAs(Long.parseLong(byTemplateId),EqByTemplateDTO.class);
List<EqByTemplateDetailDTO> details = eqByTemplateDetailService.getDetails(eqByTemplateDTO.getId());
eqByTemplateDTO.setDatas(details);
byTemplateInfos.add(eqByTemplateDTO); byTemplateInfos.add(eqByTemplateDTO);
} }
} }

5
modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateDetailServiceImpl.java

@ -44,4 +44,9 @@ public class EqByTemplateDetailServiceImpl extends BaseServiceImpl<EqByTemplateD
public void deleteByTemplateIds(Long[] ids) { public void deleteByTemplateIds(Long[] ids) {
eqByTemplateDetailDao.deleteByTemplateIds(ids); eqByTemplateDetailDao.deleteByTemplateIds(ids);
} }
@Override
public List<EqByTemplateDetailEntity> findByName(String name) {
return mapper.selectListByQuery(QueryWrapper.create().like(EqByTemplateDetailEntity::getName, name));
}
} }

33
modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateServiceImpl.java

@ -1,27 +1,30 @@
package com.thing.eq.eqby.service.impl; package com.thing.eq.eqby.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.thing.common.core.exception.SysException; import com.thing.common.core.exception.SysException;
import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.core.web.response.PageData; import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.impl.BaseServiceImpl; import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.eq.eqby.dto.EqByTemplateDTO; import com.thing.eq.eqby.dto.EqByTemplateDTO;
import com.thing.eq.eqby.dto.EqByTemplateDetailDTO; import com.thing.eq.eqby.dto.EqByTemplateDetailDTO;
import com.thing.eq.eqby.entity.EqByTemplateDetailEntity;
import com.thing.eq.eqby.entity.EqByTemplateEntity; import com.thing.eq.eqby.entity.EqByTemplateEntity;
import com.thing.eq.eqby.mapper.EqByTemplateMapper; import com.thing.eq.eqby.mapper.EqByTemplateMapper;
import com.thing.eq.eqby.service.EqByPlanService; import com.thing.eq.eqby.service.EqByPlanService;
import com.thing.eq.eqby.service.EqByTemplateDetailService; import com.thing.eq.eqby.service.EqByTemplateDetailService;
import com.thing.eq.eqby.service.EqByTemplateService; import com.thing.eq.eqby.service.EqByTemplateService;
import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.domain.SecurityUser;
import com.thing.sys.security.context.UserContext;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import static com.thing.eq.eqby.entity.table.EqByTemplateEntityTableDef.EQ_BY_TEMPLATE_ENTITY;
/** /**
* 保养模板 * 保养模板
@ -48,12 +51,20 @@ public class EqByTemplateServiceImpl extends BaseServiceImpl<EqByTemplateMapper,
@Override @Override
public PageData<EqByTemplateDTO> page(Map<String, Object> params) { public PageData<EqByTemplateDTO> page(Map<String, Object> params) {
Page<EqByTemplateEntity> page = getPage(params);
int pageNumber = MapUtil.getInt(params, "page", 1);
int pageSize = MapUtil.getInt(params, "limit", 10);
//查询 //查询
params.put("tenantCode", TenantContext.getTenantCode(SecurityUser.getUser()));
List<EqByTemplateEntity> list = eqByTemplateDao.getListData(params);
List<EqByTemplateDTO> targetList = ConvertUtils.sourceToTarget(list, EqByTemplateDTO.class);
return new PageData<>(targetList, targetList.size());
Long deviceTypeId = MapUtil.getLong(params, "eqTypeId");
String name = MapUtil.getStr(params, "name");
QueryWrapper queryWrapper = QueryWrapper.create().eq(EqByTemplateEntity::getTenantCode, UserContext.getRealTenantCode())
.eq(EqByTemplateEntity::getDeviceTypeId, deviceTypeId, Objects::nonNull);
if(StringUtils.isNotBlank(name)){
List<EqByTemplateDetailEntity> eqByTemplateDetailEntities = eqByTemplateDetailService.findByName(name);
List<Long> byTemplateIds = eqByTemplateDetailEntities.stream().map(EqByTemplateDetailEntity::getByTemplateId).toList();
queryWrapper.where(EQ_BY_TEMPLATE_ENTITY.NAME.like(name).or(EQ_BY_TEMPLATE_ENTITY.ID.in(byTemplateIds)));
}
Page<EqByTemplateDTO> paginate = mapper.paginateAs(new Page<>(pageNumber, pageSize), queryWrapper,EqByTemplateDTO.class);
return new PageData<>(paginate.getRecords(), paginate.getTotalRow());
} }
@Override @Override
@ -64,7 +75,7 @@ public class EqByTemplateServiceImpl extends BaseServiceImpl<EqByTemplateMapper,
@Override @Override
public void save(EqByTemplateDTO dto) { public void save(EqByTemplateDTO dto) {
// Long id = IdWorker.getId(); // Long id = IdWorker.getId();
Long tenantCode = TenantContext.getTenantCode(SecurityUser.getUser());
Long tenantCode = UserContext.getRealTenantCode();
if (StringUtils.isNotBlank(dto.getName())){ if (StringUtils.isNotBlank(dto.getName())){
int count = eqByTemplateDao.getTemplateByName(dto.getName(),tenantCode); int count = eqByTemplateDao.getTemplateByName(dto.getName(),tenantCode);
if (count > 0){ if (count > 0){
@ -72,6 +83,7 @@ public class EqByTemplateServiceImpl extends BaseServiceImpl<EqByTemplateMapper,
} }
} }
dto.setId(dto.getId()); dto.setId(dto.getId());
dto.setTenantCode(tenantCode);
super.saveDto(dto); super.saveDto(dto);
if (CollectionUtil.isNotEmpty(dto.getDatas())){ if (CollectionUtil.isNotEmpty(dto.getDatas())){
for (EqByTemplateDetailDTO detailDTO:dto.getDatas()){ for (EqByTemplateDetailDTO detailDTO:dto.getDatas()){
@ -92,13 +104,14 @@ public class EqByTemplateServiceImpl extends BaseServiceImpl<EqByTemplateMapper,
if (planCount > 0){ if (planCount > 0){
throw new SysException("该模板已被保养计划使用,不可修改,请确认"); throw new SysException("该模板已被保养计划使用,不可修改,请确认");
} }
Long tenantCode = TenantContext.getTenantCode(SecurityUser.getUser());
Long tenantCode = UserContext.getRealTenantCode();
if (StringUtils.isNotBlank(dto.getName())){ if (StringUtils.isNotBlank(dto.getName())){
int count = eqByTemplateDao.getTemplateByNameNoId(dto.getName(),dto.getId(),tenantCode); int count = eqByTemplateDao.getTemplateByNameNoId(dto.getName(),dto.getId(),tenantCode);
if (count > 0){ if (count > 0){
throw new SysException("模板名称已经存在,不可新增,请确认"); throw new SysException("模板名称已经存在,不可新增,请确认");
} }
} }
dto.setTenantCode(tenantCode);
super.updateDto(dto); super.updateDto(dto);
//先删除模板明细 //先删除模板明细
eqByTemplateDetailService.deleteByTemplateId(dto.getId()); eqByTemplateDetailService.deleteByTemplateId(dto.getId());

5
modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqCheckStandardController.java

@ -21,6 +21,7 @@ import com.thing.eq.eqcheck.excel.EqCheckStandardExcel;
import com.thing.eq.eqcheck.service.EqCheckSettingService; import com.thing.eq.eqcheck.service.EqCheckSettingService;
import com.thing.eq.eqcheck.service.EqCheckStandardDetailService; import com.thing.eq.eqcheck.service.EqCheckStandardDetailService;
import com.thing.eq.eqcheck.service.EqCheckStandardService; import com.thing.eq.eqcheck.service.EqCheckStandardService;
import com.thing.sys.security.context.UserContext;
import com.thing.sys.security.domain.SecurityUser; import com.thing.sys.security.domain.SecurityUser;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -139,15 +140,13 @@ public class EqCheckStandardController {
if (CollectionUtil.isEmpty(detailDTOS)) { if (CollectionUtil.isEmpty(detailDTOS)) {
throw new SysException("请添加模板检查项"); throw new SysException("请添加模板检查项");
} }
dto.setTenantCode(SecurityUser.getTenantCode());
dto.setTenantCode(UserContext.getRealTenantCode());
dto.setCreateDate(new Date()); dto.setCreateDate(new Date());
eqCheckStandardService.saveDto(dto); eqCheckStandardService.saveDto(dto);
// if (Objects.isNull(dto.getId())) { // if (Objects.isNull(dto.getId())) {
// throw new SysException("保存失败"); // throw new SysException("保存失败");
// } // }
for (EqCheckStandardDetailDTO detail : detailDTOS) { for (EqCheckStandardDetailDTO detail : detailDTOS) {
if ("0".equals(detail.getType()) && (StringUtils.isBlank(detail.getLowerLimit()) || StringUtils.isBlank(detail.getUpperLimit()))) { if ("0".equals(detail.getType()) && (StringUtils.isBlank(detail.getLowerLimit()) || StringUtils.isBlank(detail.getUpperLimit()))) {
throw new SysException("标准细项为上下限判定类型时,上下限值不能为空"); throw new SysException("标准细项为上下限判定类型时,上下限值不能为空");

26
modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqSpotCheckPlanController.java

@ -90,9 +90,7 @@ public class EqSpotCheckPlanController {
if (CollectionUtil.isNotEmpty(planDTOS)) { if (CollectionUtil.isNotEmpty(planDTOS)) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
planDTOS.forEach(eqSpotCheckPlanDTO -> { planDTOS.forEach(eqSpotCheckPlanDTO -> {
iotThingBaseInfoService.getThingInfo(eqSpotCheckPlanDTO, eqSpotCheckPlanDTO.getThingId(), null, "0", String.valueOf(params.get("relationTypeId"))); iotThingBaseInfoService.getThingInfo(eqSpotCheckPlanDTO, eqSpotCheckPlanDTO.getThingId(), null, "0", String.valueOf(params.get("relationTypeId")));
List<Long> standardList = new ArrayList<>(); List<Long> standardList = new ArrayList<>();
List<EqCheckSettingDTO> settingList = eqCheckSettingService.getSettingList(eqSpotCheckPlanDTO.getThingId(), "0"); List<EqCheckSettingDTO> settingList = eqCheckSettingService.getSettingList(eqSpotCheckPlanDTO.getThingId(), "0");
if (CollectionUtil.isNotEmpty(settingList)) { if (CollectionUtil.isNotEmpty(settingList)) {
@ -100,25 +98,24 @@ public class EqSpotCheckPlanController {
EqCheckStandardDTO eqCheckStandardDTO = eqCheckStandardService.getByIdAs(eqCheckSettingDTO.getStandardId(),EqCheckStandardDTO.class); EqCheckStandardDTO eqCheckStandardDTO = eqCheckStandardService.getByIdAs(eqCheckSettingDTO.getStandardId(),EqCheckStandardDTO.class);
if (!Objects.isNull(eqCheckStandardDTO)) { if (!Objects.isNull(eqCheckStandardDTO)) {
standardList.add(eqCheckStandardDTO.getId()); standardList.add(eqCheckStandardDTO.getId());
stringBuilder.append(eqCheckStandardDTO.getName() + ",");
stringBuilder.append(eqCheckStandardDTO.getName()).append(",");
} }
}); });
eqSpotCheckPlanDTO.setEqCode(eqSpotCheckPlanDTO.getThingCode());
eqSpotCheckPlanDTO.setCheckIdList(standardList); eqSpotCheckPlanDTO.setCheckIdList(standardList);
eqSpotCheckPlanDTO.setCheckNameList(stringBuilder.length() > 0 ? stringBuilder.toString().substring(0, stringBuilder.length() - 1) : "");
eqSpotCheckPlanDTO.setCheckNameList(!stringBuilder.isEmpty() ? stringBuilder.substring(0, stringBuilder.length() - 1) : "");
stringBuilder.setLength(0); stringBuilder.setLength(0);
} }
List<String> useIdList = StringUtils.isNotBlank(eqSpotCheckPlanDTO.getUseId()) ? Arrays.asList(eqSpotCheckPlanDTO.getUseId().split(",")) : new ArrayList<>(); List<String> useIdList = StringUtils.isNotBlank(eqSpotCheckPlanDTO.getUseId()) ? Arrays.asList(eqSpotCheckPlanDTO.getUseId().split(",")) : new ArrayList<>();
if (CollectionUtil.isNotEmpty(useIdList)) { if (CollectionUtil.isNotEmpty(useIdList)) {
useIdList.forEach(idStr -> { useIdList.forEach(idStr -> {
SysUserDTO sysUserDTO = sysUserService.get(Long.parseLong(idStr)); SysUserDTO sysUserDTO = sysUserService.get(Long.parseLong(idStr));
if (!Objects.isNull(sysUserDTO)) { if (!Objects.isNull(sysUserDTO)) {
stringBuilder.append(sysUserDTO.getRealName() + ",");
stringBuilder.append(sysUserDTO.getRealName()).append(",");
} }
}); });
eqSpotCheckPlanDTO.setUseIdList(useIdList); eqSpotCheckPlanDTO.setUseIdList(useIdList);
eqSpotCheckPlanDTO.setOperatorNameList(stringBuilder.length() > 0 ? stringBuilder.toString().substring(0, stringBuilder.length() - 1) : "");
eqSpotCheckPlanDTO.setOperatorNameList(!stringBuilder.isEmpty() ? stringBuilder.substring(0, stringBuilder.length() - 1) : "");
stringBuilder.setLength(0); stringBuilder.setLength(0);
} }
}); });
@ -139,9 +136,9 @@ public class EqSpotCheckPlanController {
} }
iotThingBaseInfoService.getThingInfo(data, data.getThingId(), null, "0", relationTypeId); iotThingBaseInfoService.getThingInfo(data, data.getThingId(), null, "0", relationTypeId);
data.setEqCode(data.getThingCode());
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
List<EqCheckSettingDTO> settingList = eqCheckSettingService.getSettingList(data.getThingId(), "0"); List<EqCheckSettingDTO> settingList = eqCheckSettingService.getSettingList(data.getThingId(), "0");
if (CollectionUtil.isNotEmpty(settingList)) { if (CollectionUtil.isNotEmpty(settingList)) {
List<DataVo> standardList = new ArrayList<>(); List<DataVo> standardList = new ArrayList<>();
List<Long> standardIdList = new ArrayList<>(); List<Long> standardIdList = new ArrayList<>();
@ -153,29 +150,26 @@ public class EqSpotCheckPlanController {
dataVo.setName(eqCheckStandardDTO.getName()); dataVo.setName(eqCheckStandardDTO.getName());
standardIdList.add(eqCheckStandardDTO.getId()); standardIdList.add(eqCheckStandardDTO.getId());
standardList.add(dataVo); standardList.add(dataVo);
stringBuilder.append(eqCheckStandardDTO.getName() + ",");
stringBuilder.append(eqCheckStandardDTO.getName()).append(",");
} }
}); });
data.setCheckIdList(standardIdList); data.setCheckIdList(standardIdList);
data.setDataList(standardList); data.setDataList(standardList);
data.setCheckNameList(stringBuilder.length() > 0 ? stringBuilder.toString().substring(0, stringBuilder.length() - 1) : "");
data.setCheckNameList(!stringBuilder.isEmpty() ? stringBuilder.substring(0, stringBuilder.length() - 1) : "");
stringBuilder.setLength(0); stringBuilder.setLength(0);
} }
List<String> useIdList = StringUtils.isNotBlank(data.getUseId()) ? Arrays.asList(data.getUseId().split(",")) : new ArrayList<>(); List<String> useIdList = StringUtils.isNotBlank(data.getUseId()) ? Arrays.asList(data.getUseId().split(",")) : new ArrayList<>();
if (CollectionUtil.isNotEmpty(useIdList)) { if (CollectionUtil.isNotEmpty(useIdList)) {
useIdList.forEach(idStr -> { useIdList.forEach(idStr -> {
SysUserDTO sysUserDTO = sysUserService.get(Long.parseLong(idStr)); SysUserDTO sysUserDTO = sysUserService.get(Long.parseLong(idStr));
if (!Objects.isNull(sysUserDTO)) { if (!Objects.isNull(sysUserDTO)) {
stringBuilder.append(sysUserDTO.getRealName() + ",");
stringBuilder.append(sysUserDTO.getRealName()).append(",");
} }
}); });
data.setUseIdList(useIdList); data.setUseIdList(useIdList);
data.setOperatorNameList(stringBuilder.length() > 0 ? stringBuilder.toString().substring(0, stringBuilder.length() - 1) : "");
data.setOperatorNameList(!stringBuilder.isEmpty() ? stringBuilder.substring(0, stringBuilder.length() - 1) : "");
} }
List<EqCheckStandardDetailDTO> detailDTOS = eqCheckStandardDetailService.getAllStandardDetailByThingId(data.getThingId(), "0"); List<EqCheckStandardDetailDTO> detailDTOS = eqCheckStandardDetailService.getAllStandardDetailByThingId(data.getThingId(), "0");
data.setDetailDTOS(detailDTOS); data.setDetailDTOS(detailDTOS);

5
modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqCheckStandardDetailDTO.java

@ -3,7 +3,9 @@ package com.thing.eq.eqcheck.dto;
import com.thing.common.orm.dto.BaseDTO; import com.thing.common.orm.dto.BaseDTO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -12,9 +14,12 @@ import java.io.Serializable;
* @author xiezw 806671840@qq.com * @author xiezw 806671840@qq.com
* @since 3.0 2021-09-22 * @since 3.0 2021-09-22
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
@Schema(description = "设备检查标准明细") @Schema(description = "设备检查标准明细")
public class EqCheckStandardDetailDTO extends BaseDTO implements Serializable { public class EqCheckStandardDetailDTO extends BaseDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id; private Long id;

4
modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqSpotCheckPlanDTO.java

@ -4,8 +4,10 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.thing.common.core.utils.DateTimeUtils; import com.thing.common.core.utils.DateTimeUtils;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -16,9 +18,11 @@ import java.util.List;
* @author zy aa@aa,com * @author zy aa@aa,com
* @since 3.0 2021-10-12 * @since 3.0 2021-10-12
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
@Schema(description = "点检计划") @Schema(description = "点检计划")
public class EqSpotCheckPlanDTO extends ThingDTO implements Serializable { public class EqSpotCheckPlanDTO extends ThingDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id; private Long id;

10
modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqPatrolCheckPlanEntity.java

@ -1,10 +1,14 @@
package com.thing.eq.eqcheck.entity; package com.thing.eq.eqcheck.entity;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
@ -16,13 +20,15 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Table("eq_patrol_check_plan") @Table("eq_patrol_check_plan")
public class EqPatrolCheckPlanEntity {
public class EqPatrolCheckPlanEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* id * id
*/ */
@Id
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id; private Long id;
/** /**
* 创建人 * 创建人

11
modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqSpotCheckPlanEntity.java

@ -1,10 +1,14 @@
package com.thing.eq.eqcheck.entity; package com.thing.eq.eqcheck.entity;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
@ -16,10 +20,13 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@Table("eq_spot_check_plan") @Table("eq_spot_check_plan")
public class EqSpotCheckPlanEntity {
public class EqSpotCheckPlanEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id; private Long id;
/** /**
* 设备thingid * 设备thingid

28
modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckPlanServiceImpl.java

@ -27,6 +27,7 @@ import com.thing.eq.equsergroup.dto.EqUserGroupDTO;
import com.thing.eq.equsergroup.service.EqUserGroupService; import com.thing.eq.equsergroup.service.EqUserGroupService;
import com.thing.eq.utils.SerialNumberUnit; import com.thing.eq.utils.SerialNumberUnit;
import com.thing.sys.security.context.TenantContext; import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.context.UserContext;
import com.thing.sys.security.domain.SecurityUser; import com.thing.sys.security.domain.SecurityUser;
import com.thing.thing.entity.dto.IotThingEntityDTO; import com.thing.thing.entity.dto.IotThingEntityDTO;
import com.thing.thing.entity.entity.IotThingEntity; import com.thing.thing.entity.entity.IotThingEntity;
@ -631,26 +632,25 @@ public class EqPatrolCheckPlanServiceImpl extends BaseServiceImpl<EqPatrolCheckP
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderBy("patrol_check_plan_no",false); queryWrapper.orderBy("patrol_check_plan_no",false);
EqPatrolCheckPlanEntity planEntity = mapper.selectOneExt(queryWrapper); EqPatrolCheckPlanEntity planEntity = mapper.selectOneExt(queryWrapper);
if (Objects.isNull(planEntity)) { if (Objects.isNull(planEntity)) {
planEntity = new EqPatrolCheckPlanEntity(); planEntity = new EqPatrolCheckPlanEntity();
} }
String lastNo = SerialNumberUnit.generateNumber("XJ", planEntity.getPatrolCheckPlanNo()); String lastNo = SerialNumberUnit.generateNumber("XJ", planEntity.getPatrolCheckPlanNo());
dto.setPatrolCheckPlanNo(lastNo); dto.setPatrolCheckPlanNo(lastNo);
saveDto(dto);
if (Objects.isNull(dto.getId())) {
dto.setTenantCode(UserContext.getRealTenantCode());
dto.setCreateDate(new Date());
dto.setUpdateDate(new Date());
EqPatrolCheckPlanEntity eqPatrolCheckPlanEntity = ConvertUtils.sourceToTarget(dto, EqPatrolCheckPlanEntity.class);
mapper.insert(eqPatrolCheckPlanEntity);
if (Objects.isNull(eqPatrolCheckPlanEntity.getId())) {
throw new SysException("巡检计划保存失败"); throw new SysException("巡检计划保存失败");
} }
saveDeviceList(dto.getId(), dto.getDeviceBaseInfoDTOS());
saveDeviceList(eqPatrolCheckPlanEntity.getId(), dto.getDeviceBaseInfoDTOS());
} }
public void saveDeviceList(Long checkPlanId, List<DeviceBaseInfoDTO> deviceBaseInfoDTOS) { public void saveDeviceList(Long checkPlanId, List<DeviceBaseInfoDTO> deviceBaseInfoDTOS) {
for (DeviceBaseInfoDTO deviceInfo : deviceBaseInfoDTOS) { for (DeviceBaseInfoDTO deviceInfo : deviceBaseInfoDTOS) {
eqScrapService.checkThingStatus(deviceInfo.getThingId()); eqScrapService.checkThingStatus(deviceInfo.getThingId());
List<Long> standardDTOS = deviceInfo.getStandardIdList(); List<Long> standardDTOS = deviceInfo.getStandardIdList();
//todo //todo
if (CollectionUtil.isEmpty(standardDTOS)) { if (CollectionUtil.isEmpty(standardDTOS)) {
@ -665,12 +665,12 @@ public class EqPatrolCheckPlanServiceImpl extends BaseServiceImpl<EqPatrolCheckP
} }
for (Long standardId : standardDTOS) { for (Long standardId : standardDTOS) {
EqCheckSettingEntity eqCheckSettingDTO = new EqCheckSettingEntity();
eqCheckSettingDTO.setThingId(deviceInfo.getThingId());
eqCheckSettingDTO.setStandardId(standardId);
eqCheckSettingDTO.setType("1");
eqCheckSettingDTO.setPatrolcheckPlanId(checkPlanId);
eqCheckSettingService.saveDto(eqCheckSettingDTO);
EqCheckSettingEntity eqCheckSettingEntity = new EqCheckSettingEntity();
eqCheckSettingEntity.setThingId(deviceInfo.getThingId());
eqCheckSettingEntity.setStandardId(standardId);
eqCheckSettingEntity.setType("1");
eqCheckSettingEntity.setPatrolcheckPlanId(checkPlanId);
eqCheckSettingService.save(eqCheckSettingEntity);
} }
} }
} }

3
modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqSpotCheckPlanServiceImpl.java

@ -17,6 +17,7 @@ import com.thing.eq.eqcheck.service.EqSpotCheckRecordService;
import com.thing.eq.eqmanager.service.EqScrapService; import com.thing.eq.eqmanager.service.EqScrapService;
import com.thing.eq.utils.SerialNumberUnit; import com.thing.eq.utils.SerialNumberUnit;
import com.thing.sys.security.context.TenantContext; import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.context.UserContext;
import com.thing.sys.security.domain.SecurityUser; import com.thing.sys.security.domain.SecurityUser;
import com.thing.thing.entity.dto.IotThingEntityDTO; import com.thing.thing.entity.dto.IotThingEntityDTO;
import com.thing.thing.entity.service.IotThingEntityService; import com.thing.thing.entity.service.IotThingEntityService;
@ -106,7 +107,7 @@ public class EqSpotCheckPlanServiceImpl extends BaseServiceImpl<EqSpotCheckPlanM
EqSpotCheckPlanEntity eqSpotCheckPlanEntity = new EqSpotCheckPlanEntity(); EqSpotCheckPlanEntity eqSpotCheckPlanEntity = new EqSpotCheckPlanEntity();
BeanUtils.copyProperties(dto, eqSpotCheckPlanEntity); BeanUtils.copyProperties(dto, eqSpotCheckPlanEntity);
eqSpotCheckPlanEntity.setThingId(thingId); eqSpotCheckPlanEntity.setThingId(thingId);
eqSpotCheckPlanEntity.setTenantCode(SecurityUser.getTenantCode());
eqSpotCheckPlanEntity.setTenantCode(UserContext.getRealTenantCode());
eqSpotCheckPlanEntity.setSpotCheckNo(lastNo); eqSpotCheckPlanEntity.setSpotCheckNo(lastNo);
saveDto(eqSpotCheckPlanEntity); saveDto(eqSpotCheckPlanEntity);
// if (Objects.isNull(eqSpotCheckPlanEntity.getId())) { // if (Objects.isNull(eqSpotCheckPlanEntity.getId())) {

3
modules/equipment/src/main/java/com/thing/eq/eqmanager/dto/EqScrapDTO.java

@ -1,5 +1,7 @@
package com.thing.eq.eqmanager.dto; package com.thing.eq.eqmanager.dto;
import com.thing.common.orm.dto.BaseDTO;
import com.thing.common.orm.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@ -41,5 +43,6 @@ public class EqScrapDTO implements Serializable {
private String scrapDisposal; private String scrapDisposal;
@Schema(description = "设备信息") @Schema(description = "设备信息")
private EqInfoDTO eqInfo; private EqInfoDTO eqInfo;
private Long tenantCode;
} }

4
modules/equipment/src/main/java/com/thing/eq/eqmanager/mapper/IotThingBaseInfoMapper.java

@ -35,7 +35,7 @@ public interface IotThingBaseInfoMapper extends PowerBaseMapper<IotThingBaseInfo
void updateScrap(@Param("eqId") Long eqId, @Param("scrap") String scrap, @Param("scrapDisposal") String scrapDisposal); void updateScrap(@Param("eqId") Long eqId, @Param("scrap") String scrap, @Param("scrapDisposal") String scrapDisposal);
List<IotThingsPartExcel> exportPartListByThingsId(@Param("params") Map<String, Object> params);
// List<IotThingsPartExcel> exportPartListByThingsId(@Param("params") Map<String, Object> params);
String getStock(@Param("eqId") Long eqId); String getStock(@Param("eqId") Long eqId);
@ -47,5 +47,5 @@ public interface IotThingBaseInfoMapper extends PowerBaseMapper<IotThingBaseInfo
List<IotThingsExcel> exportDeviceListByThingsId(@Param("relationTypeId") Long relationTypeId, @Param("toId") Long toId, @Param("ids") Long[] ids); List<IotThingsExcel> exportDeviceListByThingsId(@Param("relationTypeId") Long relationTypeId, @Param("toId") Long toId, @Param("ids") Long[] ids);
List<IotThingsPartExcel> exportPartListByThingsId(@Param("relationTypeId") Long relationTypeId, @Param("toId") Long toId, @Param("ids") Long[] ids);
List<IotThingsPartExcel> exportPartListByThingsId(@Param("relationTypeId") Long relationTypeId, @Param("toId") Long toId, @Param("ids") Long[] ids,@Param("keyWord")String keyWord);
} }

1
modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/EqScrapServiceImpl.java

@ -119,6 +119,7 @@ public class EqScrapServiceImpl extends BaseServiceImpl<EqScrapMapper, EqScrapEn
} }
//报废未处理 //报废未处理
dto.setScrapDisposal("0"); dto.setScrapDisposal("0");
dto.setTenantCode(TenantContext.getTenantCode(SecurityUser.getUser()));
//更新设备报废状态设备未处理状态 //更新设备报废状态设备未处理状态
iotThingBaseInfoService.updateScrap(eqId,scrap,"0"); iotThingBaseInfoService.updateScrap(eqId,scrap,"0");
//保存记录 //保存记录

17
modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingBaseInfoServiceImpl.java

@ -31,7 +31,6 @@ import com.thing.thing.entity.service.IotThingEntityService;
import com.thing.thing.relation.detail.entity.IotThingRelationDetailEntity; import com.thing.thing.relation.detail.entity.IotThingRelationDetailEntity;
import com.thing.thing.relation.detail.service.IotThingRelationDetailService; import com.thing.thing.relation.detail.service.IotThingRelationDetailService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -136,8 +135,8 @@ public class IotThingBaseInfoServiceImpl extends BaseServiceImpl<IotThingBaseInf
keyWord = params.get("keyWord").toString(); keyWord = params.get("keyWord").toString();
} }
Long aLong = null; Long aLong = null;
if(!Objects.isNull(params.get("useDeptId"))){
String useDeptId = params.get("useDeptId").toString();
String useDeptId = (String) params.get("useDeptId");
if(StringUtils.isNotBlank(useDeptId)){
aLong = new Long(useDeptId); aLong = new Long(useDeptId);
} }
List<EqDTO> eqDTOS = iotThingBaseInfoDao.queryDeviceListByThingsId(new Page<>(page, limit), params,aLong,aLong1,aLong2,eqTypeName,keyWord); List<EqDTO> eqDTOS = iotThingBaseInfoDao.queryDeviceListByThingsId(new Page<>(page, limit), params,aLong,aLong1,aLong2,eqTypeName,keyWord);
@ -150,7 +149,7 @@ public class IotThingBaseInfoServiceImpl extends BaseServiceImpl<IotThingBaseInf
@Override @Override
public ThingDTO getThingInfo(ThingDTO thingDTO, Long thingId, List<EqCheckSettingDTO> settingList, String showDeviceType, String relationTypeId) { public ThingDTO getThingInfo(ThingDTO thingDTO, Long thingId, List<EqCheckSettingDTO> settingList, String showDeviceType, String relationTypeId) {
IotThingBaseInfoDTO baseThing = iotThingBaseInfoService.getByThingsId(thingId);
IotThingBaseInfoDTO baseThing = iotThingBaseInfoService.getByIdAs(thingId,IotThingBaseInfoDTO.class);
EqScrapEntity eqScrapEntity = eqScrapService.getByEqId(thingId); EqScrapEntity eqScrapEntity = eqScrapService.getByEqId(thingId);
if(!Objects.isNull(eqScrapEntity)){ if(!Objects.isNull(eqScrapEntity)){
@ -198,9 +197,9 @@ public class IotThingBaseInfoServiceImpl extends BaseServiceImpl<IotThingBaseInf
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
List<EqCheckStandardDTO> standardList = eqCheckStandardService.getStandardListByStandardIdList(standardIdList); List<EqCheckStandardDTO> standardList = eqCheckStandardService.getStandardListByStandardIdList(standardIdList);
standardList.forEach(standard -> { standardList.forEach(standard -> {
stringBuilder.append(standard.getName() + ",");
stringBuilder.append(standard.getName()).append(",");
}); });
thingDTO.setStandardNameList(stringBuilder.length() > 0 ? stringBuilder.toString().substring(0, stringBuilder.length() - 1) : "");
thingDTO.setStandardNameList(!stringBuilder.isEmpty() ? stringBuilder.substring(0, stringBuilder.length() - 1) : "");
} }
} }
@ -321,8 +320,12 @@ public class IotThingBaseInfoServiceImpl extends BaseServiceImpl<IotThingBaseInf
String aLong2 = params.get("toId").toString(); String aLong2 = params.get("toId").toString();
toId = new Long(aLong2); toId = new Long(aLong2);
}; };
String keyWord = null;
if (ObjectUtil.isNotEmpty(params.get("keyWord"))){
keyWord = params.get("keyWord").toString();
}
// ids.length // ids.length
List<IotThingsPartExcel> excels = iotThingBaseInfoDao.exportPartListByThingsId(relationTypeId,toId,ids);
List<IotThingsPartExcel> excels = iotThingBaseInfoDao.exportPartListByThingsId(relationTypeId,toId,ids,keyWord);
return excels; return excels;
} }

46
modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java

@ -32,8 +32,8 @@ import com.thing.thing.entity.mapper.IotThingEntityMapper;
import com.thing.thing.entity.service.IotThingEntityService; import com.thing.thing.entity.service.IotThingEntityService;
import com.thing.thing.relation.detail.dto.IotThingRelationDetailDTO; import com.thing.thing.relation.detail.dto.IotThingRelationDetailDTO;
import com.thing.thing.relation.detail.dto.RelationDetailBatchSaveDTO; import com.thing.thing.relation.detail.dto.RelationDetailBatchSaveDTO;
import com.thing.thing.relation.detail.dto.ThingRelationDTO;
import com.thing.thing.relation.detail.entity.IotThingRelationDetailEntity; import com.thing.thing.relation.detail.entity.IotThingRelationDetailEntity;
import com.thing.thing.relation.detail.param.IotThingRelationDetailParamDTO;
import com.thing.thing.relation.detail.service.IotThingRelationDetailService; import com.thing.thing.relation.detail.service.IotThingRelationDetailService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -187,26 +187,32 @@ public class IotThingsServiceImpl implements IotThingsService {
IotThingBaseInfoDTO baseInfoDTO = new IotThingBaseInfoDTO(); IotThingBaseInfoDTO baseInfoDTO = new IotThingBaseInfoDTO();
BeanUtils.copyProperties(dto,baseInfoDTO); BeanUtils.copyProperties(dto,baseInfoDTO);
//*** //***
baseInfoDTO.setId(thingEntity.getId());
baseInfoDTO.setThingId(thingEntity.getId()); baseInfoDTO.setThingId(thingEntity.getId());
baseInfoDTO.setScrap("0"); baseInfoDTO.setScrap("0");
baseInfoDTO.setScrapDisposal("0"); baseInfoDTO.setScrapDisposal("0");
iotThingBaseInfoService.saveDto(baseInfoDTO); iotThingBaseInfoService.saveDto(baseInfoDTO);
//保存设备的关系 //保存设备的关系
ThingRelationDTO relationDTO = new ThingRelationDTO();
List<IotThingRelationDetailDTO> relationDetailDTOS =
iotThingRelationDetailService.findRootDetailChildNodeByRootIdAndFromIdAndRootThingId(dto.getRelationTypeId(), parentThing.getId(), dto.getRelationTopId());
IotThingRelationDetailParamDTO relationDTO = new IotThingRelationDetailParamDTO();
relationDTO.setRootId(dto.getRelationTypeId()); relationDTO.setRootId(dto.getRelationTypeId());
relationDTO.setRootThingId(dto.getRelationTopId()); relationDTO.setRootThingId(dto.getRelationTopId());
relationDTO.setFromId(parentThing.getId()); relationDTO.setFromId(parentThing.getId());
relationDTO.setFromCode(parentThing.getCode()); relationDTO.setFromCode(parentThing.getCode());
relationDTO.setFromName(parentThing.getName()); relationDTO.setFromName(parentThing.getName());
List<ThingRelationDTO.RelationEntity> relationList = new ArrayList<>();
ThingRelationDTO.RelationEntity relation = new ThingRelationDTO.RelationEntity();
relationDTO.setId(relationDetailDTOS.get(0).getId());
List<IotThingRelationDetailParamDTO> relationList = new ArrayList<>();
IotThingRelationDetailParamDTO relation = new IotThingRelationDetailParamDTO();
relation.setToId(thingEntity.getId()); relation.setToId(thingEntity.getId());
relation.setToCode(code); relation.setToCode(code);
relation.setToName(dto.getName()); relation.setToName(dto.getName());
relationList.add(relation); relationList.add(relation);
relationDTO.setRelationList(relationList); relationDTO.setRelationList(relationList);
iotThingRelationDetailService.saveRelationNodes(relationDTO);
iotThingRelationDetailService.save(relationDTO);
//保存附件 //保存附件
eqAttacmentService.saveBatch(ConvertUtils.sourceToTarget(attacmentDTOS, EqAttacmentEntity.class)); eqAttacmentService.saveBatch(ConvertUtils.sourceToTarget(attacmentDTOS, EqAttacmentEntity.class));
} }
@ -388,9 +394,19 @@ public class IotThingsServiceImpl implements IotThingsService {
@Override @Override
public EqDTO getInfo(Long id) { public EqDTO getInfo(Long id) {
EqDTO info = new EqDTO(); EqDTO info = new EqDTO();
//获取设备 //获取设备
IotThingEntity eq = iotThingEntityDao.selectOneById(id);
IotThingBaseInfoEntity baseInfoEntity = iotThingBaseInfoService.getById(id);
if (baseInfoEntity==null){
return null;
}
Long thingId = baseInfoEntity.getThingId();
if (thingId==null){
return null;
}
IotThingEntity eq = iotThingEntityDao.selectOneById(thingId);
if (eq==null){ if (eq==null){
return null; return null;
} }
@ -406,8 +422,7 @@ public class IotThingsServiceImpl implements IotThingsService {
info.setUpdateDate(eq.getUpdateDate()); info.setUpdateDate(eq.getUpdateDate());
// BeanUtils.copyProperties(eq,info); // BeanUtils.copyProperties(eq,info);
//获取设备基础信息 //获取设备基础信息
IotThingBaseInfoDTO baseInfoDTO = iotThingBaseInfoService.getByThingsId(id);
BeanUtils.copyProperties(baseInfoDTO,info);
BeanUtils.copyProperties(baseInfoEntity,info);
List<EqAttacmentDTO> imageUrls = new ArrayList<>(); List<EqAttacmentDTO> imageUrls = new ArrayList<>();
List<EqAttacmentDTO> attachmentUrls = new ArrayList<>(); List<EqAttacmentDTO> attachmentUrls = new ArrayList<>();
@ -439,13 +454,14 @@ public class IotThingsServiceImpl implements IotThingsService {
result.setCode(eq.getCode()); result.setCode(eq.getCode());
result.setName(eq.getName()); result.setName(eq.getName());
IotThingBaseInfoDTO baseInfoDTO = iotThingBaseInfoService.getByThingsId(thingId); IotThingBaseInfoDTO baseInfoDTO = iotThingBaseInfoService.getByThingsId(thingId);
result.setStandard(baseInfoDTO.getStandard());
result.setUseDeptId(baseInfoDTO.getUseDeptId());
result.setEqCode(baseInfoDTO.getEqCode());
result.setScrap(baseInfoDTO.getScrap());
result.setScrapDisposal(baseInfoDTO.getScrapDisposal());
if(!Objects.isNull(baseInfoDTO)){
result.setStandard(baseInfoDTO.getStandard());
result.setUseDeptId(baseInfoDTO.getUseDeptId());
result.setEqCode(baseInfoDTO.getEqCode());
result.setScrap(baseInfoDTO.getScrap());
result.setScrapDisposal(baseInfoDTO.getScrapDisposal());
}
return result; return result;
// return iotThingsDao.getThingInfo(thingId,relationTypeId);
} }
@Override @Override

10
modules/equipment/src/main/java/com/thing/eq/tree/controller/DeviceController.java

@ -108,10 +108,9 @@ public class DeviceController {
newList.add(iotThingsExcel); newList.add(iotThingsExcel);
} }
} }
} else{
newList.addAll(list);
} }
// else{
// newList.addAll(list);
// }
ExcelUtils.exportExcel(newList,null, "设备台账", IotThingsExcel.class,"设备台账.xls",response); ExcelUtils.exportExcel(newList,null, "设备台账", IotThingsExcel.class,"设备台账.xls",response);
} }
@ -148,10 +147,9 @@ public class DeviceController {
newList.add(iotThingsPartExcel); newList.add(iotThingsPartExcel);
} }
} }
} else{
newList.addAll(list);
} }
// else{
// newList.addAll(list);
// }
ExcelUtils.exportExcel(newList,null, "备件库", IotThingsPartExcel.class,"备件库.xls",response); ExcelUtils.exportExcel(newList,null, "备件库", IotThingsPartExcel.class,"备件库.xls",response);
} }

14
modules/equipment/src/main/resources/mapper/eqmanager/IotThingBaseInfoMapper.xml

@ -25,7 +25,7 @@
<result property="operator" column="operator"/> <result property="operator" column="operator"/>
</resultMap> </resultMap>
<update id="updateScrap"> <update id="updateScrap">
update iot_thing_base_info set scrap=#{scrap},scrap_disposal=#{scrapDisposal} where thing_id=#{eqId}
update iot_thing_base_info set scrap=#{scrap},scrap_disposal=#{scrapDisposal} where id=#{eqId}
</update> </update>
<delete id="deleteByThingsId"> <delete id="deleteByThingsId">
@ -130,27 +130,25 @@
FROM FROM
iot_thing_base_info baseinfo iot_thing_base_info baseinfo
LEFT JOIN iot_thing_entity things ON things.id = baseinfo.thing_id LEFT JOIN iot_thing_entity things ON things.id = baseinfo.thing_id
LEFT JOIN iot_thing_relation_detail relation on relation.to_id = baseinfo.thing_id and relation.root_id = #{params.relationTypeId} and relation.from_id =#{params.toId}
LEFT JOIN iot_thing_relation_detail relation on relation.to_id = baseinfo.thing_id
LEFT JOIN iot_thing_entity things2 ON relation.from_id = things2.id LEFT JOIN iot_thing_entity things2 ON relation.from_id = things2.id
<where> <where>
relation.root_id = #{relationTypeId}
<if test="ids !=null and ids.length >0"> <if test="ids !=null and ids.length >0">
baseinfo.thing_id in baseinfo.thing_id in
<foreach collection="ids" item="thingId" open="(" close=")" separator="," > <foreach collection="ids" item="thingId" open="(" close=")" separator="," >
#{thingId} #{thingId}
</foreach> </foreach>
</if> </if>
<if test="toId!=null and toId !=''" >
and relation.from_id =#{toId}
</if>
<if test="keyWord!=null and keyWord !=''" > <if test="keyWord!=null and keyWord !=''" >
and (things.name like concat('%',#{keyWord}::varchar,'%') and (things.name like concat('%',#{keyWord}::varchar,'%')
or things.code like concat('%',#{keyWord}::varchar,'%') or things.code like concat('%',#{keyWord}::varchar,'%')
or baseinfo.eq_code like concat('%',#{keyWord}::varchar,'%') or baseinfo.eq_code like concat('%',#{keyWord}::varchar,'%')
or baseinfo.standard like concat('%',#{keyWord}::varchar,'%')) or baseinfo.standard like concat('%',#{keyWord}::varchar,'%'))
</if> </if>
<if test="useDeptId!=null and useDeptId !=''" >
and baseinfo.use_dept_id =#{params.useDeptId}
</if>
<if test="eqTypeName!=null and eqTypeName !=''" >
and things2.name like concat('%',#{eqTypeName}::varchar,'%')
</if>
</where> </where>
order by things.create_date desc order by things.create_date desc
</select> </select>

2
modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java

@ -66,7 +66,7 @@ public class QueueDeviceEventListener {
if (CollectionUtils.isNotEmpty(insertModelList)) { if (CollectionUtils.isNotEmpty(insertModelList)) {
// 物实体 // 物实体
Map<AuthParam, Set<String>> tenantThingCodeMap = Map<AuthParam, Set<String>> tenantThingCodeMap =
validMsgList.parallelStream()
validMsgList.stream()
.filter(item -> Objects.nonNull(item.getTenantCode()) .filter(item -> Objects.nonNull(item.getTenantCode())
|| Objects.nonNull(item.getCompanyId()) || Objects.nonNull(item.getCompanyId())
|| Objects.nonNull(item.getDeptId())) || Objects.nonNull(item.getDeptId()))

4
modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java

@ -105,6 +105,7 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl<SysTenantDetailM
//转换成like //转换成like
params.put("tenantType", StringUtils.isNotBlank((String) params.get("tenantType")) params.put("tenantType", StringUtils.isNotBlank((String) params.get("tenantType"))
? Integer.valueOf((String) params.get("tenantType")) : null); ? Integer.valueOf((String) params.get("tenantType")) : null);
//构建分页对象
Page<SysTenantDetailDTO> page = getPage(params, SysTenantDetailDTO.class); Page<SysTenantDetailDTO> page = getPage(params, SysTenantDetailDTO.class);
//不为超管时查询自己下属 //不为超管时查询自己下属
sysTenantGroupService.paramsAddTenantCodeList(params, true); sysTenantGroupService.paramsAddTenantCodeList(params, true);
@ -413,7 +414,6 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl<SysTenantDetailM
// 保存企业物至物管理表 // 保存企业物至物管理表
thingManageContextService.saveModel(Collections.singletonList(thingCode)); thingManageContextService.saveModel(Collections.singletonList(thingCode));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new SysException("保存失败,请检查数据源配置"); throw new SysException("保存失败,请检查数据源配置");
} }
//保存分配物及企业物至物实体表 //保存分配物及企业物至物实体表
@ -426,7 +426,7 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl<SysTenantDetailM
.setTemplateMark(TemplateMark.NO.getValue()) .setTemplateMark(TemplateMark.NO.getValue())
.setType("企业物") .setType("企业物")
); );
thingManageContextService.saveEntity(thingTenantList);
thingManageContextService.batchSaveOrUpdateEntity(thingTenantList);
//分配企业 //分配企业
if (typeList.contains(TenantSaveType.comp)) { if (typeList.contains(TenantSaveType.comp)) {
List<Long> tenantCodeList = detailForm.getTenantCodeList(); List<Long> tenantCodeList = detailForm.getTenantCodeList();

1
modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java

@ -138,6 +138,7 @@ public class IotThingDictServiceImpl extends BaseServiceImpl<IotThingDictMapper,
if(Objects.isNull(iotThingDictDTO)){ if(Objects.isNull(iotThingDictDTO)){
return mapper.selectOneByQueryAs(QueryWrapper.create() return mapper.selectOneByQueryAs(QueryWrapper.create()
.eq(IotThingDictEntity::getCode, code) .eq(IotThingDictEntity::getCode, code)
.eq(IotThingDictEntity::getGroupName, groupName)
.eq(IotThingDictEntity::getIsDefault, 0), .eq(IotThingDictEntity::getIsDefault, 0),
IotThingDictDTO.class); IotThingDictDTO.class);
} }

7
modules/visual-design/pom.xml

@ -27,5 +27,12 @@
<groupId>com.thing.modules</groupId> <groupId>com.thing.modules</groupId>
<artifactId>thing</artifactId> <artifactId>thing</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.thing.modules</groupId>
<artifactId>configuration</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

34
modules/visual-design/src/main/java/com/thing/visual/component/controller/IotVisualComponentController.java

@ -9,6 +9,8 @@ import com.thing.common.core.validator.group.DefaultGroup;
import com.thing.common.core.validator.group.UpdateGroup; import com.thing.common.core.validator.group.UpdateGroup;
import com.thing.common.core.web.response.PageData; import com.thing.common.core.web.response.PageData;
import com.thing.common.core.web.response.Result; import com.thing.common.core.web.response.Result;
import com.thing.visual.component.dto.AdjustSortInfo;
import com.thing.visual.component.dto.GroupInfo;
import com.thing.visual.component.dto.IotVisualComponentDTO; import com.thing.visual.component.dto.IotVisualComponentDTO;
import com.thing.visual.component.service.IotVisualComponentService; import com.thing.visual.component.service.IotVisualComponentService;
@ -19,6 +21,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -41,17 +44,19 @@ public class IotVisualComponentController {
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) ,
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) ,
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") ,
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)")
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"),
@Parameter(name = "groupIds", description = "组id,多个组id以英文逗号分隔"),
@Parameter(name = "name", description = "部件名称")
}) })
public Result<PageData<IotVisualComponentDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ public Result<PageData<IotVisualComponentDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
PageData<IotVisualComponentDTO> page = iotVisualComponentService.getPageData(params, IotVisualComponentDTO.class);
PageData<IotVisualComponentDTO> page = iotVisualComponentService.getPageDataInfo(params);
return new Result<PageData<IotVisualComponentDTO>>().ok(page); return new Result<PageData<IotVisualComponentDTO>>().ok(page);
} }
@GetMapping("{id}") @GetMapping("{id}")
@Operation(summary="信息") @Operation(summary="信息")
public Result<IotVisualComponentDTO> get(@PathVariable("id") Long id){ public Result<IotVisualComponentDTO> get(@PathVariable("id") Long id){
IotVisualComponentDTO data = iotVisualComponentService.getByIdAs(id, IotVisualComponentDTO.class);
IotVisualComponentDTO data = iotVisualComponentService.getByIdDto(id);
return new Result<IotVisualComponentDTO>().ok(data); return new Result<IotVisualComponentDTO>().ok(data);
} }
@ -71,7 +76,7 @@ public class IotVisualComponentController {
public Result<Void> update(@RequestBody IotVisualComponentDTO dto){ public Result<Void> update(@RequestBody IotVisualComponentDTO dto){
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
iotVisualComponentService.updateDto(dto);
iotVisualComponentService.updateIotVisualComponentDTO(dto);
return new Result<>(); return new Result<>();
} }
@ -86,4 +91,25 @@ public class IotVisualComponentController {
} }
@GetMapping("sort")
@Operation(summary="当前组的最大序号")
public Result<Integer> getSort(@RequestParam("groupId") Long groupId){
Integer sort = iotVisualComponentService.getSort(groupId);
return new Result<Integer>().ok(sort);
}
@GetMapping("businessList")
@Operation(summary="定制接口,获取 远程组件 类型列表,新增组件的时候使用")
public Result<List<GroupInfo>> businessList(){
List<GroupInfo> businessList = iotVisualComponentService.businessList();
return new Result<List<GroupInfo>>().ok(businessList);
}
@GetMapping("adjustSort")
@Operation(summary="拖动修改排序")
public Result<String> adjustSort(AdjustSortInfo sortInfo){
String data = iotVisualComponentService.adjustSort(sortInfo);
return new Result<String>().ok(data);
}
} }

20
modules/visual-design/src/main/java/com/thing/visual/component/dto/AdjustSortInfo.java

@ -0,0 +1,20 @@
package com.thing.visual.component.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "部件拖动排序入参")
public class AdjustSortInfo {
@Schema(description = "部件id")
private Long id;
@Schema(description = "部件组类型id")
private Long groupId;
@Schema(description = "原始序号")
private Integer currentSort;
@Schema(description = "被移动的序号")
private Integer upSort;
}

30
modules/visual-design/src/main/java/com/thing/visual/component/dto/ComponentSortInfo.java

@ -0,0 +1,30 @@
package com.thing.visual.component.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 部件设计信息
*
* @author xc
* @since 3.0 2024-08-21
*/
@Data
@Schema(description = "部件设计信息")
public class ComponentSortInfo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "部件id")
private Long id;
@Schema(description = "部件名称")
private String name;
@Schema(description = "部件组id")
private Integer groupId;
@Schema(description = "部件排序序号")
private Integer sort;
}

18
modules/visual-design/src/main/java/com/thing/visual/component/dto/GroupInfo.java

@ -0,0 +1,18 @@
package com.thing.visual.component.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "组类型信息")
public class GroupInfo {
@Schema(name = "id")
private Long id;
@Schema(name = "组类型名称")
private String businessName;
}

12
modules/visual-design/src/main/java/com/thing/visual/component/dto/IotVisualComponentDTO.java

@ -24,7 +24,13 @@ public class IotVisualComponentDTO implements Serializable {
@Schema(description = "部件名称") @Schema(description = "部件名称")
private String name; private String name;
@Schema(description = "部件组id") @Schema(description = "部件组id")
private Integer groupId;
private Long groupId;
@Schema(description = "部件组名称")
private String groupName;
@Schema(description = "部件组类型名称")
private String groupBusinessName;
@Schema(description = "部件类型") @Schema(description = "部件类型")
private String type; private String type;
@Schema(description = "部件备注描述") @Schema(description = "部件备注描述")
@ -56,4 +62,8 @@ public class IotVisualComponentDTO implements Serializable {
@Schema(description = "部件排序序号") @Schema(description = "部件排序序号")
private Integer sort; private Integer sort;
private Integer oldSort;
} }

2
modules/visual-design/src/main/java/com/thing/visual/component/entity/IotVisualComponentEntity.java

@ -31,7 +31,7 @@ public class IotVisualComponentEntity extends BaseInfoEntity implements Serializ
/** /**
* 部件组id * 部件组id
*/ */
private Integer groupId;
private Long groupId;
/** /**
* 部件类型 * 部件类型
*/ */

19
modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java

@ -1,8 +1,15 @@
package com.thing.visual.component.service; package com.thing.visual.component.service;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.IBaseService; import com.thing.common.orm.service.IBaseService;
import com.thing.visual.component.dto.AdjustSortInfo;
import com.thing.visual.component.dto.GroupInfo;
import com.thing.visual.component.dto.IotVisualComponentDTO;
import com.thing.visual.component.entity.IotVisualComponentEntity; import com.thing.visual.component.entity.IotVisualComponentEntity;
import java.util.List;
import java.util.Map;
/** /**
* 部件设计信息 * 部件设计信息
* *
@ -11,4 +18,16 @@ import com.thing.visual.component.entity.IotVisualComponentEntity;
*/ */
public interface IotVisualComponentService extends IBaseService<IotVisualComponentEntity> { public interface IotVisualComponentService extends IBaseService<IotVisualComponentEntity> {
List<IotVisualComponentEntity> getInfoByGroupIds(List<Long> groupIds);
Integer getSort(Long groupId);
List<GroupInfo> businessList();
String adjustSort(AdjustSortInfo sortInfo);
void updateIotVisualComponentDTO(IotVisualComponentDTO dto);
PageData<IotVisualComponentDTO> getPageDataInfo(Map<String, Object> params);
IotVisualComponentDTO getByIdDto(Long id);
} }

181
modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java

@ -1,13 +1,32 @@
package com.thing.visual.component.service.impl; package com.thing.visual.component.service.impl;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.impl.BaseServiceImpl; import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.sys.security.context.UserContext;
import com.thing.visual.component.dto.AdjustSortInfo;
import com.thing.visual.component.dto.ComponentSortInfo;
import com.thing.visual.component.dto.GroupInfo;
import com.thing.visual.component.dto.IotVisualComponentDTO;
import com.thing.visual.component.entity.IotVisualComponentEntity; import com.thing.visual.component.entity.IotVisualComponentEntity;
import com.thing.visual.component.mapper.IotVisualComponentMapper; import com.thing.visual.component.mapper.IotVisualComponentMapper;
import com.thing.visual.component.service.IotVisualComponentService; import com.thing.visual.component.service.IotVisualComponentService;
import com.thing.visual.group.entity.IotVisualGroupEntity;
import com.thing.visual.group.service.IotVisualGroupService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import static com.mybatisflex.core.query.QueryMethods.max;
import static com.thing.visual.component.entity.table.IotVisualComponentEntityTableDef.IOT_VISUAL_COMPONENT_ENTITY;
/** /**
* 部件设计信息 * 部件设计信息
@ -18,11 +37,173 @@ import java.util.Map;
@Service @Service
public class IotVisualComponentServiceImpl extends BaseServiceImpl<IotVisualComponentMapper, IotVisualComponentEntity> implements IotVisualComponentService { public class IotVisualComponentServiceImpl extends BaseServiceImpl<IotVisualComponentMapper, IotVisualComponentEntity> implements IotVisualComponentService {
@Autowired
private IotVisualGroupService iotVisualGroupService;
@Override @Override
public QueryWrapper getWrapper(Map<String, Object> params){ public QueryWrapper getWrapper(Map<String, Object> params){
QueryWrapper wrapper = new QueryWrapper(); QueryWrapper wrapper = new QueryWrapper();
String name = MapUtils.getString(params,"name");
String groupIds = MapUtils.getString(params,"names");
List<Long> groupIdList = null;
if(StringUtils.isNotEmpty(groupIds)){
groupIdList = Arrays.stream(groupIds.split(","))
.map(String::trim) // 去掉可能的空格
.map(Long::parseLong) // 将每个字符串转换为 Long
.collect(Collectors.toList());
}
wrapper.in(IotVisualComponentEntity::getGroupId,groupIdList,ObjectUtils.isNotEmpty(groupIdList));
wrapper.like(IotVisualComponentEntity::getName,name,StringUtils.isNotEmpty(name));
return wrapper; return wrapper;
} }
@Override
public List<IotVisualComponentEntity> getInfoByGroupIds(List<Long> groupIds) {
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq( "group_id", groupIds);
return this.mapper.selectListByQuery(wrapper);
}
@Override
public Integer getSort(Long groupId) {
Long tenantCode = UserContext.getTenantCode();
QueryWrapper wrapper = new QueryWrapper();
wrapper.select(max(IOT_VISUAL_COMPONENT_ENTITY.SORT).as("sort"))
.from(IOT_VISUAL_COMPONENT_ENTITY).eq(IotVisualComponentEntity::getGroupId,groupId);
wrapper.and(IOT_VISUAL_COMPONENT_ENTITY.TENANT_CODE.eq(tenantCode).or(IOT_VISUAL_COMPONENT_ENTITY.IS_DEFAULT.eq("1")));
Integer number = this.mapper.selectOneByQueryAs(wrapper,Integer.class);
if(ObjectUtils.isEmpty(number)){
return 1;
}
return number;
}
@Override
public List<GroupInfo> businessList() {
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("name","远程组件");
wrapper.orderBy("bs_sort",true);
return iotVisualGroupService.listAs(wrapper,GroupInfo.class);
}
@Override
public String adjustSort(AdjustSortInfo sortInfo) {
List<ComponentSortInfo> sortInfos = this.getComponentSortInfo(sortInfo.getGroupId());
moveItem(sortInfos,sortInfo.getCurrentSort()-1,sortInfo.getUpSort()-1,null);
updateSortValues(sortInfos);
sortInfos.forEach(temp->{
UpdateChain.of(IotVisualGroupEntity.class)
.set(IotVisualGroupEntity::getSort, temp.getSort())
.where(IotVisualGroupEntity::getId).eq(temp.getId())
.update();
});
return "排序成功!";
}
@Override
public PageData<IotVisualComponentDTO> getPageDataInfo(Map<String, Object> params) {
PageData<IotVisualComponentDTO> dtoPageData = this.getPageData(params,IotVisualComponentDTO.class);
dtoPageData.getList().forEach(temp->{
IotVisualGroupEntity group = iotVisualGroupService.getById(temp.getGroupId());
temp.setGroupName(group.getName());
temp.setGroupBusinessName(group.getBusinessName());
});
return dtoPageData;
}
@Override
public IotVisualComponentDTO getByIdDto(Long id) {
IotVisualComponentDTO data = this.getByIdAs(id,IotVisualComponentDTO.class);
IotVisualGroupEntity group = iotVisualGroupService.getById(data.getGroupId());
data.setGroupName(group.getName());
data.setGroupBusinessName(group.getBusinessName());
return data;
}
@Override
public void updateIotVisualComponentDTO(IotVisualComponentDTO dto) {
if(ObjectUtils.isNotEmpty(dto.getOldSort())){
List<ComponentSortInfo> sortInfos = this.getComponentSortInfo(dto.getGroupId());
moveItem(sortInfos,dto.getOldSort()-1,dto.getSort()-1,dto.getName());
//重置sort字段
updateSortValues(sortInfos);
sortInfos.forEach(temp->{
UpdateChain.of(IotVisualComponentEntity.class)
.set(IotVisualComponentEntity::getSort, temp.getSort())
.set(IotVisualComponentEntity::getName,dto.getName())
.set(IotVisualComponentEntity::getThumbnailUrl,dto.getThumbnailUrl())
.set(IotVisualComponentEntity::getRemarks,dto.getRemarks())
.set(IotVisualComponentEntity::getDesc,dto.getDesc())
.set(IotVisualComponentEntity::getHash,dto.getHash())
.set(IotVisualComponentEntity::getPreviewOptions,dto.getPreviewOptions())
.set(IotVisualComponentEntity::getIsDefault,dto.getIsDefault())
.where(IotVisualComponentEntity::getId).eq(temp.getId())
.update();
});
}else {
this.updateDto(dto);
}
}
private List<ComponentSortInfo> getComponentSortInfo(Long groupId){
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("group_id",groupId);
wrapper.orderBy("sort",true);
return this.listAs(wrapper,ComponentSortInfo.class);
}
/**
* 删除原坐标在新的坐标插入我的对象
* @param list
* @param fromIndex
* @param toIndex
*/
private static void moveItem(List<ComponentSortInfo> list, int fromIndex, int toIndex, String name) {
if (fromIndex < 0 || fromIndex >= list.size()) {
throw new IndexOutOfBoundsException("Invalid index");
}
if(toIndex < 0 ){
toIndex=0;
}
if(toIndex >= list.size()){
toIndex= list.size()-1;
}
ComponentSortInfo item = list.remove(fromIndex);
if(ObjectUtils.isNotEmpty(name)){
item.setName(name);
}
list.add(toIndex, item);
updateSortValues(list);
}
/**
* 重新修改 name中对应的sort信息
* @param list
*/
private static void updateSortValues(List<ComponentSortInfo> list) {
Integer sortValue = 1;
for (ComponentSortInfo item : list) {
item.setSort(sortValue++);
}
}
} }

62
modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java

@ -4,9 +4,8 @@ import com.thing.common.core.constants.Constant;
import com.thing.common.core.validator.AssertUtils; import com.thing.common.core.validator.AssertUtils;
import com.thing.common.core.web.response.PageData; import com.thing.common.core.web.response.PageData;
import com.thing.common.core.web.response.Result; import com.thing.common.core.web.response.Result;
import com.thing.visual.group.dto.AdjustGroupDto;
import com.thing.visual.group.dto.GroupSortInfo;
import com.thing.visual.group.dto.IotVisualGroupDTO;
import com.thing.thing.group.dto.IotGroupInfoFormatDTO;
import com.thing.visual.group.dto.*;
import com.thing.visual.group.service.IotVisualGroupService; import com.thing.visual.group.service.IotVisualGroupService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -15,6 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -37,13 +37,19 @@ public class IotVisualGroupController {
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) ,
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) ,
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") ,
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)")
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"),
@Parameter(name = "type", description = "类型,1素材,2部件 必传"),
@Parameter(name = "name", description = "组名称"),
@Parameter(name = "businessName", description = "组类型名称"),
@Parameter(name = "names", description = "组名称集合,多个组名称,以英文逗号分割")
}) })
public Result<PageData<IotVisualGroupDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){ public Result<PageData<IotVisualGroupDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
PageData<IotVisualGroupDTO> page = iotVisualGroupService.getPageData(params, IotVisualGroupDTO.class); PageData<IotVisualGroupDTO> page = iotVisualGroupService.getPageData(params, IotVisualGroupDTO.class);
return new Result<PageData<IotVisualGroupDTO>>().ok(page); return new Result<PageData<IotVisualGroupDTO>>().ok(page);
} }
@GetMapping("{id}") @GetMapping("{id}")
@Operation(summary="信息") @Operation(summary="信息")
public Result<IotVisualGroupDTO> get(@PathVariable("id") Long id){ public Result<IotVisualGroupDTO> get(@PathVariable("id") Long id){
@ -59,14 +65,22 @@ public class IotVisualGroupController {
} }
@PutMapping @PutMapping
@Operation(summary="修改")
@Operation(summary="修改,这个接口,只能修改二级得组类型")
public Result<Void> update(@RequestBody IotVisualGroupDTO dto){ public Result<Void> update(@RequestBody IotVisualGroupDTO dto){
iotVisualGroupService.updateIotVisualGroupDTO(dto); iotVisualGroupService.updateIotVisualGroupDTO(dto);
return new Result<>(); return new Result<>();
} }
@PutMapping("group")
@Operation(summary="修改,这个接口,只能修改一级得组")
public Result<Void> updateGroup(@RequestBody IotVisualGroupDTO dto){
iotVisualGroupService.updateGroup(dto);
return new Result<>();
}
@DeleteMapping @DeleteMapping
@Operation(summary="删除")
@Operation(summary="删除 这个接口删除二级右侧列表里面的数据,传入数据id")
public Result<Void> delete(@RequestBody Long[] ids){ public Result<Void> delete(@RequestBody Long[] ids){
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
@ -74,18 +88,46 @@ public class IotVisualGroupController {
return new Result<>(); return new Result<>();
} }
@DeleteMapping("group")
@Operation(summary="删除 这个接口删除一级左侧列表里面的数据,传入组名称")
public Result<String> deleteGroup(@RequestParam(required = false) String name, @RequestParam(required = true) String type){
return new Result<String>().ok(iotVisualGroupService.deleteGroup(name,type));
}
@GetMapping("groupInfo")
@Operation(summary="左侧组列表,可按名称模糊查询")
public Result<List<NameSort>> groupInfo(@RequestParam(required = false) String name, @RequestParam(required = true) String type){
List<NameSort> data = iotVisualGroupService.groupInfo(name,type);
return new Result<List<NameSort>>().ok(data);
}
@GetMapping("groupSortInfo") @GetMapping("groupSortInfo")
@Operation(summary="获取排序信息,可以传入已存在的组名称")
public Result<GroupSortInfo> groupSortInfo(@RequestParam(required = false) String name){
GroupSortInfo data = iotVisualGroupService.groupSortInfo(name);
@Operation(summary="获取排序信息,可以传入已存在的组名称,新增得时候使用")
public Result<GroupSortInfo> groupSortInfo(@RequestParam(required = false) String name,@RequestParam(required = true) String type){
GroupSortInfo data = iotVisualGroupService.groupSortInfo(name,type);
return new Result<GroupSortInfo>().ok(data); return new Result<GroupSortInfo>().ok(data);
} }
@PostMapping("adjustGroupSort") @PostMapping("adjustGroupSort")
@Operation(summary="调整组排序")
@Operation(summary="调整组排序,拖动排序,如果传入name,就是组内排序")
public Result<String> adjustGroupSort(@RequestBody AdjustGroupDto dto){ public Result<String> adjustGroupSort(@RequestBody AdjustGroupDto dto){
String data = iotVisualGroupService.adjustGroupSort(dto); String data = iotVisualGroupService.adjustGroupSort(dto);
return new Result<String>().ok(data); return new Result<String>().ok(data);
} }
@GetMapping("listTree")
@Operation(summary="返回所有可见组的树结构,部件素材侧边栏使用(组级别是虚拟的,没有id生成的虚拟id)")
@Parameters({
@Parameter(name ="type",description ="1素材,2部件"),
@Parameter(name ="name",description ="组名称")
})
public Result<List<GroupInfoFormatDTO>> listTree(String type, String name){
return iotVisualGroupService.listTree(type,name);
}
} }

9
modules/visual-design/src/main/java/com/thing/visual/group/dto/AdjustGroupDto.java

@ -8,12 +8,13 @@ import lombok.Data;
@Schema(description = "调整组排序入参对象") @Schema(description = "调整组排序入参对象")
public class AdjustGroupDto { public class AdjustGroupDto {
private String currentName;
private Long currentSort;
private String name;
private String upName;
private Integer currentSort;
private String upSort;
private Integer upSort;
private String type;
} }

32
modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupInfoFormatDTO.java

@ -0,0 +1,32 @@
package com.thing.visual.group.dto;
import com.thing.thing.group.dto.IotGroupInfoFormatDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Data
public class GroupInfoFormatDTO {
@Schema(description = "id")
private Long id;
@Schema(description = "组名称")
private String name;
@Schema(description = "组类型名称")
private String businessName;
@Schema(description = "缩略图url")
private String thumbnailUrl;
private Integer sort;
private Integer bsSort;
@Schema(description = "组类型列表")
private List<GroupInfoFormatDTO> typeList;
}

4
modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupSortInfo.java

@ -7,8 +7,8 @@ import lombok.Data;
@Schema(description = "组排序信息") @Schema(description = "组排序信息")
public class GroupSortInfo { public class GroupSortInfo {
private Long sort;
private Integer sort;
private Long bsSort;
private Integer bsSort;
} }

17
modules/visual-design/src/main/java/com/thing/visual/group/dto/IotVisualGroupDTO.java

@ -32,9 +32,9 @@ public class IotVisualGroupDTO implements Serializable {
@Schema(description = "缩略图url/这里放text,也可以是svg或base64") @Schema(description = "缩略图url/这里放text,也可以是svg或base64")
private String thumbnailUrl; private String thumbnailUrl;
@Schema(description = "组排序") @Schema(description = "组排序")
private Long sort;
private Integer sort;
@Schema(description = "二级业务排序") @Schema(description = "二级业务排序")
private Long bsSort;
private Integer bsSort;
@Schema(description = "备注说明") @Schema(description = "备注说明")
private String remark; private String remark;
@Schema(description = "所属企业(租户code)") @Schema(description = "所属企业(租户code)")
@ -52,4 +52,17 @@ public class IotVisualGroupDTO implements Serializable {
@Schema(description = "更新时间") @Schema(description = "更新时间")
private Long updateDate; private Long updateDate;
@Schema(description = "素材/部件组修改之前得名称")
private String oldName;
@Schema(description = "素材/部件组修改之前得排序")
private Integer oldSort;
@Schema(description = "素材/部件组修改之前得业务二级名称")
private String oldBusinessName;
@Schema(description = "修改之前得二级业务排序")
private Integer oldBsSort;
} }

17
modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java

@ -0,0 +1,17 @@
package com.thing.visual.group.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class NameSort {
private String name;
private Integer sort;
}

4
modules/visual-design/src/main/java/com/thing/visual/group/entity/IotVisualGroupEntity.java

@ -47,11 +47,11 @@ public class IotVisualGroupEntity extends BaseInfoEntity implements Serializable
/** /**
* 组排序 * 组排序
*/ */
private Long sort;
private Integer sort;
/** /**
* 二级业务排序 * 二级业务排序
*/ */
private Long bsSort;
private Integer bsSort;
/** /**
* 备注说明 * 备注说明
*/ */

17
modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java

@ -1,11 +1,13 @@
package com.thing.visual.group.service; package com.thing.visual.group.service;
import com.thing.common.core.web.response.Result;
import com.thing.common.orm.service.IBaseService; import com.thing.common.orm.service.IBaseService;
import com.thing.visual.group.dto.AdjustGroupDto;
import com.thing.visual.group.dto.GroupSortInfo;
import com.thing.visual.group.dto.IotVisualGroupDTO;
import com.thing.thing.group.dto.IotGroupInfoFormatDTO;
import com.thing.visual.group.dto.*;
import com.thing.visual.group.entity.IotVisualGroupEntity; import com.thing.visual.group.entity.IotVisualGroupEntity;
import java.util.List;
/** /**
* 素材部件组管理 * 素材部件组管理
* *
@ -18,7 +20,14 @@ public interface IotVisualGroupService extends IBaseService<IotVisualGroupEntity
void updateIotVisualGroupDTO(IotVisualGroupDTO dto); void updateIotVisualGroupDTO(IotVisualGroupDTO dto);
GroupSortInfo groupSortInfo(String name);
GroupSortInfo groupSortInfo(String name,String type);
String adjustGroupSort(AdjustGroupDto dto); String adjustGroupSort(AdjustGroupDto dto);
void updateGroup(IotVisualGroupDTO dto);
List<NameSort> groupInfo(String name, String type);
String deleteGroup(String name, String type);
Result<List<GroupInfoFormatDTO>> listTree(String type, String name);
} }

291
modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java

@ -1,17 +1,29 @@
package com.thing.visual.group.service.impl; package com.thing.visual.group.service.impl;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.core.web.response.Result;
import com.thing.common.orm.service.impl.BaseServiceImpl; import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.visual.group.dto.AdjustGroupDto;
import com.thing.visual.group.dto.GroupSortInfo;
import com.thing.visual.group.dto.IotVisualGroupDTO;
import com.thing.configuration.newmaterial.entity.IotNewSourceMaterialEntity;
import com.thing.configuration.newmaterial.service.IotNewSourceMaterialService;
import com.thing.sys.security.context.UserContext;
import com.thing.thing.group.dto.IotGroupInfoDTO;
import com.thing.thing.group.dto.IotGroupInfoFormatDTO;
import com.thing.visual.component.entity.IotVisualComponentEntity;
import com.thing.visual.component.service.IotVisualComponentService;
import com.thing.visual.group.dto.*;
import com.thing.visual.group.mapper.IotVisualGroupMapper; import com.thing.visual.group.mapper.IotVisualGroupMapper;
import com.thing.visual.group.entity.IotVisualGroupEntity; import com.thing.visual.group.entity.IotVisualGroupEntity;
import com.thing.visual.group.service.IotVisualGroupService; import com.thing.visual.group.service.IotVisualGroupService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import static com.mybatisflex.core.query.QueryMethods.max; import static com.mybatisflex.core.query.QueryMethods.max;
import static com.mybatisflex.core.query.QueryMethods.max; import static com.mybatisflex.core.query.QueryMethods.max;
@ -26,49 +38,292 @@ import static com.thing.visual.group.entity.table.IotVisualGroupEntityTableDef.I
@Service @Service
public class IotVisualGroupServiceImpl extends BaseServiceImpl<IotVisualGroupMapper, IotVisualGroupEntity> implements IotVisualGroupService { public class IotVisualGroupServiceImpl extends BaseServiceImpl<IotVisualGroupMapper, IotVisualGroupEntity> implements IotVisualGroupService {
@Autowired
private IotNewSourceMaterialService iotNewSourceMaterialService;
@Autowired
private IotVisualComponentService iotVisualComponentService;
@Override @Override
public QueryWrapper getWrapper(Map<String, Object> params){ public QueryWrapper getWrapper(Map<String, Object> params){
Long tenantCode = UserContext.getTenantCode();
QueryWrapper wrapper = new QueryWrapper(); QueryWrapper wrapper = new QueryWrapper();
String name = MapUtils.getString(params,"name");
String names = MapUtils.getString(params,"names");
List<String> nameList = null;
if(StringUtils.isNotEmpty(names)){
nameList = Arrays.asList(names.split(","));
}
String businessName = MapUtils.getString(params,"businessName");
wrapper.eq(IotVisualGroupEntity::getType,MapUtils.getString(params,"type"));
wrapper.and(IOT_VISUAL_GROUP_ENTITY.TENANT_CODE.eq(tenantCode).or(IOT_VISUAL_GROUP_ENTITY.IS_DEFAULT.eq("1")));
wrapper.like(IotVisualGroupEntity::getName,name, StringUtils.isNotEmpty(name));
wrapper.like(IotVisualGroupEntity::getBusinessName,businessName, StringUtils.isNotEmpty(businessName));
wrapper.in(IotVisualGroupEntity::getName,nameList,ObjectUtils.isNotEmpty(nameList));
wrapper.orderBy(IotVisualGroupEntity::getSort,true);
wrapper.orderBy(IotVisualGroupEntity::getBsSort,true);
return wrapper; return wrapper;
} }
@Override @Override
public void saveIotVisualGroupDTO(IotVisualGroupDTO dto) { public void saveIotVisualGroupDTO(IotVisualGroupDTO dto) {
GroupSortInfo groupSortInfo = this.groupSortInfo(dto.getName(),dto.getType());
dto.setSort(groupSortInfo.getSort());
dto.setBsSort(groupSortInfo.getBsSort());
this.saveDto(dto);
} }
@Override @Override
public void updateIotVisualGroupDTO(IotVisualGroupDTO dto) { public void updateIotVisualGroupDTO(IotVisualGroupDTO dto) {
List<NameSort> sortInfo = this.getNameSort(dto.getName(),dto.getType());
if(dto.getOldBusinessName().equals(dto.getBusinessName())){
moveItem(sortInfo,dto.getOldBsSort()-1,dto.getBsSort()-1,null);
//重置sort字段
updateSortValues(sortInfo);
}else {
moveItem(sortInfo,dto.getOldBsSort()-1,dto.getBsSort()-1,dto.getBusinessName());
//重置sort字段
updateSortValues(sortInfo);
}
sortInfo.forEach(temp->{
if(dto.getBusinessName().equals(temp.getName())){
UpdateChain.of(IotVisualGroupEntity.class)
.set(IotVisualGroupEntity::getBsSort, temp.getSort())
.set(IotVisualGroupEntity::getThumbnailUrl,dto.getThumbnailUrl())
.set(IotVisualGroupEntity::getBusinessName,dto.getBusinessName())
.set(IotVisualGroupEntity::getRemark,dto.getRemark())
.where(IotVisualGroupEntity::getName).eq(dto.getName()).eq(IotVisualGroupEntity::getBusinessName,temp.getName())
.update();
}else {
UpdateChain.of(IotVisualGroupEntity.class)
.set(IotVisualGroupEntity::getBsSort, temp.getSort())
.where(IotVisualGroupEntity::getName).eq(dto.getName()).eq(IotVisualGroupEntity::getBusinessName,temp.getName())
.update();
}
});
} }
@Override @Override
public GroupSortInfo groupSortInfo(String name) {
public GroupSortInfo groupSortInfo(String name,String type) {
Long tenantCode = UserContext.getTenantCode();
QueryWrapper wrapper = new QueryWrapper(); QueryWrapper wrapper = new QueryWrapper();
wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"), max(IOT_VISUAL_GROUP_ENTITY.BS_SORT).as("bs_sort")) wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"), max(IOT_VISUAL_GROUP_ENTITY.BS_SORT).as("bs_sort"))
.from(IOT_VISUAL_GROUP_ENTITY);
.from(IOT_VISUAL_GROUP_ENTITY).eq(IotVisualGroupEntity::getType,type);
wrapper.and(IOT_VISUAL_GROUP_ENTITY.TENANT_CODE.eq(tenantCode).or(IOT_VISUAL_GROUP_ENTITY.IS_DEFAULT.eq("1")));
if(ObjectUtils.isNotEmpty(name)){ if(ObjectUtils.isNotEmpty(name)){
wrapper.eq(IotVisualGroupEntity::getName,name);
wrapper.eq(IotVisualGroupEntity::getName,name);
} }
GroupSortInfo sortInfo = this.mapper.selectOneByQueryAs(wrapper,GroupSortInfo.class); GroupSortInfo sortInfo = this.mapper.selectOneByQueryAs(wrapper,GroupSortInfo.class);
if(ObjectUtils.isEmpty(sortInfo)){ if(ObjectUtils.isEmpty(sortInfo)){
sortInfo = new GroupSortInfo(); sortInfo = new GroupSortInfo();
sortInfo.setBsSort(1L);
sortInfo.setSort(1L);
sortInfo.setBsSort(1);
wrapper = new QueryWrapper();
//当前最大 sort 返回
wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"))
.from(IOT_VISUAL_GROUP_ENTITY).eq(IotVisualGroupEntity::getType,type);
wrapper.and(IOT_VISUAL_GROUP_ENTITY.TENANT_CODE.eq(tenantCode).or(IOT_VISUAL_GROUP_ENTITY.IS_DEFAULT.eq("1")));
GroupSortInfo maxSort = this.mapper.selectOneByQueryAs(wrapper,GroupSortInfo.class);
sortInfo.setSort(maxSort.getSort()+1);
return sortInfo; return sortInfo;
} }
if(ObjectUtils.isNotEmpty(name)){
sortInfo.setSort(sortInfo.getSort()==null?1L:sortInfo.getSort());
}else {
sortInfo.setSort(sortInfo.getSort()==null?1L:sortInfo.getSort()+1);
}
sortInfo.setBsSort(sortInfo.getBsSort()==null?1L:sortInfo.getBsSort()+1);
sortInfo.setBsSort(sortInfo.getBsSort()==null?1:sortInfo.getBsSort()+1);
return sortInfo ; return sortInfo ;
} }
@Override @Override
public String adjustGroupSort(AdjustGroupDto dto) { public String adjustGroupSort(AdjustGroupDto dto) {
return null;
List<NameSort> sortInfo = this.getNameSort(dto.getName(),dto.getType());
//修改排序
moveItem(sortInfo,dto.getCurrentSort()-1,dto.getUpSort()-1,null);
//重置sort字段
updateSortValues(sortInfo);
if(ObjectUtils.isNotEmpty(dto.getName())){
//组内排序
sortInfo.forEach(temp->{
UpdateChain.of(IotVisualGroupEntity.class)
.set(IotVisualGroupEntity::getBsSort, temp.getSort())
.where(IotVisualGroupEntity::getName).eq(dto.getName()).eq(IotVisualGroupEntity::getBusinessName,temp.getName())
.update();
});
}else {
//组排序
sortInfo.forEach(temp->{
UpdateChain.of(IotVisualGroupEntity.class)
.set(IotVisualGroupEntity::getSort, temp.getSort())
.where(IotVisualGroupEntity::getName).eq(temp.getName())
.update();
});
}
return "ok";
}
@Override
public void updateGroup(IotVisualGroupDTO dto) {
//修改一级得组名称or排序
List<NameSort> sortInfo = this.getNameSort(null,dto.getType());
if(dto.getOldName().equals(dto.getName())){
//修改排序
moveItem(sortInfo,dto.getOldSort()-1,dto.getSort()-1,null);
//重置sort字段
updateSortValues(sortInfo);
}else {
//修改排序
moveItem(sortInfo,dto.getOldSort()-1,dto.getSort()-1,dto.getName());
//重置sort字段
updateSortValues(sortInfo);
}
//组排序
sortInfo.forEach(temp->{
if(temp.getName().equals(dto.getName())){
UpdateChain.of(IotVisualGroupEntity.class)
.set(IotVisualGroupEntity::getSort, temp.getSort())
.set(IotVisualGroupEntity::getName, temp.getName())
.where(IotVisualGroupEntity::getName).eq(dto.getOldName()).and("type = '"+dto.getType()+"'")
.update();
}else {
UpdateChain.of(IotVisualGroupEntity.class)
.set(IotVisualGroupEntity::getSort, temp.getSort())
.where(IotVisualGroupEntity::getName).eq(temp.getName()).and("type = '"+dto.getType()+"'")
.update();
}
});
}
@Override
public List<NameSort> groupInfo(String name, String type) {
Long tenantCode = UserContext.getTenantCode();
QueryWrapper wrapper = new QueryWrapper();
wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"), IOT_VISUAL_GROUP_ENTITY.NAME.as("name"))
.from(IOT_VISUAL_GROUP_ENTITY).eq(IotVisualGroupEntity::getType,type);
//本企业得or 默认得
wrapper.and(IOT_VISUAL_GROUP_ENTITY.TENANT_CODE.eq(tenantCode).or(IOT_VISUAL_GROUP_ENTITY.IS_DEFAULT.eq("1")));
wrapper.eq(IotVisualGroupEntity::getName,name,StringUtils.isNotEmpty(name));
wrapper.groupBy(IOT_VISUAL_GROUP_ENTITY.NAME).orderBy(IOT_VISUAL_GROUP_ENTITY.SORT,true);
return this.mapper.selectListByQueryAs(wrapper,NameSort.class);
}
@Override
public String deleteGroup(String name, String type) {
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq(IotVisualGroupEntity::getName,name);
wrapper.eq(IotVisualGroupEntity::getType,type);
List<IotVisualGroupEntity> entities = this.list(wrapper);
List<Long> groupIds = entities.stream()
.map(IotVisualGroupEntity::getId)
.toList();
//素材or部件 有被引用则不允许删除
List<IotNewSourceMaterialEntity> materialList = iotNewSourceMaterialService.getInfoByGroupIds(groupIds);
if(ObjectUtils.isNotEmpty(materialList)){
return "当前组下有类型被引用,不允许删除!";
}
List<IotVisualComponentEntity> componentEntityList = iotVisualComponentService.getInfoByGroupIds(groupIds);
if(ObjectUtils.isNotEmpty(componentEntityList)){
return "当前组下有类型被引用,不允许删除!";
}
//删除组
QueryWrapper queryWrapper = QueryWrapper.create();
queryWrapper.eq(IotVisualGroupEntity::getName,name);
queryWrapper.eq(IotVisualGroupEntity::getType,type);
this.mapper.deleteByQuery(queryWrapper);
return "删除成功!";
}
@Override
public Result<List<GroupInfoFormatDTO>> listTree(String type, String name) {
List<GroupInfoFormatDTO> resultList = new ArrayList<>();
QueryWrapper queryWrapper = QueryWrapper.create();
queryWrapper.eq(IotVisualGroupEntity::getType,type);
queryWrapper.like(IotVisualGroupEntity::getName,name);
List<IotVisualGroupDTO> infos = listAs(queryWrapper, IotVisualGroupDTO.class);
Map<String, List<IotVisualGroupDTO>> map = infos.stream().collect(Collectors.groupingBy(IotVisualGroupDTO::getName));
for (String temp : map.keySet()) {
GroupInfoFormatDTO dto = new GroupInfoFormatDTO();
dto.setName(temp);
dto.setBusinessName(temp);
dto.setId((new Random().nextInt()*-1- 19900000000L));
List<IotVisualGroupDTO> infoDTOS = map.get(temp).parallelStream().sorted(Comparator.comparingLong(IotVisualGroupDTO::getBsSort)).collect(Collectors.toList());
dto.setThumbnailUrl(infoDTOS.get(0).getThumbnailUrl());
map.get(temp).forEach(info->{
info.setName(info.getBusinessName());
});
dto.setSort(infoDTOS.get(0).getSort());
dto.setTypeList(ConvertUtils.sourceToTarget(infoDTOS,GroupInfoFormatDTO.class));
resultList.add(dto);
}
return new Result<List<GroupInfoFormatDTO>>().ok(resultList.parallelStream().sorted(Comparator.comparingLong(GroupInfoFormatDTO::getSort)).collect(Collectors.toList()));
} }
/**
* 获取所有排序信息看没有没有穿name传name了就是组内排序没传name就是组排序
* @param name
* @return
*/
private List<NameSort> getNameSort(String name,String type){
Long tenantCode = UserContext.getTenantCode();
QueryWrapper wrapper = new QueryWrapper();
if(ObjectUtils.isNotEmpty(name)){
wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.BS_SORT).as("sort"), IOT_VISUAL_GROUP_ENTITY.BUSINESS_NAME.as("name"))
.from(IOT_VISUAL_GROUP_ENTITY).eq(IotVisualGroupEntity::getType,type);
//本企业得or 默认得
wrapper.and(IOT_VISUAL_GROUP_ENTITY.TENANT_CODE.eq(tenantCode).or(IOT_VISUAL_GROUP_ENTITY.IS_DEFAULT.eq("1")));
wrapper.eq(IotVisualGroupEntity::getName,name).groupBy(IOT_VISUAL_GROUP_ENTITY.BUSINESS_NAME).orderBy("sort",true);
}else {
wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"), IOT_VISUAL_GROUP_ENTITY.NAME.as("name"))
.from(IOT_VISUAL_GROUP_ENTITY).eq(IotVisualGroupEntity::getType,type);
wrapper.and(IOT_VISUAL_GROUP_ENTITY.TENANT_CODE.eq(tenantCode).or(IOT_VISUAL_GROUP_ENTITY.IS_DEFAULT.eq("1")));
wrapper.groupBy(IOT_VISUAL_GROUP_ENTITY.NAME).orderBy(IOT_VISUAL_GROUP_ENTITY.SORT,true);;
}
return this.mapper.selectListByQueryAs(wrapper,NameSort.class);
}
/**
* 删除原坐标在新的坐标插入我的对象
* @param list
* @param fromIndex
* @param toIndex
*/
private static void moveItem(List<NameSort> list, int fromIndex, int toIndex,String name) {
if (fromIndex < 0 || fromIndex >= list.size()) {
throw new IndexOutOfBoundsException("Invalid index");
}
if(toIndex < 0 ){
toIndex=0;
}
if(toIndex >= list.size()){
toIndex= list.size()-1;
}
NameSort item = list.remove(fromIndex);
if(ObjectUtils.isNotEmpty(name)){
item.setName(name);
}
list.add(toIndex, item);
updateSortValues(list);
}
/**
* 重新修改 name中对应的sort信息
* @param list
*/
private static void updateSortValues(List<NameSort> list) {
Integer sortValue = 1;
for (NameSort item : list) {
item.setSort(sortValue++);
}
}
} }
Loading…
Cancel
Save