This commit is contained in:
zjh 2025-12-14 20:38:46 +08:00
parent 359f9e9999
commit d542ab5fc0
11 changed files with 28 additions and 213 deletions

View File

@ -23,8 +23,8 @@ public class UserPermissionGetter {
private RuntimeAppContextService runtimeAppContextService;
public String getCurrentUserId() {
return runtimeAppContextService.getCurrentUserId();
// return "zjh";
// return runtimeAppContextService.getCurrentUserId();
return "zjh";
}
// 获取子系统下的参数权限

View File

@ -1,27 +1,18 @@
package com.xdap.self_development.controller;
import com.definesys.mpaas.common.http.Response;
import com.definesys.mpaas.query.MpaasQueryFactory;
import com.xdap.motor.entity.SnowflakeIdWorker;
import com.xdap.runtime.service.RuntimeAppContextService;
import com.xdap.self_development.common.UserPermissionGetter;
import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.feign.ApaasMyTokenFeign;
import com.xdap.self_development.feign.dto.AppTokenDTO;
import com.xdap.self_development.feign.dto.ProcessLaunchRequest;
import com.xdap.self_development.feign.dto.ProcessLaunchResponse;
import com.xdap.self_development.feign.dto.UserTokenDT0;
import com.xdap.self_development.pojo.ApprovalParameterChangeDetails;
import com.xdap.self_development.pojo.ApprovalPerson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.*;
@Slf4j
@RestController
@ -44,112 +35,4 @@ public class DeleteController {
private String clientId;
@Value("${apaas.token.clientSecred}")
private String clientSecret;
@GetMapping("submitApproval")
public Response submitApproval() {
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
String currentUserId = getter.getCurrentUserId();
AppTokenDTO token = apaasMyTokenFeign.getAppToken(
"client_credentials",
clientId,
clientSecret
);
UserTokenDT0 userToken = apaasMyTokenFeign.getUserToken(
token.getAccess_token(),
currentUserId
);
String formId = "693cce312153aa5a1ac8599b";
String documentId = snowflakeIdWorker.nextId();
ApprovalPerson approvalPerson = new ApprovalPerson();
approvalPerson.getDetails().setParameterName("测试参数名11");
approvalPerson.setPz(Collections.singletonList("100771325212057665536"));
approvalPerson.setSh(Collections.singletonList("100771325212057665536"));
approvalPerson.setJd(Collections.singletonList("100771325212057665536"));
approvalPerson.setDocumentId(documentId);
bd.getBusinessDatabase().doInsert(approvalPerson);
List<String> documentIds = Collections.singletonList(documentId);
// 调用接口
ProcessLaunchResponse response = batchLaunch(userToken.getAccess_token(), formId, documentIds);
// 处理响应
if (response.isSuccess()) {
return Response.ok().data("流程批量发起成功:" + response.getMessage());
} else {
return Response.error("流程批量发起失败:" + response.getMessage());
}
}
public ProcessLaunchResponse batchLaunch(String userToken, String formId, List<String> documentIds) {
// 1. 构造请求头参数
// 毫秒级时间戳必填来源系统当前时间戳Java8通过System.currentTimeMillis()获取
String xdapTimestamp = String.valueOf(System.currentTimeMillis());
// 构造Authorization格式bearer + 空格 + token
String authorization = "Bearer " + userToken;
// 2. 构造请求体参数
ProcessLaunchRequest request =
new ProcessLaunchRequest(formId, documentIds);
// 3. 调用Feign接口
return apaasMyTokenFeign.batchLaunchProcess(
"application/json;charset=UTF-8",
authorization,
xdapTimestamp,
request
);
}
@GetMapping("/submitPro")
public Response submitPro() {
List<String> tableNames = getTablesWithFormId();
Map<String, List<String>> params = new HashMap<>();
params.put("tableNames", new ArrayList<>());
tableNames.forEach(tableName -> {
String table = countFormIdInTable(tableName, "693cce312153aa5a1ac8599b");
if (table != null) {
params.get("tableNames").add(table);
}
});
return Response.ok().data(params);
}
public List<String> getTablesWithFormId() {
// 查询所有包含 form_id 字段的表
String sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS " +
"WHERE COLUMN_NAME = 'form_id' " +
"AND TABLE_SCHEMA = DATABASE()";
List<Map<String, Object>> tables = bd.getBusinessDatabase().sql(sql).doQuery();
System.out.println(tables);
List<String> tableNames = new ArrayList<>();
for (Map<String, Object> table : tables) {
tableNames.add((String) table.get("TABLE_NAME"));
}
return tableNames;
}
public String countFormIdInTable(String tableName, String formIdValue) {
// 构建查询语句
String sql = "SELECT form_id FROM "+tableName+" WHERE form_id = '" + formIdValue +"'";
try {
System.out.println(sql);
List<Map<String, Object>> result = bd.getBusinessDatabase()
.sql(sql)
.doQuery();
if (!result.isEmpty()) {
return tableName;
}
} catch (Exception e) {
// 记录日志表可能不存在或没有form_id字段
System.err.println("查询表 " + tableName + " 时出错: " + e.getMessage());
}
return null;
}
}

View File

@ -26,15 +26,7 @@ public class TemplateApprovalController {
@Resource
private RuntimeDatasourceService runtimeDatasourceService;
@GetMapping("/saveApprovalId")
public Response saveApprovalId(
@NotBlank String documentId
) {
ApprovalFlow approvalFlow = new ApprovalFlow();
approvalFlow.setId(documentId);
return Response.ok();
}
// 获取用户和部门
@GetMapping("/getUsersByCondition")
public Response getUsersByCondition(
@RequestParam String name
@ -133,5 +125,4 @@ public class TemplateApprovalController {
ApprovalFlowView approvalFlowView = templateApprovalService.getApprovalProcess(form);
return Response.ok().data(approvalFlowView);
}
}

View File

@ -30,28 +30,6 @@ public class TemplateController {
@Resource
private BusinessDatabase bd;
// 更新模板状态
@GetMapping("/updateTemplateStatus")
public Response updateTemplateStatus(
@NotBlank String templateId,
@NotBlank String status
) {
if (Objects.equals(status, "COMPLETE")) {
Template template = bd.getBusinessDatabase().eq("id", templateId).doQueryFirst(Template.class);
bd.getBusinessDatabase()
.eq("template_name", template.getTemplateName())
.update("status", "HISTORY")
.doUpdate(Template.class);
}
bd.getBusinessDatabase()
.eq("id", templateId)
.update("status", status)
.doUpdate(Template.class);
return Response.ok();
}
// ------------------------------------------
// 模板名的模糊搜索
@GetMapping("/getTemplateByCondition")
public Response getTemplateByCondition(

View File

@ -43,21 +43,4 @@ public interface ApaasMyTokenFeign {
@RequestPart("tenantId") String tenantId,
@RequestPart("userId") String userId
);
/**
* 批量发起流程无流程实例的单据
* @param contentType 请求体格式固定application/json;charset=UTF-8
* @param access_token 用户token非必填格式bearer + 空格 + token值
* @param xdapTimestamp 毫秒级时间戳必填1744238901000
* @param requestParam 请求体参数
* @return 响应结果
*/
@PostMapping(value = "/xdap-open/open/process/v1/batch/pureLaunchProcess",
consumes = "application/json;charset=UTF-8")
ProcessLaunchResponse batchLaunchProcess(
@RequestHeader("Content-Type") String contentType,
@RequestHeader(value = "Authorization") String access_token,
@RequestHeader("xdaptimestamp") String xdapTimestamp,
@RequestBody ProcessLaunchRequest requestParam
);
}

View File

@ -1,15 +0,0 @@
package com.xdap.self_development.feign.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProcessLaunchRequest {
private String formId;
private List<String> documentIds;
}

View File

@ -1,24 +0,0 @@
package com.xdap.self_development.feign.dto;
import com.definesys.mpaas.query.annotation.RowID;
import com.definesys.mpaas.query.annotation.RowIDType;
import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.checkerframework.checker.units.qual.A;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProcessLaunchResponse {
private String code;
private String message;
// 快捷判断是否成功
public boolean isSuccess() {
return "ok".equals(this.code);
}
}

View File

@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
@SQLQuery(value = {
@SQL(view = "getCommonAndParameters",
sql = "SELECT ymcp.*, ymp.parameter_name AS \"parameterName\", ymp.parameter_type AS \"parameterType\", ymp.subsystem_name AS \"subsystemName\" FROM yfsjglpt_model_common_parameters ymcp LEFT JOIN yfsjglpt_model_parameter ymp ON ymcp.parameter_id = ymp.id WHERE ymcp.common_id IN (#ids)"),
sql = "SELECT ymcp.*, ymp.parameter_name, ymp.parameter_type, ymp.subsystem_name, ymp.parts_name FROM yfsjglpt_model_common_parameters ymcp LEFT JOIN yfsjglpt_model_parameter ymp ON ymcp.parameter_id = ymp.id WHERE ymcp.common_id IN (#ids)"),
@SQL(view = "getCommonById",
sql = "SELECT ymcp.*, ymp.parameter_name as 'parameterName', ymp.parameter_type as 'parameterType', ymp.subsystem_name as 'subsystemName' FROM yfsjglpt_model_common_parameters ymcp LEFT JOIN yfsjglpt_model_parameter ymp ON ymcp.parameter_id = ymp.id WHERE ymcp.user_id = #userId")
})
@ -26,4 +26,6 @@ public class ModelCommonParameters extends MpaasBasePojo {
private String parameterType;
@Column(type = ColumnType.CALCULATE)
private String subsystemName;
@Column(type = ColumnType.CALCULATE)
private String partsName;
}

View File

@ -8,6 +8,7 @@ import com.xdap.self_development.pojo.Template;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import java.util.List;
public interface TemplateService {
@ -25,4 +26,6 @@ public interface TemplateService {
void exportTemplate(ExportTemplateForm form, HttpServletResponse response);
List<Template> getTemplateVersion(TemplateRowIdForm form);
void updateTemplateStatus(@NotBlank String templateId, @NotBlank String status);
}

View File

@ -2,6 +2,7 @@ package com.xdap.self_development.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson2.JSON;
import com.definesys.mpaas.query.db.PageQueryResult;
import com.xdap.self_development.common.MyResponse;
import com.xdap.self_development.common.UserPermissionGetter;
@ -9,10 +10,7 @@ import com.xdap.self_development.config.BusinessDatabase;
import com.xdap.self_development.controller.form.*;
import com.xdap.self_development.exception.CommonException;
import com.xdap.self_development.listener.SheetDataListener;
import com.xdap.self_development.pojo.Parameter;
import com.xdap.self_development.pojo.RevisionRecord;
import com.xdap.self_development.pojo.Template;
import com.xdap.self_development.pojo.TemplateAndParameter;
import com.xdap.self_development.pojo.*;
import com.xdap.self_development.service.TemplateService;
import com.xdap.self_development.utils.FormulaValidator;
import lombok.extern.slf4j.Slf4j;
@ -211,6 +209,22 @@ public class TemplateServiceImpl implements TemplateService {
.doQuery(Template.class);
}
@Override
@Transactional(rollbackFor = CommonException.class)
public void updateTemplateStatus(String templateId, String status) {
if (Objects.equals(status, "COMPLETE")) {// 更新之前模板为历史
Template template = bd.getBusinessDatabase().eq("id", templateId).doQueryFirst(Template.class);
bd.getBusinessDatabase()
.eq("template_name", template.getTemplateName())
.update("status", "HISTORY")
.doUpdate(Template.class);
}
bd.getBusinessDatabase()
.eq("id", templateId)
.update("status", status)
.doUpdate(Template.class);
}
@Override
public void processSheetData(List<Parameter> dataList, String sheetName,
String templateRowId, String createBy, MyResponse problems, Integer maxOrder) {