From 96aa3237516fb70cb9630b8faf44fb1c20178687 Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Wed, 5 Jul 2023 23:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/common/脚本.js | 68 +++++++++++++++++++ .../controller/ExamBtnControlController.java | 45 ++++++++++++ .../mapper/ExamBtnControlMapper.java | 43 ++++++++++++ .../service/ExamBtnControlService.java | 61 +++++++++++++++++ src/test/java/youhong/ai/pcn/UtilTest.java | 8 +++ .../utiltest/resultjsonparase/ParseTest.java | 2 + 6 files changed, 227 insertions(+) create mode 100644 javascript/common/脚本.js create mode 100644 src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java create mode 100644 src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java create mode 100644 src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java diff --git a/javascript/common/脚本.js b/javascript/common/脚本.js new file mode 100644 index 0000000..dffd9ee --- /dev/null +++ b/javascript/common/脚本.js @@ -0,0 +1,68 @@ +(function runJs() { + let currentYear = new Date().getFullYear(); + let currentMonth = new Date().getMonth() + 1; + let currentDate = new Date().getDate(); + + let month = prompt("请输入月份(1-12):", currentMonth); + let day = prompt("请输入日期(1-31):", currentDate); + + let dateInput = new Date(currentYear, month - 1, day); + + let year = dateInput.getFullYear(); + let formattedMonth = ("0" + (dateInput.getMonth() + 1)).slice(-2); + let formattedDay = ("0" + dateInput.getDate()).slice(-2); + + let date = year + "-" + formattedMonth + "-" + formattedDay; + + let todate = date + " 23:00"; + let fromDate = date + " 08:00"; + let wf = WeFormSDK.getWeFormInstance(); + wf.changeFieldValue("100003720000000607", {value: fromDate}); + wf.changeFieldValue("100003720000000609", {value: todate}); + wf.changeFieldValue("100003720000030038", {value: '0'}); + wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); + wf.changeFieldValue("100003720000008715", {value: '2'}); + wf.changeFieldValue("877132351682273302", {value: '1'}); + let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"'); + let workflowTitle = workflowTitleObj.value; + workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; + const container = document.getElementById("widget_100003720000000664"); + const svgIcon = container.querySelector(".associative-search-icon svg"); + if (svgIcon) { + svgIcon.dispatchEvent(new MouseEvent('click', { + bubbles: true, + cancelable: true, + view: window + })); + } + let closeTab = window.close; + window.close = () => { + window.open('/sp/workflow/flowpage/fullCreate/100003460000000746?workflowId=100003460000000746&isCreate=1', "_blank"); + closeTab() + } +})() + +(function runJs() { + let currentYear = new Date().getFullYear(); + let currentMonth = new Date().getMonth() + 1; + let currentDate = new Date().getDate(); + let month = prompt("请输入月份(1-12):", currentMonth); + let day = prompt("请输入日期(1-31):", currentDate); + let dateInput = new Date(currentYear, month - 1, day); + let year = dateInput.getFullYear(); + let formattedMonth = ("0" + (dateInput.getMonth() + 1)).slice(-2); + let formattedDay = ("0" + dateInput.getDate()).slice(-2); + let date = year + "-" + formattedMonth + "-" + formattedDay; + let todate = date + " 23:00"; + let fromDate = date + " 08:00"; + let wf = WeFormSDK.getWeFormInstance(); + wf.changeFieldValue("100003720000000607", {value: fromDate}); + wf.changeFieldValue("100003720000000609", {value: todate}); + wf.changeFieldValue("100003720000030038", {value: '0'}); + wf.changeFieldValue("100003720000000611", {value: "外出技术支持"}); + wf.changeFieldValue("100003720000008715", {value: '4'}); + wf.changeFieldValue("877132351682273302", {value: '1'}); + let workflowTitleObj = document.querySelector('input[weid="3rdcst_oxa9w7_i8bbvp_vc1wev_kc1m3l_r1vh81_snhw9p_3r9w93_g28s4n_abfe5k_a9abii"'); + let workflowTitle = workflowTitleObj.value; + workflowTitleObj.value = workflowTitle.substring(0, workflowTitle.length - 5) + formattedMonth + "-" + formattedDay; +})() \ No newline at end of file diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java new file mode 100644 index 0000000..d96336e --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/controller/ExamBtnControlController.java @@ -0,0 +1,45 @@ +package com.api.youhong.ai.pcn.examcontrol.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.youhong.ai.pcn.examcontrol.service.ExamBtnControlService; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + *

考试按钮控制

+ * + *

create: 2023/7/5 16:33

+ * + * @author youHong.ai + */ +@Path("/aiyh/exam-btn/control") +public class ExamBtnControlController { + + private final Logger log = Util.getLogger(); + + private final ExamBtnControlService service = new ExamBtnControlService(); + + @Path("/is-read") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String isReadDoc(@Context HttpServletRequest request, @Context HttpServletResponse response, + @RequestBody Map params) { + try { + User user = HrmUserVarify.getUser(request, response); + return ApiResult.success(service.isReadDoc(user,params)); + } catch (Exception e) { + log.error("is read doc error!\n" + Util.getErrString(e)); + return ApiResult.error("system error!"); + } + } +} diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java new file mode 100644 index 0000000..a67a401 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/mapper/ExamBtnControlMapper.java @@ -0,0 +1,43 @@ +package com.api.youhong.ai.pcn.examcontrol.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; + +/** + *

+ * + *

create: 2023/7/5 16:59

+ * + * @author youHong.ai + */ +@SqlMapper +public interface ExamBtnControlMapper { + + + /** + *

查询所有的文档附件id

+ * + * @param tableName 表名 + * @param docIdField 附件id字段 + * @param whereSql 查询条件字符串 + * @return 所有的文档附件id + */ + @Select("select $t{docIdField} from $t{tableName} $t{whereSql}") + List selectDocIds(@ParamMapper("tableName") String tableName, + @ParamMapper("docIdField") String docIdField, + @ParamMapper("whereSql") String whereSql); + + /** + *

查询已读标记

+ * + * @param userId 用户ID + * @param docIds 文件ID + * @return 已读标记 + */ + @Select("select id from docreadtag where userid = #{userId} and docid in ($t{docIds})") + List selectReadTag(@ParamMapper("userId") int userId, + @ParamMapper("docIds") String docIds); +} diff --git a/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java b/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java new file mode 100644 index 0000000..65e1dd9 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/examcontrol/service/ExamBtnControlService.java @@ -0,0 +1,61 @@ +package com.api.youhong.ai.pcn.examcontrol.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.recordset.MapperBuilderSql; +import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.api.youhong.ai.pcn.examcontrol.mapper.ExamBtnControlMapper; +import org.apache.log4j.Logger; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +/** + *

+ * + *

create: 2023/7/5 16:39

+ * + * @author youHong.ai + */ +public class ExamBtnControlService { + + private final Logger log = Util.getLogger(); + + + private final ExamBtnControlMapper mapper = Util.getMapper(ExamBtnControlMapper.class); + + + public boolean isReadDoc(User user, Map params) { + // 系统管理员可以直接考试 + if (user.isAdmin()) { + return true; + } + // 没有参数不给考试 + if (CollectionUtil.isEmpty(params)) { + return false; + } + // 获取表名称 + String tableName = Util.null2String(params.get("tableName")); + String docIdField = Util.null2String(params.get("docIdField")); + Map conditions = (Map) params.get("conditions"); + if (CollectionUtil.isEmpty(conditions)) { + return false; + } + String where = MapperBuilderSql.builderNoWhereAndEn(conditions, true); + if (StrUtil.isBlank(where)) { + log.error("没有生成where条件!"); + return false; + } + List docIdList = mapper.selectDocIds(tableName, docIdField, where); + if (CollectionUtil.isEmpty(docIdList)) { + throw new CustomerException("没有查询到对应的文件ID信息,请检查sql!"); + } + List readIdList = mapper.selectReadTag(user.getUID(), Util.join(docIdList, ",")); + if (CollectionUtil.isEmpty(readIdList)) { + return false; + } + return readIdList.size() == docIdList.size(); + } +} diff --git a/src/test/java/youhong/ai/pcn/UtilTest.java b/src/test/java/youhong/ai/pcn/UtilTest.java index 142899d..12bde69 100644 --- a/src/test/java/youhong/ai/pcn/UtilTest.java +++ b/src/test/java/youhong/ai/pcn/UtilTest.java @@ -6,6 +6,7 @@ import aiyh.utils.tool.org.apache.commons.jexl3.*; import basetest.BaseTest; import com.alibaba.fastjson.JSON; import com.api.youhong.ai.jitu.hrmlogintip.service.HrmLoinTipService; +import com.weaver.formmodel.util.EncryptHelper; import ebu7common.youhong.ai.bean.Builder; import org.apache.log4j.Logger; import org.junit.Test; @@ -44,6 +45,13 @@ import static java.lang.System.out; public class UtilTest extends BaseTest { + + @Test + public void testpass() { + out.println(EncryptHelper.encodeMd5("123").toUpperCase()); + } + + @Test public void test() { diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java index 3f8fb4e..b7620a4 100644 --- a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java @@ -32,6 +32,8 @@ public class ParseTest extends BaseTest { public void test() { MainTable baseData = getBaseData(); Map resultData = getResultData(); + System.out.println(JSON.toJSONString(baseData)); + System.out.println(JSON.toJSONString(resultData)); List aliasesList = baseData.getAliasesList(); Map resultParas = new HashMap<>(); Map dateMap = new HashMap<>(resultData);