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 index e9659fe..26cd9d5 100644 --- 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 @@ -1,11 +1,17 @@ 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.TokenData; +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; @@ -14,9 +20,12 @@ 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.*; @@ -25,11 +34,10 @@ import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; @RestController @RequestMapping("/api/template") @@ -76,7 +84,7 @@ public class DocxTemplateController { 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")); + hashMap.put("create_time", objectValue.getString("create_time").substring(0, 10)); hashMap.put("qty", objectValue.getString("qty")); String signatureImage = user.getString("signature_image"); @@ -108,6 +116,8 @@ public class DocxTemplateController { 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(); @@ -208,7 +218,6 @@ public class DocxTemplateController { } - private void replaceImageInParagraphs(XWPFDocument document, String placeholderKey, byte[] imageBytes, int width, int height) throws IOException, InvalidFormatException { String placeholder = "#{" + placeholderKey + "}"; for (XWPFParagraph paragraph : document.getParagraphs()) { @@ -257,4 +266,88 @@ public class DocxTemplateController { } } + + 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/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..1c8918a 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 @@ -54,50 +54,51 @@ public class AssociationActivitiesController { } 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 + " 签到单位下签到人不存在!!!"); - } +// 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("membership_id", member); value.put("create_time", new Date()); 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 filter = new Filter(); +// filter.add(new FilterItem("membership_id", FilterItem.equals, member.get("id"))); 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()); + ObjectCollection collection = ormGenDataSourceUtil.query("check_in_out", filter, new Selector()); if (collection != null && !collection.isEmpty()) { ObjectValue object = collection.getObject(0); object.put("check_out", 1); 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 5867c00..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 @@ -130,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; @@ -146,9 +146,9 @@ public class ActivityInfoDetailsPlugin extends ListPlugin { 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/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/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} +