diff --git a/application-tenant/tenant-admin/pom.xml b/application-tenant/tenant-admin/pom.xml index 9c94759..867b72e 100644 --- a/application-tenant/tenant-admin/pom.xml +++ b/application-tenant/tenant-admin/pom.xml @@ -141,7 +141,7 @@ apelet common-flow-online - 1.0.0 + 1.0.2 apelet @@ -174,6 +174,17 @@ 1.0.0 + + org.docx4j + docx4j-JAXB-ReferenceImpl + 8.3.9 + + + org.docx4j + docx4j-export-fo + 8.3.9 + + diff --git a/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/tenant/controller/DocxTemplateController.java b/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/tenant/controller/DocxTemplateController.java deleted file mode 100644 index 1c3af35..0000000 --- a/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/tenant/controller/DocxTemplateController.java +++ /dev/null @@ -1,141 +0,0 @@ - -package apelet.tenantadmin.tenant.controller; - -import apelet.common.core.annotation.MyRequestBody; -import apelet.common.core.exception.MyRuntimeException; -import apelet.common.core.object.ObjectValue; -import apelet.common.generator.utils.OrmGenDataSourceUtil; -import cn.hutool.core.io.IoUtil; -import org.apache.poi.xwpf.usermodel.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ClassPathResource; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.*; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@RestController -@RequestMapping("/api/template") -public class DocxTemplateController { - - - @Autowired - private OrmGenDataSourceUtil ormGenDataSourceUtil; - - private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("\\$\\{(.+?)\\}"); - - /** - * 替换字符串中 ${key},JDK8兼容 - */ - private String replaceContent(String text, Map dataMap) { - if (text == null) return ""; - Matcher matcher = PLACEHOLDER_PATTERN.matcher(text); - StringBuffer sb = new StringBuffer(); - while (matcher.find()) { - String key = matcher.group(1).trim(); - Object val = dataMap.get(key); - String realVal = val == null ? "" : val.toString(); - matcher.appendReplacement(sb, Matcher.quoteReplacement(realVal)); - } - matcher.appendTail(sb); - return sb.toString(); - } - - @GetMapping("/downloadDocx") - public void downloadDocx(@RequestParam("id") String quotationId, HttpServletResponse response) { - XWPFDocument document = null; - InputStream templateIs = null; - OutputStream out = null; - try { - // 1. 查数据 - ObjectValue objectValue = ormGenDataSourceUtil.queryOne("quotation", quotationId); - Map hashMap = new HashMap<>(); - hashMap.put("name", objectValue.getString("name")); - hashMap.put("number", objectValue.getString("number")); - hashMap.put("create_time", objectValue.getString("create_time")); - hashMap.put("qty", objectValue.getObjectValue("qty")); - ObjectValue managerperson = objectValue.getObjectValue("managerperson"); - if(managerperson != null){ - managerperson = ormGenDataSourceUtil.queryOne(managerperson.getTableName(), managerperson.getString("id")); - hashMap.put("managerperson",1); - } - // 2. 读模板 - File file = new File("D:\\work\\xykj-project\\xhgl\\zz-resource\\quotation_template.docx"); - templateIs = new FileInputStream(file); - document = new XWPFDocument(templateIs); - // 3. 替换占位符 - replaceParagraph(document, hashMap); - replaceTable(document, hashMap); - // 4. 设置响应头 —— 关键! - response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); - response.setCharacterEncoding("UTF-8"); - String fileName = URLEncoder.encode("报价单.docx", StandardCharsets.UTF_8.name()) - .replaceAll("\\+", "%20"); - // 兼容各浏览器的文件名写法 - response.setHeader("Content-Disposition", - "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName); - response.setHeader("Pragma", "no-cache"); - response.setHeader("Cache-Control", "no-cache"); - response.setDateHeader("Expires", 0); - // 5. 写出 - out = response.getOutputStream(); - document.write(out); - out.flush(); - } catch (Exception e) { - e.printStackTrace(); - throw new MyRuntimeException("导出失败: " + e.getMessage()); - } finally { - IoUtil.close(document); - IoUtil.close(templateIs); - IoUtil.close(out); - } - } - - - - - private void replaceParagraph(XWPFDocument document, Map dataMap) { - for (XWPFParagraph paragraph : document.getParagraphs()) { - String text = paragraph.getText(); - Matcher matcher = PLACEHOLDER_PATTERN.matcher(text); - if (!matcher.find()) { - continue; - } - //清空原有run - for (XWPFRun run : paragraph.getRuns()) { - run.setText("", 0); - } - String newText = replaceContent(text, dataMap); - paragraph.createRun().setText(newText); - } - } - - private void replaceTable(XWPFDocument document, Map dataMap) { - for (XWPFTable table : document.getTables()) { - for (XWPFTableRow row : table.getRows()) { - for (XWPFTableCell cell : row.getTableCells()) { - for (XWPFParagraph paragraph : cell.getParagraphs()) { - String text = paragraph.getText(); - Matcher matcher = PLACEHOLDER_PATTERN.matcher(text); - if (!matcher.find()) { - continue; - } - for (XWPFRun run : paragraph.getRuns()) { - run.setText("", 0); - } - String newText = replaceContent(text, dataMap); - paragraph.createRun().setText(newText); - } - } - } - } - } - - -} diff --git a/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/controller/DocxTemplateController.java b/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/controller/DocxTemplateController.java new file mode 100644 index 0000000..26cd9d5 --- /dev/null +++ b/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/controller/DocxTemplateController.java @@ -0,0 +1,353 @@ +package apelet.tenantadmin.upms.controller; + +import apelet.common.core.exception.MyRuntimeException; +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.object.ResponseResult; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.service.OnlineDictService; +import apelet.common.orm.impl.Filter; +import apelet.common.orm.impl.Selector; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.ExcelReader; +import cn.hutool.poi.excel.ExcelUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.xwpf.usermodel.*; +import org.docx4j.Docx4J; +import org.docx4j.fonts.IdentityPlusMapper; +import org.docx4j.fonts.PhysicalFonts; +import org.docx4j.openpackaging.packages.WordprocessingMLPackage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/api/template") +public class DocxTemplateController { + + @Autowired + private OrmGenDataSourceUtil ormGenDataSourceUtil; + @Autowired + private OnlineDictService onlineDictService; + + private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("#\\{(.+?)\\}"); + + private String replaceContent(String text, Map dataMap) { + if (text == null) return ""; + Matcher matcher = PLACEHOLDER_PATTERN.matcher(text); + StringBuffer sb = new StringBuffer(); + while (matcher.find()) { + String key = matcher.group(1).trim(); + if ("personimage".equals(key)) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(matcher.group(0))); + continue; + } + Object val = dataMap.get(key); + String realVal = val == null ? "" : val.toString(); + matcher.appendReplacement(sb, Matcher.quoteReplacement(realVal)); + } + matcher.appendTail(sb); + return sb.toString(); + } + + + @GetMapping("/downloadDocx") + public void downloadDocx(@RequestParam("id") String quotationId, @RequestParam("userId") String userId, HttpServletResponse response) { + XWPFDocument document = null; + InputStream templateIs = null; + OutputStream out = null; + ByteArrayOutputStream pdfOut = null; + try { + // 1. 查数据 + ObjectValue objectValue = ormGenDataSourceUtil.queryOne("quotation", quotationId); + ObjectValue user = ormGenDataSourceUtil.queryOne("xy_sys_user", userId); + Map dictMap = onlineDictService.getDictMap(2052225870772310016L); + Map hashMap = new HashMap<>(); + hashMap.put("name", objectValue.getString("name")); + hashMap.put("type", dictMap.get(String.valueOf(objectValue.get("type", "")))); + hashMap.put("number", objectValue.getString("number")); + hashMap.put("create_time", objectValue.getString("create_time").substring(0, 10)); + hashMap.put("qty", objectValue.getString("qty")); + + String signatureImage = user.getString("signature_image"); + String imageUrl = getUrl(signatureImage); + byte[] imageBytes = null; + if (StringUtils.isNotEmpty(imageUrl)) { + imageBytes = downloadImage(imageUrl); + } + ObjectValue managerperson = objectValue.getObjectValue("managerperson"); + if (managerperson != null) { + managerperson = ormGenDataSourceUtil.queryOne(managerperson.getTableName(), managerperson.getString("id")); + hashMap.put("managerperson", managerperson.getString("show_name")); + } + // 2. 读模板 + String savePath = System.getProperty("user.dir") + "\\zz-resource\\"; + File file = new File(savePath + "quotation_template.docx"); + templateIs = Files.newInputStream(file.toPath()); + document = new XWPFDocument(templateIs); + // 3. 替换文本占位符 + replaceParagraph(document, hashMap); + replaceTable(document, hashMap); + // 4. 替换图片占位符 + replaceImageInParagraphs(document, "personimage", imageBytes, 100, 100); + replaceImageInTables(document, "personimage", imageBytes, 100, 100); + // 5. 将填充后的 DOCX 转为 PDF(使用 docx4j) + ByteArrayOutputStream docxOut = new ByteArrayOutputStream(); + document.write(docxOut); + byte[] docxBytes = docxOut.toByteArray(); + docxOut.close(); + + WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new ByteArrayInputStream(docxBytes)); + PhysicalFonts.discoverPhysicalFonts(); + wordMLPackage.setFontMapper(new IdentityPlusMapper()); + pdfOut = new ByteArrayOutputStream(); + Docx4J.toPDF(wordMLPackage, pdfOut); + byte[] pdfBytes = pdfOut.toByteArray(); + + // 6. 设置响应头 + response.setContentType("application/pdf"); + response.setCharacterEncoding("UTF-8"); + String fileName = URLEncoder.encode("报价单.pdf", StandardCharsets.UTF_8.name()) + .replaceAll("\\+", "%20"); + response.setHeader("Content-Disposition", + "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''" + fileName); + response.setHeader("Pragma", "no-cache"); + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expires", 0); + // 7. 写出 PDF + out = response.getOutputStream(); + out.write(pdfBytes); + out.flush(); + } catch (Exception e) { + e.printStackTrace(); + throw new MyRuntimeException("导出失败: " + e.getMessage()); + } finally { + IoUtil.close(pdfOut); + IoUtil.close(document); + IoUtil.close(templateIs); + IoUtil.close(out); + } + } + + + String getUrl(String signatureImage) { + if (StringUtils.isEmpty(signatureImage)) { + return ""; + } + JSONArray jsonArray = JSON.parseArray(signatureImage); + if (jsonArray.isEmpty()) { + return ""; + } + JSONObject jsonObject = jsonArray.getJSONObject(0); + String baseUrl = jsonObject.getString("baseUrl"); + String uploadPath = jsonObject.getString("uploadPath"); + String filename = jsonObject.getString("filename"); + + return baseUrl + "/" + uploadPath + "/" + filename; + } + + private void replaceParagraph(XWPFDocument document, Map dataMap) { + for (XWPFParagraph paragraph : document.getParagraphs()) { + String text = paragraph.getText(); + Matcher matcher = PLACEHOLDER_PATTERN.matcher(text); + if (!matcher.find()) { + continue; + } + for (XWPFRun run : paragraph.getRuns()) { + run.setText("", 0); + } + String newText = replaceContent(text, dataMap); + paragraph.createRun().setText(newText); + } + } + + private void replaceTable(XWPFDocument document, Map dataMap) { + for (XWPFTable table : document.getTables()) { + for (XWPFTableRow row : table.getRows()) { + for (XWPFTableCell cell : row.getTableCells()) { + for (XWPFParagraph paragraph : cell.getParagraphs()) { + String text = paragraph.getText(); + Matcher matcher = PLACEHOLDER_PATTERN.matcher(text); + if (!matcher.find()) { + continue; + } + for (XWPFRun run : paragraph.getRuns()) { + run.setText("", 0); + } + String newText = replaceContent(text, dataMap); + paragraph.createRun().setText(newText); + } + } + } + } + } + + private byte[] downloadImage(String imageUrl) throws IOException { + URL url = new URL(imageUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + conn.setConnectTimeout(5000); + conn.setReadTimeout(10000); + InputStream is = conn.getInputStream(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int len; + while ((len = is.read(buffer)) != -1) { + baos.write(buffer, 0, len); + } + IoUtil.close(is); + return baos.toByteArray(); + } + + + private void replaceImageInParagraphs(XWPFDocument document, String placeholderKey, byte[] imageBytes, int width, int height) throws IOException, InvalidFormatException { + String placeholder = "#{" + placeholderKey + "}"; + for (XWPFParagraph paragraph : document.getParagraphs()) { + String text = paragraph.getText(); + if (text != null && text.contains(placeholder)) { + List runs = paragraph.getRuns(); + for (int i = runs.size() - 1; i >= 0; i--) { + XWPFRun run = runs.get(i); + String runText = run.getText(0); + if (runText != null && runText.contains(placeholder)) { + run.setText("", 0); + if (imageBytes != null) { + run.addPicture(new ByteArrayInputStream(imageBytes), XWPFDocument.PICTURE_TYPE_PNG, placeholderKey + ".png", + width * 9525, height * 9525); + } + } + } + } + } + } + + private void replaceImageInTables(XWPFDocument document, String placeholderKey, byte[] imageBytes, int width, int height) throws IOException, InvalidFormatException { + String placeholder = "#{" + placeholderKey + "}"; + for (XWPFTable table : document.getTables()) { + for (XWPFTableRow row : table.getRows()) { + for (XWPFTableCell cell : row.getTableCells()) { + for (XWPFParagraph paragraph : cell.getParagraphs()) { + String text = paragraph.getText(); + if (text != null && text.contains(placeholder)) { + List runs = paragraph.getRuns(); + for (int i = runs.size() - 1; i >= 0; i--) { + XWPFRun run = runs.get(i); + String runText = run.getText(0); + if (runText != null && runText.contains(placeholder)) { + run.setText("", 0); + if (imageBytes != null) { + run.addPicture(new ByteArrayInputStream(imageBytes), XWPFDocument.PICTURE_TYPE_PNG, placeholderKey + ".png", + width * 9525, height * 9525); + } + } + } + } + } + } + } + } + } + + + private static final Map HEADER_MAP = new LinkedHashMap<>(); + + static { + HEADER_MAP.put("名称", "name"); + HEADER_MAP.put("性别", "gender"); + HEADER_MAP.put("手机号码", "phone"); + HEADER_MAP.put("出生年月", "birth_date"); + HEADER_MAP.put("学历", "education"); + HEADER_MAP.put("民族", "nation"); + HEADER_MAP.put("政治面貌", "political_status"); + HEADER_MAP.put("身份证号码", "id_card"); + HEADER_MAP.put("毕业院校", "graduate_school"); + HEADER_MAP.put("所属专业", "major"); + HEADER_MAP.put("常住地", "permanent_address"); + } + + @PostMapping("/expertImport") + public ResponseResult expertImport(@RequestParam("file") MultipartFile file) { + List> dataList = new ArrayList<>(); + try (InputStream is = file.getInputStream()) { + ExcelReader reader = ExcelUtil.getReader(is); + // 第一行作为表头,key 为表头名称,自动兼容 xls/xlsx + List> rawList = reader.readAll(); + //学历 + Map educationDictMap = onlineDictService.getDictMap(2054094099727781888L); + educationDictMap = educationDictMap.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); + //政治面貌 + Map politicalDictMap = onlineDictService.getDictMap(2054098587905691648L); + politicalDictMap = politicalDictMap.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); + for (Map row : rawList) { + Map dataMap = new LinkedHashMap<>(); + + for (Map.Entry entry : row.entrySet()) { + String header = entry.getKey() == null ? "" : entry.getKey().trim(); + // 中文表头转英文,映射中没有的表头保留原值 + String key = HEADER_MAP.getOrDefault(header, header); + Object value = entry.getValue(); + dataMap.put(key, value); + if (key.equals("gender")) { + dataMap.put("gender", value.equals("男") ? "1" : "0"); + } + if (key.equals("education")) { + dataMap.put("education", educationDictMap.get(value.toString())); + } + if (key.equals("political_status")) { + dataMap.put("political_status", politicalDictMap.get(value.toString())); + } + if ("birth_date".equals(key)) { + if (value instanceof Date) { + value = DateUtil.formatDateTime((Date) value); + } else if (value instanceof String && StringUtils.isNotBlank((String) value)) { + value = DateUtil.formatDateTime(DateUtil.parse((String) value)); + } + dataMap.put(key, value); + } + } + dataMap.put("billstatus", "A"); + dataMap.put("apply_time", DateUtil.formatDateTime(new Date())); + dataList.add(dataMap); + } + ObjectCollection expertManage = ormGenDataSourceUtil.query("expert_manage", new Filter(), new Selector()); + dataList.forEach(dataMap -> { + long count = expertManage.stream().filter(f -> f.get("id_card").equals(dataMap.get("id_card"))).count(); + if (count > 0) { + return; + } + ObjectValue value = new ObjectValue("expert_manage"); + value.setValues(dataMap); + try { + ormGenDataSourceUtil.addNew("expert_manage", value); + } catch (Exception e) { + e.printStackTrace(); + } + }); + + } catch (IOException e) { + throw new MyRuntimeException("文件解析失败: " + e.getMessage()); + } + return ResponseResult.success("导入成功"); + } + +} \ No newline at end of file diff --git a/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/controller/LoginController.java b/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/controller/LoginController.java index 7387b36..c38e7ee 100644 --- a/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/controller/LoginController.java +++ b/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/controller/LoginController.java @@ -126,6 +126,10 @@ public class LoginController { private UpDownloaderFactory upDownloaderFactory; @Autowired private DataFilterProperties dataFilterProperties; + + @Autowired + private SupersetSsoService supersetSsoService; + @Value("${hubCloud.secret}") private String HubCloudSecret; @Value("${dingTalk.secret}") @@ -196,6 +200,48 @@ public class LoginController { return ResponseResult.success(myPageData); } + + + + @GetMapping("/getSupersetDashboardUrl") + public ResponseResult getSupersetDashboardUrl( + @RequestParam(name = "dashboardId") String dashboardId) { + try { + String accessToken = supersetSsoService.getAccessToken(); + JSONObject result = new JSONObject(); + result.put("accessToken", accessToken); + result.put("dashboardUrl", supersetSsoService.buildDashboardUrl(dashboardId)); + return ResponseResult.success(result); + } catch (Exception e) { + log.error("获取Superset仪表盘地址失败", e); + return ResponseResult.error("500", "获取Superset仪表盘地址失败: " + e.getMessage()); + } + } + + @GetMapping("/getSupersetGuestToken") + public ResponseResult getSupersetGuestToken( + @RequestParam(name = "dashboardId") String dashboardId, + @RequestParam(name = "username", required = false) String username, + @RequestParam(name = "firstName", required = false, defaultValue = "Guest") String firstName, + @RequestParam(name = "lastName", required = false, defaultValue = "User") String lastName) { + try { + TokenData tokenData = TokenData.takeFromRequest(); + if (StrUtil.isBlank(username)) { + username = tokenData != null ? tokenData.getLoginName() : "guest_user"; + } + String guestToken = supersetSsoService.getGuestToken( + dashboardId, username, firstName, lastName, null); + JSONObject result = new JSONObject(); + result.put("guestToken", guestToken); + result.put("embeddedUrl", supersetSsoService.buildEmbeddedDashboardUrl(dashboardId, guestToken)); + return ResponseResult.success(result); + } catch (Exception e) { + log.error("获取Superset Guest Token失败", e); + return ResponseResult.error("500", "获取Superset Guest Token失败: " + e.getMessage()); + } + } + + private BillData convertOvToBillData(ObjectValue objectValue) { BillData billData = new BillData(); diff --git a/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/service/SupersetSsoService.java b/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/service/SupersetSsoService.java new file mode 100644 index 0000000..b8a9e82 --- /dev/null +++ b/application-tenant/tenant-admin/src/main/java/apelet/tenantadmin/upms/service/SupersetSsoService.java @@ -0,0 +1,121 @@ +package apelet.tenantadmin.upms.service; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBucket; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Slf4j +@Service +public class SupersetSsoService { + + @Value("${superset.baseUrl}") + private String supersetBaseUrl; + + @Value("${superset.username}") + private String supersetUsername; + + @Value("${superset.password}") + private String supersetPassword; + + @Autowired + private RedissonClient redissonClient; + + private static final String SUPERSET_TOKEN_CACHE_KEY = "superset:access_token"; + private static final int TOKEN_CACHE_SECONDS = 3500; + + public String getAccessToken() { + RBucket cached = redissonClient.getBucket(SUPERSET_TOKEN_CACHE_KEY); + if (cached.isExists()) { + return cached.get(); + } + String url = supersetBaseUrl + "/api/v1/security/login"; + JSONObject payload = new JSONObject(); + payload.put("username", supersetUsername); + payload.put("password", supersetPassword); + payload.put("provider", "db"); + payload.put("refresh", true); + + HttpResponse response = HttpRequest.post(url) + .header("Content-Type", "application/json") + .body(payload.toJSONString()) + .timeout(10000) + .execute(); + + if (!response.isOk()) { + log.error("Superset login failed, status={}, body={}", response.getStatus(), response.body()); + throw new RuntimeException("Superset认证失败: " + response.body()); + } + + JSONObject result = JSON.parseObject(response.body()); + String accessToken = result.getString("access_token"); + + cached.set(accessToken, TOKEN_CACHE_SECONDS, TimeUnit.SECONDS); + log.info("Superset access token refreshed successfully."); + return accessToken; + } + + public String getGuestToken(String dashboardId, String username, String firstName, String lastName, + List> rlsRules) { + String accessToken = getAccessToken(); + + String url = supersetBaseUrl + "/api/v1/security/guest_token/"; + + JSONObject user = new JSONObject(); + user.put("username", username); + user.put("first_name", firstName); + user.put("last_name", lastName); + + List> resources = new ArrayList<>(); + Map resource = new HashMap<>(); + resource.put("type", "dashboard"); + resource.put("id", dashboardId); + resources.add(resource); + + JSONObject payload = new JSONObject(); + payload.put("user", user); + payload.put("resources", resources); + if (rlsRules != null && !rlsRules.isEmpty()) { + payload.put("rls", rlsRules); + } else { + payload.put("rls", new ArrayList<>()); + } + + HttpResponse response = HttpRequest.post(url) + .header("Content-Type", "application/json") + .header("Authorization", "Bearer " + accessToken) + .body(payload.toJSONString()) + .timeout(10000) + .execute(); + + if (!response.isOk()) { + log.error("Superset get guest token failed, status={}, body={}", response.getStatus(), response.body()); + redissonClient.getBucket(SUPERSET_TOKEN_CACHE_KEY).delete(); + throw new RuntimeException("获取Superset Guest Token失败: " + response.body()); + } + + JSONObject result = JSON.parseObject(response.body()); + return result.getString("token"); + } + + public String buildDashboardUrl(String dashboardId) { + String accessToken = getAccessToken(); + return supersetBaseUrl + "superset/dashboard/" + dashboardId + "/?token=" + accessToken; + } + + public String buildEmbeddedDashboardUrl(String dashboardId, String guestToken) { + return supersetBaseUrl + "superset/embed/dashboard/" + dashboardId + "/?guest_token=" + guestToken; + } +} \ No newline at end of file diff --git a/application-tenant/tenant-admin/src/main/resources/application-config.yml b/application-tenant/tenant-admin/src/main/resources/application-config.yml index b51ea11..3cd7ae6 100644 --- a/application-tenant/tenant-admin/src/main/resources/application-config.yml +++ b/application-tenant/tenant-admin/src/main/resources/application-config.yml @@ -159,3 +159,8 @@ common-redis: poolSize: 20 # 连接池中最小空闲数量。 minIdle: 5 + +superset: + baseUrl: http://192.168.100.24:8088/ + username: admin + password: admin \ No newline at end of file diff --git a/common/common-association/pom.xml b/common/common-association/pom.xml index e97366e..9e7b096 100644 --- a/common/common-association/pom.xml +++ b/common/common-association/pom.xml @@ -42,7 +42,7 @@ apelet common-generator - 1.0.2 + 1.0.3 apelet @@ -69,8 +69,11 @@ javase 3.5.1 - - + + com.deepoove + poi-tl + 1.12.2 + diff --git a/common/common-association/src/main/java/apelet/association/controller/AssociationActivitiesController.java b/common/common-association/src/main/java/apelet/association/controller/AssociationActivitiesController.java index 91060c2..d3e9f38 100644 --- a/common/common-association/src/main/java/apelet/association/controller/AssociationActivitiesController.java +++ b/common/common-association/src/main/java/apelet/association/controller/AssociationActivitiesController.java @@ -1,6 +1,7 @@ package apelet.association.controller; import apelet.association.utils.DataTransformationUtil; +import apelet.common.core.annotation.NoAuthInterface; import apelet.common.core.object.ObjectCollection; import apelet.common.core.object.ObjectValue; import apelet.common.core.object.ResponseResult; @@ -8,16 +9,14 @@ import apelet.common.generator.utils.OrmGenDataSourceUtil; import apelet.common.orm.impl.Filter; import apelet.common.orm.impl.FilterItem; import apelet.common.orm.impl.Selector; -import cn.hutool.core.util.ObjectUtil; + import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; + @RestController @RequestMapping("/tenantadmin/activity") @@ -52,56 +51,38 @@ public class AssociationActivitiesController { if (StringUtils.isEmpty(signInUnit)) { return ResponseResult.error("500", "签到单位为空!!!"); } + + System.out.println("333333333333333333333333333333333333333333333333"); Integer type = jsonObject.getInteger("type"); Filter filter = new Filter(); filter.add(new FilterItem("unit_name", FilterItem.equals, signInUnit)); ObjectCollection collection = ormGenDataSourceUtil.query("membership_apply", filter, new Selector()); - if (collection == null || collection.isEmpty()) { - return ResponseResult.error("500", "签到单位不存在, 请检查签到单位!!!"); - } - - ObjectCollection managerCollection = ormGenDataSourceUtil.query("membership_manager", new Filter(), new Selector()); - List> managerList = DataTransformationUtil.objectCollectionToList(managerCollection); - Map> mapMap = managerList.stream().collect(Collectors.toMap(map -> String.valueOf(map.get("id")), map -> map, (oldValue, newValue) -> oldValue)); - - ObjectValue member = null; - for (int i = 0; i < collection.size(); i++) { - ObjectValue object = collection.getObject(i); - ObjectValue manger = object.getObjectValue("membership_manger_id"); - Map map = mapMap.get(manger != null && manger.get("id") != null ? manger.get("id") : ""); - Object phone = map.get("phone"); - if (ObjectUtil.equal(phone, phoneNumber)) { - member = object; - } - } - if (member == null) { - return ResponseResult.error("500", signInUnit + " 签到单位下签到人不存在!!!"); - } if (type == 1) { //签到 ObjectValue value = new ObjectValue("check_in_out"); value.put("name", signInPerson); value.put("phone", phoneNumber); - value.put("membership_id", member); - value.put("create_time", new Date()); +// value.put("membership_id", member); value.put("create_time", new Date()); value.put("parent_id", activityId); value.put("check_in", 1); ormGenDataSourceUtil.addNew(value.getTableName(), value); } + if (type == 2) { //签退 filter = new Filter(); - filter.add(new FilterItem("membership_id", FilterItem.equals, member.get("id"))); + filter.add(new FilterItem("name", FilterItem.equals, signInPerson)); + filter.add(new FilterItem("phone", FilterItem.equals, phoneNumber)); filter.add(new FilterItem("parent_id", FilterItem.equals, activityId)); filter.add(new FilterItem("check_in", FilterItem.equals, 1)); collection = ormGenDataSourceUtil.query("check_in_out", filter, new Selector()); if (collection != null && !collection.isEmpty()) { ObjectValue object = collection.getObject(0); object.put("check_out", 1); - ormGenDataSourceUtil.update("check_in_out", object, new Selector()); + ormGenDataSourceUtil.update("check_in_out", object, null); } } return ResponseResult.success("签到成功!!!"); diff --git a/common/common-association/src/main/java/apelet/association/controller/HomeController.java b/common/common-association/src/main/java/apelet/association/controller/HomeController.java index 370cee8..f74b5f7 100644 --- a/common/common-association/src/main/java/apelet/association/controller/HomeController.java +++ b/common/common-association/src/main/java/apelet/association/controller/HomeController.java @@ -67,7 +67,7 @@ public class HomeController { // 入会申请 Filter filter = new Filter(); - filter.add(new FilterItem("billstatus", FilterItem.not_equals, "C")); + filter.add(new FilterItem("billstatus", FilterItem.equals, "B")); ObjectCollection membershipApply = ormGenDataSourceUtil.query("membership_apply", filter, new Selector()); map.put("MembershipApplication", membershipApply.size()); diff --git a/common/common-association/src/main/java/apelet/association/plugin/active/ActivityInfoDetailsPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/active/ActivityInfoDetailsPlugin.java index 018c538..26aaca6 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/active/ActivityInfoDetailsPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/active/ActivityInfoDetailsPlugin.java @@ -69,35 +69,58 @@ public class ActivityInfoDetailsPlugin extends ListPlugin { if (!collect.isEmpty()) { ObjectValue memberInvitation = collect.get(0); ObjectValue membershipApplyId = memberInvitation.getObjectValue("membership_apply_id"); - if (membershipApplyId == null) { + if (membershipApplyId == null || !membershipApplyId.containsKey("id")) { return; } ObjectValue membershipApply = ormGenDataSourceUtil.queryOne(membershipApplyId.getTableName(), membershipApplyId.getString("id")); + if (membershipApply == null) { + return; + } ObjectCollection applyEntry = membershipApply.getObjectCollection("membership_apply_entry"); - if (applyEntry == null) { + if (applyEntry == null || applyEntry.isEmpty()) { return; } ObjectValue entryObject = applyEntry.getObject(0); + if (entryObject == null) { + return; + } this.setWidgetAttributeByEntry("table1786587576012", "unit_name", AttributeEnum.VALUE_CHANGE, membershipApply.getString("unit_name"), objectValue.getString("rowkeysubset")); this.setWidgetAttributeByEntry("table1786587576012", "person", AttributeEnum.VALUE_CHANGE, entryObject.getString("contact_name"), objectValue.getString("rowkeysubset")); this.setWidgetAttributeByEntry("table1786587576012", "phone", AttributeEnum.VALUE_CHANGE, entryObject.getString("contact_phone"), objectValue.getString("rowkeysubset")); } } //专家邀请 - if(widgetVariableName.equals("table1786587648327")){ + if (widgetVariableName.equals("table1786587648327")) { ObjectCollection expertInvitations = objectValue.getObjectCollection("expert_invitation"); List collect = expertInvitations.stream().filter(f -> f.getString("rowkey").equals(objectValue.getString("rowkeysubset"))).collect(Collectors.toList()); if (!collect.isEmpty()) { ObjectValue expertInvitation = collect.get(0); ObjectValue expert = expertInvitation.getObjectValue("expert_id"); + if (expert == null || !expert.containsKey("id")) { + return; + } expert = ormGenDataSourceUtil.queryOne(expert.getTableName(), expert.getString("id")); this.setWidgetAttributeByEntry("table1786587648327", "person", AttributeEnum.VALUE_CHANGE, expert.getString("name"), objectValue.getString("rowkeysubset")); this.setWidgetAttributeByEntry("table1786587648327", "phone", AttributeEnum.VALUE_CHANGE, expert.getString("phone"), objectValue.getString("rowkeysubset")); } } //访客邀请 - if(widgetVariableName.equals("table1786587726532")){ - + if (widgetVariableName.equals("table1786587726532")) { + ObjectCollection visitorInvitations = objectValue.getObjectCollection("visitor_invitation"); + List collect = visitorInvitations.stream().filter(f -> f.getString("rowkey").equals(objectValue.getString("rowkeysubset"))).collect(Collectors.toList()); + if (!collect.isEmpty()) { + ObjectValue visitorInvitation = collect.get(0); + ObjectValue number = visitorInvitation.getObjectValue("number"); + if (number == null || !number.containsKey("id")) { + return; + } + ObjectValue visitorHistory = ormGenDataSourceUtil.queryOne(number.getTableName(), number.getString("id")); + if (visitorHistory == null) { + return; + } + this.setWidgetAttributeByEntry("table1786587726532", "person", AttributeEnum.VALUE_CHANGE, visitorHistory.getString("name"), objectValue.getString("rowkeysubset")); + this.setWidgetAttributeByEntry("table1786587726532", "phone", AttributeEnum.VALUE_CHANGE, visitorHistory.getString("phone"), objectValue.getString("rowkeysubset")); + } } } @@ -107,10 +130,10 @@ public class ActivityInfoDetailsPlugin extends ListPlugin { // 生成报名二维码 if (widgetVariableName.equals("button1786587153460")) { String registrationQr = objectValue.getString("registration_qr"); - if (StringUtils.isNotEmpty(registrationQr)) { - this.showErrorMessage("当前已存在报名二维码, 请勿重复生成!!!"); - return; - } +// if (StringUtils.isNotEmpty(registrationQr)) { +// this.showErrorMessage("当前已存在报名二维码, 请勿重复生成!!!"); +// return; +// } OnlineEventPluginExecuteDto dto = getDto(); String savePath = System.getProperty("user.dir") + "\\zz-resource\\qrcode"; File QRFile = null; @@ -120,12 +143,12 @@ public class ActivityInfoDetailsPlugin extends ListPlugin { // 生成 报名二维码 long id = objectValue.getLong("id"); - String url = "http://192.168.100.42:8099" + "/#/?" + + String url = "http://58.48.135.5:8069" + "/#/?" + "loginName=" + "admin" + "&password=" + "123456" + - "&entryId=" + "2087710350152568832" + + "&entryId=" + "2087413611113746432" + "&bindType=" + "1" + - "&onlineFormId=" + "2048951917157027840" + + "&onlineFormId=" + "2087385700075835392" + "&activeId=" + id; byte[] checkInQr = qrCodeUtil.generateQrCode(url, 350, 350); diff --git a/common/common-association/src/main/java/apelet/association/plugin/active/ActivityInvitationSavePlugin.java b/common/common-association/src/main/java/apelet/association/plugin/active/ActivityInvitationSavePlugin.java new file mode 100644 index 0000000..17dab6d --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/active/ActivityInvitationSavePlugin.java @@ -0,0 +1,48 @@ +package apelet.association.plugin.active; + +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.plugin.EndOperationTransactionArgs; +import apelet.common.online.plugin.OperationServicePlugIn; +import apelet.common.orm.impl.Filter; +import apelet.common.orm.impl.FilterItem; +import apelet.common.orm.impl.Selector; + +public class ActivityInvitationSavePlugin extends OperationServicePlugIn { + + private OrmGenDataSourceUtil ormGenDataSourceUtil; + + public ActivityInvitationSavePlugin() { + ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); + } + + @Override + public void endOperationTransaction(EndOperationTransactionArgs e) { + ObjectValue objectValue = e.getModel(); + ObjectCollection collection = objectValue.getObjectCollection("visitor_invitation"); + if(collection == null){ + return; + } + Filter filter = new Filter(); + filter.add(new FilterItem("parent_id", FilterItem.equals, objectValue.get("id"))); + ObjectCollection visitorInvitationHis = ormGenDataSourceUtil.query("visitor_invitation_his", filter, new Selector()); + + for (ObjectValue value : collection) { + long count = visitorInvitationHis.stream().filter(f -> f.get("name").equals(value.get("name")) && + f.get("unit_name").equals(value.get("unit_name"))).count(); + if(count == 0){ + continue; + } + ObjectValue invitationHis = new ObjectValue("visitor_invitation_his"); + invitationHis.setValues(value.getValues()); + invitationHis.remove("id"); + try { + ormGenDataSourceUtil.addNew(invitationHis.getTableName(), invitationHis); + } catch (Exception ex) { + + } + } + } +} diff --git a/common/common-association/src/main/java/apelet/association/plugin/active/ActivitySignConfigPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/active/ActivitySignConfigPlugin.java index 4c40e69..cf9cd36 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/active/ActivitySignConfigPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/active/ActivitySignConfigPlugin.java @@ -27,6 +27,8 @@ import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -113,20 +115,23 @@ public class ActivitySignConfigPlugin extends ListPlugin { File checkOutFile = null; File checkInFile = null; try { - Object activityId = objectValue.get("id"); - Object activityName = objectValue.get("name"); + Map parentParams = getDto().getParentParams(); + Object activityId = parentParams.get("id"); + ObjectValue value = ormGenDataSourceUtil.queryOne("association_activity", activityId); + String name = value.getString("name"); OnlineDatasource onlineDatasource = onlineDatasourceService.getById(model.getDatasourceId()); OnlineTable table = onlineTableService.getOnlineTableFromCache(onlineDatasource.getMasterTableId()); - - String checkIn = url + "/#/pages/login/routerHdView?activityId=" + activityId + "&activityName=" + activityName + "&type=" + 1; + // 中文活动名称做 URL 编码,保证扫码 URL 为纯 ASCII;前端 decodeURIComponent 后仍是原中文 + String encodedName = URLEncoder.encode(name, StandardCharsets.UTF_8.name()); + String checkIn = url + "/#/pages/login/routerHdView?activityId=" + activityId + "&activityName=" + encodedName + "&type=1"; byte[] checkInQr = qrCodeUtil.generateQrCode(checkIn, 350, 350); checkInFile = MyFileUtil.writeToFile(checkInQr, savePath, "qrcode-" + System.currentTimeMillis() + ".png"); MultipartFile checkInMultipart = MyFileUtil.readFileAsMultipartFile(checkInFile, "image/png"); UploadResponseInfo checkInUpload = myFileUtil.uploadMyFile(table, "sign_in_code", true, checkInMultipart); this.setWidgetAttribute("signInCode", AttributeEnum.VALUE_CHANGE, checkInUpload); - String checkOut = url + "#/pages/login/routerHdView?activityId=" + activityId + "&activityName=" + activityName + "&type=" + 2; + String checkOut = url + "/#/pages/login/routerHdView?activityId=" + activityId + "&activityName=" + encodedName + "&type=2"; byte[] checkOutQr = qrCodeUtil.generateQrCode(checkOut, 300, 300); checkOutFile = MyFileUtil.writeToFile(checkOutQr, savePath, "qrcode-" + System.currentTimeMillis() + ".png"); MultipartFile checkOutMultipart = MyFileUtil.readFileAsMultipartFile(checkOutFile, "image/png"); diff --git a/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueAuditNewOpPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueAuditNewOpPlugin.java new file mode 100644 index 0000000..e6026f8 --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueAuditNewOpPlugin.java @@ -0,0 +1,53 @@ +package apelet.association.plugin.clueManage; + +import apelet.common.core.exception.MyRuntimeException; +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.plugin.BeginOperationTransactionArgs; +import apelet.common.online.plugin.OperationServicePlugIn; +import apelet.common.online.plugin.OperationServicePlugInArgs; +import apelet.common.orm.impl.Selector; +import apelet.common.orm.impl.SelectorItem; + +public class ClueAuditNewOpPlugin extends OperationServicePlugIn { + + private final OrmGenDataSourceUtil ormGenDataSourceUtil; + + public ClueAuditNewOpPlugin() { + ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); + } + + @Override + public void onPreparePropertys(OperationServicePlugInArgs e) { + e.addFiledKey("id"); + e.addFiledKey("status"); + } + + @Override + public void beginOperationTransaction(BeginOperationTransactionArgs e) { + super.beginOperationTransaction(e); + ObjectCollection modelCollcetion = e.getModelCollcetion(); + + if (modelCollcetion != null && !modelCollcetion.isEmpty()) { + for (int i = 0; i < modelCollcetion.size(); i++) { + try { + // 获取单据对象 + ObjectValue bill = modelCollcetion.getObject(i); + if (bill.get("status").equals("B")) { + bill.put("status", "C"); + Selector selector = new Selector(); + selector.getList().add(new SelectorItem("status")); + ormGenDataSourceUtil.update(bill.getTableName(), bill, selector); + } else { + throw new MyRuntimeException("单据不为提交状态"); + } + + } catch (Exception ex) { + throw new MyRuntimeException(ex.getMessage()); + } + } + } + } +} diff --git a/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueManageFormPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueManageFormPlugin.java index 4c64b60..4ed2104 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueManageFormPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueManageFormPlugin.java @@ -3,6 +3,11 @@ package apelet.association.plugin.clueManage; import apelet.common.core.object.ObjectValue; import apelet.common.online.abstractplugin.ExecutePluginParent; import apelet.common.online.model.constant.AttributeEnum; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +import java.util.Arrays; +import java.util.List; public class ClueManageFormPlugin extends ExecutePluginParent { @@ -10,6 +15,46 @@ public class ClueManageFormPlugin extends ExecutePluginParent { @Override public void formCreated(String widgetVariableName, ObjectValue objectValue) { + + if(objectValue.getString("id") != null){ + String billstatus = objectValue.getString("billstatus"); + if("A".equals(billstatus)){ + List list = Arrays.asList( + createButtonConfig("保存", true), + createButtonConfig("放弃线索申请", false), + createButtonConfig("审核", false), + createButtonConfig("激活", true), + createButtonConfig("撤销", false), + createButtonConfig("反审核", false) + ); + this.setWidgetAttribute("", AttributeEnum.BTN_HIDDEN, list); + } + if("B".equals(billstatus)){ + + List list = Arrays.asList( + createButtonConfig("保存", false), + createButtonConfig("放弃线索申请", false), + createButtonConfig("审核", false), + createButtonConfig("激活", false), + createButtonConfig("撤销", true), + createButtonConfig("反审核", false) + ); + this.setWidgetAttribute("", AttributeEnum.BTN_HIDDEN, list); + } + + if("C".equals(billstatus)){ + + List list = Arrays.asList( + createButtonConfig("保存", false), + createButtonConfig("放弃线索申请", true), + createButtonConfig("审核", false), + createButtonConfig("激活", false), + createButtonConfig("撤销", true), + createButtonConfig("反审核", false) + ); + this.setWidgetAttribute("", AttributeEnum.BTN_HIDDEN, list); + } + } super.formCreated(widgetVariableName, objectValue); if (objectValue.get("clue_type") == null) { this.setWidgetAttribute("clueType", AttributeEnum.VALUE_CHANGE, "0"); @@ -17,6 +62,18 @@ public class ClueManageFormPlugin extends ExecutePluginParent { if (objectValue.get("clue_type") == null) { this.setWidgetAttribute("billstatus", AttributeEnum.VALUE_CHANGE, "A"); } + if (objectValue.get("clue_type") == null) { + this.setWidgetAttribute("status", AttributeEnum.VALUE_CHANGE, "A"); + } + } + + + private JSONObject createButtonConfig(String name, boolean isHidden) { + JSONObject btn = new JSONObject(); + btn.put("name", name); + btn.put("isHidden", !isHidden); + return btn; } + } diff --git a/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueSubmitNewOpPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueSubmitNewOpPlugin.java new file mode 100644 index 0000000..3dd8c30 --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueSubmitNewOpPlugin.java @@ -0,0 +1,54 @@ +package apelet.association.plugin.clueManage; + +import apelet.common.core.exception.MyRuntimeException; +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.plugin.BeginOperationTransactionArgs; +import apelet.common.online.plugin.OperationResult; +import apelet.common.online.plugin.OperationServicePlugIn; +import apelet.common.online.plugin.OperationServicePlugInArgs; +import apelet.common.orm.impl.Selector; +import apelet.common.orm.impl.SelectorItem; + +public class ClueSubmitNewOpPlugin extends OperationServicePlugIn { + + private final OrmGenDataSourceUtil ormGenDataSourceUtil; + + public ClueSubmitNewOpPlugin() { + ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); + } + + @Override + public void onPreparePropertys(OperationServicePlugInArgs e) { + e.addFiledKey("id"); + e.addFiledKey("status"); + } + + @Override + public void beginOperationTransaction(BeginOperationTransactionArgs e) { + super.beginOperationTransaction(e); + ObjectCollection modelCollcetion = e.getModelCollcetion(); + + if (modelCollcetion != null && !modelCollcetion.isEmpty()) { + for (int i = 0; i < modelCollcetion.size(); i++) { + try { + // 获取单据对象 + ObjectValue bill = modelCollcetion.getObject(i); + if (bill.get("status").equals("A")) { + bill.put("status", "B"); + Selector selector = new Selector(); + selector.getList().add(new SelectorItem("status")); + ormGenDataSourceUtil.update(bill.getTableName(), bill, selector); + } else { + throw new MyRuntimeException("单据不为编辑状态"); + } + + } catch (Exception ex) { + throw new MyRuntimeException(ex.getMessage()); + } + } + } + } + } diff --git a/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueUnAuditNewOpPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueUnAuditNewOpPlugin.java new file mode 100644 index 0000000..47d61e1 --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueUnAuditNewOpPlugin.java @@ -0,0 +1,53 @@ +package apelet.association.plugin.clueManage; + +import apelet.common.core.exception.MyRuntimeException; +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.plugin.BeginOperationTransactionArgs; +import apelet.common.online.plugin.OperationServicePlugIn; +import apelet.common.online.plugin.OperationServicePlugInArgs; +import apelet.common.orm.impl.Selector; +import apelet.common.orm.impl.SelectorItem; + +public class ClueUnAuditNewOpPlugin extends OperationServicePlugIn { + + private final OrmGenDataSourceUtil ormGenDataSourceUtil; + + public ClueUnAuditNewOpPlugin() { + ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); + } + + @Override + public void onPreparePropertys(OperationServicePlugInArgs e) { + e.addFiledKey("id"); + e.addFiledKey("status"); + } + + @Override + public void beginOperationTransaction(BeginOperationTransactionArgs e) { + super.beginOperationTransaction(e); + ObjectCollection modelCollcetion = e.getModelCollcetion(); + + if (modelCollcetion != null && !modelCollcetion.isEmpty()) { + for (int i = 0; i < modelCollcetion.size(); i++) { + try { + // 获取单据对象 + ObjectValue bill = modelCollcetion.getObject(i); + if (bill.get("status").equals("C")) { + bill.put("status", "A"); + Selector selector = new Selector(); + selector.getList().add(new SelectorItem("status")); + ormGenDataSourceUtil.update(bill.getTableName(), bill, selector); + } else { + throw new MyRuntimeException("单据不为审核状态"); + } + + } catch (Exception ex) { + throw new MyRuntimeException(ex.getMessage()); + } + } + } + } +} diff --git a/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueUnSubmitNewOpPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueUnSubmitNewOpPlugin.java new file mode 100644 index 0000000..776eac3 --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/clueManage/ClueUnSubmitNewOpPlugin.java @@ -0,0 +1,53 @@ +package apelet.association.plugin.clueManage; + +import apelet.common.core.exception.MyRuntimeException; +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.plugin.BeginOperationTransactionArgs; +import apelet.common.online.plugin.OperationServicePlugIn; +import apelet.common.online.plugin.OperationServicePlugInArgs; +import apelet.common.orm.impl.Selector; +import apelet.common.orm.impl.SelectorItem; + +public class ClueUnSubmitNewOpPlugin extends OperationServicePlugIn { + + private final OrmGenDataSourceUtil ormGenDataSourceUtil; + + public ClueUnSubmitNewOpPlugin() { + ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); + } + + @Override + public void onPreparePropertys(OperationServicePlugInArgs e) { + e.addFiledKey("id"); + e.addFiledKey("status"); + } + + @Override + public void beginOperationTransaction(BeginOperationTransactionArgs e) { + super.beginOperationTransaction(e); + ObjectCollection modelCollcetion = e.getModelCollcetion(); + + if (modelCollcetion != null && !modelCollcetion.isEmpty()) { + for (int i = 0; i < modelCollcetion.size(); i++) { + try { + // 获取单据对象 + ObjectValue bill = modelCollcetion.getObject(i); + if (bill.get("status").equals("B")) { + bill.put("status", "A"); + Selector selector = new Selector(); + selector.getList().add(new SelectorItem("status")); + ormGenDataSourceUtil.update(bill.getTableName(), bill, selector); + } else { + throw new MyRuntimeException("单据不为提交状态不能撤销"); + } + + } catch (Exception ex) { + throw new MyRuntimeException(ex.getMessage()); + } + } + } + } +} diff --git a/common/common-association/src/main/java/apelet/association/plugin/fileLibraryMange/FileLibrayListPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/fileLibraryMange/FileLibrayListPlugin.java index fa817e7..eee49b8 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/fileLibraryMange/FileLibrayListPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/fileLibraryMange/FileLibrayListPlugin.java @@ -1,6 +1,10 @@ package apelet.association.plugin.fileLibraryMange; import apelet.common.core.object.ObjectValue; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.object.TokenData; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; import apelet.common.online.abstractplugin.ListPlugin; import apelet.common.online.dto.OnlineEventPluginExecuteDto; import apelet.common.online.dto.OnlineFilterDto; @@ -13,19 +17,46 @@ import java.util.Map; public class FileLibrayListPlugin extends ListPlugin { @Override - protected Filter getFilter() { + public String getSql(ObjectValue objectValue) { OnlineEventPluginExecuteDto filter1 = this.getDto(); ArrayList filterDtoList = (ArrayList) filter1.getListParams().get("filterDtoList"); - Filter filter = new Filter(); + +// return super.getSql(objectValue); + String sql = "select * from file_library "; + //阅读权限 + sql += "where (read_auth = 1"; if (!filterDtoList.isEmpty()) { OnlineFilterDto onlineFilterDto = filterDtoList.get(0); Object filterFile = onlineFilterDto.getColumnValue(); - filter.add(new FilterItem("classification", "=", filterFile)); + //上线 + sql += " and classification = "+filterFile.toString(); + } + System.out.println(sql); + Long userId = TokenData.takeFromRequest().getUserId(); + //获取当前用户 + ObjectValue user = ormGenDataSourceUtil().queryOne("xy_sys_user", userId); + String userName = user.getString("show_name"); + String userType = user.getString("user_type"); - } else { - filter = new Filter(); + System.out.println("userName:" + userName+user.getString("user_type")); + if (userType.equals("0")) { + sql += " or read_auth = 2"; } - return filter; + sql += " and publish_status = 1"; + sql += " or (create_user_id = "+userId.toString()+" and read_auth = 3))"; + //下线 + sql += " or (publish_status = 2"; + if (!filterDtoList.isEmpty()) { + OnlineFilterDto onlineFilterDto = filterDtoList.get(0); + Object filterFile = onlineFilterDto.getColumnValue(); + sql += " and classification = "+filterFile.toString(); + } + if (userType.equals("0")) { + sql += " or read_auth = 2"; + } + sql += " or (create_user_id = "+userId.toString()+" and read_auth = 3))"; + + return sql; } /** diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java index e45add3..d3b9077 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipApplyListFilterPlugin.java @@ -1,9 +1,22 @@ package apelet.association.plugin.member; +import apelet.common.core.exception.MyRuntimeException; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; import apelet.common.online.abstractplugin.ListPlugin; +import apelet.common.online.dto.OnlineEventPluginExecuteDto; +import apelet.common.online.model.ShowParameter; +import apelet.common.online.model.constant.AttributeEnum; +import apelet.common.online.model.constant.ShowTypeEnum; +import apelet.common.online.model.constant.ViewStatus; import apelet.common.orm.impl.Filter; import apelet.common.orm.impl.FilterItem; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * @ClassName: MembershipApplyListFilterPlugin * @Author: huangdehua @@ -12,20 +25,148 @@ import apelet.common.orm.impl.FilterItem; * 在列表加载前添加过滤条件,只显示最新单据(is_history=0) */ public class MembershipApplyListFilterPlugin extends ListPlugin { + /** - * 是否历史字段 + * 目标表单ID - membership_apply 表单在平台中的表单ID */ - private static final String FIELD_IS_HISTORY = "history"; - + private static final String TARGET_FORM_ID = "2048951917157027840"; + /** + * 传递到弹窗的参数key - 单据ID + */ + private static final String PARAM_BILL_ID = "sourceBillId"; /** - * 非历史记录 + * 传递到弹窗的参数key - 单据编号 */ - private static final String IS_HISTORY_NO = "1"; + private static final String PARAM_BILL_NUMBER = "sourceBillNumber"; + private final OrmGenDataSourceUtil ormGenDataSourceUtil; + + public MembershipApplyListFilterPlugin() { + ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); + } @Override protected Filter getFilter() { Filter filter = new Filter(); - filter.add(new FilterItem(FIELD_IS_HISTORY, "!=", IS_HISTORY_NO)); + filter.add(new FilterItem("deleted_flag", FilterItem.equals, "1")); + filter.add(new FilterItem("history", "!=", 1)); return filter; } + + + @Override + protected void afterLoadData(List> dataList) { + super.afterLoadData(dataList); + } + + @Override + public void afterLoadFormData(String widgetVariableName, ObjectValue objectValue) { + super.afterLoadFormData(widgetVariableName, objectValue); + + } + + @Override + public void beforeLoadTableData(String widgetVariableName, ObjectValue objectValue) { + OnlineEventPluginExecuteDto dto = getDto(); + List> jumpParams = getDto().getJumpParams(); + if (jumpParams == null || jumpParams.isEmpty()) { + return; + } + for (Map jumpParam : jumpParams) { + jumpParam.forEach( (k,v)->{ + if(k.equals("billstatus")){ + this.setWidgetAttribute("billstatus", AttributeEnum.VALUE_CHANGE, v); + } + if(k.equals("overdue")){ + this.setWidgetAttribute("overdue", AttributeEnum.VALUE_CHANGE, v); + } + }); + } + } + + @Override + public void formCreated(String widgetVariableName, ObjectValue objectValue) { + super.formCreated(widgetVariableName, objectValue); + + + + } + + /** + * 按钮点击事件(列表按钮) + * 点击"变更"按钮时,通过 getSelectData 获取列表中选中行的单据数据, + * 以弹窗方式打开入会申请表单,并将选中行数据带入 + * + * @param buttonKey 按钮标识 + * @param objectValue 列表按钮事件数据对象(非表单数据) + */ + @Override + public void buttonTriggered(String buttonKey, ObjectValue objectValue) { + OnlineEventPluginExecuteDto dto = getDto(); + + if ("新建".equals(buttonKey)) { + return; + } + + List rowDatas = dto.getModel().getRowDatas(); + if (rowDatas == null || rowDatas.size() != 1) { + showWarningMessage("请先在列表中选中一条单据"); + this.cancelOperate(); + return; + } + Map data = rowDatas.get(0); + if ("变更".equals(buttonKey)) { + + // 调用 showForm 打开入会申请表单(新建空表单,不加载任何已有记录) + ShowParameter showParameter = new ShowParameter(); + showParameter.setFormId(TARGET_FORM_ID); + showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); + showParameter.setStatus(ViewStatus.EDIT); + showParameter.setPkId(null); // 明确指定为空,表示新建表单而非打开已有单据 + // 设置自定义参数,用于在目标表单中获取源单据数据 + Map customParam = new HashMap<>(); + customParam.put(PARAM_BILL_ID, data.get("id")); + customParam.put(PARAM_BILL_NUMBER, data.get("number")); + showParameter.setCustomParam(customParam); + super.showForm(showParameter); + } + if ("退会".equals(buttonKey)) { + this.showConfirm("withdrawal", "确定是否退出协会?"); + this.cancelOperate(); + } + if ("查看历史".equals(buttonKey)) { + ShowParameter showParameter = new ShowParameter(); + showParameter.setFormId("2071862530363363328"); + showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); + showParameter.setStatus(ViewStatus.VIEW); + + // 设置自定义参数 + Map customParam = new HashMap<>(); + customParam.put("id", data.get("id")); + showParameter.setCustomParam(customParam); + + super.showForm(showParameter); + } + } + + + @Override + public void confirmCallBack(String widgetVariableName, ObjectValue objectValue) { + if (widgetVariableName.equals("withdrawal")) {//confirmid + Map clickResult = (Map) this.getDto().getEventObject(); + if ((Integer) clickResult.get("result") == 1) {//confirm + Map data = getDto().getModel().getRowDatas().get(0); + Object id = data.get("id"); + Filter filter = new Filter(); + filter.add(new FilterItem("id", FilterItem.equals, id)); + try { + ormGenDataSourceUtil.delete("membership_apply", filter); + } catch (Exception e) { + throw new MyRuntimeException(e.getMessage()); + } + } else {//取消 + this.cancelOperate();//取消操作 + } + } + + } } \ No newline at end of file diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipBenefitsUpdatePlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipBenefitsUpdatePlugin.java new file mode 100644 index 0000000..cee3123 --- /dev/null +++ b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipBenefitsUpdatePlugin.java @@ -0,0 +1,48 @@ +package apelet.association.plugin.member; + +import apelet.common.core.exception.MyRuntimeException; +import apelet.common.core.object.ObjectCollection; +import apelet.common.core.object.ObjectValue; +import apelet.common.core.util.ApplicationContextHolder; +import apelet.common.generator.utils.OrmGenDataSourceUtil; +import apelet.common.online.abstractplugin.ExecutePluginParent; +import apelet.common.online.abstractplugin.ListPlugin; +import apelet.common.online.dto.OnlineEventPluginExecuteDto; +import apelet.common.online.model.constant.AttributeEnum; +import apelet.common.orm.impl.Filter; +import apelet.common.orm.impl.FilterItem; +import apelet.common.orm.impl.Selector; + +import java.sql.Date; +import java.util.Map; +import java.util.Optional; + + +public class MembershipBenefitsUpdatePlugin extends ListPlugin { + + private OrmGenDataSourceUtil ormGenDataSourceUtil; + + public MembershipBenefitsUpdatePlugin() { + ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); + } + + @Override + public void formCreated(String widgetVariableName, ObjectValue objectValue) { + ObjectValue value = ormGenDataSourceUtil.queryOne(objectValue.getTableName(), objectValue.getString("id")); + ObjectCollection collection = value.getObjectCollection("equity_services"); + ObjectCollection equityServices = objectValue.getObjectCollection("equity_services"); + for (ObjectValue equityService : equityServices) { + Optional first = collection.stream().filter(f -> f.getString("id").equals(equityService.getString("id"))).findFirst(); + ObjectValue value1 = first.get(); + this.setWidgetAttributeByEntry("table1782205467614", "member", + AttributeEnum.VALUE_CHANGE, value1.getInt("member"), equityService.getString("rowkey")); + this.setWidgetAttributeByEntry("table1782205467614", "director", + AttributeEnum.VALUE_CHANGE, value1.getInt("director"), equityService.getString("rowkey")); + this.setWidgetAttributeByEntry("table1782205467614", "executive_director", + AttributeEnum.VALUE_CHANGE, value1.getInt("executive_director"), equityService.getString("rowkey")); + this.setWidgetAttributeByEntry("table1782205467614", "vice_president", + AttributeEnum.VALUE_CHANGE, value1.getInt("vice_president"), equityService.getString("rowkey")); + } + } +} + diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipFeePayPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipFeePayPlugin.java index 1982e84..9ea2d4a 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipFeePayPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipFeePayPlugin.java @@ -39,6 +39,11 @@ public class MembershipFeePayPlugin extends ExecutePluginParent { this.setWidgetAttribute("membershipDate", AttributeEnum.VALUE_CHANGE, eventParams.get("create_time")); this.setWidgetAttribute("membershipType", AttributeEnum.VALUE_CHANGE, eventParams.get("membership_type")); + + if (eventParams.get("membership_type").equals("E") ) { + this.setWidgetAttribute("bankReceiptV", AttributeEnum.SHOW, false); + } + } } diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipPayPopupPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipPayPopupPlugin.java index 60091c8..baba92c 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipPayPopupPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipPayPopupPlugin.java @@ -43,11 +43,7 @@ public class MembershipPayPopupPlugin extends ExecutePluginParent { customParam.putAll(objectValue.getValues()); showParameter.setCustomParam(customParam); super.showForm(showParameter); - - } - - } } diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipSavePlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipSavePlugin.java index b36b002..f9e16ef 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/member/MembershipSavePlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/member/MembershipSavePlugin.java @@ -64,6 +64,7 @@ public class MembershipSavePlugin extends ExecutePluginParent { DB_FIELD_WIDGET_MAPPING.put("company_address", "companyAddress"); DB_FIELD_WIDGET_MAPPING.put("version_number", "versionNumber"); DB_FIELD_WIDGET_MAPPING.put("change_reason", "changeReason"); + DB_FIELD_WIDGET_MAPPING.put("billstatus", "billstatus"); } /** 保存时需要跳过的非主表字段(objectValue 中的控件 key) */ @@ -137,18 +138,15 @@ public class MembershipSavePlugin extends ExecutePluginParent { private void saveAsNew(ObjectValue objectValue) throws Exception { // 取唯一键单位名称(兼容 unit_name / unitName 两种控件 key) String unitName = getUnitName(objectValue); - // 新增验重:unit_name 已存在则拒绝新增 ObjectValue existBill = findExistBillByUnitName(unitName); if (existBill != null) { - throw new MyRuntimeException("单位【" + unitName + "】已存在,请勿重复新增"); + this.showErrorMessage("单位【" + unitName + "】已存在,请勿重复新增"); + return; } - - // 自动生成单据号(S + yyyyMMdd + 4 位流水号) String number = generateNumber(); - // 组装数据库记录并新增 - ObjectValue newBill = buildNewBill(objectValue, number); - ormGenDataSourceUtil().addNew(TABLE_NAME, newBill); + objectValue.put("number", number); + ormGenDataSourceUtil().addNew(TABLE_NAME, objectValue); } /** diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeFormInitPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeFormInitPlugin.java index e0b1fbd..48be527 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeFormInitPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangeFormInitPlugin.java @@ -95,6 +95,10 @@ public class UnitNameChangeFormInitPlugin extends ExecutePluginParent { public void formCreated(String widgetVariableName, ObjectValue objectValue) { super.formCreated(widgetVariableName, objectValue); + if(objectValue.getString("id") == null){ + this.setWidgetAttribute("billstatus",AttributeEnum.VALUE_CHANGE, "A"); + } + // 获取源单据ID String sourceBillId = getSourceBillId(objectValue); String sourceBillNumber = getSourceBillNumber(objectValue); diff --git a/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangePopupPlugin.java b/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangePopupPlugin.java index 61d1290..19c0c85 100644 --- a/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangePopupPlugin.java +++ b/common/common-association/src/main/java/apelet/association/plugin/member/UnitNameChangePopupPlugin.java @@ -25,132 +25,4 @@ import java.util.Map; */ public class UnitNameChangePopupPlugin extends ListPlugin { - /** - * 目标表单ID - membership_apply 表单在平台中的表单ID - */ - private static final String TARGET_FORM_ID = "2048951917157027840"; - /** - * 传递到弹窗的参数key - 单据ID - */ - private static final String PARAM_BILL_ID = "sourceBillId"; - /** - * 传递到弹窗的参数key - 单据编号 - */ - private static final String PARAM_BILL_NUMBER = "sourceBillNumber"; - private final OrmGenDataSourceUtil ormGenDataSourceUtil; - - public UnitNameChangePopupPlugin() { - ormGenDataSourceUtil = ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); - } - - @Override - protected Filter getFilter() { - Filter filter = new Filter(); - filter.add(new FilterItem("deleted_flag", FilterItem.equals, "1")); - return filter; - } - - - @Override - protected void afterLoadData(List> dataList) { - super.afterLoadData(dataList); - } - - @Override - public void afterLoadFormData(String widgetVariableName, ObjectValue objectValue) { - super.afterLoadFormData(widgetVariableName, objectValue); - - } - - @Override - public void beforeLoadTableData(String widgetVariableName, ObjectValue objectValue) { - OnlineEventPluginExecuteDto dto = getDto(); - super.beforeLoadTableData(widgetVariableName, objectValue); - - } - - @Override - public void formCreated(String widgetVariableName, ObjectValue objectValue) { - super.formCreated(widgetVariableName, objectValue); - - } - - /** - * 按钮点击事件(列表按钮) - * 点击"变更"按钮时,通过 getSelectData 获取列表中选中行的单据数据, - * 以弹窗方式打开入会申请表单,并将选中行数据带入 - * - * @param buttonKey 按钮标识 - * @param objectValue 列表按钮事件数据对象(非表单数据) - */ - @Override - public void buttonTriggered(String buttonKey, ObjectValue objectValue) { - OnlineEventPluginExecuteDto dto = getDto(); - - if("新建".equals(buttonKey)) { - return; - } - - List rowDatas = dto.getModel().getRowDatas(); - if (rowDatas == null || rowDatas.size() != 1) { - showWarningMessage("请先在列表中选中一条单据"); - this.cancelOperate(); - return; - } - Map data = rowDatas.get(0); - if ("变更".equals(buttonKey)) { - - // 调用 showForm 打开入会申请表单(新建空表单,不加载任何已有记录) - ShowParameter showParameter = new ShowParameter(); - showParameter.setFormId(TARGET_FORM_ID); - showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); - showParameter.setStatus(ViewStatus.EDIT); - showParameter.setPkId(null); // 明确指定为空,表示新建表单而非打开已有单据 - // 设置自定义参数,用于在目标表单中获取源单据数据 - Map customParam = new HashMap<>(); - customParam.put(PARAM_BILL_ID, data.get("id")); - customParam.put(PARAM_BILL_NUMBER, data.get("number")); - showParameter.setCustomParam(customParam); - super.showForm(showParameter); - } - if ("退会".equals(buttonKey)) { - this.showConfirm("withdrawal", "确定是否退出协会?"); - this.cancelOperate(); - } - if("查看历史".equals(buttonKey)){ - ShowParameter showParameter = new ShowParameter(); - showParameter.setFormId("2071862530363363328"); - showParameter.setHowType(ShowTypeEnum.OPEN_ONLINE_MODAL); - showParameter.setStatus(ViewStatus.VIEW); - - // 设置自定义参数 - Map customParam = new HashMap<>(); - customParam.put("id", data.get("id")); - showParameter.setCustomParam(customParam); - - super.showForm(showParameter); - } - } - - - @Override - public void confirmCallBack(String widgetVariableName, ObjectValue objectValue) { - if (widgetVariableName.equals("withdrawal")) {//confirmid - Map clickResult = (Map) this.getDto().getEventObject(); - if ((Integer) clickResult.get("result") == 1) {//confirm - Map data = getDto().getModel().getRowDatas().get(0); - Object id = data.get("id"); - Filter filter = new Filter(); - filter.add(new FilterItem("id", FilterItem.equals, id)); - try { - ormGenDataSourceUtil.delete("membership_apply", filter); - } catch (Exception e) { - throw new MyRuntimeException(e.getMessage()); - } - } else {//取消 - this.cancelOperate();//取消操作 - } - } - - } } diff --git a/common/common-qy/pom.xml b/common/common-qy/pom.xml index 6871b25..829f1ad 100644 --- a/common/common-qy/pom.xml +++ b/common/common-qy/pom.xml @@ -23,14 +23,15 @@ swagger-annotations 2.2.28 + apelet - common-generator + common-orm 1.0.2 apelet - common-orm + common-generator 1.0.2 diff --git a/zz-resource/quotation_template.docx b/zz-resource/quotation_template.docx new file mode 100644 index 0000000..07147ad --- /dev/null +++ b/zz-resource/quotation_template.docx @@ -0,0 +1,23 @@ + 线下报价单 + +报价内容 +#{name} +项目类型 +#{type} +报价负责人 +#{managerperson} +总报价(元) +#{qty} +报价日期 +#{create_time} +报价编号 +#{number} + + + + + +负责人签字: + + #{personimage} +