优化二维表格导出,故障修复

This commit is contained in:
daiqy88
2025-11-27 08:37:54 +08:00
parent 8b299225ad
commit 0e020a6276
20 changed files with 255 additions and 77 deletions

View File

@@ -71,12 +71,13 @@ public class FlowController implements ISimulationFlowTemplateFeignClient {
/**
* 查询仿真流程模版版本信息
* @param uuid
* @param code
* @param type 0:uuid 1:templateCode
* @return
*/
@GetMapping("/queryFlowTemplateVersion")
public SdmResponse queryFlowTemplateVersion(@RequestParam("uuid") String uuid) {
return IFlowService.getFlowTemplateVersions(uuid);
public SdmResponse queryFlowTemplateVersion(@RequestParam("code") String code,@RequestParam("type") int type) {
return IFlowService.getFlowTemplateVersions(code,type);
}
/**

View File

@@ -18,14 +18,17 @@ public interface FlowMapper {
@Delete("DELETE FROM simulation_flow_template WHERE uuid=#{uuid}")
int deleteFlowTemplate(@Param("uuid") String uuid);
@Update("UPDATE simulation_flow_template SET templateName=#{newName} WHERE templateName=#{oldName}")
int updateFlowTemplateName(@Param("oldName") String oldName,@Param("newName") String newName);
@Update("UPDATE simulation_flow_template SET templateName=#{newName} WHERE templateName=#{oldName} AND tenantId=#{tenantId}")
int updateFlowTemplateName(@Param("oldName") String oldName,@Param("newName") String newName,@Param("tenantId")long tenantId);
@Select("SELECT * FROM simulation_flow_template WHERE ${condition}")
List<SimulationFlowTemplate> queryFlowTemplateByCondition(@Param("condition") String condition);
@Select("SELECT templateVersion,approveType,uuid FROM simulation_flow_template WHERE templateName=#{templateName}")
List<SimulationFlowTemplateBrief> queryFlowTemplateVersion(@Param("templateName") String templateName);
@Select("SELECT templateVersion,approveType,uuid,templateCode FROM simulation_flow_template WHERE templateName=#{templateName} AND tenantId=#{tenantId}")
List<SimulationFlowTemplateBrief> queryFlowTemplateVersion(@Param("templateName") String templateName,@Param("tenantId")long tenantId);
@Select("SELECT templateVersion,approveType,uuid,templateCode FROM simulation_flow_template WHERE templateCode=#{templateCode} AND tenantId=#{tenantId}")
List<SimulationFlowTemplateBrief> queryFlowTemplateVersionByCode(@Param("templateCode") String templateCode,@Param("tenantId")long tenantId);

View File

@@ -10,6 +10,9 @@ public class SimulationFlowTemplateBrief {
@Schema(description = "评审状态")
public int approveType;
@Schema(description = "流程模版编号")
public String templateCode;
@Schema(description = "流程模版唯一ID")
public String uuid;

View File

@@ -66,10 +66,11 @@ public interface IFlowService {
/**
* 获取流程模版版本信息
* @param uuid
* @param code
* @param type
* @return
*/
SdmResponse getFlowTemplateVersions(String uuid);
SdmResponse getFlowTemplateVersions(String code,int type);
/**
* 获取流程模版详情

View File

@@ -35,7 +35,9 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
public SdmResponse createFlowTemplateDraft(SimulationFlowTemplate flowTemplate)
{
SdmResponse response = SdmResponse.success();
String condition = "templateName='"+flowTemplate.templateName+"'";
long tenantId = ThreadLocalContext.getTenantId();
long creator = ThreadLocalContext.getUserId();
String condition = "templateName='"+flowTemplate.templateName+"' AND tenantId="+tenantId;
List<SimulationFlowTemplate> templates = flowMapper.queryFlowTemplateByCondition(condition);
if(!templates.isEmpty())
{
@@ -43,8 +45,6 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
}
else
{
long tenantId = ThreadLocalContext.getTenantId();
long creator = ThreadLocalContext.getUserId();
String createName = ThreadLocalContext.getUserName();
flowTemplate.uuid = generateUuid("flow_template_");
flowTemplate.templateCode = generateUuid("flow_code_");
@@ -70,9 +70,9 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
SdmResponse response = SdmResponse.success();
String templateName = flowTemplate.getTemplateName();
String condition = "templateName='"+templateName+"' ORDER BY createTime DESC LIMIT 1" ;
long tenantId = ThreadLocalContext.getTenantId();
long creator = ThreadLocalContext.getUserId();
String condition = "templateName='"+templateName+"' AND tenantId="+tenantId+" ORDER BY createTime DESC LIMIT 1" ;
String createName = ThreadLocalContext.getUserName();
List<SimulationFlowTemplate> templates = flowMapper.queryFlowTemplateByCondition(condition);
if (templates.isEmpty()) {
@@ -102,6 +102,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
public SdmResponse updateFlowTemplateDraft(SimulationFlowTemplate flowTemplate) {
SdmResponse response = SdmResponse.success();
String queryConditon = "uuid='"+flowTemplate.uuid+"'";
long tenantId = ThreadLocalContext.getTenantId();
List<SimulationFlowTemplate> oldTemplates = flowMapper.queryFlowTemplateByCondition(queryConditon);
if(!oldTemplates.isEmpty())
{
@@ -109,7 +110,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
//模版名称进行修改
if(!oldTemplate.getTemplateName().equals(flowTemplate.getTemplateName()))
{
String condition = "templateName='"+flowTemplate.templateName+"'";
String condition = "templateName='"+flowTemplate.templateName+"' AND tenantId="+tenantId;
List<SimulationFlowTemplate> templates = flowMapper.queryFlowTemplateByCondition(condition);
if(!templates.isEmpty())
{
@@ -118,7 +119,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
}
else
{
flowMapper.updateFlowTemplateName(oldTemplate.templateName,flowTemplate.templateName);
flowMapper.updateFlowTemplateName(oldTemplate.templateName,flowTemplate.templateName,tenantId);
}
}
}
@@ -201,6 +202,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
@Override
public SdmResponse getReleaseFlowTemplateByCondition(String templateType,String templateName,int approveType,String beginTime,String endTime,long creator,int current,int size,int type,int templateStatus) {
SdmResponse response = SdmResponse.success();
long tenantId = ThreadLocalContext.getTenantId();
String condition = "true";
if(templateType != null && !templateType.isEmpty())
{
@@ -220,15 +222,19 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
if(type == 1)
{
condition += " AND approveType=2 ";
if(creator > 0)
{
condition += " AND creator="+creator;
}
}
else if(approveType >= 0)
else
{
condition += " AND approveType="+approveType;
}
if(approveType >= 0) {
condition += " AND approveType=" + approveType;
}
long userId = ThreadLocalContext.getUserId();
condition += " AND creator="+userId;
if(creator > 0)
{
condition += " AND creator="+creator;
}
String timeCondition = Tools.timeRange("createTime",beginTime,endTime);
@@ -236,7 +242,7 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
{
condition += " AND " + timeCondition;
}
condition += " ORDER BY createTime DESC";
condition += " AND tenantId="+tenantId+" ORDER BY createTime DESC";
List<SimulationFlowTemplate> templates = flowMapper.queryFlowTemplateByCondition(condition);
List<SimulationFlowTemplate> latestVersions = filterLatestVersion(templates);
int total = latestVersions.size();
@@ -303,19 +309,29 @@ public class FlowServiceImpl extends BaseService implements IFlowService {
@Override
public SdmResponse getFlowTemplateVersions(String uuid) {
public SdmResponse getFlowTemplateVersions(String code,int type) {
SdmResponse response = SdmResponse.success();
SimulationFlowTemplate template = getFlowTemplateInfoByUuid(uuid);
if(template == null)
long tenantId = ThreadLocalContext.getTenantId();
if(type == 1)
{
response = SdmResponse.failed("仿真流程模版不存在");
}
else
{
List<SimulationFlowTemplateBrief> versions = flowMapper.queryFlowTemplateVersion(template.templateName);
List<SimulationFlowTemplateBrief> versions = flowMapper.queryFlowTemplateVersion(code,tenantId);
response.setData(versions);
}
else if(type == 0)
{
SimulationFlowTemplate template = getFlowTemplateInfoByUuid(code);
if(template == null)
{
response = SdmResponse.failed("仿真流程模版不存在");
}
else
{
List<SimulationFlowTemplateBrief> versions = flowMapper.queryFlowTemplateVersion(template.templateName,tenantId);
response.setData(versions);
}
}
return response;
}

View File

@@ -21,4 +21,18 @@ public class ExportExcelFormat {
@Schema(description = "字典值")
private JSONObject dictData;
@Schema(description = "标记该属性是否已处理")
private boolean bUsed = false;
public ExportExcelFormat deepCopy() {
ExportExcelFormat format = new ExportExcelFormat();
format.key = key;
format.title = title;
format.dictCode = dictCode;
format.dictData = dictData;
return format;
}
}

View File

@@ -8,6 +8,7 @@ import com.sdm.common.entity.ExportExcelFormat;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
@@ -290,6 +291,8 @@ public class ExcelUtil {
{
List<String> keyValues = new ArrayList<>();
int lines;
int firstRow;
int lastRow;
ParaseData parent;
List<ParaseData> children = new ArrayList<>();
public void increaseLine()
@@ -308,7 +311,21 @@ public class ExcelUtil {
}
}
/**
* list 深度拷贝
* @param orgList
* @return
*/
private static List<ExportExcelFormat> listDeepCopy(List<ExportExcelFormat> orgList)
{
List<ExportExcelFormat> list = new ArrayList<>();
for (ExportExcelFormat item : orgList) {
list.add(item.deepCopy());
}
return list;
}
/**
* 解析excel字段数据
* @param jsonObject
@@ -318,8 +335,8 @@ public class ExcelUtil {
*/
private static ParaseData paraseJsonObject(JSONObject jsonObject,List<ExportExcelFormat> exportExcelFormats,ParaseData parent)
{
List<ExportExcelFormat> excelFormats = new ArrayList<>(exportExcelFormats);
Iterator<ExportExcelFormat> iterator = excelFormats.iterator();
List<ExportExcelFormat> formats = listDeepCopy(exportExcelFormats);
Iterator<ExportExcelFormat> iterator = formats.iterator();
boolean bMatch = false;
ParaseData paraseData = null;
while (iterator.hasNext()) {
@@ -335,16 +352,17 @@ public class ExcelUtil {
{
parent.addchildren(paraseData);
}
paraseData.increaseLine();
//paraseData.increaseLine();
}
String value = jsonObject.getString(key);
JSONObject dictObj = format.getDictData();
if(ObjectUtils.isNotEmpty(dictObj))
if(dictObj != null)
{
value = dictObj.getString(value);
}
paraseData.keyValues.add(value);
iterator.remove();
jsonObject.remove(key);
}
else
{
@@ -357,9 +375,10 @@ public class ExcelUtil {
ParaseData parentData = paraseData;
if(parentData == null)
parentData = parent;
paraseJsonObject(child,exportExcelFormats,parentData);
paraseJsonObject(child,formats,parentData);
}
}
break;
}
}
return paraseData;
@@ -391,8 +410,8 @@ public class ExcelUtil {
ExcelCellValue cellValue = new ExcelCellValue();
cellValue.setValue(key);
cellValue.setMerge(true);
cellValue.setFirstRow(beginRow+rowIndex);
cellValue.setLastRow(beginRow+paraseData.lines-1);
cellValue.setFirstRow(paraseData.firstRow);
cellValue.setLastRow(paraseData.lastRow);
cellValues.add(cellValue);
}
}
@@ -404,7 +423,7 @@ public class ExcelUtil {
cellValues.add(cellValue);
}
}
int rowNum = 0;
int rowNum = beginRow;
for(ParaseData paseData : paraseData.children)
{
combineParaseData(paseData,paraseDataMap,beginColumn+paraseData.keyValues.size(),rowNum);
@@ -419,6 +438,32 @@ public class ExcelUtil {
}
}
/**
* 整理数据中的行数
* @param paraseData
*/
private static void computeParaseData(ParaseData paraseData,int rowIndex)
{
if(paraseData.children.isEmpty())
{
paraseData.lines = 1;
}
else
{
int beginRow = rowIndex;
for(ParaseData child : paraseData.children)
{
computeParaseData(child,beginRow);
paraseData.lines += child.lines;
child.firstRow = beginRow;
child.lastRow = beginRow+child.lines-1;
beginRow += child.lines;
}
}
paraseData.firstRow = rowIndex;
paraseData.lastRow = rowIndex+paraseData.lines-1;
}
/**
* 导出有合并单元格excel
* @param dataArray
@@ -432,20 +477,17 @@ public class ExcelUtil {
List<HeadVO> excelHeader = getExcelHeader(exportExcelFormats);
excelSheet.setHeads(excelHeader);
Map<Integer,List<ExcelCellValue>> paraseDataMap = new HashMap<>();
int rowNum = 0;
int rowNum = 1;
for(int index=0;index<dataArray.size();index++)
{
JSONObject jsonObject = dataArray.getJSONObject(index);
ParaseData data = paraseJsonObject(jsonObject,exportExcelFormats,null);
if(data == null)
continue;
computeParaseData(data,rowNum);
combineParaseData(data,paraseDataMap,0,rowNum);
if(data.lines>1)
{
rowNum += data.lines;
}
else
{
rowNum++;
}
rowNum += data.lines;
}
int columnSize = paraseDataMap.size();
int rowIndex = 0;

View File

@@ -2,6 +2,7 @@ package com.sdm.system.controller;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.ExportExcelFormat;
import com.sdm.system.model.req.tenant.ExportExcelReq;
import com.sdm.system.model.req.tenant.TenantListReq;
import com.sdm.system.model.req.tenant.TenantReq;
import com.sdm.system.service.ISysTenantService;
@@ -79,8 +80,8 @@ public class SysTenantController {
@PostMapping("/export")
@Operation(summary = "查询租户列表")
public SdmResponse listTenant(@RequestBody @Validated List<ExportExcelFormat> excelFormats ,HttpServletResponse httpservletResponse) {
return tenantService.exportTenant(excelFormats, httpservletResponse);
public SdmResponse exportTenant(@RequestBody @Validated ExportExcelReq req, HttpServletResponse httpservletResponse) {
return tenantService.exportTenant(req, httpservletResponse);
}
/**

View File

@@ -23,14 +23,14 @@ public interface SimulationSystemMapper {
@Delete("DELETE FROM simulation_data_dictionary WHERE dictClass=#{dictClass}")
int deleteDictionaryClassItems(@Param("dictClass")String dictClass);
@Select("SELECT * FROM simulation_data_dictionary WHERE dictName=#{dictName} AND dictClass=#{dictClass} LIMIT 1")
DataDictionary queryDataDictionary(@Param("dictName")String dictName,@Param("dictClass")String dictClass);
@Select("SELECT * FROM simulation_data_dictionary WHERE dictName=#{dictName} AND dictClass=#{dictClass} AND tenantId=#{tenantId} LIMIT 1")
DataDictionary queryDataDictionary(@Param("dictName")String dictName,@Param("dictClass")String dictClass,@Param("tenantId")long tenantId);
@Select("SELECT * FROM simulation_data_dictionary WHERE uuid=#{uuid}")
DataDictionary queryDictionaryDataDetail(@Param("uuid")String uuid);
@Select("SELECT DISTINCT (dictClass) FROM simulation_data_dictionary")
List<String> queryDictionaryClass();
@Select("SELECT DISTINCT (dictClass) FROM simulation_data_dictionary WHERE tenantId=#{tenantId}")
List<String> queryDictionaryClass(long tenantId);
@Delete("DELETE FROM simulation_data_dictionary WHERE uuid=#{uuid}")
int deleteDictionary(@Param("uuid") String uuid);
@@ -44,14 +44,14 @@ public interface SimulationSystemMapper {
@Delete("DELETE FROM simulation_dictionary_class WHERE uuid=#{uuid}")
int deleteDictionaryClass(@Param("uuid")String uuid);
@Select("SELECT * FROM simulation_dictionary_class WHERE ${condition} ORDER BY createTime DESC LIMIT ${pos},${size}")
List<DictionaryClass> queryAllDictionaryClass(@Param("condition")String condition,int pos,int size);
@Select("SELECT * FROM simulation_dictionary_class WHERE ${condition} AND tenantId=#{tenantId} ORDER BY createTime DESC LIMIT ${pos},${size}")
List<DictionaryClass> queryAllDictionaryClass(@Param("condition")String condition,@Param("pos") int pos,@Param("size") int size,@Param("tenantId")long tenantId);
@Select("SELECT COUNT(*) FROM simulation_dictionary_class WHERE ${condition}")
int queryDictionaryClassTotal(@Param("condition")String condition);
@Select("SELECT COUNT(*) FROM simulation_dictionary_class WHERE ${condition} AND tenantId=#{tenantId}")
int queryDictionaryClassTotal(@Param("condition")String condition, @Param("tenantId") long tenantId);
@Select("SELECT * FROM simulation_dictionary_class WHERE className=#{className}")
DictionaryClass queryDictionaryClassByName(@Param("className")String className);
@Select("SELECT * FROM simulation_dictionary_class WHERE className=#{className} AND tenantId=#{tenantId}")
DictionaryClass queryDictionaryClassByName(@Param("className")String className, @Param("tenantId") long tenantId);
@Update("UPDATE simulation_dictionary_class SET comment=#{dictClass.comment},titleName=#{dictClass.titleName} WHERE uuid=#{dictClass.uuid}")
int updateDictinaryClass(@Param("dictClass") DictionaryClass dictClass);
@@ -59,11 +59,11 @@ public interface SimulationSystemMapper {
@Select("SELECT * FROM simulation_dictionary_class WHERE uuid=#{uuid}")
DictionaryClass queryDictionaryClassDetail(@Param("uuid")String uuid);
@Insert("INSERT INTO system_form_configure(formName,formConfig,comment,creator) VALUES (#{config.formName},#{config.formConfig},#{config.comment},#{config.creator})")
@Insert("INSERT INTO system_form_configure(formName,formConfig,comment,tenantId,creator) VALUES (#{config.formName},#{config.formConfig},#{config.comment},#{config.tenantId}#{config.creator})")
int addFormConfigure(@Param("config") FormConfigure config);
@Select("SELECT * FROM system_form_configure WHERE formName=#{formName}")
FormConfigure queryFormConfigure(@Param("formName")String formName);
@Select("SELECT * FROM system_form_configure WHERE formName=#{formName} AND tenantId=#{tenantId}")
FormConfigure queryFormConfigure(@Param("formName")String formName,@Param("tenantId")long tenantId);
@Insert("UPDATE system_form_configure SET formConfig=#{config.formConfig},comment=#{config.comment} WHERE formName=#{config.formName}")
int updateFormConfigure(@Param("config") FormConfigure config);

View File

@@ -0,0 +1,16 @@
package com.sdm.system.model.req.tenant;
import com.sdm.common.entity.ExportExcelFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList;
import java.util.List;
public class ExportExcelReq {
@Schema(description = "导出Excel表头信息")
public List<ExportExcelFormat> excelHeaders = new ArrayList<>();
@Schema(description = "导出过滤条件")
public TenantListReq params;
}

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.ExportExcelFormat;
import com.sdm.system.model.entity.SysTenant;
import com.sdm.system.model.req.tenant.ExportExcelReq;
import com.sdm.system.model.req.tenant.TenantListReq;
import com.sdm.system.model.req.tenant.TenantReq;
import jakarta.servlet.http.HttpServletResponse;
@@ -47,11 +48,11 @@ public interface ISysTenantService extends IService<SysTenant> {
/**
* 导出租户列表
* @param excelFormats
* @param req
* @param httpservletResponse
* @return
*/
SdmResponse exportTenant(List<ExportExcelFormat> excelFormats , HttpServletResponse httpservletResponse);
SdmResponse exportTenant(ExportExcelReq req , HttpServletResponse httpservletResponse);
/**
* 根据ID查询租户信息

View File

@@ -12,6 +12,7 @@ import com.sdm.common.utils.excel.ExcelSheet;
import com.sdm.common.utils.excel.ExcelUtil;
import com.sdm.system.dao.SysTenantMapper;
import com.sdm.system.model.entity.SysTenant;
import com.sdm.system.model.req.tenant.ExportExcelReq;
import com.sdm.system.model.req.tenant.TenantListReq;
import com.sdm.system.model.req.tenant.TenantReq;
import com.sdm.system.model.resp.TenantResp;
@@ -75,18 +76,16 @@ public class CIDtenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
}
@Override
public SdmResponse exportTenant(List<ExportExcelFormat> exportExcelFormats, HttpServletResponse httpServletResponse)
public SdmResponse exportTenant(ExportExcelReq req, HttpServletResponse httpServletResponse)
{
SdmResponse response = new SdmResponse();
TenantListReq req = new TenantListReq();
req.setSize(1000);
req.setCurrent(0);
SdmResponse tenantRespond = listTenant(req);
SdmResponse tenantRespond = listTenant(req.params);
if(tenantRespond.isSuccess())
{
JSONObject dataObj = (JSONObject) tenantRespond.getData();
JSONArray jsonArray = dataObj.getJSONArray("data");
ExcelUtil.exportExcelNoMerge(jsonArray,exportExcelFormats,httpServletResponse);
ExcelUtil.exportExcelNoMerge(jsonArray,req.excelHeaders,httpServletResponse);
}
else
{

View File

@@ -9,6 +9,7 @@ import com.sdm.common.entity.ExportExcelFormat;
import com.sdm.common.utils.PageUtils;
import com.sdm.system.dao.SysTenantMapper;
import com.sdm.system.model.entity.SysTenant;
import com.sdm.system.model.req.tenant.ExportExcelReq;
import com.sdm.system.model.req.tenant.TenantListReq;
import com.sdm.system.model.req.tenant.TenantReq;
import com.sdm.system.model.resp.TenantResp;
@@ -110,7 +111,7 @@ public class LocalSysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysT
}
@Override
public SdmResponse exportTenant(List<ExportExcelFormat> excelFormats, HttpServletResponse httpservletResponse) {
public SdmResponse exportTenant(ExportExcelReq req, HttpServletResponse httpservletResponse) {
return null;
}

View File

@@ -46,13 +46,16 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
public SdmResponse addDataDictionary(DataDictionary dict)
{
SdmResponse response = SdmResponse.success();
DataDictionary dictionary = mapper.queryDataDictionary(dict.dictName,dict.dictClass);
long tenantId = ThreadLocalContext.getTenantId();
DataDictionary dictionary = mapper.queryDataDictionary(dict.dictName,dict.dictClass,tenantId);
if(dictionary != null)
{
response = SdmResponse.failed("数据字典信息已存在");
}
else
{
dict.tenantId = ThreadLocalContext.getTenantId();
dict.creator = ThreadLocalContext.getUserId();
dict.uuid = generateDictionaryUuid();
if(mapper.addDataDictionary(dict) <= 0) {
response = SdmResponse.failed("添加数据字典信息失败");
@@ -68,7 +71,8 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
public SdmResponse queryDataDictioaryClasses()
{
SdmResponse response = SdmResponse.success();
List<String> dictClasses = mapper.queryDictionaryClass();
long tenantId = ThreadLocalContext.getTenantId();
List<String> dictClasses = mapper.queryDictionaryClass(tenantId);
response.setData(dictClasses);
return response;
}
@@ -149,7 +153,11 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
{
SdmResponse response = SdmResponse.success();
dictionaryCla.uuid = generateDictionaryUuid();
if(mapper.queryDictionaryClassByName(dictionaryCla.className) != null)
long tenantId = ThreadLocalContext.getTenantId();
long creator = ThreadLocalContext.getUserId();
dictionaryCla.tenantId = tenantId;
dictionaryCla.creator = creator;
if(mapper.queryDictionaryClassByName(dictionaryCla.className,tenantId) != null)
{
response = SdmResponse.failed("数据字典分类已存在");
}
@@ -176,9 +184,10 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
{
condition += " AND className LIKE '%"+className+"%'";
}
int count = mapper.queryDictionaryClassTotal(condition);
long tenantId = ThreadLocalContext.getTenantId();
int count = mapper.queryDictionaryClassTotal(condition,tenantId);
int pos = (pageNo-1)*size;
List<DictionaryClass> classes = mapper.queryAllDictionaryClass(condition,pos,size);
List<DictionaryClass> classes = mapper.queryAllDictionaryClass(condition,pos,size,tenantId);
DataPageInfo pageInfo = new DataPageInfo();
pageInfo.total = count;
@@ -319,7 +328,8 @@ public class SimulationSystemConfigServiceImpl extends BaseService implements IS
public SdmResponse queryFormConfigure(String formName)
{
SdmResponse response = SdmResponse.success();
FormConfigure formConfigure = mapper.queryFormConfigure(formName);
long tenantId = ThreadLocalContext.getTenantId();
FormConfigure formConfigure = mapper.queryFormConfigure(formName,tenantId);
if(formConfigure == null)
{
response = SdmResponse.failed("表单不存在");

View File

@@ -5,6 +5,7 @@ import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.req.system.LaunchApproveReq;
import com.sdm.common.feign.inter.task.ISimuluationTaskPoolFeignClient;
import com.sdm.task.model.entity.TaskPoolUpdateBean;
import com.sdm.task.model.req.ExportTaskPoolReq;
import com.sdm.task.service.ISimulationTaskPoolService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +33,13 @@ public class SimuluationTaskPoolController implements ISimuluationTaskPoolFeignC
return service.getPoolTreeByVersion(poolName,version);
}
@PostMapping(value = "/exportTaskPoolToExcel")
@ResponseBody
void exportSimulationTaskPool(@RequestBody ExportTaskPoolReq req,HttpServletResponse response)
{
service.exportTaskPoolToExcel(req,response);
}
@PostMapping(value = "/updateTaskPool")
@ResponseBody
SdmResponse updateSimulationTaskPool(@RequestBody TaskPoolUpdateBean updateBean)

View File

@@ -116,7 +116,9 @@ public class TaskPoolOperate {
String pythonCmd = "python "+shellPath+" "+poolJsonFileName+" "+poolFileName+" "+dictFileName;
try
{
log.info("shell begin time:"+System.currentTimeMillis());
String resultString = SystemOperate.exeShellCmd(pythonCmd);
log.info("shell end time:"+System.currentTimeMillis());
if(resultString.contains("error"))
{
response = SdmResponse.failed("解析分析项库文件脚本执行错误");

View File

@@ -0,0 +1,18 @@
package com.sdm.task.model.req;
import com.sdm.common.entity.ExportExcelFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList;
import java.util.List;
public class ExportTaskPoolReq {
@Schema(description = "导出excel表头信息")
public List<ExportExcelFormat> excelHeaders = new ArrayList<>();
@Schema(description = "导出过滤条件")
public QueryTaskPoolReq params;
}

View File

@@ -0,0 +1,12 @@
package com.sdm.task.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
public class QueryTaskPoolReq {
@Schema(description = "分析项库名称")
public String poolName;
@Schema(description = "分析项库版本")
public String version;
}

View File

@@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.req.system.LaunchApproveReq;
import com.sdm.task.model.entity.TaskPoolUpdateBean;
import com.sdm.task.model.req.ExportTaskPoolReq;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
@@ -32,5 +33,7 @@ public interface ISimulationTaskPoolService {
SdmResponse exportTaskPool(HttpServletResponse httpServletResponse,JSONObject jsonObject);
void exportTaskPoolToExcel(ExportTaskPoolReq req,HttpServletResponse httpServletResponse);
SdmResponse handleApproveNotice(LaunchApproveReq req);
}

View File

@@ -11,9 +11,12 @@ import com.sdm.common.entity.req.system.LaunchApproveReq;
import com.sdm.common.feign.impl.system.ApproveFeignClientImpl;
import com.sdm.common.service.BaseService;
import com.sdm.common.utils.SystemOperate;
import com.sdm.common.utils.excel.ExcelUtil;
import com.sdm.task.dao.SimulationPoolMapper;
import com.sdm.task.model.bo.TaskPoolOperate;
import com.sdm.task.model.entity.*;
import com.sdm.task.model.req.ExportTaskPoolReq;
import com.sdm.task.model.req.QueryTaskPoolReq;
import com.sdm.task.service.ISimulationTaskPoolService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
@@ -229,6 +232,29 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
return response;
}
/**
* 按格式导出分析项库
* @param req
* @param httpServletResponse
* @return
*/
public void exportTaskPoolToExcel(ExportTaskPoolReq req, HttpServletResponse httpServletResponse)
{
SdmResponse response = SdmResponse.success();
QueryTaskPoolReq filterCodition = req.params;
SdmResponse taskPoolResp = getPoolTreeByVersion(filterCodition.poolName,filterCodition.version);
if(!taskPoolResp.isSuccess())
{
response = SdmResponse.failed("获取分析项库失败");
}
else
{
JSONObject taskPool = (JSONObject) taskPoolResp.getData();
ExcelUtil.exportExcelWithMerge(taskPool.getJSONArray("nodes"),req.excelHeaders,httpServletResponse);
}
return ;
}
/**
* 获取分析项库当前版本信息
* @param poolName
@@ -1316,6 +1342,7 @@ public class SimulationTaskPoolServiceImpl extends BaseService implements ISimul
//response = createTaskPool(poolTreeObj);
response.setData(poolTreeObj);
}
log.info("import endTime:"+System.currentTimeMillis());
return response;
}