Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

# Conflicts:
#	hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/StartStopScheduledTask.java
zhongwei
yang_shj 2 months ago
parent
commit
9acc0baa33
  1. 190
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/UpdateDeptIdController.java
  2. 16
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IUpdateDeptIdService.java
  3. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/BladexUpdateDataServiceImpl.java
  4. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/DutyUpdateDeptIdServiceImpl.java
  5. 16
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EquipmentUpdateDeptIdServiceImpl.java
  6. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/HzimsUpdateDeptIdServiceImpl.java
  7. 10
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/InspectUpdateDeptIdServiceImpl.java
  8. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/MessageUpdateDeptIdServiceImpl.java
  9. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/OperationUpdateIdServiceImpl.java
  10. 10
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/RealMonitorUpdateDeptIdServiceImpl.java
  11. 164
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/UpdateDeptIdServiceImpl.java
  12. 12
      hzims-service/equipment/src/main/resources/template/template.yml
  13. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInteraction.java
  14. 83
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
  15. 17
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java
  16. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java
  17. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileFragment.java
  18. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java
  19. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java
  20. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java
  21. 81
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java

190
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/UpdateDeptIdController.java

@ -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("更新失败");
// }
// }
}

16
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IUpdateDeptIdService.java

@ -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);
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/BladexUpdateDataServiceImpl.java

@ -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 {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/DutyUpdateDeptIdServiceImpl.java

@ -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 {
}

16
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EquipmentUpdateDeptIdServiceImpl.java

@ -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 {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/HzimsUpdateDeptIdServiceImpl.java

@ -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{
}

10
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/InspectUpdateDeptIdServiceImpl.java

@ -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 {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/MessageUpdateDeptIdServiceImpl.java

@ -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 {
}

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/OperationUpdateIdServiceImpl.java

@ -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 {
}

10
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/RealMonitorUpdateDeptIdServiceImpl.java

@ -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 {
}

164
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/UpdateDeptIdServiceImpl.java

@ -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<UpdateDeptIdMapper, EmInfoEntity> implements IUpdateDeptIdService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateDeptId(UpdateDeptVo updateDeptVo) {
Map<String, Object> map = new HashMap<>();
if(StringUtils.isNotBlank(updateDeptVo.getTableName())) {
// 更新具体的表的字段
if("blade_user".equals(updateDeptVo.getTableName())){
List<Map<String, Object>> list = baseMapper.getBladeUserList();
if(null != list && !list.isEmpty()) {
for(Map<String, Object> 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<Map<String, Object>> tableList = baseMapper.getTablesList();
if(null != tableList && !tableList.isEmpty()) {
for(Map<String, Object> 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<Map<String, Object>> tableColumns = baseMapper.getTableColumnList(item);
boolean flag = false;
if(null != tableColumns && !tableColumns.isEmpty()) {
for(Map<String, Object> 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<DataMappingVo> 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<String, Object> map = new HashMap<>();
List<Map<String, Object>> tableList = baseMapper.getTablesList();
if(null != tableList && !tableList.isEmpty()) {
for(Map<String, Object> 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<Map<String, Object>> tableColumns = baseMapper.getTableColumnList(item);
boolean flag = false;
if(null != tableColumns && !tableColumns.isEmpty()) {
for(Map<String, Object> 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<String, Object> map = new HashMap<>();
List<Map<String, Object>> tableList = baseMapper.getTablesList();
if(null != tableList && !tableList.isEmpty()) {
for(Map<String, Object> 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<Map<String, Object>> tableColumns = baseMapper.getTableColumnList(item);
int hasColumnCount = 0;
if(null != tableColumns && !tableColumns.isEmpty()) {
for(Map<String, Object> 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;
}
}

12
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 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} username: ${hzinfo.db.busines.username}
password: ${hzinfo.db.busines.password} 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配置
oss: oss:

16
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInteraction.java

@ -0,0 +1,16 @@
package com.hnac.hzims.bigmodel.configuration;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @Author: ypj
* @Date: 2024/9/12 16:10
*/
@Data
@ConfigurationProperties(prefix = "gglm")
@Component
public class BigModelInteraction {
private String url;
}

83
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java

@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest; import com.hnac.hzims.bigmodel.business.dto.RunReportAnalyseRequest;
import com.hnac.hzims.bigmodel.business.feign.IAuthClient; import com.hnac.hzims.bigmodel.business.feign.IAuthClient;
import com.hnac.hzims.bigmodel.business.dto.RunReportDataAnalyseDTO;
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi;
import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.hzims.bigmodel.interactive.service.IHznlmInvokeService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
@ -21,6 +20,7 @@ import com.hnac.hzinfo.exception.HzServiceException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -51,10 +52,11 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override @Override
public void ask(String question, String sessionId, String userId) { public void ask(String question, String sessionId, String userId) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("chat_id",sessionId); params.put("chat_id", sessionId);
params.put("user_id", userId); params.put("user_id", userId);
params.put("query",question); params.put("query", question);
params.put("q_id", UUID.randomUUID());
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds); params.putAll(authDataIds);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params);
@ -69,30 +71,34 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override @Override
public void specialAsk(String sessionId, String userId, Map<String, Object> extra) { public void specialAsk(String sessionId, String userId, Map<String, Object> extra) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("chat_id",sessionId); params.put("chat_id", sessionId);
params.put("user_id", userId); params.put("user_id", userId);
params.put("extra",extra); params.put("extra", extra);
params.put("q_id", UUID.randomUUID());
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds); 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); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params);
sessionRedisManager.addSessionId(sessionId); sessionRedisManager.addSessionId(sessionId);
} }
@Override @Override
public void specialAsk(QuestionDTO question) { public void specialAsk(QuestionDTO question) {
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(question)); Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question));
questionMap.put("q_id", UUID.randomUUID());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(questionMap));
sessionRedisManager.addSessionId(question.getChatId()); sessionRedisManager.addSessionId(question.getChatId());
} }
@Override @Override
public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("chat_id", sessionId); params.put("chat_id", sessionId);
params.put("user_id", userId); params.put("user_id", userId);
params.put("query", question); params.put("query", question);
params.put("knowledge", knowledge); params.put("knowledge", knowledge);
params.put("q_id", UUID.randomUUID());
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds); params.putAll(authDataIds);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params);
@ -101,13 +107,17 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override @Override
public void knowledgeAsk(QuestionDTO question) { public void knowledgeAsk(QuestionDTO question) {
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(question)); Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question));
questionMap.put("q_id", UUID.randomUUID());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(questionMap));
sessionRedisManager.addSessionId(question.getChatId()); sessionRedisManager.addSessionId(question.getChatId());
} }
@Override @Override
public void analyseAsk(QuestionDTO question) { public void analyseAsk(QuestionDTO question) {
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(question)); Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question));
questionMap.put("q_id", UUID.randomUUID());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(questionMap));
sessionRedisManager.addSessionId(question.getChatId()); sessionRedisManager.addSessionId(question.getChatId());
} }
@ -121,8 +131,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override @Override
public void askAbort(String sessionId) { public void askAbort(String sessionId) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("chat_id",sessionId); params.put("chat_id", sessionId);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params);
sessionRedisManager.removeSessionId(sessionId); sessionRedisManager.removeSessionId(sessionId);
} }
@ -134,70 +144,71 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
int attempts = 0; int attempts = 0;
while (status > 0) { while (status > 0) {
// 若重连超过10次 则抛出错误 // 若重连超过10次 则抛出错误
if(attempts >= 8) { if (attempts >= 8) {
throw new HzServiceException("中断失败!长时间未获取到中断状态"); throw new HzServiceException("中断失败!长时间未获取到中断状态");
} }
List<AnswerVO> answers = this.getAnswerBySessionIds(sessionId); List<AnswerVO> answers = this.getAnswerBySessionIds(sessionId);
if(Func.isNotEmpty(answers)) { if (Func.isNotEmpty(answers)) {
log.info(answers.get(0).getStatus()+""); log.info(answers.get(0).getStatus() + "");
status = answers.get(0).getStatus(); status = answers.get(0).getStatus();
} }
// 若获取到的状态不等于2 则延时0.5秒 // 若获取到的状态不等于2 则延时0.5秒
if(status > 0) { if (status > 0) {
try { try {
Thread.sleep(500); Thread.sleep(500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
attempts ++; attempts++;
} }
} }
@Override @Override
public void smartReportGeneratePower(RunReportAnalyseRequest req) { public void smartReportGeneratePower(RunReportAnalyseRequest req) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
String sessionId = IdWorker.get32UUID(); String sessionId = IdWorker.get32UUID();
params.put("chat_id",sessionId); params.put("chat_id", sessionId);
params.put("user_id", CommonConstant.SYSTEM_USER.toString()); params.put("user_id", CommonConstant.SYSTEM_USER.toString());
params.put("data", req.getAnalyseDTOS()); params.put("data", req.getAnalyseDTOS());
params.put("query", ""); params.put("query", "");
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params);
// 将sessionId存入redis,拿到数据之后输入月报中 // 将sessionId存入redis,拿到数据之后输入月报中
JSONObject report = new JSONObject(); JSONObject report = new JSONObject();
report.put("stationCode",req.getStationCode()); report.put("stationCode", req.getStationCode());
report.put("month",req.getMonth()); report.put("month", req.getMonth());
report.put("sessionId",sessionId); report.put("sessionId", sessionId);
redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID,JSON.toJSONString(report)); redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID, JSON.toJSONString(report));
redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID,5, TimeUnit.MINUTES); redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID, 5, TimeUnit.MINUTES);
} }
@Override @Override
public void updateKnowledge(String name) { public void updateKnowledge(String name) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("name",name); params.put("name", name);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params);
} }
@Override @Override
public List hotQuestions() { public List hotQuestions() {
try { try {
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>(){}); return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>() {
} });
catch (Exception e) { } catch (Exception e) {
log.error("An error occurred",e); log.error("An error occurred", e);
return Lists.newArrayList(); return Lists.newArrayList();
} }
} }
@Override @Override
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { public List<AnswerVO> getAnswerBySessionIds(String sessionIds) {
Map<String,Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("chat_ids",Func.toStrList(",",sessionIds).toArray()); params.put("chat_ids", Func.toStrList(",", sessionIds).toArray());
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>(){}); return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>() {
});
} }
private Map<String,String[]> getAuthDataIds(String userId) { private Map<String, String[]> getAuthDataIds(String userId) {
Map<String, String[]> result = new HashMap<>(2); Map<String, String[]> result = new HashMap<>(2);
R<Map<String, String[]>> authDataR = authClient.getAuthData(userId); R<Map<String, String[]>> authDataR = authClient.getAuthData(userId);
result.putAll(authDataR.getData()); result.putAll(authDataR.getData());

17
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java

@ -5,6 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo;
import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService; import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService;
import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest; import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest;
import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; 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.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.oss.model.BladeFile; 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.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.resource.feign.IOssClient;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -31,14 +32,12 @@ import org.springframework.web.multipart.MultipartFile;
@AllArgsConstructor @AllArgsConstructor
public class KnowledgeFileInfoController { public class KnowledgeFileInfoController {
private final KnowledgeFileInfoService knowledgeFileInfoService; private final KnowledgeFileInfoService knowledgeFileInfoService;
private final IOssClient ossClient;
@GetMapping("/listPage") @GetMapping("/listPage")
@ApiOperation(value = "分页查询") @ApiOperation(value = "分页查询")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<IPage<KnowledgeFileInfo>> listPage(Query query, KnowledgeFileInfo req) { public R<IPage<KnowledgeFileInfo>> listPage(Query query, KnowledgeFileInfo req) {
return R.data(knowledgeFileInfoService.page(Condition.getPage(query), return R.data(knowledgeFileInfoService.listPage(Condition.getPage(query), req));
Condition.getQueryWrapper(new KnowledgeFileInfo(), req).orderByDesc(KnowledgeFileInfo::getCreateTime)));
} }
@GetMapping("/detail") @GetMapping("/detail")
@ -52,6 +51,7 @@ public class KnowledgeFileInfoController {
@ApiOperation(value = "保存") @ApiOperation(value = "保存")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R save(@RequestBody KnowledgeFileInfo req) { public R save(@RequestBody KnowledgeFileInfo req) {
req.setCreateUserName(AuthUtil.getUserName());
return R.status(knowledgeFileInfoService.save(req)); return R.status(knowledgeFileInfoService.save(req));
} }
@ -73,7 +73,7 @@ public class KnowledgeFileInfoController {
@ApiOperation(value = "上传文件") @ApiOperation(value = "上传文件")
@ApiOperationSupport(order = 6) @ApiOperationSupport(order = 6)
public R<BladeFile> upload(@ApiParam(value = "上传文件", required = true) @RequestPart("file") MultipartFile file) { public R<BladeFile> upload(@ApiParam(value = "上传文件", required = true) @RequestPart("file") MultipartFile file) {
return ossClient.putFile(file); return knowledgeFileInfoService.upload(file);
} }
@PostMapping("/store") @PostMapping("/store")
@ -82,4 +82,11 @@ public class KnowledgeFileInfoController {
public R store(@RequestBody IdRequest req) { public R store(@RequestBody IdRequest req) {
return R.status(knowledgeFileInfoService.store(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));
}
} }

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java

@ -108,7 +108,7 @@ public class VectorParamController {
return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken)); return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken));
} }
@PutMapping("/synchronization/") @PutMapping("/synchronization")
@ApiOperation(value = "同步") @ApiOperation(value = "同步")
@ApiOperationSupport(order = 10) @ApiOperationSupport(order = 10)
public R synchronization(@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken, public R synchronization(@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken,

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileFragment.java

@ -18,7 +18,7 @@ import java.io.Serializable;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@TableName("knowledge_file_fragment") @TableName("knowledge_file_segment")
@ApiModel(value = "知识库文件分片信息",description = "知识库文件分片信息") @ApiModel(value = "知识库文件分片信息",description = "知识库文件分片信息")
public class KnowledgeFileFragment extends TenantEntity implements Serializable { public class KnowledgeFileFragment extends TenantEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java

@ -65,4 +65,9 @@ public class KnowledgeFileInfo extends TenantEntity implements Serializable {
@QueryField(condition = SqlCondition.LIKE) @QueryField(condition = SqlCondition.LIKE)
private String remark; private String remark;
@ApiModelProperty("创建人名称")
@TableField("CREATE_USER_NAME")
@QueryField(condition = SqlCondition.LIKE)
private String createUserName;
} }

13
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java

@ -1,13 +1,26 @@
package com.hnac.hzims.bigmodel.maintenance.service; package com.hnac.hzims.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo;
import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest; import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest;
import com.hnac.hzims.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 * @Author: ypj
* @Date: 2024/9/10 16:42 * @Date: 2024/9/10 16:42
*/ */
public interface KnowledgeFileInfoService extends IService<KnowledgeFileInfo> { public interface KnowledgeFileInfoService extends IService<KnowledgeFileInfo> {
String SEGMENT_URL= "/kn/doc_segment";
Boolean store(IdRequest req); Boolean store(IdRequest req);
Boolean batchStore(IdsRequest req);
IPage<KnowledgeFileInfo> listPage(IPage<KnowledgeFileInfo> page, KnowledgeFileInfo req);
R<BladeFile> upload(MultipartFile file);
} }

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java

@ -65,8 +65,8 @@ public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEnt
.eq(ObjectUtil.isNotEmpty(req.getId()), AgentLogEntity::getId, req.getId()) .eq(ObjectUtil.isNotEmpty(req.getId()), AgentLogEntity::getId, req.getId())
.eq(ObjectUtil.isNotEmpty(req.getChatId()), AgentLogEntity::getChatId, req.getChatId()) .eq(ObjectUtil.isNotEmpty(req.getChatId()), AgentLogEntity::getChatId, req.getChatId())
.eq(ObjectUtil.isNotEmpty(req.getQId()), AgentLogEntity::getQId, req.getQId()) .eq(ObjectUtil.isNotEmpty(req.getQId()), AgentLogEntity::getQId, req.getQId())
.eq(ObjectUtil.isNotEmpty(req.getModelName()), AgentLogEntity::getModelName, req.getModelName()) .like(ObjectUtil.isNotEmpty(req.getModelName()), AgentLogEntity::getModelName, req.getModelName())
.orderByDesc(AgentLogEntity::getCreateTime) .orderByAsc(AgentLogEntity::getCreateTime)
.orderByAsc(AgentLogEntity::getChatId); .orderByAsc(AgentLogEntity::getChatId);
return this.page(page, queryWrapper); return this.page(page, queryWrapper);
} }

81
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java

@ -1,17 +1,34 @@
package com.hnac.hzims.bigmodel.maintenance.service.impl; package com.hnac.hzims.bigmodel.maintenance.service.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.bigmodel.configuration.BigModelInteraction;
import com.hnac.hzims.bigmodel.maintenance.constants.StoreStatus; import com.hnac.hzims.bigmodel.maintenance.constants.StoreStatus;
import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo;
import com.hnac.hzims.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper; import com.hnac.hzims.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper;
import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService; import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService;
import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest; import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest;
import com.hnac.hzims.bigmodel.maintenance.vo.IdsRequest;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
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.jackson.JsonUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.resource.feign.IOssClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
@ -23,14 +40,72 @@ import org.springframework.stereotype.Service;
@DS("hznlm") @DS("hznlm")
public class KnowledgeFileInfoServiceImpl extends ServiceImpl<KnowledgeFileInfoMapper, KnowledgeFileInfo> implements KnowledgeFileInfoService { public class KnowledgeFileInfoServiceImpl extends ServiceImpl<KnowledgeFileInfoMapper, KnowledgeFileInfo> implements KnowledgeFileInfoService {
private final KnowledgeFileInfoMapper knowledgeFileInfoMapper; private final KnowledgeFileInfoMapper knowledgeFileInfoMapper;
private final IOssClient ossClient;
private final BigModelInteraction interactionConfig;
@Override @Override
public Boolean store(IdRequest req) { public Boolean store(IdRequest req) {
KnowledgeFileInfo knowledgeFileInfo = knowledgeFileInfoMapper.selectById(req.getId()); 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<String, Object> 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);
}
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<KnowledgeFileInfo> wrapper = Wrappers.<KnowledgeFileInfo>lambdaUpdate()
.set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode())
.eq(KnowledgeFileInfo::getId, knowledgeFileInfo.getId());
return this.update(wrapper);
}
LambdaUpdateWrapper<KnowledgeFileInfo> queryWrapper = Wrappers.<KnowledgeFileInfo>lambdaUpdate() @Override
public Boolean batchStore(IdsRequest req) {
List<KnowledgeFileInfo> 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<KnowledgeFileInfo> wrapper = Wrappers.<KnowledgeFileInfo>lambdaUpdate()
.set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode()) .set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode())
.eq(KnowledgeFileInfo::getId, req.getId()); .in(KnowledgeFileInfo::getId, req.getIds());
return this.update(queryWrapper); return this.update(wrapper);
}
@Override
public IPage<KnowledgeFileInfo> listPage(IPage<KnowledgeFileInfo> 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<BladeFile> upload(MultipartFile file) {
return ossClient.putFile(file);
} }
} }

Loading…
Cancel
Save