diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/UpdateDeptIdController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/UpdateDeptIdController.java deleted file mode 100644 index eeb04d0..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/UpdateDeptIdController.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.hnac.hzims.equipment.controller; - -import com.hnac.hzims.equipment.service.IUpdateDeptIdService; -import io.swagger.annotations.Api; -import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -@RestController -@AllArgsConstructor -@RequestMapping("/db/dataUpdate") -@Api(value = "更新所有业务数据机构ID和租户ID字段", tags = "更新所有业务数据机构ID和租户ID字段") -public class UpdateDeptIdController { - - @Resource(name="equipmentUpdateDeptIdService") - private IUpdateDeptIdService equipmentUpdateDeptIdService; - - @Resource(name="inspectUpdateDeptIdService") - private IUpdateDeptIdService inspectUpdateDeptIdService; - - @Resource(name="operationUpdateDeptIdService") - private IUpdateDeptIdService operationUpdateDeptIdService; - - @Resource(name="hzimsUpdateDeptIdService") - private IUpdateDeptIdService hzimsUpdateDeptIdService; - - @Resource(name="dutyUpdateDeptIdService") - private IUpdateDeptIdService dutyUpdateDeptIdService; - - @Resource(name="messageUpdateDeptIdService") - private IUpdateDeptIdService messageUpdateDeptIdService; - - @Resource(name="realMonitorUpdateDeptIdService") - private IUpdateDeptIdService realMonitorUpdateDeptIdService; - - @Resource(name="bladexUpdateDataService") - private IUpdateDeptIdService bladexUpdateDataService; - - -// @PostMapping("/updateDeptId") -// @ApiOperationSupport(order = 4) -// @ApiOperation(value = "更新所有业务数据部门机构字段", notes = "传入数据库相关信息") -// public R updateDeptId(@RequestBody UpdateDeptVo updateDeptVo) { -// if(StringUtils.isBlank(updateDeptVo.getDbName())) { -// return R.fail("请输入数据库名"); -// } -// if(null == updateDeptVo.getDataMappingList() || updateDeptVo.getDataMappingList().isEmpty()) { -// return R.fail("请输入机构ID映射信息"); -// } -// boolean result = false; -// switch (updateDeptVo.getDbName()) { -// case "equipment" : -// // 设备管理 -// result = equipmentUpdateDeptIdService.updateDeptId(updateDeptVo); -// break; -// case "hzims_inspect": -// // 巡检管理 -// result = inspectUpdateDeptIdService.updateDeptId(updateDeptVo); -// break; -// case "hzims_operation": -// result = operationUpdateDeptIdService.updateDeptId(updateDeptVo); -// break; -// case "hzims": -// result = hzimsUpdateDeptIdService.updateDeptId(updateDeptVo); -// break; -// case "duty": -// result = dutyUpdateDeptIdService.updateDeptId(updateDeptVo); -// break; -// case "message": -// result = messageUpdateDeptIdService.updateDeptId(updateDeptVo); -// break; -// case "realmonitor": -// result = realMonitorUpdateDeptIdService.updateDeptId(updateDeptVo); -// break; -// case "bladex": -// result = bladexUpdateDataService.updateDeptId(updateDeptVo); -// break; -// default: -// break; -// -// } -// if(result) { -// return R.success("成功"); -// } else { -// return R.fail("更新失败"); -// } -// } -// -// @PostMapping("/updateTenantId") -// @ApiOperationSupport(order = 5) -// @ApiOperation(value = "更新所有业务数据租户ID字段", notes = "传入数据库相关信息") -// public R updateTenantId(@RequestBody UpdateTenantVo updateTenantVo) { -// if(StringUtils.isBlank(updateTenantVo.getDbName())) { -// return R.fail("请输入数据库名"); -// } -// if(null == updateTenantVo.getDataMappingList() || updateTenantVo.getDataMappingList().isEmpty()) { -// return R.fail("请输入机构ID映射信息"); -// } -// boolean result = false; -// switch (updateTenantVo.getDbName()) { -// case "equipment" : -// // 设备管理 -// result = equipmentUpdateDeptIdService.updateTenantId(updateTenantVo); -// break; -// case "hzims_inspect": -// // 巡检管理 -// result = inspectUpdateDeptIdService.updateTenantId(updateTenantVo); -// break; -// case "hzims_operation": -// result = operationUpdateDeptIdService.updateTenantId(updateTenantVo); -// break; -// case "hzims": -// result = hzimsUpdateDeptIdService.updateTenantId(updateTenantVo); -// break; -// case "duty": -// result = dutyUpdateDeptIdService.updateTenantId(updateTenantVo); -// break; -// case "message": -// result = messageUpdateDeptIdService.updateTenantId(updateTenantVo); -// break; -// case "realmonitor": -// result = realMonitorUpdateDeptIdService.updateTenantId(updateTenantVo); -// break; -// case "bladex" : -// result = bladexUpdateDataService.updateTenantId(updateTenantVo); -// break; -// default: -// break; -// -// } -// if(result) { -// return R.success("成功"); -// } else { -// return R.fail("更新失败"); -// } -// } -// -// @PostMapping("/updateDeptIdByTenantId") -// @ApiOperationSupport(order = 5) -// @ApiOperation(value = "根据租户ID更新机构ID", notes = "传入数据库相关信息") -// public R updateDeptIdByTenantId(@RequestBody UpdateDeptIdByTenantIdVO updateDeptIdByTenantIdVO) { -// if(StringUtils.isBlank(updateDeptIdByTenantIdVO.getDbName())) { -// return R.fail("请输入数据库名"); -// } -// if(null == updateDeptIdByTenantIdVO.getDeptAndTenantIdList() || updateDeptIdByTenantIdVO.getDeptAndTenantIdList().isEmpty()) { -// return R.fail("请输入机构ID映射信息"); -// } -// boolean result = false; -// -// switch (updateDeptIdByTenantIdVO.getDbName()) { -// case "equipment" : -// // 设备管理 -// result = equipmentUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// case "hzims_inspect": -// // 巡检管理 -// result = inspectUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// case "hzims_operation": -// result = operationUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// case "hzims": -// result = hzimsUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// case "duty": -// result = dutyUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// case "message": -// result = messageUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// case "realmonitor": -// result = realMonitorUpdateDeptIdService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// case "bladex" : -// result = bladexUpdateDataService.updateDeptIdByTenantId(updateDeptIdByTenantIdVO); -// break; -// default: -// break; -// -// } -// if(result) { -// return R.success("成功"); -// } else { -// return R.fail("更新失败"); -// } -// } - -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IUpdateDeptIdService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IUpdateDeptIdService.java deleted file mode 100644 index 193bc57..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IUpdateDeptIdService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.equipment.service; - -import com.hnac.hzims.equipment.vo.UpdateDeptIdByTenantIdVO; -import com.hnac.hzims.equipment.vo.UpdateDeptVo; -import com.hnac.hzims.equipment.vo.UpdateTenantVo; - -import java.util.List; - -public interface IUpdateDeptIdService { - - boolean updateDeptId(UpdateDeptVo updateDeptVo); - - boolean updateTenantId(UpdateTenantVo updateTenantVo); - - boolean updateDeptIdByTenantId(UpdateDeptIdByTenantIdVO updateDeptIdByTenantIdVO); -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/BladexUpdateDataServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/BladexUpdateDataServiceImpl.java deleted file mode 100644 index 3126f6d..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/BladexUpdateDataServiceImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import org.springframework.stereotype.Service; - -@Service("bladexUpdateDataService") -@DS("bladex") -public class BladexUpdateDataServiceImpl extends UpdateDeptIdServiceImpl { -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/DutyUpdateDeptIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/DutyUpdateDeptIdServiceImpl.java deleted file mode 100644 index 80633db..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/DutyUpdateDeptIdServiceImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import org.springframework.stereotype.Service; - -@Service("dutyUpdateDeptIdService") -@DS("duty") -public class DutyUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl { -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EquipmentUpdateDeptIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EquipmentUpdateDeptIdServiceImpl.java deleted file mode 100644 index e905d4e..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EquipmentUpdateDeptIdServiceImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import com.hnac.hzims.equipment.entity.EmInfoEntity; -import com.hnac.hzims.equipment.mapper.UpdateDeptIdMapper; -import com.hnac.hzims.equipment.service.IUpdateDeptIdService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Service; - -@Service("equipmentUpdateDeptIdService") -@Primary -@DS("equipment") -public class EquipmentUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl { - -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/HzimsUpdateDeptIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/HzimsUpdateDeptIdServiceImpl.java deleted file mode 100644 index 09e5ee4..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/HzimsUpdateDeptIdServiceImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import org.springframework.stereotype.Service; - -@Service("hzimsUpdateDeptIdService") -@DS("hzims") -public class HzimsUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl{ -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/InspectUpdateDeptIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/InspectUpdateDeptIdServiceImpl.java deleted file mode 100644 index 93a26e1..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/InspectUpdateDeptIdServiceImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - - -import com.baomidou.dynamic.datasource.annotation.DS; -import org.springframework.stereotype.Service; - -@Service("inspectUpdateDeptIdService") -@DS("inspect") -public class InspectUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl { -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/MessageUpdateDeptIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/MessageUpdateDeptIdServiceImpl.java deleted file mode 100644 index 0b87855..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/MessageUpdateDeptIdServiceImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import org.springframework.stereotype.Service; - -@Service("messageUpdateDeptIdService") -@DS("message") -public class MessageUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl { -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/OperationUpdateIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/OperationUpdateIdServiceImpl.java deleted file mode 100644 index b0337fb..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/OperationUpdateIdServiceImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import org.springframework.stereotype.Service; - -@Service("operationUpdateDeptIdService") -@DS("operation") -public class OperationUpdateIdServiceImpl extends UpdateDeptIdServiceImpl { -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/RealMonitorUpdateDeptIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/RealMonitorUpdateDeptIdServiceImpl.java deleted file mode 100644 index 6f97720..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/RealMonitorUpdateDeptIdServiceImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.baomidou.dynamic.datasource.annotation.DS; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Service; - -@Service("realMonitorUpdateDeptIdService") -@DS("realMonitor") -public class RealMonitorUpdateDeptIdServiceImpl extends UpdateDeptIdServiceImpl { -} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/UpdateDeptIdServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/UpdateDeptIdServiceImpl.java deleted file mode 100644 index d3c4efd..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/UpdateDeptIdServiceImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.hnac.hzims.equipment.service.impl; - -import com.google.common.base.Joiner; -import com.hnac.hzims.common.logs.utils.StringUtils; -import com.hnac.hzims.equipment.entity.EmInfoEntity; -import com.hnac.hzims.equipment.mapper.UpdateDeptIdMapper; -import com.hnac.hzims.equipment.service.IUpdateDeptIdService; -import com.hnac.hzims.equipment.vo.DataMappingVo; -import com.hnac.hzims.equipment.vo.UpdateDeptIdByTenantIdVO; -import com.hnac.hzims.equipment.vo.UpdateDeptVo; -import com.hnac.hzims.equipment.vo.UpdateTenantVo; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; - -public class UpdateDeptIdServiceImpl extends ServiceImpl implements IUpdateDeptIdService { - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateDeptId(UpdateDeptVo updateDeptVo) { - Map map = new HashMap<>(); - if(StringUtils.isNotBlank(updateDeptVo.getTableName())) { - // 更新具体的表的字段 - if("blade_user".equals(updateDeptVo.getTableName())){ - List> list = baseMapper.getBladeUserList(); - if(null != list && !list.isEmpty()) { - for(Map mapTemp : list) { - String deptIds = (String)mapTemp.get("dept_ids"); - deptIds = searchDeptId(deptIds, updateDeptVo.getDataMappingList()); - mapTemp.put("dept_ids", deptIds); - String deptId = (String)mapTemp.get("dept_id"); - deptId = searchDeptId(deptId, updateDeptVo.getDataMappingList()); - map.put("dept_id", deptId); - baseMapper.updateBladeUserDeptIds(mapTemp); - } - } - } else { - map.put("tableName", updateDeptVo.getTableName()); - map.put("columnName", updateDeptVo.getColumnName()); - updateDeptVo.getDataMappingList().stream().forEach(item -> { - map.put("oldDeptId", item.getOldId()); - map.put("newDeptId", item.getNewId()); - baseMapper.updateTableDeptId(map); - }); - } - - } else { - // 更新整个库的create_dept字段 - List> tableList = baseMapper.getTablesList(); - if(null != tableList && !tableList.isEmpty()) { - for(Map item : tableList) { - map.put("tableName", item.get("TABLE_NAME")); - map.put("columnName", "create_dept"); - if(item.get("TABLE_NAME").toString().toLowerCase().indexOf("log") >= 0 || item.get("TABLE_NAME").toString().toLowerCase().indexOf("copy1") >= 0) { - continue; - } - List> tableColumns = baseMapper.getTableColumnList(item); - boolean flag = false; - if(null != tableColumns && !tableColumns.isEmpty()) { - for(Map columnMap : tableColumns) { - if("create_dept".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) { - flag = true; - break; - } - } - } - if(flag) { - updateDeptVo.getDataMappingList().stream().forEach(item1 -> { - map.put("oldDeptId", item1.getOldId()); - map.put("newDeptId", item1.getNewId()); - baseMapper.updateTableDeptId(map); - }); - } - } - } - } - return true; - } - - private String searchDeptId(String deptIds, List dataMappingList) { - if(StringUtils.isNotBlank(deptIds)) { - String[] deptIdsArr =deptIds.split(","); - for(int i = 0; i< deptIdsArr.length; i++) { - for(DataMappingVo dataMappingVo : dataMappingList) { - if(deptIdsArr[i].equals(dataMappingVo.getOldId().toString())) { - deptIdsArr[i] = dataMappingVo.getNewId().toString(); - break; - } - } - } - return Joiner.on(',').join(deptIdsArr); - } - return null; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateTenantId(UpdateTenantVo updateTenantVo) { - Map map = new HashMap<>(); - List> tableList = baseMapper.getTablesList(); - if(null != tableList && !tableList.isEmpty()) { - for(Map item : tableList) { - if(item.get("TABLE_NAME").toString().toLowerCase().indexOf("log") >= 0 || item.get("TABLE_NAME").toString().toLowerCase().indexOf("copy1") >= 0) { - continue; - } - map.put("tableName", item.get("TABLE_NAME")); - map.put("columnName", "tenant_id"); - List> tableColumns = baseMapper.getTableColumnList(item); - boolean flag = false; - if(null != tableColumns && !tableColumns.isEmpty()) { - for(Map columnMap : tableColumns) { - if("tenant_id".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) { - flag = true; - break; - } - } - } - if(flag) { - updateTenantVo.getDataMappingList().stream().forEach(item1 -> { - map.put("oldTenantId", item1.getOldId()); - map.put("newTenantId", item1.getNewId()); - baseMapper.updateTableTenantId(map); - }); - } - } - } - return true; - } - - @Override - public boolean updateDeptIdByTenantId(UpdateDeptIdByTenantIdVO updateDeptIdByTenantIdVO) { - Map map = new HashMap<>(); - List> tableList = baseMapper.getTablesList(); - if(null != tableList && !tableList.isEmpty()) { - for(Map item : tableList) { - if(item.get("TABLE_NAME").toString().toLowerCase().indexOf("log") >= 0 || item.get("TABLE_NAME").toString().toLowerCase().indexOf("copy1") >= 0) { - continue; - } - map.put("tableName", item.get("TABLE_NAME")); - List> tableColumns = baseMapper.getTableColumnList(item); - int hasColumnCount = 0; - if(null != tableColumns && !tableColumns.isEmpty()) { - for(Map columnMap : tableColumns) { - if("tenant_id".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) { - hasColumnCount++; - } - if("create_dept".equalsIgnoreCase(columnMap.get("COLUMN_NAME").toString())) { - hasColumnCount++; - } - } - } - if(hasColumnCount == 2) { - updateDeptIdByTenantIdVO.getDeptAndTenantIdList().stream().forEach(item1 -> { - map.put("tenantId", item1.getTenantId()); - map.put("deptId", item1.getDeptId()); - baseMapper.updateDeptIdByTenantId(map); - }); - } - } - } - return true; - } - -} diff --git a/hzims-service/equipment/src/main/resources/template/template.yml b/hzims-service/equipment/src/main/resources/template/template.yml index 03de46d..5ab4b6f 100644 --- a/hzims-service/equipment/src/main/resources/template/template.yml +++ b/hzims-service/equipment/src/main/resources/template/template.yml @@ -19,18 +19,6 @@ spring: url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/equipment?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: ${hzinfo.db.busines.username} password: ${hzinfo.db.busines.password} - inspect: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims-inspect?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - hzims: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/hzims?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} - bladex: - url: jdbc:mysql://${hzinfo.db.busines.ip}:${hzinfo.db.busines.port}/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true - username: ${hzinfo.db.busines.username} - password: ${hzinfo.db.busines.password} #oss配置 oss: @@ -159,4 +147,4 @@ url: deLianUrl: http://iot.delianfa.com:8081/api/Docking/DockingData deLian: hostId: 400184 - passWord: 654321 \ No newline at end of file + passWord: 654321 diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInteraction.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInteraction.java new file mode 100644 index 0000000..e69de29 diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java index 5309f21..90e58a4 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java @@ -20,6 +20,7 @@ import com.hnac.hzinfo.exception.HzServiceException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.utils.Func; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; @@ -28,6 +29,7 @@ import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; /** @@ -50,10 +52,11 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public void ask(String question, String sessionId, String userId) { - Map params = new HashMap<>(); - params.put("chat_id",sessionId); + Map params = new HashMap<>(); + params.put("chat_id", sessionId); params.put("user_id", userId); - params.put("query",question); + params.put("query", question); + params.put("q_id", UUID.randomUUID()); Map authDataIds = this.getAuthDataIds(userId); params.putAll(authDataIds); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); @@ -68,30 +71,34 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public void specialAsk(String sessionId, String userId, Map extra) { - Map params = new HashMap<>(); - params.put("chat_id",sessionId); + Map params = new HashMap<>(); + params.put("chat_id", sessionId); params.put("user_id", userId); - params.put("extra",extra); + params.put("extra", extra); + params.put("q_id", UUID.randomUUID()); Map authDataIds = this.getAuthDataIds(userId); params.putAll(authDataIds); - log.info("调用大模型接口:{},传参为:{}",gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(),JSON.toJSONString(params)); + log.info("调用大模型接口:{},传参为:{}", gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(params)); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params); sessionRedisManager.addSessionId(sessionId); } @Override public void specialAsk(QuestionDTO question) { - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(question)); + Map questionMap = JsonUtil.toMap(JSON.toJSONString(question)); + questionMap.put("q_id", UUID.randomUUID()); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(questionMap)); sessionRedisManager.addSessionId(question.getChatId()); } @Override public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { - Map params = new HashMap<>(); + Map params = new HashMap<>(); params.put("chat_id", sessionId); params.put("user_id", userId); params.put("query", question); params.put("knowledge", knowledge); + params.put("q_id", UUID.randomUUID()); Map authDataIds = this.getAuthDataIds(userId); params.putAll(authDataIds); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); @@ -100,13 +107,17 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public void knowledgeAsk(QuestionDTO question) { - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(question)); + Map questionMap = JsonUtil.toMap(JSON.toJSONString(question)); + questionMap.put("q_id", UUID.randomUUID()); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(questionMap)); sessionRedisManager.addSessionId(question.getChatId()); } @Override public void analyseAsk(QuestionDTO question) { - RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(question)); + Map questionMap = JsonUtil.toMap(JSON.toJSONString(question)); + questionMap.put("q_id", UUID.randomUUID()); + RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(questionMap)); sessionRedisManager.addSessionId(question.getChatId()); } @@ -120,8 +131,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { @Override public void askAbort(String sessionId) { - Map params = new HashMap<>(); - params.put("chat_id",sessionId); + Map params = new HashMap<>(); + params.put("chat_id", sessionId); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params); sessionRedisManager.removeSessionId(sessionId); } @@ -130,73 +141,74 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService { this.askAbort(sessionId); // 循环获取该会话ID中断状态,当状态等于-2或重连超6次则中断返回结果 int status = 999; - int attempts = 0; + int attempts = 0; while (status > 0) { // 若重连超过10次 则抛出错误 - if(attempts >= 8) { + if (attempts >= 8) { throw new HzServiceException("中断失败!长时间未获取到中断状态"); } List answers = this.getAnswerBySessionIds(sessionId); - if(Func.isNotEmpty(answers)) { - log.info(answers.get(0).getStatus()+""); + if (Func.isNotEmpty(answers)) { + log.info(answers.get(0).getStatus() + ""); status = answers.get(0).getStatus(); } // 若获取到的状态不等于2 则延时0.5秒 - if(status > 0) { + if (status > 0) { try { Thread.sleep(500); } catch (InterruptedException e) { throw new RuntimeException(e); } } - attempts ++; + attempts++; } } @Override public void smartReportGeneratePower(RunReportAnalyseRequest req) { - Map params = new HashMap<>(); + Map params = new HashMap<>(); String sessionId = IdWorker.get32UUID(); - params.put("chat_id",sessionId); + params.put("chat_id", sessionId); params.put("user_id", CommonConstant.SYSTEM_USER.toString()); params.put("data", req.getAnalyseDTOS()); params.put("query", ""); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params); // 将sessionId存入redis,拿到数据之后输入月报中 JSONObject report = new JSONObject(); - report.put("stationCode",req.getStationCode()); - report.put("month",req.getMonth()); - report.put("sessionId",sessionId); - redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID,JSON.toJSONString(report)); - redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID,5, TimeUnit.MINUTES); + report.put("stationCode", req.getStationCode()); + report.put("month", req.getMonth()); + report.put("sessionId", sessionId); + redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID, JSON.toJSONString(report)); + redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID, 5, TimeUnit.MINUTES); } @Override public void updateKnowledge(String name) { - Map params = new HashMap<>(); - params.put("name",name); + Map params = new HashMap<>(); + params.put("name", name); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params); } @Override public List hotQuestions() { try { - return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference>(){}); - } - catch (Exception e) { - log.error("An error occurred",e); + return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference>() { + }); + } catch (Exception e) { + log.error("An error occurred", e); return Lists.newArrayList(); } } @Override public List getAnswerBySessionIds(String sessionIds) { - Map params = new HashMap<>(); - params.put("chat_ids",Func.toStrList(",",sessionIds).toArray()); - return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference>(){}); + Map params = new HashMap<>(); + params.put("chat_ids", Func.toStrList(",", sessionIds).toArray()); + return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference>() { + }); } - private Map getAuthDataIds(String userId) { + private Map getAuthDataIds(String userId) { Map result = new HashMap<>(2); R> authDataR = authClient.getAuthData(userId); result.putAll(authDataR.getData()); diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java index baf968b..3e6a8f8 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileInfoController.java @@ -5,6 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileInfoService; import com.hnac.gglm.bigmodel.maintenance.vo.IdRequest; +import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -13,9 +14,9 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; -import org.springblade.resource.feign.IOssClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -31,14 +32,12 @@ import org.springframework.web.multipart.MultipartFile; @AllArgsConstructor public class KnowledgeFileInfoController { private final KnowledgeFileInfoService knowledgeFileInfoService; - private final IOssClient ossClient; @GetMapping("/listPage") @ApiOperation(value = "分页查询") @ApiOperationSupport(order = 1) public R> listPage(Query query, KnowledgeFileInfo req) { - return R.data(knowledgeFileInfoService.page(Condition.getPage(query), - Condition.getQueryWrapper(new KnowledgeFileInfo(), req).orderByDesc(KnowledgeFileInfo::getCreateTime))); + return R.data(knowledgeFileInfoService.listPage(Condition.getPage(query), req)); } @GetMapping("/detail") @@ -52,6 +51,7 @@ public class KnowledgeFileInfoController { @ApiOperation(value = "保存") @ApiOperationSupport(order = 3) public R save(@RequestBody KnowledgeFileInfo req) { + req.setCreateUserName(AuthUtil.getUserName()); return R.status(knowledgeFileInfoService.save(req)); } @@ -73,7 +73,7 @@ public class KnowledgeFileInfoController { @ApiOperation(value = "上传文件") @ApiOperationSupport(order = 6) public R upload(@ApiParam(value = "上传文件", required = true) @RequestPart("file") MultipartFile file) { - return ossClient.putFile(file); + return knowledgeFileInfoService.upload(file); } @PostMapping("/store") @@ -82,4 +82,11 @@ public class KnowledgeFileInfoController { public R store(@RequestBody IdRequest req) { return R.status(knowledgeFileInfoService.store(req)); } + + @PostMapping("/batchStore") + @ApiOperation(value = "批量入库") + @ApiOperationSupport(order = 8) + public R batchStore(@RequestBody IdsRequest req) { + return R.status(knowledgeFileInfoService.batchStore(req)); + } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java index d8142a8..1f6d690 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java @@ -108,7 +108,7 @@ public class VectorParamController { return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken)); } - @PutMapping("/synchronization/") + @PutMapping("/synchronization") @ApiOperation(value = "同步") @ApiOperationSupport(order = 10) public R synchronization(@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileFragment.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileFragment.java index 2982ae1..c0af5d7 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileFragment.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileFragment.java @@ -18,7 +18,7 @@ import java.io.Serializable; */ @Data @EqualsAndHashCode(callSuper=false) -@TableName("knowledge_file_fragment") +@TableName("knowledge_file_segment") @ApiModel(value = "知识库文件分片信息",description = "知识库文件分片信息") public class KnowledgeFileFragment extends TenantEntity implements Serializable { private static final long serialVersionUID = 1L; diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java index 970b6da..3a74b3c 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileInfo.java @@ -65,4 +65,9 @@ public class KnowledgeFileInfo extends TenantEntity implements Serializable { @QueryField(condition = SqlCondition.LIKE) private String remark; + @ApiModelProperty("创建人名称") + @TableField("CREATE_USER_NAME") + @QueryField(condition = SqlCondition.LIKE) + private String createUserName; + } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java index cee156a..fb2f232 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java @@ -1,13 +1,26 @@ package com.hnac.gglm.bigmodel.maintenance.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.gglm.bigmodel.maintenance.vo.IdRequest; +import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; +import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.tool.api.R; +import org.springframework.web.multipart.MultipartFile; /** * @Author: ypj * @Date: 2024/9/10 16:42 */ public interface KnowledgeFileInfoService extends IService { + String SEGMENT_URL= "/kn/doc_segment"; + Boolean store(IdRequest req); + + Boolean batchStore(IdsRequest req); + + IPage listPage(IPage page, KnowledgeFileInfo req); + + R upload(MultipartFile file); } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java index 7af5942..23f7331 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java @@ -65,8 +65,8 @@ public class AgentLogServiceImpl extends ServiceImpl implements KnowledgeFileInfoService { private final KnowledgeFileInfoMapper knowledgeFileInfoMapper; + private final IOssClient ossClient; + + private final BigModelInteraction interactionConfig; @Override public Boolean store(IdRequest req) { KnowledgeFileInfo knowledgeFileInfo = knowledgeFileInfoMapper.selectById(req.getId()); + return store(knowledgeFileInfo, AuthUtil.getTenantId(), AuthUtil.getUserId(), AuthUtil.getDeptId()); + } + + private String getParamsJson(KnowledgeFileInfo knowledgeFileInfo, String tenantId, Long createUser, String createDept) { + Map params = new HashMap<>(); + params.put("doc_id", knowledgeFileInfo.getId().toString()); + params.put("url", knowledgeFileInfo.getUrl()); + params.put("tenant_id", tenantId); + params.put("create_user", createUser.toString()); + params.put("create_dept", createDept); + return JsonUtil.toJson(params); + } - LambdaUpdateWrapper queryWrapper = Wrappers.lambdaUpdate() + private Boolean store(KnowledgeFileInfo knowledgeFileInfo, String tenantId, Long createUser, String createDept) { + HttpResponse response = HttpRequest.post(interactionConfig.getUrl() + SEGMENT_URL) + .body(getParamsJson(knowledgeFileInfo, tenantId, createUser, createDept), "application/json") + .execute(); + if (!response.isOk()) { + return false; + } + LambdaUpdateWrapper wrapper = Wrappers.lambdaUpdate() .set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode()) - .eq(KnowledgeFileInfo::getId, req.getId()); - return this.update(queryWrapper); + .eq(KnowledgeFileInfo::getId, knowledgeFileInfo.getId()); + return this.update(wrapper); + } + + @Override + public Boolean batchStore(IdsRequest req) { + List list = knowledgeFileInfoMapper.selectBatchIds(req.getIds()); + final String tenantId = AuthUtil.getTenantId(); + final Long createUser = AuthUtil.getUserId(); + final String createDept = AuthUtil.getDeptId(); + list.forEach(knowledgeFileInfo -> { + store(knowledgeFileInfo, tenantId, createUser, createDept); + }); + LambdaUpdateWrapper wrapper = Wrappers.lambdaUpdate() + .set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode()) + .in(KnowledgeFileInfo::getId, req.getIds()); + return this.update(wrapper); + } + + @Override + public IPage listPage(IPage page, KnowledgeFileInfo req) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(KnowledgeFileInfo.class) + .like(ObjectUtil.isNotEmpty(req.getName()), KnowledgeFileInfo::getName, req.getName()) + .like(ObjectUtil.isNotEmpty(req.getUrl()), KnowledgeFileInfo::getUrl, req.getUrl()) + .like(ObjectUtil.isNotEmpty(req.getBriefs()), KnowledgeFileInfo::getBriefs, req.getBriefs()) + .eq(ObjectUtil.isNotEmpty(req.getDomain()), KnowledgeFileInfo::getDomain, req.getDomain()) + .eq(ObjectUtil.isNotEmpty(req.getAuthorityClass()), KnowledgeFileInfo::getAuthorityClass, req.getAuthorityClass()) + .eq(ObjectUtil.isNotEmpty(req.getVisible()), KnowledgeFileInfo::getVisible, req.getVisible()) + .eq(ObjectUtil.isNotEmpty(req.getFileStatus()), KnowledgeFileInfo::getFileStatus, req.getFileStatus()) + .like(ObjectUtil.isNotEmpty(req.getRemark()), KnowledgeFileInfo::getRemark, req.getRemark()) + .like(ObjectUtil.isNotEmpty(req.getTags()), KnowledgeFileInfo::getTags, req.getTags()) + .orderByDesc(KnowledgeFileInfo::getCreateTime); + return this.page(page, wrapper); + } + + @Override + public R upload(MultipartFile file) { + return ossClient.putFile(file); } } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java index 2057148..a197664 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; import java.util.Date; +//import static com.hnac.hzims.operational.main.constant.ScheduledConstant.START_STOP_TIME_RECORD; import static com.hnac.hzims.operational.main.constant.ScheduledConstant.THIS_DAY_START_STOP_RECORD; @@ -39,4 +40,18 @@ public class StartStopScheduledTask { service.thisDayStartStopRecord(param); return new ReturnT<>("SUCCESS"); } + + /** + * 设备开停机时间记录 + */ + //@XxlJob(START_STOP_TIME_RECORD) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT startStopTimeRecord() { + String param = ""; + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.startStopTimeRecord(param); + return new ReturnT<>("SUCCESS"); + } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index 6d92b14..1ea944f 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -23,10 +23,7 @@ import com.hnac.hzinfo.sdk.core.response.Result; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.jackson.JsonUtil; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.*; import org.springblade.mqtt.producer.IMqttSender; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -228,15 +225,19 @@ public class AlarmServiceImpl implements AlarmService { List soes = result.getData().getRecords(); // 查询当天数据中断告警记录 List saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - List entities = soes.stream().filter(o-> CollectionUtil.isEmpty(saves) || !saves.stream().map(InterruptionEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId())).map(soe->{ + List entities = soes.stream().filter( + o -> (CollectionUtil.isEmpty(saves) || !saves.stream().map(itr -> itr.getStationId() + itr.getRealId() + itr.getAlarmTime()).collect(Collectors.toList()).contains(o.getStation() + o.getRealId() + o.getTs())) + && StringUtil.isNotBlank(o.getStation())).map(soe->{ InterruptionEntity entity = new InterruptionEntity(); - List soeStations = stations.stream().filter(o->o.getCode().equals(soe.getStation())).collect(Collectors.toList()); - if(!CollectionUtil.isEmpty(soeStations)){ - entity.setStationId(soeStations.get(0).getCode()); - entity.setStationName(soeStations.get(0).getName()); - entity.setCreateDept(soeStations.get(0).getRefDept()); - entity.setTenantId(soeStations.get(0).getTenantId()); - entity.setCreateUser(soeStations.get(0).getCreateUser()); + Optional optional = stations.stream().filter(o->o.getCode().equals(soe.getStation())).findFirst(); + if(optional.isPresent()){ + entity.setStationId(optional.get().getCode()); + entity.setStationName(optional.get().getName()); + entity.setCreateDept(optional.get().getRefDept()); + entity.setTenantId(optional.get().getTenantId()); + entity.setCreateUser(optional.get().getCreateUser()); + }else{ + entity.setStationId(soe.getStation()); } entity.setAlarmId(soe.getId()); entity.setRealId(soe.getRealId()); @@ -248,8 +249,6 @@ public class AlarmServiceImpl implements AlarmService { if(InterruptionConstants.ABNORMAL_STATUS.equals(soe.getSoeAlarmType())){ entity.setStatus(1); } - - return entity; }).collect(Collectors.toList()); if(CollectionUtil.isEmpty(entities)){ diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/StartStopDurationService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/StartStopDurationService.java index 2c854e5..5db1340 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/StartStopDurationService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/StartStopDurationService.java @@ -9,4 +9,6 @@ import com.hnac.hzims.equipment.entity.StartStopDurationEntity; public interface StartStopDurationService extends IService { void thisDayStartStopRecord(String param); + + void startStopTimeRecord(String param); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java index d4e23d0..a65d855 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/equipment/impl/StartStopDurationServiceImpl.java @@ -149,6 +149,15 @@ public class StartStopDurationServiceImpl extends ServiceImpl