From c315824babb605037c54aa6f6a6aac750e038050 Mon Sep 17 00:00:00 2001 From: lishuai Date: Fri, 23 Aug 2024 16:09:43 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BF=9D=E5=85=BB=2020?= =?UTF-8?q?24=E5=B9=B48=E6=9C=8823=E6=97=A516:09:39?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tskv/event/TsKvEventServiceImpl.java | 1 - .../service/EqByTemplateDetailService.java | 2 ++ .../impl/EqByTemplateDetailServiceImpl.java | 5 +++ .../service/impl/EqByTemplateServiceImpl.java | 33 +++++++++++++------ .../listener/QueueDeviceEventListener.java | 2 +- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/common/tskv/src/main/java/com/thing/common/tskv/event/TsKvEventServiceImpl.java b/common/tskv/src/main/java/com/thing/common/tskv/event/TsKvEventServiceImpl.java index 37aa8ab..488c62a 100644 --- a/common/tskv/src/main/java/com/thing/common/tskv/event/TsKvEventServiceImpl.java +++ b/common/tskv/src/main/java/com/thing/common/tskv/event/TsKvEventServiceImpl.java @@ -1,6 +1,5 @@ package com.thing.common.tskv.event; -import com.alibaba.fastjson2.JSON; import com.thing.common.data.proto.QueueProto.DataProto; import com.thing.common.tskv.service.DBExecutor; import com.thing.common.tskv.service.TsKvService; diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/service/EqByTemplateDetailService.java b/modules/equipment/src/main/java/com/thing/eq/eqby/service/EqByTemplateDetailService.java index 3c10392..732b699 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/service/EqByTemplateDetailService.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqby/service/EqByTemplateDetailService.java @@ -23,4 +23,6 @@ public interface EqByTemplateDetailService extends IBaseService findByName(String name); + } diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateDetailServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateDetailServiceImpl.java index cf462d6..ad28651 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateDetailServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateDetailServiceImpl.java @@ -44,4 +44,9 @@ public class EqByTemplateDetailServiceImpl extends BaseServiceImpl findByName(String name) { + return mapper.selectListByQuery(QueryWrapper.create().like(EqByTemplateDetailEntity::getName, name)); + } } diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateServiceImpl.java index f10678d..5ebd45a 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByTemplateServiceImpl.java @@ -1,27 +1,30 @@ package com.thing.eq.eqby.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.map.MapUtil; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; 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.orm.service.impl.BaseServiceImpl; import com.thing.eq.eqby.dto.EqByTemplateDTO; 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.mapper.EqByTemplateMapper; import com.thing.eq.eqby.service.EqByPlanService; import com.thing.eq.eqby.service.EqByTemplateDetailService; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; 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 page(Map params) { - Page 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 list = eqByTemplateDao.getListData(params); - List 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 eqByTemplateDetailEntities = eqByTemplateDetailService.findByName(name); + List 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 paginate = mapper.paginateAs(new Page<>(pageNumber, pageSize), queryWrapper,EqByTemplateDTO.class); + return new PageData<>(paginate.getRecords(), paginate.getTotalRow()); } @Override @@ -64,7 +75,7 @@ public class EqByTemplateServiceImpl extends BaseServiceImpl 0){ @@ -72,6 +83,7 @@ public class EqByTemplateServiceImpl extends BaseServiceImpl 0){ throw new SysException("该模板已被保养计划使用,不可修改,请确认"); } - Long tenantCode = TenantContext.getTenantCode(SecurityUser.getUser()); + Long tenantCode = UserContext.getRealTenantCode(); if (StringUtils.isNotBlank(dto.getName())){ int count = eqByTemplateDao.getTemplateByNameNoId(dto.getName(),dto.getId(),tenantCode); if (count > 0){ throw new SysException("模板名称已经存在,不可新增,请确认"); } } + dto.setTenantCode(tenantCode); super.updateDto(dto); //先删除模板明细 eqByTemplateDetailService.deleteByTemplateId(dto.getId()); diff --git a/modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java b/modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java index 4c3d62b..2640cf0 100644 --- a/modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java +++ b/modules/thing/src/main/java/com/thing/listener/QueueDeviceEventListener.java @@ -66,7 +66,7 @@ public class QueueDeviceEventListener { if (CollectionUtils.isNotEmpty(insertModelList)) { // 物实体 Map> tenantThingCodeMap = - validMsgList.parallelStream() + validMsgList.stream() .filter(item -> Objects.nonNull(item.getTenantCode()) || Objects.nonNull(item.getCompanyId()) || Objects.nonNull(item.getDeptId())) From af288e84549f2dc5e9958b8c8f2f6a5d2f48f6d3 Mon Sep 17 00:00:00 2001 From: lishuai Date: Fri, 23 Aug 2024 17:09:00 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=89=A9=E5=85=B3=E7=B3=BB=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4=202024=E5=B9=B48=E6=9C=8823=E6=97=A517:08:55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IotThingsServiceImpl.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java index 8aceb51..5edce9d 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java +++ b/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.relation.detail.dto.IotThingRelationDetailDTO; 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.param.IotThingRelationDetailParamDTO; import com.thing.thing.relation.detail.service.IotThingRelationDetailService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -192,21 +192,26 @@ public class IotThingsServiceImpl implements IotThingsService { baseInfoDTO.setScrapDisposal("0"); iotThingBaseInfoService.saveDto(baseInfoDTO); //保存设备的关系 - ThingRelationDTO relationDTO = new ThingRelationDTO(); + + List relationDetailDTOS = + iotThingRelationDetailService.findRootDetailChildNodeByRootIdAndFromIdAndRootThingId(dto.getRelationTypeId(), parentThing.getId(), dto.getRelationTopId()); + + IotThingRelationDetailParamDTO relationDTO = new IotThingRelationDetailParamDTO(); relationDTO.setRootId(dto.getRelationTypeId()); relationDTO.setRootThingId(dto.getRelationTopId()); relationDTO.setFromId(parentThing.getId()); relationDTO.setFromCode(parentThing.getCode()); relationDTO.setFromName(parentThing.getName()); - List relationList = new ArrayList<>(); - ThingRelationDTO.RelationEntity relation = new ThingRelationDTO.RelationEntity(); - + relationDTO.setId(relationDetailDTOS.get(0).getId()); + List relationList = new ArrayList<>(); + IotThingRelationDetailParamDTO relation = new IotThingRelationDetailParamDTO(); relation.setToId(thingEntity.getId()); relation.setToCode(code); relation.setToName(dto.getName()); relationList.add(relation); relationDTO.setRelationList(relationList); - iotThingRelationDetailService.saveRelationNodes(relationDTO); + + iotThingRelationDetailService.save(relationDTO); //保存附件 eqAttacmentService.saveBatch(ConvertUtils.sourceToTarget(attacmentDTOS, EqAttacmentEntity.class)); } From d61fc540f48afb0cc6e1921e289e7ffa99aeb1df Mon Sep 17 00:00:00 2001 From: xiachao Date: Fri, 23 Aug 2024 17:20:17 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E7=B4=A0=E6=9D=90=E9=83=A8=E4=BB=B6?= =?UTF-8?q?=E7=BB=84=E7=AE=A1=E7=90=86=EF=BC=8C=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../visual/group/dto/AdjustGroupDto.java | 9 ++- .../com/thing/visual/group/dto/NameSort.java | 13 +++ .../impl/IotVisualGroupServiceImpl.java | 80 ++++++++++++++++++- 3 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/dto/AdjustGroupDto.java b/modules/visual-design/src/main/java/com/thing/visual/group/dto/AdjustGroupDto.java index 2b780c3..dfacef0 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/dto/AdjustGroupDto.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/dto/AdjustGroupDto.java @@ -8,12 +8,13 @@ import lombok.Data; @Schema(description = "调整组排序入参对象") 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; } diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java b/modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java new file mode 100644 index 0000000..9172a90 --- /dev/null +++ b/modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java @@ -0,0 +1,13 @@ +package com.thing.visual.group.dto; + + +import lombok.Data; + +@Data +public class NameSort { + + private String name; + + private Long sort; + +} diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java index 6b9c64a..85e64e6 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java @@ -1,16 +1,20 @@ package com.thing.visual.group.service.impl; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.update.UpdateChain; +import com.mybatisflex.core.update.UpdateWrapper; 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.visual.group.dto.NameSort; import com.thing.visual.group.mapper.IotVisualGroupMapper; import com.thing.visual.group.entity.IotVisualGroupEntity; import com.thing.visual.group.service.IotVisualGroupService; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Map; import static com.mybatisflex.core.query.QueryMethods.max; @@ -69,6 +73,80 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl sortInfo = this.getNameSort(dto.getName()); + //修改排序 + moveItem(sortInfo,dto.getCurrentSort()-1,dto.getUpSort()-1); + //重置sort字段 + updateSortValues(sortInfo); + + if(ObjectUtils.isNotEmpty(dto.getName())){ + //组内排序 + sortInfo.forEach(temp->{ + UpdateChain.of(IotVisualGroupEntity.class) + .set(IotVisualGroupEntity::getSort, 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"; } + + + + + + /** + * 获取所有信息,看没有没有穿name,传name了,就是组内排序,没传name就是组排序 + * @param name + * @return + */ + private List getNameSort(String name){ + QueryWrapper wrapper = new QueryWrapper(); + if(ObjectUtils.isNotEmpty(name)){ + wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"), IOT_VISUAL_GROUP_ENTITY.BUSINESS_NAME.as("name")) + .from(IOT_VISUAL_GROUP_ENTITY); + wrapper.eq(IotVisualGroupEntity::getName,name).groupBy(IOT_VISUAL_GROUP_ENTITY.NAME).orderBy(IOT_VISUAL_GROUP_ENTITY.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); + 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 list, int fromIndex, int toIndex) { + if (fromIndex < 0 || fromIndex >= list.size() || toIndex < 0 || toIndex >= list.size()) { + throw new IndexOutOfBoundsException("Invalid index"); + } + NameSort item = list.remove(fromIndex); + list.add(toIndex, item); + updateSortValues(list); + } + + /** + * 重新修改 name中对应的sort信息 + * @param list + */ + private static void updateSortValues(List list) { + long sortValue = 1L; + for (NameSort item : list) { + item.setSort(sortValue++); + } + } + } \ No newline at end of file From 2da0b65971ea1ef4af2858b42c01758a58129ff6 Mon Sep 17 00:00:00 2001 From: lishuai Date: Fri, 23 Aug 2024 17:32:05 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=89=A9=E5=85=B3=E7=B3=BB=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E6=95=B4=202024=E5=B9=B48=E6=9C=8823=E6=97=A517:08:55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eq/eqbxwx/service/impl/EqBxServiceImpl.java | 3 ++- .../service/impl/IotThingsServiceImpl.java | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java index 6dffb9f..0e4d8f5 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java +++ b/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.service.SysUserService; import com.thing.sys.security.context.TenantContext; +import com.thing.sys.security.context.UserContext; import com.thing.sys.security.domain.SecurityUser; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -256,7 +257,7 @@ public class EqBxServiceImpl extends BaseServiceImpl imp lastNo = SerialNumberUnit.generateNumber("BX", eqBxEntity.getBxNo()); dto.setBxNo(lastNo); - dto.setTenantCode(SecurityUser.getTenantCode()); + dto.setTenantCode(UserContext.getRealTenantCode()); // Long eqBxId = IdWorker.getId(); // dto.setId(eqBxId); diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java index 5edce9d..88281bf 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java @@ -393,9 +393,19 @@ public class IotThingsServiceImpl implements IotThingsService { @Override public EqDTO getInfo(Long id) { + 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){ return null; } @@ -411,8 +421,7 @@ public class IotThingsServiceImpl implements IotThingsService { info.setUpdateDate(eq.getUpdateDate()); // BeanUtils.copyProperties(eq,info); //获取设备基础信息 - IotThingBaseInfoDTO baseInfoDTO = iotThingBaseInfoService.getByThingsId(id); - BeanUtils.copyProperties(baseInfoDTO,info); + BeanUtils.copyProperties(baseInfoEntity,info); List imageUrls = new ArrayList<>(); List attachmentUrls = new ArrayList<>(); From 3b30019d9177781f46bb6424df6b08fcec124d15 Mon Sep 17 00:00:00 2001 From: xiachao Date: Mon, 26 Aug 2024 14:41:15 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E6=96=B0=E7=9A=84=E7=B4=A0=E6=9D=90?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E7=BB=84=E7=AE=A1=E7=90=86=EF=BC=8C=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IotVisualGroupController.java | 35 ++++- .../thing/visual/group/dto/GroupSortInfo.java | 4 +- .../visual/group/dto/IotVisualGroupDTO.java | 17 ++- .../com/thing/visual/group/dto/NameSort.java | 6 +- .../group/entity/IotVisualGroupEntity.java | 4 +- .../group/service/IotVisualGroupService.java | 9 +- .../impl/IotVisualGroupServiceImpl.java | 127 +++++++++++++++--- 7 files changed, 172 insertions(+), 30 deletions(-) diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java b/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java index d09d801..a9ffbe5 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java @@ -7,6 +7,7 @@ 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.visual.group.dto.NameSort; import com.thing.visual.group.service.IotVisualGroupService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -15,6 +16,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; /** @@ -37,13 +39,18 @@ public class IotVisualGroupController { @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , - @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") + @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"), + @Parameter(name = "name", description = "组名称"), + @Parameter(name = "businessName", description = "组类型名称"), + @Parameter(name = "names", description = "组名称集合,多个组名称,以英文逗号分割") }) public Result> page(@Parameter(hidden = true) @RequestParam Map params){ PageData page = iotVisualGroupService.getPageData(params, IotVisualGroupDTO.class); return new Result>().ok(page); } + + @GetMapping("{id}") @Operation(summary="信息") public Result get(@PathVariable("id") Long id){ @@ -59,12 +66,20 @@ public class IotVisualGroupController { } @PutMapping - @Operation(summary="修改") + @Operation(summary="修改,这个接口,只能修改二级得组类型") public Result update(@RequestBody IotVisualGroupDTO dto){ iotVisualGroupService.updateIotVisualGroupDTO(dto); return new Result<>(); } + + @PutMapping("group") + @Operation(summary="修改,这个接口,只能修改一级得组") + public Result updateGroup(@RequestBody IotVisualGroupDTO dto){ + iotVisualGroupService.updateGroup(dto); + return new Result<>(); + } + @DeleteMapping @Operation(summary="删除") public Result delete(@RequestBody Long[] ids){ @@ -75,15 +90,23 @@ public class IotVisualGroupController { } + @GetMapping("groupInfo") + @Operation(summary="左侧组列表,可按名称模糊查询") + public Result> groupInfo(@RequestParam(required = false) String name, @RequestParam(required = true) String type){ + List data = iotVisualGroupService.groupInfo(name,type); + return new Result>().ok(data); + } + + @GetMapping("groupSortInfo") - @Operation(summary="获取排序信息,可以传入已存在的组名称") - public Result groupSortInfo(@RequestParam(required = false) String name){ - GroupSortInfo data = iotVisualGroupService.groupSortInfo(name); + @Operation(summary="获取排序信息,可以传入已存在的组名称,新增得时候使用") + public Result groupSortInfo(@RequestParam(required = false) String name,@RequestParam(required = true) String type){ + GroupSortInfo data = iotVisualGroupService.groupSortInfo(name,type); return new Result().ok(data); } @PostMapping("adjustGroupSort") - @Operation(summary="调整组排序") + @Operation(summary="调整组排序,拖动排序,如果传入name,就是组内排序") public Result adjustGroupSort(@RequestBody AdjustGroupDto dto){ String data = iotVisualGroupService.adjustGroupSort(dto); return new Result().ok(data); diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupSortInfo.java b/modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupSortInfo.java index aa3c9cd..b8a5e15 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupSortInfo.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupSortInfo.java @@ -7,8 +7,8 @@ import lombok.Data; @Schema(description = "组排序信息") public class GroupSortInfo { - private Long sort; + private Integer sort; - private Long bsSort; + private Integer bsSort; } diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/dto/IotVisualGroupDTO.java b/modules/visual-design/src/main/java/com/thing/visual/group/dto/IotVisualGroupDTO.java index 4a0d7c9..4996174 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/dto/IotVisualGroupDTO.java +++ b/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") private String thumbnailUrl; @Schema(description = "组排序") - private Long sort; + private Integer sort; @Schema(description = "二级业务排序") - private Long bsSort; + private Integer bsSort; @Schema(description = "备注说明") private String remark; @Schema(description = "所属企业(租户code)") @@ -52,4 +52,17 @@ public class IotVisualGroupDTO implements Serializable { @Schema(description = "更新时间") private Long updateDate; + @Schema(description = "素材/部件组修改之前得名称") + private String oldName; + + @Schema(description = "素材/部件组修改之前得排序") + private Integer oldSort; + + + @Schema(description = "素材/部件组修改之前得业务二级名称") + private String oldBusinessName; + + + @Schema(description = "修改之前得二级业务排序") + private Integer oldBsSort; } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java b/modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java index 9172a90..c834cb8 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/dto/NameSort.java @@ -1,13 +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 Long sort; + private Integer sort; } diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/entity/IotVisualGroupEntity.java b/modules/visual-design/src/main/java/com/thing/visual/group/entity/IotVisualGroupEntity.java index 7f1d211..a742150 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/entity/IotVisualGroupEntity.java +++ b/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; /** * 备注说明 */ diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java b/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java index 6c4e003..2a23545 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java @@ -4,8 +4,11 @@ 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.visual.group.dto.NameSort; import com.thing.visual.group.entity.IotVisualGroupEntity; +import java.util.List; + /** * 素材部件组管理 * @@ -18,7 +21,11 @@ public interface IotVisualGroupService extends IBaseService groupInfo(String name, String type); } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java index 85e64e6..2bd5ce1 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java @@ -4,6 +4,7 @@ import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.update.UpdateChain; import com.mybatisflex.core.update.UpdateWrapper; import com.thing.common.orm.service.impl.BaseServiceImpl; +import com.thing.sys.security.context.UserContext; import com.thing.visual.group.dto.AdjustGroupDto; import com.thing.visual.group.dto.GroupSortInfo; import com.thing.visual.group.dto.IotVisualGroupDTO; @@ -11,9 +12,12 @@ import com.thing.visual.group.dto.NameSort; import com.thing.visual.group.mapper.IotVisualGroupMapper; 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.stereotype.Service; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -32,50 +36,100 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl params){ + Long tenantCode = UserContext.getTenantCode(); QueryWrapper wrapper = new QueryWrapper(); + String name = MapUtils.getString(params,"name"); + String names = MapUtils.getString(params,"names"); + List nameList = Arrays.asList(names.split(",")); + String businessName = MapUtils.getString(params,"businessName"); + 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; } @Override public void saveIotVisualGroupDTO(IotVisualGroupDTO dto) { + List sortInfo = this.getNameSort(dto.getName(),dto.getType()); + GroupSortInfo groupSortInfo =null; + if(ObjectUtils.isEmpty(sortInfo)){ + //如果sortInfo 是空得话,那就是没有,组得排序给当前最大值+1,类型给默认值1 + groupSortInfo = this.groupSortInfo(null,dto.getType()); + }else { + //如果不是空,那就获取这个组得序号,组类型最大值+1 + groupSortInfo = this.groupSortInfo(dto.getName(),dto.getType()); + } + dto.setSort(groupSortInfo.getSort()); + dto.setBsSort(groupSortInfo.getBsSort()); + this.saveDto(dto); } @Override public void updateIotVisualGroupDTO(IotVisualGroupDTO dto) { - + List 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.getOldBusinessName().equals(temp.getName())){ + UpdateChain.of(IotVisualGroupEntity.class) + .set(IotVisualGroupEntity::getSort, temp.getSort()) + .where(IotVisualGroupEntity::getName).eq(dto.getName()).eq(IotVisualGroupEntity::getBusinessName,temp.getName()) + .update(); + }else { + UpdateChain.of(IotVisualGroupEntity.class) + .set(IotVisualGroupEntity::getSort, 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(); + } + }); } @Override - public GroupSortInfo groupSortInfo(String name) { + public GroupSortInfo groupSortInfo(String name,String type) { + Long tenantCode = UserContext.getTenantCode(); QueryWrapper wrapper = new QueryWrapper(); 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)){ wrapper.eq(IotVisualGroupEntity::getName,name); } GroupSortInfo sortInfo = this.mapper.selectOneByQueryAs(wrapper,GroupSortInfo.class); if(ObjectUtils.isEmpty(sortInfo)){ sortInfo = new GroupSortInfo(); - sortInfo.setBsSort(1L); - sortInfo.setSort(1L); + sortInfo.setBsSort(1); + sortInfo.setSort(1); return sortInfo; } if(ObjectUtils.isNotEmpty(name)){ - sortInfo.setSort(sortInfo.getSort()==null?1L:sortInfo.getSort()); + sortInfo.setSort(sortInfo.getSort()==null?1:sortInfo.getSort()); }else { - sortInfo.setSort(sortInfo.getSort()==null?1L:sortInfo.getSort()+1); + sortInfo.setSort(sortInfo.getSort()==null?1:sortInfo.getSort()+1); } - sortInfo.setBsSort(sortInfo.getBsSort()==null?1L:sortInfo.getBsSort()+1); + sortInfo.setBsSort(sortInfo.getBsSort()==null?1:sortInfo.getBsSort()+1); return sortInfo ; } @Override public String adjustGroupSort(AdjustGroupDto dto) { - List sortInfo = this.getNameSort(dto.getName()); + List sortInfo = this.getNameSort(dto.getName(),dto.getType()); //修改排序 - moveItem(sortInfo,dto.getCurrentSort()-1,dto.getUpSort()-1); + moveItem(sortInfo,dto.getCurrentSort()-1,dto.getUpSort()-1,null); //重置sort字段 updateSortValues(sortInfo); @@ -99,24 +153,62 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl 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->{ + UpdateChain.of(IotVisualGroupEntity.class) + .set(IotVisualGroupEntity::getSort, temp.getSort()) + .where(IotVisualGroupEntity::getName).eq(temp.getName()) + .update(); + }); + } + @Override + public List 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.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.NAME).orderBy(IOT_VISUAL_GROUP_ENTITY.SORT,true); + return this.mapper.selectListByQueryAs(wrapper,NameSort.class); + } /** - * 获取所有信息,看没有没有穿name,传name了,就是组内排序,没传name就是组排序 + * 获取所有排序信息,看没有没有穿name,传name了,就是组内排序,没传name就是组排序 * @param name * @return */ - private List getNameSort(String name){ + private List getNameSort(String name,String type){ + Long tenantCode = UserContext.getTenantCode(); QueryWrapper wrapper = new QueryWrapper(); if(ObjectUtils.isNotEmpty(name)){ wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"), IOT_VISUAL_GROUP_ENTITY.BUSINESS_NAME.as("name")) - .from(IOT_VISUAL_GROUP_ENTITY); + .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.NAME).orderBy(IOT_VISUAL_GROUP_ENTITY.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); + .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); @@ -129,11 +221,14 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl list, int fromIndex, int toIndex) { + private static void moveItem(List list, int fromIndex, int toIndex,String name) { if (fromIndex < 0 || fromIndex >= list.size() || toIndex < 0 || toIndex >= list.size()) { throw new IndexOutOfBoundsException("Invalid index"); } NameSort item = list.remove(fromIndex); + if(ObjectUtils.isNotEmpty(name)){ + item.setName(name); + } list.add(toIndex, item); updateSortValues(list); } @@ -143,7 +238,7 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl list) { - long sortValue = 1L; + Integer sortValue = 1; for (NameSort item : list) { item.setSort(sortValue++); } From c95d97ee216e7f7b111106f510cd56fe965da627 Mon Sep 17 00:00:00 2001 From: lishuai Date: Mon, 26 Aug 2024 15:08:32 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E4=BF=9D=E5=85=BB?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D=202024=E5=B9=B48=E6=9C=882?= =?UTF-8?q?6=E6=97=A515:08:25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/orm/entity/BaseTenantEntity.java | 4 +- .../eqbxwx/controller/EqWxPlanController.java | 106 +++++++++--------- .../eq/eqby/entity/EqByPlanPartEntity.java | 34 +++++- .../eq/eqby/entity/EqByTemplateEntity.java | 6 +- .../service/impl/EqByPlanServiceImpl.java | 51 ++++++--- .../controller/EqCheckStandardController.java | 5 +- .../entity/EqPatrolCheckPlanEntity.java | 10 +- .../eqcheck/entity/EqSpotCheckPlanEntity.java | 11 +- .../impl/EqPatrolCheckPlanServiceImpl.java | 28 ++--- .../impl/EqSpotCheckPlanServiceImpl.java | 3 +- .../impl/IotThingBaseInfoServiceImpl.java | 11 +- .../service/impl/IotThingsServiceImpl.java | 13 ++- 12 files changed, 177 insertions(+), 105 deletions(-) diff --git a/common/orm/src/main/java/com/thing/common/orm/entity/BaseTenantEntity.java b/common/orm/src/main/java/com/thing/common/orm/entity/BaseTenantEntity.java index b8a9325..6978bbe 100644 --- a/common/orm/src/main/java/com/thing/common/orm/entity/BaseTenantEntity.java +++ b/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.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.core.keygen.KeyGenerators; import lombok.Data; import lombok.experimental.Accessors; @@ -26,7 +28,7 @@ public class BaseTenantEntity implements Serializable { @Serial private static final long serialVersionUID = 1536009703312548328L; - @Id + @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId) private Long id; /*------------------------租户信息--------------------------------*/ diff --git a/modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java b/modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java index d5b3211..9dc33af 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java +++ b/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.SysDictTypeListDTO; 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.SysDictDataService; 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.tags.Tag; import jakarta.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; + import java.util.*; import java.util.stream.Collectors; @@ -94,7 +95,7 @@ public class EqWxPlanController { // private IotDictTypeService iotDictTypeService; @GetMapping("page") - @Operation(summary= "分页") + @Operation(summary = "分页") @Parameters({ @Parameter(name = Constant.PAGE, description = "当前页码,从1开始"), @Parameter(name = Constant.LIMIT, description = "每页显示记录数"), @@ -128,16 +129,16 @@ public class EqWxPlanController { EqWxInfoRes eqWxInfoRes = ConvertUtils.sourceToTarget(data, EqWxInfoRes.class); //调整 String userId = data.getWxUser(); - if(StringUtils.isNotBlank(userId)){ + if (StringUtils.isNotBlank(userId)) { String[] split = userId.split(","); List longs = new ArrayList<>(); for (String s : split) { longs.add(Long.parseLong(s)); } List planUserName = sysUserService.getUserNameLists(longs); - String name=""; + String name = ""; for (String s : planUserName) { - name+=s+","; + name += s + ","; } name = name.substring(0, name.length() - 1); eqWxInfoRes.setWxUseText(name); @@ -157,7 +158,7 @@ public class EqWxPlanController { eqWxInfoRes.setBxInfo(storeEqBxMap.get(data.getEqBxId())); } else { EqBxEntity eqBxEntity = null; - if(!Objects.isNull(data.getEqBxId())){ + if (!Objects.isNull(data.getEqBxId())) { eqBxEntity = eqBxService.getById(data.getEqBxId()); } if (!Objects.isNull(eqBxEntity)) { @@ -177,55 +178,59 @@ public class EqWxPlanController { } @GetMapping("{id}/{relationTypeId}") - @Operation(summary= "信息") + @Operation(summary = "信息") // @RequiresPermissions("eqwxplan:eqwxplan:info") public Result 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)) { throw new SysException("维修计划不存在"); } - - EqWxInfoRes eqWxInfoRes = new EqWxInfoRes(); - BeanUtils.copyProperties(data, eqWxInfoRes); +// +// EqWxInfoRes eqWxInfoRes = new EqWxInfoRes(); +// BeanUtils.copyProperties(data, eqWxInfoRes); // 查询设备信息 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[] split = userId.split(","); - List longs = new ArrayList<>(); + + if (ArrayUtils.isNotEmpty(split)) { + List longs = new ArrayList<>(); for (String s : split) { - longs.add(Long.parseLong(s)); - } List 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 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> document = fileService.getDocument(data.getEqBxId()); bxInfoDTO.setImageUrls(document.get("image")); bxInfoDTO.setAttachmentUrls(document.get("attachment")); } // 查询维修备件信息 - eqWxInfoRes.setReplacements(eqWxReplacementService.getWxReplacementByWxPlanId(data.getId())); + data.setReplacements(eqWxReplacementService.getWxReplacementByWxPlanId(data.getId())); - return new Result().ok(eqWxInfoRes); + return new Result().ok(data); } @PostMapping - @Operation(summary= "保存") + @Operation(summary = "保存") @LogOperation("保存") // @RequiresPermissions("equipment:maintainRecords:add") public Result save(@RequestBody EqWxPlanAddDTO dto) { @@ -254,7 +259,7 @@ public class EqWxPlanController { } @PutMapping - @Operation(summary= "修改") + @Operation(summary = "修改") @LogOperation("修改") @Transactional(rollbackFor = Exception.class) // @RequiresPermissions("equipment:maintainRecords:update") @@ -278,7 +283,7 @@ public class EqWxPlanController { } @DeleteMapping - @Operation(summary= "删除") + @Operation(summary = "删除") @LogOperation("删除") @Transactional(rollbackFor = Exception.class) // @RequiresPermissions("equipment:maintainRecords:delete") @@ -287,7 +292,7 @@ public class EqWxPlanController { AssertUtils.isArrayEmpty(ids, "id"); 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())) { throw new SysException("不能删除已完成的维修记录"); } @@ -303,7 +308,7 @@ public class EqWxPlanController { } @PostMapping("export") - @Operation(summary= "导出") + @Operation(summary = "导出") @LogOperation("导出") // @Parameters({ // @Parameter(name = "relationTypeId", description = "结构类型id", paramType = "query", required = true, dataType = "String"), @@ -356,13 +361,14 @@ public class EqWxPlanController { //调整 String userId = data.getWxUser(); String[] split = userId.split(","); - List longs = new ArrayList<>(); - for (String s : split) { - longs.add(Long.parseLong(s)); - } List planUserName = sysUserService.getUserNameLists(longs); - String name=""; + List longs = new ArrayList<>(); + for (String s : split) { + longs.add(Long.parseLong(s)); + } + List planUserName = sysUserService.getUserNameLists(longs); + String name = ""; for (String s : planUserName) { - name+=s+","; + name += s + ","; } name = name.substring(0, name.length() - 1); eqWxPlanExcel.setWxUser(name); @@ -424,16 +430,16 @@ public class EqWxPlanController { } List newList = new ArrayList<>(); List 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); } } - }else{ + } else { 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 ""; } List 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)) { return ""; } Map dictObject = new HashMap<>(); - for (SysDictDataEntity dictData:temp){ - dictObject.put(dictData.getDictValue(),dictData.getDictLabel()); + for (SysDictDataEntity dictData : temp) { + dictObject.put(dictData.getDictValue(), dictData.getDictLabel()); } // List temp = (List) dictMap.get(dictType); diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java b/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java index 4e1bf02..ded9587 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByPlanPartEntity.java @@ -1,11 +1,15 @@ package com.thing.eq.eqby.entity; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; -import com.thing.common.orm.entity.BaseDateEntity; +import com.mybatisflex.core.keygen.KeyGenerators; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serial; +import java.io.Serializable; +import java.util.Date; /** * 部件使用记录 @@ -16,11 +20,37 @@ import java.io.Serial; @Data @EqualsAndHashCode(callSuper=false) @Table("eq_by_plan_part") -public class EqByPlanPartEntity extends BaseDateEntity { +public class EqByPlanPartEntity implements Serializable { @Serial 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; + /** * 更换数量 */ diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateEntity.java b/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateEntity.java index 8d24bff..e9d44e4 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateEntity.java +++ b/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.EqualsAndHashCode; +import java.io.Serial; +import java.io.Serializable; import java.util.Date; /** @@ -16,7 +18,9 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper=false) @Table("eq_by_template") -public class EqByTemplateEntity { +public class EqByTemplateEntity implements Serializable { + + @Serial private static final long serialVersionUID = 1L; @Id diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java index c6915a7..48a1718 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java @@ -1,6 +1,7 @@ package com.thing.eq.eqby.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; 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.entity.SysDeptEntity; 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.service.SysDeptService; import com.thing.sys.biz.service.SysDictDataService; @@ -86,24 +86,36 @@ public class EqByPlanServiceImpl extends BaseServiceImpl params) { 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 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; } @Override public PageData page(Map params) { - Page page = getPage(params); + int pageNumber = MapUtil.getInt(params, "page",1); + int pageSize = MapUtil.getInt(params, "limit",10); -// IPage thingsEntityPage = baseDao.selectPage(page, getWrapper(params)); - String eqIds; - List 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 paginate = mapper.paginateAs(new Page<>(pageNumber, pageSize), getWrapper(params),EqByPlanDTO.class); + List eqByPlansDTOS = paginate.getRecords(); String relationTypeId = params.get("relationTypeId").toString(); - List eqByPlansDTOS = eqByPlanDao.getListData(params); for (EqByPlanDTO eqByPlansDTO : eqByPlansDTOS) { EqInfo thingsInfo = iotThingsService.getThingInfo(eqByPlansDTO.getThingsId(),relationTypeId); if (thingsInfo != null) { @@ -160,9 +172,13 @@ public class EqByPlanServiceImpl extends BaseServiceImpl eqByPlanPartEntities = ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class); + eqByPlanPartService.saveBatch(eqByPlanPartEntities); } } } @@ -197,13 +213,14 @@ public class EqByPlanServiceImpl extends BaseServiceImpl eqByParts = new ArrayList<>(); + List eqByParts = new ArrayList<>(); if (CollectionUtil.isNotEmpty(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)); } } diff --git a/modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqCheckStandardController.java b/modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqCheckStandardController.java index 5e25fed..48db611 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqCheckStandardController.java +++ b/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.EqCheckStandardDetailService; import com.thing.eq.eqcheck.service.EqCheckStandardService; +import com.thing.sys.security.context.UserContext; import com.thing.sys.security.domain.SecurityUser; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -139,15 +140,13 @@ public class EqCheckStandardController { if (CollectionUtil.isEmpty(detailDTOS)) { throw new SysException("请添加模板检查项"); } - - dto.setTenantCode(SecurityUser.getTenantCode()); + dto.setTenantCode(UserContext.getRealTenantCode()); dto.setCreateDate(new Date()); eqCheckStandardService.saveDto(dto); // if (Objects.isNull(dto.getId())) { // throw new SysException("保存失败"); // } - for (EqCheckStandardDetailDTO detail : detailDTOS) { if ("0".equals(detail.getType()) && (StringUtils.isBlank(detail.getLowerLimit()) || StringUtils.isBlank(detail.getUpperLimit()))) { throw new SysException("标准细项为上下限判定类型时,上下限值不能为空"); diff --git a/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqPatrolCheckPlanEntity.java b/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqPatrolCheckPlanEntity.java index d2386e8..0484385 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqPatrolCheckPlanEntity.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqPatrolCheckPlanEntity.java @@ -1,10 +1,14 @@ package com.thing.eq.eqcheck.entity; import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; +import com.mybatisflex.core.keygen.KeyGenerators; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serial; +import java.io.Serializable; import java.util.Date; /** @@ -16,13 +20,15 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper = false) @Table("eq_patrol_check_plan") -public class EqPatrolCheckPlanEntity { +public class EqPatrolCheckPlanEntity implements Serializable { + + @Serial private static final long serialVersionUID = 1L; /** * id */ - @Id + @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId) private Long id; /** * 创建人 diff --git a/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqSpotCheckPlanEntity.java b/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqSpotCheckPlanEntity.java index 94c0630..5de42a8 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqSpotCheckPlanEntity.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqcheck/entity/EqSpotCheckPlanEntity.java @@ -1,10 +1,14 @@ package com.thing.eq.eqcheck.entity; import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; +import com.mybatisflex.core.keygen.KeyGenerators; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serial; +import java.io.Serializable; import java.util.Date; /** @@ -16,10 +20,13 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper=false) @Table("eq_spot_check_plan") -public class EqSpotCheckPlanEntity { +public class EqSpotCheckPlanEntity implements Serializable { + + + @Serial private static final long serialVersionUID = 1L; - @Id + @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId) private Long id; /** * 设备thingid diff --git a/modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckPlanServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckPlanServiceImpl.java index c0bbfe6..0976911 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckPlanServiceImpl.java +++ b/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.utils.SerialNumberUnit; import com.thing.sys.security.context.TenantContext; +import com.thing.sys.security.context.UserContext; import com.thing.sys.security.domain.SecurityUser; import com.thing.thing.entity.dto.IotThingEntityDTO; import com.thing.thing.entity.entity.IotThingEntity; @@ -631,26 +632,25 @@ public class EqPatrolCheckPlanServiceImpl extends BaseServiceImpl deviceBaseInfoDTOS) { for (DeviceBaseInfoDTO deviceInfo : deviceBaseInfoDTOS) { - eqScrapService.checkThingStatus(deviceInfo.getThingId()); - List standardDTOS = deviceInfo.getStandardIdList(); //todo if (CollectionUtil.isEmpty(standardDTOS)) { @@ -665,12 +665,12 @@ public class EqPatrolCheckPlanServiceImpl extends BaseServiceImpl eqDTOS = iotThingBaseInfoDao.queryDeviceListByThingsId(new Page<>(page, limit), params,aLong,aLong1,aLong2,eqTypeName,keyWord); @@ -150,7 +149,7 @@ public class IotThingBaseInfoServiceImpl extends BaseServiceImpl settingList, String showDeviceType, String relationTypeId) { - IotThingBaseInfoDTO baseThing = iotThingBaseInfoService.getByThingsId(thingId); + IotThingBaseInfoDTO baseThing = iotThingBaseInfoService.getByIdAs(thingId,IotThingBaseInfoDTO.class); EqScrapEntity eqScrapEntity = eqScrapService.getByEqId(thingId); if(!Objects.isNull(eqScrapEntity)){ @@ -198,9 +197,9 @@ public class IotThingBaseInfoServiceImpl extends BaseServiceImpl standardList = eqCheckStandardService.getStandardListByStandardIdList(standardIdList); 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) : ""); } } diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java index 88281bf..fa2b33c 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java @@ -453,13 +453,14 @@ public class IotThingsServiceImpl implements IotThingsService { result.setCode(eq.getCode()); result.setName(eq.getName()); 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 iotThingsDao.getThingInfo(thingId,relationTypeId); } @Override From c90f55045d34d77051c858c5c21ce0f313753017 Mon Sep 17 00:00:00 2001 From: lishuai Date: Mon, 26 Aug 2024 15:28:16 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E4=BF=9D=E5=85=BB?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D=202024=E5=B9=B48=E6=9C=882?= =?UTF-8?q?6=E6=97=A515:08:25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thing/eq/eqby/entity/EqByTemplateDetailEntity.java | 10 ++++++++-- .../eq/eqby/service/impl/EqByPlanServiceImpl.java | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateDetailEntity.java b/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateDetailEntity.java index f7a96ad..f0545f6 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateDetailEntity.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByTemplateDetailEntity.java @@ -1,10 +1,14 @@ package com.thing.eq.eqby.entity; import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; +import com.mybatisflex.core.keygen.KeyGenerators; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serial; +import java.io.Serializable; import java.util.Date; /** @@ -16,10 +20,12 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper=false) @Table("eq_by_template_detail") -public class EqByTemplateDetailEntity { +public class EqByTemplateDetailEntity implements Serializable { + + @Serial private static final long serialVersionUID = 1L; - @Id + @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId) private Long id; /** * 保养模板id diff --git a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java index 48a1718..4c2a730 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByPlanServiceImpl.java @@ -252,6 +252,8 @@ public class EqByPlanServiceImpl extends BaseServiceImpl details = eqByTemplateDetailService.getDetails(eqByTemplateDTO.getId()); + eqByTemplateDTO.setDatas(details); byTemplateInfos.add(eqByTemplateDTO); } } From d5c93849f4c833f6012bcbc94e4825ace62a700c Mon Sep 17 00:00:00 2001 From: lishuai Date: Mon, 26 Aug 2024 15:43:57 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E4=BF=9D=E5=85=BB?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D=202024=E5=B9=B48=E6=9C=882?= =?UTF-8?q?6=E6=97=A515:08:25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java index 0e4d8f5..08a46d6 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java @@ -108,7 +108,7 @@ public class EqBxServiceImpl extends BaseServiceImpl imp for (EqBxDTO eqBxEntity : eqBxEntities) { EqBxDTO eqBxDTO = new EqBxDTO(); BeanUtils.copyProperties(eqBxEntity, eqBxDTO); - + eqBxDTO.setCreateDate(eqBxEntity.getHappenDate()); Map> document = fileService.getDocument(eqBxDTO.getId()); eqBxDTO.setImageUrls(document.get("image")); eqBxDTO.setAttachmentUrls(document.get("attachment")); @@ -123,8 +123,7 @@ public class EqBxServiceImpl extends BaseServiceImpl imp eqBxDTOS.add(eqBxDTO); } - PageData pageData = new PageData<>(eqBxDTOS, eqBxDTOS.size()); - return pageData; + return new PageData<>(eqBxDTOS, eqBxDTOS.size()); } @Override From 2f835b8d26d014035b177e65070f42e33cc48cf8 Mon Sep 17 00:00:00 2001 From: lishuai Date: Mon, 26 Aug 2024 16:52:42 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E7=82=B9=E6=A3=80=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D=202024=E5=B9=B48=E6=9C=882?= =?UTF-8?q?6=E6=97=A516:52:30?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EqSpotCheckPlanController.java | 26 +++++++------------ .../eqcheck/dto/EqCheckStandardDetailDTO.java | 5 ++++ .../eq/eqcheck/dto/EqSpotCheckPlanDTO.java | 4 +++ .../impl/SysTenantDetailServiceImpl.java | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqSpotCheckPlanController.java b/modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqSpotCheckPlanController.java index dab4899..858f2f5 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqSpotCheckPlanController.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqcheck/controller/EqSpotCheckPlanController.java @@ -90,9 +90,7 @@ public class EqSpotCheckPlanController { if (CollectionUtil.isNotEmpty(planDTOS)) { StringBuilder stringBuilder = new StringBuilder(); planDTOS.forEach(eqSpotCheckPlanDTO -> { - iotThingBaseInfoService.getThingInfo(eqSpotCheckPlanDTO, eqSpotCheckPlanDTO.getThingId(), null, "0", String.valueOf(params.get("relationTypeId"))); - List standardList = new ArrayList<>(); List settingList = eqCheckSettingService.getSettingList(eqSpotCheckPlanDTO.getThingId(), "0"); if (CollectionUtil.isNotEmpty(settingList)) { @@ -100,25 +98,24 @@ public class EqSpotCheckPlanController { EqCheckStandardDTO eqCheckStandardDTO = eqCheckStandardService.getByIdAs(eqCheckSettingDTO.getStandardId(),EqCheckStandardDTO.class); if (!Objects.isNull(eqCheckStandardDTO)) { standardList.add(eqCheckStandardDTO.getId()); - stringBuilder.append(eqCheckStandardDTO.getName() + ","); + stringBuilder.append(eqCheckStandardDTO.getName()).append(","); } }); + eqSpotCheckPlanDTO.setEqCode(eqSpotCheckPlanDTO.getThingCode()); 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); } - - List useIdList = StringUtils.isNotBlank(eqSpotCheckPlanDTO.getUseId()) ? Arrays.asList(eqSpotCheckPlanDTO.getUseId().split(",")) : new ArrayList<>(); if (CollectionUtil.isNotEmpty(useIdList)) { useIdList.forEach(idStr -> { SysUserDTO sysUserDTO = sysUserService.get(Long.parseLong(idStr)); if (!Objects.isNull(sysUserDTO)) { - stringBuilder.append(sysUserDTO.getRealName() + ","); + stringBuilder.append(sysUserDTO.getRealName()).append(","); } }); 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); } }); @@ -139,9 +136,9 @@ public class EqSpotCheckPlanController { } iotThingBaseInfoService.getThingInfo(data, data.getThingId(), null, "0", relationTypeId); + data.setEqCode(data.getThingCode()); StringBuilder stringBuilder = new StringBuilder(); List settingList = eqCheckSettingService.getSettingList(data.getThingId(), "0"); - if (CollectionUtil.isNotEmpty(settingList)) { List standardList = new ArrayList<>(); List standardIdList = new ArrayList<>(); @@ -153,29 +150,26 @@ public class EqSpotCheckPlanController { dataVo.setName(eqCheckStandardDTO.getName()); standardIdList.add(eqCheckStandardDTO.getId()); standardList.add(dataVo); - stringBuilder.append(eqCheckStandardDTO.getName() + ","); + stringBuilder.append(eqCheckStandardDTO.getName()).append(","); } }); data.setCheckIdList(standardIdList); 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); } - List useIdList = StringUtils.isNotBlank(data.getUseId()) ? Arrays.asList(data.getUseId().split(",")) : new ArrayList<>(); - if (CollectionUtil.isNotEmpty(useIdList)) { useIdList.forEach(idStr -> { SysUserDTO sysUserDTO = sysUserService.get(Long.parseLong(idStr)); if (!Objects.isNull(sysUserDTO)) { - stringBuilder.append(sysUserDTO.getRealName() + ","); + stringBuilder.append(sysUserDTO.getRealName()).append(","); } }); 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 detailDTOS = eqCheckStandardDetailService.getAllStandardDetailByThingId(data.getThingId(), "0"); data.setDetailDTOS(detailDTOS); diff --git a/modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqCheckStandardDetailDTO.java b/modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqCheckStandardDetailDTO.java index 7cc5fc3..95c9e7a 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqCheckStandardDetailDTO.java +++ b/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 io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; +import java.io.Serial; import java.io.Serializable; /** @@ -12,9 +14,12 @@ import java.io.Serializable; * @author xiezw 806671840@qq.com * @since 3.0 2021-09-22 */ +@EqualsAndHashCode(callSuper = true) @Data @Schema(description = "设备检查标准明细") public class EqCheckStandardDetailDTO extends BaseDTO implements Serializable { + + @Serial private static final long serialVersionUID = 1L; private Long id; diff --git a/modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqSpotCheckPlanDTO.java b/modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqSpotCheckPlanDTO.java index e545bd0..0a35713 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqSpotCheckPlanDTO.java +++ b/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 io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.format.annotation.DateTimeFormat; +import java.io.Serial; import java.io.Serializable; import java.util.Date; import java.util.List; @@ -16,9 +18,11 @@ import java.util.List; * @author zy aa@aa,com * @since 3.0 2021-10-12 */ +@EqualsAndHashCode(callSuper = true) @Data @Schema(description = "点检计划") public class EqSpotCheckPlanDTO extends ThingDTO implements Serializable { + @Serial private static final long serialVersionUID = 1L; private Long id; diff --git a/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java b/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java index eb176b0..333e6e9 100644 --- a/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java +++ b/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java @@ -105,6 +105,7 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl page = getPage(params, SysTenantDetailDTO.class); //不为超管时,查询自己下属 sysTenantGroupService.paramsAddTenantCodeList(params, true); From 914043d2d5a03219cc2f70becb0e52f876d7dbe3 Mon Sep 17 00:00:00 2001 From: xiezw Date: Tue, 27 Aug 2024 15:42:45 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86-2024?= =?UTF-8?q?0827=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 276 +++++++++++++++++- .../thing/eq/eqmanager/dto/EqScrapDTO.java | 3 + .../mapper/IotThingBaseInfoMapper.java | 4 +- .../service/impl/EqScrapServiceImpl.java | 1 + .../impl/IotThingBaseInfoServiceImpl.java | 6 +- .../service/impl/IotThingsServiceImpl.java | 1 + .../eq/tree/controller/DeviceController.java | 10 +- .../eqmanager/IotThingBaseInfoMapper.xml | 14 +- 8 files changed, 295 insertions(+), 20 deletions(-) diff --git a/application/src/main/resources/application.yml b/application/src/main/resources/application.yml index 3042094..fafb84c 100644 --- a/application/src/main/resources/application.yml +++ b/application/src/main/resources/application.yml @@ -1,271 +1,541 @@ server: - port: 18080 + + port: 8070 + servlet: + context-path: /thing + spring: + cache: + type: caffeine # 支持 redis/caffeine, 当选择redis时,要在application.yml中配置redis连接信息 + main: + allow-bean-definition-overriding: true + allow-circular-references: true + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + enabled: true + messages: + encoding: UTF-8 + basename: i18n/messages + data: + redis: + host: 192.168.188.185 + port: 7963 + password: Sddt8888! + database: 5 + #项目入口签名 + title: + sign: ck #企业签名 + technical: + phone: + map-bucket: geojson #地图文件路径 + + queue: + type: in-memory # 队列类型: inMemory / disruptor + inMemory: + maxSize: 500 + pollInterval: 100 + disruptor: + maximumPoolSize: 8 + bufferSize: 256 # 指定ringbuffer字节大小,当前值将乘1024 + partitions: + hash_function_name: murmur3_128 # murmur3_32, murmur3_128 or sha256 + core: + topic: queue_core + poll-interval: 1000 + partitions: 30 + debug: false + log-interval: 300 + rabbitmq: + exchange_name: + host: localhost + port: 5673 + virtual_host: / + username: guest + password: guest + automatic_recovery_enabled: false + connection_timeout: 60000 + handshake_timeout: 10000 + queue-properties: + core: x-max-length-bytes:1048576000;x-message-ttl:604800000 + #数据源配置 + database: + ts_kv: + type: postgresql # 时序数据存储类型 clickhouse/timescale/postgresql/tidb/mysql + latest: + type: postgresql # 最新数据存储类型 postgresql/timescale/mysql/tidb/clickhouse + save_maximumPoolSize: 12 + # 数据源及mybatis、mybatis-flex配置 + mybatis-flex: + typeAliasesPackage: com.thing.**.mapper + mapperLocations: classpath*:/mapper/**/*.xml + #本部分(Configuration)的配置都为 MyBatis 原生支持的配置,有关配置请参考:https://mybatis.org/mybatis-3/zh/configuration.html#%E8%AE%BE%E7%BD%AE%EF%BC%88settings%EF%BC%89 + configuration: + mapUnderscoreToCamelCase: true + autoMappingBehavior: FULL + autoMappingUnknownColumnBehavior: NONE + cacheEnabled: true + global-config: + print-banner: true + normal-value-of-logic-delete: 0 + deleted-value-of-logic-delete: 1 + datasource: + pg: + type: com.zaxxer.hikari.HikariDataSource - url: jdbc:postgresql://192.168.188.185:5432/thing_v2 + + url: jdbc:postgresql://192.168.188.184:5432/thingbi_v3 + driver-class-name: org.postgresql.Driver + username: postgres + password: sddt8888 + postgresql: + type: com.zaxxer.hikari.HikariDataSource - url: jdbc:postgresql://192.168.188.185:5432/thing_v2 + + url: jdbc:postgresql://192.168.188.184:5432/thingbi_v3 + driver-class-name: org.postgresql.Driver + username: postgres + password: sddt8888 + sqlServer: + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:sqlserver://127.0.0.1:1433;databaseName=销售生产其他 + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + username: czj + password: 1234 + + # 区间统计计算相关配置 + calculate: + am_total: + offset: 24 #当数据出现断点时,向后偏移查询多少小时 + interval: 15 # 分区间统计,间隔时长(分)1/3/5/10/15/20/30/60 + keys: A29,B2,C2,C6,D2,D4,E3,E4,F4,G2,G4,H2,I2,I4,K2,N2,N4,P4,Q2,R2,R4,S2,S4,F2,T2,T4,U2,U4,J2,J4,L2,A30,P2,Q4,V2,V4,A29_rush,A29_peak,A29_valley,A29_normal,A29_generate,A30_rush,A30_peak,A30_valley,A30_normal,tce_C6,tce_A29,tce_E3,CO2_A29,CO2_C6,CO2_E3,CO2_run,tce_run,tce_E3,A201,A202,A204,tce_J2 + ddmmyy: #例如:每月1号0时0分 开始统计年/月/日用量 + start_hh: 0 #小时/天/月/年 用量统计开始的分钟数(0-59) + start_dd: 0 #天/月/年 用量统计开始的小时(0-23) + start_mm: 1 #月/年 用量统计开始的天(1-30) + start_yy: 1 #年 用量统计开始的月份(1-12) + maximumPoolSize: 12 + + # 产品碳足迹 相关配置 + carbon: + syncButton: false + pub: + # 公共服务侧租户标识 + tenantTag: 公共服务 + api: + secret: nba!w^0@01 + + #物管理相关配置 + thing: + # token 过期时间 30天 + token: + expire: 2592000 + + ##数据解析配置 + nashorn: + # JS Eval max request timeout. 0 - no timeout + max_requests_timeout: 0 + # Specify thread pool size for javascript executor service + js_thread_pool_size: 120 + # Specify thread pool size for JavaScript sandbox resource monitor + monitor_thread_pool_size: 12 + # Maximum CPU time in milliseconds allowed for script execution + max_cpu_time: 8000 + tbel: + # JS Eval max request timeout. 0 - no timeout + max_requests_timeout: 0 + # Specify thread pool size for javascript executor service + thread_pool_size: 100 + # Maximum allowed TBEL script execution memory + max_memory_limit_mb: 8 + compiled_scripts_cache_size: 1000 + aviator: + # JS Eval max request timeout. 0 - no timeout + max_requests_timeout: 0 + # Specify thread pool size for javascript executor service + js_thread_pool_size: 100 + # Whether to put capturing groups into passed-in env map + # when regular-expression pattern matches + put_capturing_groups_into_env: false + # Max loop count to prevent too much CPU consumption. If it's value is zero or negative, it means + # no limitation on loop count.Default is zero. + max_loop_count: 1000 + #队列相关配置 + transport: + # Enable/disable http/mqtt/... transport protocols (has higher priority than certain protocol's 'enabled' property) + api_enabled: true + sessions: + inactivity_timeout: 300000 + report_timeout: 30000 + rate_limits: + enabled: false + # 1s 10次,60s 300次 + device: 10:1,300:60 + # Local HTTP transport parameters + http: + # Enable/disable http transport protocol. + enabled: false + request_timeout: 60000 + # Local MQTT transport parameters + mqtt: + # Enable/disable mqtt transport protocol. + enabled: false + bind_address: 0.0.0.0 + bind_port: 1883 + timeout: 10000 + netty: + leak_detector_level: DISABLED + boss_group_thread_count: 1 + worker_group_thread_count: 12 + max_payload_size: 65536 + so_keep_alive: false + #告警模块 配置 + alarm: + event_bus: + queue_size: 50 + core_pool_size: 5 + max_pool_size: 20 + + #swagger 文档配置 + springdoc: + swagger-ui: + path: /swagger-ui.html + packages-to-scan: com.thing + api-docs: + enabled: true + # knife4j的增强配置,不需要增强可以不配 + knife4j: + enable: true + setting: + language: zh_cn + #数据过滤配置 + filter: + rule: + enable: false + #项目状态 + management: + health: + redis: + enabled: false + endpoints: + enabled-by-default: true #暴露所有端点信息 + web: + exposure: + include: '*' #以web方式暴露 + + # 缓存管理 + cache-manager: + specs: + security: + timeToLiveInMinutes: 10 + maxSize: 50 + thingModel: + timeToLiveInMinutes: 1440 + maxSize: 10000 + authThingCodes: + timeToLiveInMinutes: 1440 + maxSize: 10000 + thingEntity: + timeToLiveInMinutes: 1440 + maxSize: 10000 + thingDict: + timeToLiveInMinutes: 1440 + maxSize: 10000 + thingDictRelation: + timeToLiveInMinutes: 1440 + maxSize: 10000 + thingDetailRelation: + timeToLiveInMinutes: 1440 + maxSize: 10000 + thingRootRelation: + timeToLiveInMinutes: 1440 + maxSize: 10000 + thingCalcConfig: + timeToLiveInMinutes: 525600 + maxSize: 10000 + filterRule: + timeToLiveInMinutes: 525600 + maxSize: 10000 + alarmRule: + timeToLiveInMinutes: 525600 + maxSize: 1000 + alarmRuleEntity: + timeToLiveInMinutes: 525600 + maxSize: 1000 + alarmRuleAction: + timeToLiveInMinutes: 525600 + maxSize: 1000 + scriptInfo: + timeToLiveInMinutes: 525600 + maxSize: 1000 + mockDataConfig: + timeToLiveInMinutes: 525600 + maxSize: 1000 + mockDataLatestTime: + timeToLiveInMinutes: 525600 + maxSize: 1000 diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/dto/EqScrapDTO.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/dto/EqScrapDTO.java index 929ec9e..eed9eb6 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/dto/EqScrapDTO.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqmanager/dto/EqScrapDTO.java @@ -1,5 +1,7 @@ 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 lombok.Data; @@ -41,5 +43,6 @@ public class EqScrapDTO implements Serializable { private String scrapDisposal; @Schema(description = "设备信息") private EqInfoDTO eqInfo; + private Long tenantCode; } diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/mapper/IotThingBaseInfoMapper.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/mapper/IotThingBaseInfoMapper.java index 60d601b..6795c9d 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/mapper/IotThingBaseInfoMapper.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqmanager/mapper/IotThingBaseInfoMapper.java @@ -35,7 +35,7 @@ public interface IotThingBaseInfoMapper extends PowerBaseMapper exportPartListByThingsId(@Param("params") Map params); +// List exportPartListByThingsId(@Param("params") Map params); String getStock(@Param("eqId") Long eqId); @@ -47,5 +47,5 @@ public interface IotThingBaseInfoMapper extends PowerBaseMapper exportDeviceListByThingsId(@Param("relationTypeId") Long relationTypeId, @Param("toId") Long toId, @Param("ids") Long[] ids); - List exportPartListByThingsId(@Param("relationTypeId") Long relationTypeId, @Param("toId") Long toId, @Param("ids") Long[] ids); + List exportPartListByThingsId(@Param("relationTypeId") Long relationTypeId, @Param("toId") Long toId, @Param("ids") Long[] ids,@Param("keyWord")String keyWord); } diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/EqScrapServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/EqScrapServiceImpl.java index 40b2bf1..947ff01 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/EqScrapServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/EqScrapServiceImpl.java @@ -119,6 +119,7 @@ public class EqScrapServiceImpl extends BaseServiceImpl excels = iotThingBaseInfoDao.exportPartListByThingsId(relationTypeId,toId,ids); + List excels = iotThingBaseInfoDao.exportPartListByThingsId(relationTypeId,toId,ids,keyWord); return excels; } diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java index fa2b33c..26c4a25 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java @@ -187,6 +187,7 @@ public class IotThingsServiceImpl implements IotThingsService { IotThingBaseInfoDTO baseInfoDTO = new IotThingBaseInfoDTO(); BeanUtils.copyProperties(dto,baseInfoDTO); //*** + baseInfoDTO.setId(thingEntity.getId()); baseInfoDTO.setThingId(thingEntity.getId()); baseInfoDTO.setScrap("0"); baseInfoDTO.setScrapDisposal("0"); diff --git a/modules/equipment/src/main/java/com/thing/eq/tree/controller/DeviceController.java b/modules/equipment/src/main/java/com/thing/eq/tree/controller/DeviceController.java index 4241b32..24ae894 100644 --- a/modules/equipment/src/main/java/com/thing/eq/tree/controller/DeviceController.java +++ b/modules/equipment/src/main/java/com/thing/eq/tree/controller/DeviceController.java @@ -108,10 +108,9 @@ public class DeviceController { newList.add(iotThingsExcel); } } + } else{ + newList.addAll(list); } -// else{ -// newList.addAll(list); -// } ExcelUtils.exportExcel(newList,null, "设备台账", IotThingsExcel.class,"设备台账.xls",response); } @@ -148,10 +147,9 @@ public class DeviceController { newList.add(iotThingsPartExcel); } } + } else{ + newList.addAll(list); } -// else{ -// newList.addAll(list); -// } ExcelUtils.exportExcel(newList,null, "备件库", IotThingsPartExcel.class,"备件库.xls",response); } diff --git a/modules/equipment/src/main/resources/mapper/eqmanager/IotThingBaseInfoMapper.xml b/modules/equipment/src/main/resources/mapper/eqmanager/IotThingBaseInfoMapper.xml index f240d78..2ed807f 100644 --- a/modules/equipment/src/main/resources/mapper/eqmanager/IotThingBaseInfoMapper.xml +++ b/modules/equipment/src/main/resources/mapper/eqmanager/IotThingBaseInfoMapper.xml @@ -25,7 +25,7 @@ - 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} @@ -130,27 +130,25 @@ FROM iot_thing_base_info baseinfo 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 + relation.root_id = #{relationTypeId} baseinfo.thing_id in #{thingId} + + and relation.from_id =#{toId} + and (things.name like concat('%',#{keyWord}::varchar,'%') or things.code like concat('%',#{keyWord}::varchar,'%') or baseinfo.eq_code like concat('%',#{keyWord}::varchar,'%') or baseinfo.standard like concat('%',#{keyWord}::varchar,'%')) - - and baseinfo.use_dept_id =#{params.useDeptId} - - - and things2.name like concat('%',#{eqTypeName}::varchar,'%') - order by things.create_date desc From 4eab6bf1006280e26eb728890454fb093d3ef31d Mon Sep 17 00:00:00 2001 From: xiezw Date: Tue, 27 Aug 2024 15:50:07 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86-2024?= =?UTF-8?q?0827=E4=BC=98=E5=8C=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 276 +----------------- 1 file changed, 3 insertions(+), 273 deletions(-) diff --git a/application/src/main/resources/application.yml b/application/src/main/resources/application.yml index fafb84c..3042094 100644 --- a/application/src/main/resources/application.yml +++ b/application/src/main/resources/application.yml @@ -1,541 +1,271 @@ server: - - port: 8070 - + port: 18080 servlet: - context-path: /thing - spring: - cache: - type: caffeine # 支持 redis/caffeine, 当选择redis时,要在application.yml中配置redis连接信息 - main: - allow-bean-definition-overriding: true - allow-circular-references: true - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - enabled: true - messages: - encoding: UTF-8 - basename: i18n/messages - data: - redis: - host: 192.168.188.185 - port: 7963 - password: Sddt8888! - database: 5 - #项目入口签名 - title: - sign: ck #企业签名 - technical: - phone: - map-bucket: geojson #地图文件路径 - - queue: - type: in-memory # 队列类型: inMemory / disruptor - inMemory: - maxSize: 500 - pollInterval: 100 - disruptor: - maximumPoolSize: 8 - bufferSize: 256 # 指定ringbuffer字节大小,当前值将乘1024 - partitions: - hash_function_name: murmur3_128 # murmur3_32, murmur3_128 or sha256 - core: - topic: queue_core - poll-interval: 1000 - partitions: 30 - debug: false - log-interval: 300 - rabbitmq: - exchange_name: - host: localhost - port: 5673 - virtual_host: / - username: guest - password: guest - automatic_recovery_enabled: false - connection_timeout: 60000 - handshake_timeout: 10000 - queue-properties: - core: x-max-length-bytes:1048576000;x-message-ttl:604800000 - #数据源配置 - database: - ts_kv: - type: postgresql # 时序数据存储类型 clickhouse/timescale/postgresql/tidb/mysql - latest: - type: postgresql # 最新数据存储类型 postgresql/timescale/mysql/tidb/clickhouse - save_maximumPoolSize: 12 - # 数据源及mybatis、mybatis-flex配置 - mybatis-flex: - typeAliasesPackage: com.thing.**.mapper - mapperLocations: classpath*:/mapper/**/*.xml - #本部分(Configuration)的配置都为 MyBatis 原生支持的配置,有关配置请参考:https://mybatis.org/mybatis-3/zh/configuration.html#%E8%AE%BE%E7%BD%AE%EF%BC%88settings%EF%BC%89 - configuration: - mapUnderscoreToCamelCase: true - autoMappingBehavior: FULL - autoMappingUnknownColumnBehavior: NONE - cacheEnabled: true - global-config: - print-banner: true - normal-value-of-logic-delete: 0 - deleted-value-of-logic-delete: 1 - datasource: - pg: - type: com.zaxxer.hikari.HikariDataSource - - url: jdbc:postgresql://192.168.188.184:5432/thingbi_v3 - + url: jdbc:postgresql://192.168.188.185:5432/thing_v2 driver-class-name: org.postgresql.Driver - username: postgres - password: sddt8888 - postgresql: - type: com.zaxxer.hikari.HikariDataSource - - url: jdbc:postgresql://192.168.188.184:5432/thingbi_v3 - + url: jdbc:postgresql://192.168.188.185:5432/thing_v2 driver-class-name: org.postgresql.Driver - username: postgres - password: sddt8888 - sqlServer: - type: com.zaxxer.hikari.HikariDataSource - url: jdbc:sqlserver://127.0.0.1:1433;databaseName=销售生产其他 - driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver - username: czj - password: 1234 - - # 区间统计计算相关配置 - calculate: - am_total: - offset: 24 #当数据出现断点时,向后偏移查询多少小时 - interval: 15 # 分区间统计,间隔时长(分)1/3/5/10/15/20/30/60 - keys: A29,B2,C2,C6,D2,D4,E3,E4,F4,G2,G4,H2,I2,I4,K2,N2,N4,P4,Q2,R2,R4,S2,S4,F2,T2,T4,U2,U4,J2,J4,L2,A30,P2,Q4,V2,V4,A29_rush,A29_peak,A29_valley,A29_normal,A29_generate,A30_rush,A30_peak,A30_valley,A30_normal,tce_C6,tce_A29,tce_E3,CO2_A29,CO2_C6,CO2_E3,CO2_run,tce_run,tce_E3,A201,A202,A204,tce_J2 - ddmmyy: #例如:每月1号0时0分 开始统计年/月/日用量 - start_hh: 0 #小时/天/月/年 用量统计开始的分钟数(0-59) - start_dd: 0 #天/月/年 用量统计开始的小时(0-23) - start_mm: 1 #月/年 用量统计开始的天(1-30) - start_yy: 1 #年 用量统计开始的月份(1-12) - maximumPoolSize: 12 - - # 产品碳足迹 相关配置 - carbon: - syncButton: false - pub: - # 公共服务侧租户标识 - tenantTag: 公共服务 - api: - secret: nba!w^0@01 - - #物管理相关配置 - thing: - # token 过期时间 30天 - token: - expire: 2592000 - - ##数据解析配置 - nashorn: - # JS Eval max request timeout. 0 - no timeout - max_requests_timeout: 0 - # Specify thread pool size for javascript executor service - js_thread_pool_size: 120 - # Specify thread pool size for JavaScript sandbox resource monitor - monitor_thread_pool_size: 12 - # Maximum CPU time in milliseconds allowed for script execution - max_cpu_time: 8000 - tbel: - # JS Eval max request timeout. 0 - no timeout - max_requests_timeout: 0 - # Specify thread pool size for javascript executor service - thread_pool_size: 100 - # Maximum allowed TBEL script execution memory - max_memory_limit_mb: 8 - compiled_scripts_cache_size: 1000 - aviator: - # JS Eval max request timeout. 0 - no timeout - max_requests_timeout: 0 - # Specify thread pool size for javascript executor service - js_thread_pool_size: 100 - # Whether to put capturing groups into passed-in env map - # when regular-expression pattern matches - put_capturing_groups_into_env: false - # Max loop count to prevent too much CPU consumption. If it's value is zero or negative, it means - # no limitation on loop count.Default is zero. - max_loop_count: 1000 - #队列相关配置 - transport: - # Enable/disable http/mqtt/... transport protocols (has higher priority than certain protocol's 'enabled' property) - api_enabled: true - sessions: - inactivity_timeout: 300000 - report_timeout: 30000 - rate_limits: - enabled: false - # 1s 10次,60s 300次 - device: 10:1,300:60 - # Local HTTP transport parameters - http: - # Enable/disable http transport protocol. - enabled: false - request_timeout: 60000 - # Local MQTT transport parameters - mqtt: - # Enable/disable mqtt transport protocol. - enabled: false - bind_address: 0.0.0.0 - bind_port: 1883 - timeout: 10000 - netty: - leak_detector_level: DISABLED - boss_group_thread_count: 1 - worker_group_thread_count: 12 - max_payload_size: 65536 - so_keep_alive: false - #告警模块 配置 - alarm: - event_bus: - queue_size: 50 - core_pool_size: 5 - max_pool_size: 20 - - #swagger 文档配置 - springdoc: - swagger-ui: - path: /swagger-ui.html - packages-to-scan: com.thing - api-docs: - enabled: true - # knife4j的增强配置,不需要增强可以不配 - knife4j: - enable: true - setting: - language: zh_cn - #数据过滤配置 - filter: - rule: - enable: false - #项目状态 - management: - health: - redis: - enabled: false - endpoints: - enabled-by-default: true #暴露所有端点信息 - web: - exposure: - include: '*' #以web方式暴露 - - # 缓存管理 - cache-manager: - specs: - security: - timeToLiveInMinutes: 10 - maxSize: 50 - thingModel: - timeToLiveInMinutes: 1440 - maxSize: 10000 - authThingCodes: - timeToLiveInMinutes: 1440 - maxSize: 10000 - thingEntity: - timeToLiveInMinutes: 1440 - maxSize: 10000 - thingDict: - timeToLiveInMinutes: 1440 - maxSize: 10000 - thingDictRelation: - timeToLiveInMinutes: 1440 - maxSize: 10000 - thingDetailRelation: - timeToLiveInMinutes: 1440 - maxSize: 10000 - thingRootRelation: - timeToLiveInMinutes: 1440 - maxSize: 10000 - thingCalcConfig: - timeToLiveInMinutes: 525600 - maxSize: 10000 - filterRule: - timeToLiveInMinutes: 525600 - maxSize: 10000 - alarmRule: - timeToLiveInMinutes: 525600 - maxSize: 1000 - alarmRuleEntity: - timeToLiveInMinutes: 525600 - maxSize: 1000 - alarmRuleAction: - timeToLiveInMinutes: 525600 - maxSize: 1000 - scriptInfo: - timeToLiveInMinutes: 525600 - maxSize: 1000 - mockDataConfig: - timeToLiveInMinutes: 525600 - maxSize: 1000 - mockDataLatestTime: - timeToLiveInMinutes: 525600 - maxSize: 1000 From ba46dc4ac737b65a29221f02f5acf51112fc4de7 Mon Sep 17 00:00:00 2001 From: xiachao Date: Tue, 27 Aug 2024 15:56:08 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E7=B4=A0=E6=9D=90=E9=83=A8=E4=BB=B6?= =?UTF-8?q?=E7=BB=84=E7=AE=A1=E7=90=86=EF=BC=8C=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IotNewSourceMaterialController.java | 2 +- .../service/IotNewSourceMaterialService.java | 2 + .../impl/IotNewSourceMaterialServiceImpl.java | 9 +- modules/visual-design/pom.xml | 7 + .../service/IotVisualComponentService.java | 3 + .../impl/IotVisualComponentServiceImpl.java | 7 + .../controller/IotVisualGroupController.java | 29 ++- .../visual/group/dto/GroupInfoFormatDTO.java | 32 ++++ .../group/service/IotVisualGroupService.java | 10 +- .../impl/IotVisualGroupServiceImpl.java | 168 +++++++++++++----- 10 files changed, 215 insertions(+), 54 deletions(-) create mode 100644 modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupInfoFormatDTO.java diff --git a/modules/configuration/src/main/java/com/thing/configuration/newmaterial/controller/IotNewSourceMaterialController.java b/modules/configuration/src/main/java/com/thing/configuration/newmaterial/controller/IotNewSourceMaterialController.java index 73d3aa9..3ba96d7 100644 --- a/modules/configuration/src/main/java/com/thing/configuration/newmaterial/controller/IotNewSourceMaterialController.java +++ b/modules/configuration/src/main/java/com/thing/configuration/newmaterial/controller/IotNewSourceMaterialController.java @@ -127,7 +127,7 @@ public class IotNewSourceMaterialController { @PostMapping("export") @Operation(summary="导出") @Parameters({ - @Parameter(name ="groupIds",description ="部件组id 多个以英文逗号分割"), + @Parameter(name ="groupIds",description ="素材组id 多个以英文逗号分割"), @Parameter(name ="name",description ="素材名称"), @Parameter(name ="type",description ="文件类型"), @Parameter(name ="ids",description ="id数组"), diff --git a/modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/IotNewSourceMaterialService.java b/modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/IotNewSourceMaterialService.java index c8a8a74..6ec232d 100644 --- a/modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/IotNewSourceMaterialService.java +++ b/modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/IotNewSourceMaterialService.java @@ -32,4 +32,6 @@ public interface IotNewSourceMaterialService extends IBaseService getInfoByGroupIds(List groupIds); } \ No newline at end of file diff --git a/modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/impl/IotNewSourceMaterialServiceImpl.java b/modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/impl/IotNewSourceMaterialServiceImpl.java index 40e94ae..dc5d52c 100644 --- a/modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/impl/IotNewSourceMaterialServiceImpl.java +++ b/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.sys.biz.dto.SysUserDTO; 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.security.context.TenantContext; import com.thing.sys.security.context.UserContext; @@ -240,4 +239,12 @@ public class IotNewSourceMaterialServiceImpl extends BaseServiceImpl getInfoByGroupIds(List groupIds) { + + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq( "group_id", groupIds); + return this.mapper.selectListByQuery(wrapper); + } } \ No newline at end of file diff --git a/modules/visual-design/pom.xml b/modules/visual-design/pom.xml index dbccc95..3e084a5 100644 --- a/modules/visual-design/pom.xml +++ b/modules/visual-design/pom.xml @@ -27,5 +27,12 @@ com.thing.modules thing + + + com.thing.modules + configuration + + + diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java b/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java index 7d9aff9..96fa55b 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java +++ b/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java @@ -3,6 +3,8 @@ package com.thing.visual.component.service; import com.thing.common.orm.service.IBaseService; import com.thing.visual.component.entity.IotVisualComponentEntity; +import java.util.List; + /** * 部件设计信息 * @@ -11,4 +13,5 @@ import com.thing.visual.component.entity.IotVisualComponentEntity; */ public interface IotVisualComponentService extends IBaseService { + List getInfoByGroupIds(List groupIds); } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java b/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java index eb9ab1b..7eb2ea8 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java +++ b/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java @@ -7,6 +7,7 @@ import com.thing.visual.component.mapper.IotVisualComponentMapper; import com.thing.visual.component.service.IotVisualComponentService; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Map; /** @@ -25,4 +26,10 @@ public class IotVisualComponentServiceImpl extends BaseServiceImpl getInfoByGroupIds(List groupIds) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq( "group_id", groupIds); + return this.mapper.selectListByQuery(wrapper); + } } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java b/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java index a9ffbe5..141d4f0 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java @@ -4,10 +4,8 @@ import com.thing.common.core.constants.Constant; import com.thing.common.core.validator.AssertUtils; import com.thing.common.core.web.response.PageData; 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.visual.group.dto.NameSort; +import com.thing.thing.group.dto.IotGroupInfoFormatDTO; +import com.thing.visual.group.dto.*; import com.thing.visual.group.service.IotVisualGroupService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -40,6 +38,7 @@ public class IotVisualGroupController { @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , @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 = "组名称集合,多个组名称,以英文逗号分割") @@ -81,7 +80,7 @@ public class IotVisualGroupController { } @DeleteMapping - @Operation(summary="删除") + @Operation(summary="删除 这个接口删除二级右侧列表里面的数据,传入数据id") public Result delete(@RequestBody Long[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); @@ -89,6 +88,13 @@ public class IotVisualGroupController { return new Result<>(); } + @DeleteMapping("group") + @Operation(summary="删除 这个接口删除一级左侧列表里面的数据,传入组名称") + public Result deleteGroup(@RequestParam(required = false) String name, @RequestParam(required = true) String type){ + return new Result().ok(iotVisualGroupService.deleteGroup(name,type)); + } + + @GetMapping("groupInfo") @Operation(summary="左侧组列表,可按名称模糊查询") @@ -111,4 +117,17 @@ public class IotVisualGroupController { String data = iotVisualGroupService.adjustGroupSort(dto); return new Result().ok(data); } + + @GetMapping("listTree") + @Operation(summary="返回所有可见组的树结构,部件素材侧边栏使用(组级别是虚拟的,没有id生成的虚拟id)") + @Parameters({ + @Parameter(name ="type",description ="1素材,2部件"), + @Parameter(name ="name",description ="组名称") + }) + public Result> listTree(String type, String name){ + return iotVisualGroupService.listTree(type,name); + } + + + } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupInfoFormatDTO.java b/modules/visual-design/src/main/java/com/thing/visual/group/dto/GroupInfoFormatDTO.java new file mode 100644 index 0000000..e39b800 --- /dev/null +++ b/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 typeList; + +} diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java b/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java index 2a23545..a85d3c5 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/service/IotVisualGroupService.java @@ -1,10 +1,9 @@ package com.thing.visual.group.service; +import com.thing.common.core.web.response.Result; 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.visual.group.dto.NameSort; +import com.thing.thing.group.dto.IotGroupInfoFormatDTO; +import com.thing.visual.group.dto.*; import com.thing.visual.group.entity.IotVisualGroupEntity; import java.util.List; @@ -28,4 +27,7 @@ public interface IotVisualGroupService extends IBaseService groupInfo(String name, String type); + String deleteGroup(String name, String type); + + Result> listTree(String type, String name); } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java index 2bd5ce1..9d80ad2 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java @@ -2,24 +2,28 @@ package com.thing.visual.group.service.impl; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.update.UpdateChain; -import com.mybatisflex.core.update.UpdateWrapper; +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.configuration.newmaterial.entity.IotNewSourceMaterialEntity; +import com.thing.configuration.newmaterial.service.IotNewSourceMaterialService; import com.thing.sys.security.context.UserContext; -import com.thing.visual.group.dto.AdjustGroupDto; -import com.thing.visual.group.dto.GroupSortInfo; -import com.thing.visual.group.dto.IotVisualGroupDTO; -import com.thing.visual.group.dto.NameSort; +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.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 java.util.Arrays; -import java.util.List; -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; @@ -28,20 +32,34 @@ import static com.thing.visual.group.entity.table.IotVisualGroupEntityTableDef.I /** * 素材部件组管理 * - * @author xc + * @author xc * @since 3.0 2024-08-21 */ @Service public class IotVisualGroupServiceImpl extends BaseServiceImpl implements IotVisualGroupService { + + + @Autowired + private IotNewSourceMaterialService iotNewSourceMaterialService; + @Autowired + private IotVisualComponentService iotVisualComponentService; + + + + @Override public QueryWrapper getWrapper(Map params){ Long tenantCode = UserContext.getTenantCode(); QueryWrapper wrapper = new QueryWrapper(); String name = MapUtils.getString(params,"name"); String names = MapUtils.getString(params,"names"); - List nameList = Arrays.asList(names.split(",")); + List 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)); @@ -54,16 +72,7 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl sortInfo = this.getNameSort(dto.getName(),dto.getType()); - GroupSortInfo groupSortInfo =null; - if(ObjectUtils.isEmpty(sortInfo)){ - //如果sortInfo 是空得话,那就是没有,组得排序给当前最大值+1,类型给默认值1 - groupSortInfo = this.groupSortInfo(null,dto.getType()); - - }else { - //如果不是空,那就获取这个组得序号,组类型最大值+1 - groupSortInfo = this.groupSortInfo(dto.getName(),dto.getType()); - } + GroupSortInfo groupSortInfo = this.groupSortInfo(dto.getName(),dto.getType()); dto.setSort(groupSortInfo.getSort()); dto.setBsSort(groupSortInfo.getBsSort()); this.saveDto(dto); @@ -82,17 +91,17 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl{ - if(dto.getOldBusinessName().equals(temp.getName())){ + if(dto.getBusinessName().equals(temp.getName())){ UpdateChain.of(IotVisualGroupEntity.class) - .set(IotVisualGroupEntity::getSort, temp.getSort()) + .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::getSort, temp.getSort()) - .set(IotVisualGroupEntity::getThumbnailUrl,dto.getThumbnailUrl()) - .set(IotVisualGroupEntity::getBusinessName,dto.getBusinessName()) - .set(IotVisualGroupEntity::getRemark,dto.getRemark()) + .set(IotVisualGroupEntity::getBsSort, temp.getSort()) .where(IotVisualGroupEntity::getName).eq(dto.getName()).eq(IotVisualGroupEntity::getBusinessName,temp.getName()) .update(); } @@ -107,20 +116,22 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl{ - UpdateChain.of(IotVisualGroupEntity.class) - .set(IotVisualGroupEntity::getSort, temp.getSort()) - .where(IotVisualGroupEntity::getName).eq(temp.getName()) - .update(); + 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(); + } }); } @@ -182,14 +201,70 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl entities = this.list(wrapper); + + List groupIds = entities.stream() + .map(IotVisualGroupEntity::getId) + .toList(); + //素材or部件 有被引用,则不允许删除 + List materialList = iotNewSourceMaterialService.getInfoByGroupIds(groupIds); + if(ObjectUtils.isNotEmpty(materialList)){ + return "当前组下有类型被引用,不允许删除!"; + } + List 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> listTree(String type, String name) { + List resultList = new ArrayList<>(); + QueryWrapper queryWrapper = QueryWrapper.create(); + queryWrapper.eq(IotVisualGroupEntity::getType,type); + queryWrapper.like(IotVisualGroupEntity::getName,name); + List infos = listAs(queryWrapper, IotVisualGroupDTO.class); + + Map> 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 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>().ok(resultList.parallelStream().sorted(Comparator.comparingLong(GroupInfoFormatDTO::getSort)).collect(Collectors.toList())); + } + /** * 获取所有排序信息,看没有没有穿name,传name了,就是组内排序,没传name就是组排序 @@ -197,14 +272,14 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl getNameSort(String name,String type){ - Long tenantCode = UserContext.getTenantCode(); + Long tenantCode = UserContext.getTenantCode(); QueryWrapper wrapper = new QueryWrapper(); if(ObjectUtils.isNotEmpty(name)){ - wrapper.select(max(IOT_VISUAL_GROUP_ENTITY.SORT).as("sort"), IOT_VISUAL_GROUP_ENTITY.BUSINESS_NAME.as("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.NAME).orderBy(IOT_VISUAL_GROUP_ENTITY.SORT,true); + 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); @@ -222,9 +297,16 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl list, int fromIndex, int toIndex,String name) { - if (fromIndex < 0 || fromIndex >= list.size() || toIndex < 0 || toIndex >= list.size()) { + 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); From 5a5fea28815594a4b56f65f0373b2241bc9566c7 Mon Sep 17 00:00:00 2001 From: xiachao Date: Wed, 28 Aug 2024 15:56:55 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E7=BB=84=E6=80=81=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=EF=BC=8C=E9=83=A8=E4=BB=B6=E8=AE=BE=E8=AE=A1=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IotVisualComponentController.java | 34 +++- .../visual/component/dto/AdjustSortInfo.java | 20 ++ .../component/dto/ComponentSortInfo.java | 30 +++ .../thing/visual/component/dto/GroupInfo.java | 18 ++ .../component/dto/IotVisualComponentDTO.java | 12 +- .../entity/IotVisualComponentEntity.java | 2 +- .../service/IotVisualComponentService.java | 16 ++ .../impl/IotVisualComponentServiceImpl.java | 174 ++++++++++++++++++ .../impl/IotVisualGroupServiceImpl.java | 2 +- 9 files changed, 301 insertions(+), 7 deletions(-) create mode 100644 modules/visual-design/src/main/java/com/thing/visual/component/dto/AdjustSortInfo.java create mode 100644 modules/visual-design/src/main/java/com/thing/visual/component/dto/ComponentSortInfo.java create mode 100644 modules/visual-design/src/main/java/com/thing/visual/component/dto/GroupInfo.java diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/controller/IotVisualComponentController.java b/modules/visual-design/src/main/java/com/thing/visual/component/controller/IotVisualComponentController.java index ac1fe86..3dd9bce 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/component/controller/IotVisualComponentController.java +++ b/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.web.response.PageData; 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.service.IotVisualComponentService; @@ -19,6 +21,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; /** @@ -41,17 +44,19 @@ public class IotVisualComponentController { @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , @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> page(@Parameter(hidden = true) @RequestParam Map params){ - PageData page = iotVisualComponentService.getPageData(params, IotVisualComponentDTO.class); + PageData page = iotVisualComponentService.getPageDataInfo(params); return new Result>().ok(page); } @GetMapping("{id}") @Operation(summary="信息") public Result get(@PathVariable("id") Long id){ - IotVisualComponentDTO data = iotVisualComponentService.getByIdAs(id, IotVisualComponentDTO.class); + IotVisualComponentDTO data = iotVisualComponentService.getByIdDto(id); return new Result().ok(data); } @@ -71,7 +76,7 @@ public class IotVisualComponentController { public Result update(@RequestBody IotVisualComponentDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - iotVisualComponentService.updateDto(dto); + iotVisualComponentService.updateIotVisualComponentDTO(dto); return new Result<>(); } @@ -86,4 +91,25 @@ public class IotVisualComponentController { } + @GetMapping("sort") + @Operation(summary="当前组的最大序号") + public Result getSort(@RequestParam("groupId") Long groupId){ + Integer sort = iotVisualComponentService.getSort(groupId); + return new Result().ok(sort); + } + + @GetMapping("businessList") + @Operation(summary="定制接口,获取 远程组件 类型列表,新增组件的时候使用") + public Result> businessList(){ + List businessList = iotVisualComponentService.businessList(); + return new Result>().ok(businessList); + } + + @GetMapping("adjustSort") + @Operation(summary="拖动修改排序") + public Result adjustSort(AdjustSortInfo sortInfo){ + String data = iotVisualComponentService.adjustSort(sortInfo); + return new Result().ok(data); + } + } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/dto/AdjustSortInfo.java b/modules/visual-design/src/main/java/com/thing/visual/component/dto/AdjustSortInfo.java new file mode 100644 index 0000000..4ff0630 --- /dev/null +++ b/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; + +} diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/dto/ComponentSortInfo.java b/modules/visual-design/src/main/java/com/thing/visual/component/dto/ComponentSortInfo.java new file mode 100644 index 0000000..be1a025 --- /dev/null +++ b/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; + +} \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/dto/GroupInfo.java b/modules/visual-design/src/main/java/com/thing/visual/component/dto/GroupInfo.java new file mode 100644 index 0000000..5aeb3f8 --- /dev/null +++ b/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; + + +} diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/dto/IotVisualComponentDTO.java b/modules/visual-design/src/main/java/com/thing/visual/component/dto/IotVisualComponentDTO.java index cb63093..a2f4d42 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/component/dto/IotVisualComponentDTO.java +++ b/modules/visual-design/src/main/java/com/thing/visual/component/dto/IotVisualComponentDTO.java @@ -24,7 +24,13 @@ public class IotVisualComponentDTO implements Serializable { @Schema(description = "部件名称") private String name; @Schema(description = "部件组id") - private Integer groupId; + private Long groupId; + + @Schema(description = "部件组名称") + private String groupName; + @Schema(description = "部件组类型名称") + private String groupBusinessName; + @Schema(description = "部件类型") private String type; @Schema(description = "部件备注描述") @@ -56,4 +62,8 @@ public class IotVisualComponentDTO implements Serializable { @Schema(description = "部件排序序号") private Integer sort; + private Integer oldSort; + + + } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/entity/IotVisualComponentEntity.java b/modules/visual-design/src/main/java/com/thing/visual/component/entity/IotVisualComponentEntity.java index a6f8435..7476051 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/component/entity/IotVisualComponentEntity.java +++ b/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 */ - private Integer groupId; + private Long groupId; /** * 部件类型 */ diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java b/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java index 96fa55b..648938e 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java +++ b/modules/visual-design/src/main/java/com/thing/visual/component/service/IotVisualComponentService.java @@ -1,9 +1,14 @@ package com.thing.visual.component.service; +import com.thing.common.core.web.response.PageData; 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 java.util.List; +import java.util.Map; /** * 部件设计信息 @@ -14,4 +19,15 @@ import java.util.List; public interface IotVisualComponentService extends IBaseService { List getInfoByGroupIds(List groupIds); + + Integer getSort(Long groupId); + + List businessList(); + + String adjustSort(AdjustSortInfo sortInfo); + void updateIotVisualComponentDTO(IotVisualComponentDTO dto); + + PageData getPageDataInfo(Map params); + + IotVisualComponentDTO getByIdDto(Long id); } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java b/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java index 7eb2ea8..99d951f 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java +++ b/modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java @@ -1,14 +1,32 @@ package com.thing.visual.component.service.impl; 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.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.mapper.IotVisualComponentMapper; 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 java.util.Arrays; import java.util.List; 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; /** * 部件设计信息 @@ -19,9 +37,26 @@ import java.util.Map; @Service public class IotVisualComponentServiceImpl extends BaseServiceImpl implements IotVisualComponentService { + + @Autowired + private IotVisualGroupService iotVisualGroupService; + + + @Override public QueryWrapper getWrapper(Map params){ QueryWrapper wrapper = new QueryWrapper(); + String name = MapUtils.getString(params,"name"); + String groupIds = MapUtils.getString(params,"names"); + List 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; } @@ -32,4 +67,143 @@ public class IotVisualComponentServiceImpl extends BaseServiceImpl 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 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 getPageDataInfo(Map params) { + + PageData 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 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 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 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 list) { + Integer sortValue = 1; + for (ComponentSortInfo item : list) { + item.setSort(sortValue++); + } + } } \ No newline at end of file diff --git a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java index 9d80ad2..a4afe8f 100644 --- a/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java +++ b/modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java @@ -148,7 +148,7 @@ public class IotVisualGroupServiceImpl extends BaseServiceImpl{ UpdateChain.of(IotVisualGroupEntity.class) - .set(IotVisualGroupEntity::getSort, temp.getSort()) + .set(IotVisualGroupEntity::getBsSort, temp.getSort()) .where(IotVisualGroupEntity::getName).eq(dto.getName()).eq(IotVisualGroupEntity::getBusinessName,temp.getName()) .update(); }); From cab73d9ce0754898cce0494cefa53a76cffc1932 Mon Sep 17 00:00:00 2001 From: lishuai Date: Thu, 29 Aug 2024 10:31:55 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=88=90=E5=8A=9F=202024=E5=B9=B48=E6=9C=882?= =?UTF-8?q?9=E6=97=A510:31:52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/tenant/service/impl/SysTenantDetailServiceImpl.java | 3 +-- .../thing/thing/dict/service/impl/IotThingDictServiceImpl.java | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java b/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java index 333e6e9..90461bb 100644 --- a/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java +++ b/modules/thing/src/main/java/com/thing/sys/tenant/service/impl/SysTenantDetailServiceImpl.java @@ -414,7 +414,6 @@ public class SysTenantDetailServiceImpl extends BaseServiceImpl tenantCodeList = detailForm.getTenantCodeList(); diff --git a/modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java b/modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java index 87c9ee1..139ca07 100644 --- a/modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java +++ b/modules/thing/src/main/java/com/thing/thing/dict/service/impl/IotThingDictServiceImpl.java @@ -138,6 +138,7 @@ public class IotThingDictServiceImpl extends BaseServiceImpl