diff --git a/secDevLib/secondev-chapanda-integration.jar b/secDevLib/secondev-chapanda-integration.jar new file mode 100644 index 0000000..2bab73d Binary files /dev/null and b/secDevLib/secondev-chapanda-integration.jar differ diff --git a/secDevLib/secondev-chapanda-portal.jar b/secDevLib/secondev-chapanda-portal.jar new file mode 100644 index 0000000..75e7aa3 Binary files /dev/null and b/secDevLib/secondev-chapanda-portal.jar differ diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/KqMindDoneAction.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/KqMindDoneAction.java new file mode 100644 index 0000000..1002086 --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/KqMindDoneAction.java @@ -0,0 +1,140 @@ +package com.weaver.seconddev.chapanda.action; + +import cn.hutool.json.JSONArray; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.common.cache.base.BaseCache; +import com.weaver.common.hrm.util.HrmCommonUtil; +import com.weaver.eb.common.util.TimeUtils; +import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface; +import com.weaver.mc.api.async.AsyncSystemMessageRest; +import com.weaver.mc.api.entity.SendMessageEntity; +import com.weaver.seconddev.chapanda.constant.Constant; +import com.weaver.seconddev.chapanda.entity.dto.EmployeeAttendDTO; +import com.weaver.seconddev.chapanda.feishu.constant.Constants; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendTodoUtil; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuTokenUtil; +import com.weaver.seconddev.chapanda.mapper.EmployeeAttendMapper; +import com.weaver.seconddev.chapanda.util.SystemMessageUtil; +import com.weaver.teams.domain.user.SimpleEmployee; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +@Slf4j +@Service("kqMindDoneAction") +public class KqMindDoneAction implements EsbServerlessRpcRemoteInterface { + @Autowired + EmployeeAttendMapper employeeAttendMapper; + @Autowired + private AsyncSystemMessageRest asyncSystemMessageRest; + @Autowired + Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil; + @Autowired + private Esb2FeishuTokenUtil esb2FeishuTokenUtil; + @Autowired + Esb2FeishuSendTodoUtil esb2FeishuSendTodoUtil; + @Autowired + private HrmCommonUtil hrmCommonUtil; + @Autowired + private BaseCache baseCache; + + @Override + public WeaResult> execute(Map params) { + // 在动作流中配置的输入参数可从 params 中读取 + log.error("params: {}", JSON.toJSONString(params)); + + String dataId = (String) params.get("dataId"); + String operator = (String) params.get("operator"); + String status = (String) params.get("status"); + SimpleEmployee user = hrmCommonUtil.getSimpleEmployee(Long.valueOf(operator)); + + String pcUrl = ""; + String mobileUrl = ""; + + sendToFeiShuTodo(user, dataId, pcUrl, mobileUrl, status); + + return WeaResult.success(params); + } + + private void sendToFeiShuTodo(SimpleEmployee user, String dataId, String pcUrl, String mobileUrl, String status) { + Map userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(user.getMobile()); + String operator_open_id = String.valueOf(userMap.get(user.getMobile())); + + String token = (String) baseCache.get(Constant.MODULE_KEY, Constant.FEI_SHU_TOKEN_KEY); + if (StringUtils.isEmpty(token)) { + token = esb2FeishuTokenUtil.getToken(); + baseCache.set(Constant.MODULE_KEY, Constant.FEI_SHU_TOKEN_KEY, token, 6000); + } + long currentTimeStamp = System.currentTimeMillis(); + //接收人openid + String receiver_open_id = operator_open_id; + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("approval_code", Constants.approvalCode); + bodyJson.put("status", status); + bodyJson.put("instance_id", dataId); + JSONObject linksJson = new JSONObject(); + linksJson.put("pc_link", pcUrl); + linksJson.put("mobile_link", mobileUrl); + bodyJson.put("links", linksJson); + bodyJson.put("title", "@i18n@title"); + bodyJson.put("open_id", operator_open_id); + bodyJson.put("start_time", currentTimeStamp); + bodyJson.put("end_time", 0); + bodyJson.put("update_time", currentTimeStamp); + bodyJson.put("display_method", Constants.browser); + bodyJson.put("update_mode", Constants.updateMode); + + JSONArray i18nResourcesTextsArray = new JSONArray(); + JSONObject i18nResourcesTextsJson = new JSONObject(); + i18nResourcesTextsJson.put("key", "@i18n@title"); + i18nResourcesTextsJson.put("value", ""); + i18nResourcesTextsArray.add(i18nResourcesTextsJson); + + JSONObject i18nResourcesJson = new JSONObject(); + i18nResourcesJson.put("locale", "zh-CN"); + i18nResourcesJson.put("texts", i18nResourcesTextsArray); + i18nResourcesJson.put("is_default", "true"); + JSONArray i18nResourcesArray = new JSONArray(); + i18nResourcesArray.add(i18nResourcesJson); + bodyJson.put("i18n_resources", i18nResourcesArray); + + JSONArray taskListArray = new JSONArray(); + JSONObject taskListJson = new JSONObject(); + taskListJson.put("task_id", dataId + "_" + user.getMobile()); + taskListJson.put("open_id", receiver_open_id); + taskListJson.put("title", "@i18n@title"); + taskListJson.put("links", linksJson); + taskListJson.put("status", status); + taskListJson.put("create_time", currentTimeStamp); + + taskListJson.put("end_time", 0); + taskListJson.put("update_time", String.valueOf(System.currentTimeMillis())); + taskListJson.put("display_method", Constants.browser); + taskListJson.put("exclude_statistics", Constants.excludeStatistics); + taskListArray.add(taskListJson); + bodyJson.put("task_list", taskListArray); + log.error("sendToFeiShuTodo-bodyJson:{}", bodyJson.toJSONString()); + String sendResult = esb2FeishuSendTodoUtil.doPostSendMessage(bodyJson.toJSONString(), token); + if (StringUtils.isNotBlank(sendResult)) { + JSONObject returnData = JSONObject.parseObject(sendResult); + if (returnData.containsKey("code")) { + String code = returnData.getString("code"); + if (!"0".equals(code)) { + log.error("todoOpenIdList:{}", "创建飞书待办异常" + user.getName() + dataId); + } + } + } + } +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/SendKqMindAction.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/SendKqMindAction.java new file mode 100644 index 0000000..0e0606c --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/SendKqMindAction.java @@ -0,0 +1,285 @@ +package com.weaver.seconddev.chapanda.action; + +import cn.hutool.json.JSONArray; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.common.cache.base.BaseCache; +import com.weaver.common.hrm.util.HrmCommonUtil; +import com.weaver.eb.common.util.TimeUtils; +import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface; +import com.weaver.mc.api.async.AsyncSystemMessageRest; +import com.weaver.mc.api.entity.SendMessageEntity; +import com.weaver.seconddev.chapanda.constant.Constant; +import com.weaver.seconddev.chapanda.entity.dto.EmployeeAttendDTO; +import com.weaver.seconddev.chapanda.feishu.constant.Constants; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuBotCreateTodoUtil; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuSendTodoUtil; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuTokenUtil; +import com.weaver.seconddev.chapanda.mapper.EmployeeAttendMapper; +import com.weaver.seconddev.chapanda.util.SystemMessageUtil; +import com.weaver.teams.domain.user.SimpleEmployee; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +@Slf4j +@Service("sendKqMindAction") +public class SendKqMindAction implements EsbServerlessRpcRemoteInterface { + @Autowired + EmployeeAttendMapper employeeAttendMapper; + @Autowired + private AsyncSystemMessageRest asyncSystemMessageRest; + @Autowired + Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil; + @Autowired + private Esb2FeishuTokenUtil esb2FeishuTokenUtil; + @Autowired + Esb2FeishuSendTodoUtil esb2FeishuSendTodoUtil; + @Autowired + Esb2FeishuBotCreateTodoUtil esb2FeishuBotTodoUtil; + @Autowired + private HrmCommonUtil hrmCommonUtil; + @Autowired + private BaseCache baseCache; + + @Override + public WeaResult> execute(Map params) { + // 在动作流中配置的输入参数可从 params 中读取 + log.error("params: {}", JSON.toJSONString(params)); + String operatorMobile = (String) params.get("operatorMobile"); + String month = (String) params.get("month"); + String dataId = (String) params.get("dataId"); + String dbName = (String) params.get("dbName"); + String domain = (String) params.get("domain"); + String text = (String) params.get("text"); + String title = (String) params.get("title"); + String content = (String) params.get("content"); + // 获取该月的最后一天 + Date lastDay = TimeUtils.getString2Date(YearMonth.parse(month).atEndOfMonth().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), "yyyy-MM-dd"); + + //勾选批量发送 + if (StringUtils.isNotEmpty(dataId)) { + //批量发送可以传人员id,不用再去查一遍,直接查人员考勤规则对应的模板id + String userId = (String) params.get("userId"); + SimpleEmployee user = hrmCommonUtil.getSimpleEmployee(Long.valueOf(userId)); + log.error("SimpleEmployee:{}", JSON.toJSONString(user)); + + EmployeeAttendDTO employeeAttendDTO = employeeAttendMapper.getModeIdByUserId(Long.valueOf(userId), lastDay, dbName); + log.error("employeeAttendDTO:{}", JSON.toJSONString(employeeAttendDTO)); + if (employeeAttendDTO == null) { + return WeaResult.fail("未查询到考勤确认单模板,请确认该人员是否参与考勤:" + user.getName()); + } + String pcUrl = domain + "/sp/ebdfpage/card/0/1152452803526967297/" + dataId + "?layoutId=" + employeeAttendDTO.getConfirmModelId(); + String mobileUrl = domain + "/mobile/ebdfpage/card/0/1152452803526967297/" + dataId + "?layoutId=" + employeeAttendDTO.getConfirmModelId(); + + //发送系统消息 + WeaResult weaResult = sendMessage(text, title, content, pcUrl, mobileUrl, employeeAttendDTO, user); + log.error("weaResult:{}", JSON.toJSONString(weaResult)); + //发送飞书消息 + sendToFeiShuBotTodo(operatorMobile, dataId, text, title, content, pcUrl, mobileUrl, user); + sendToFeiShuTodo(operatorMobile, dataId, text, title, content, pcUrl, mobileUrl, user); + } else { + //全量发送 + //查询考勤汇总所有考勤周期内的人员id + HashSet failUser = new HashSet<>(); + List employeeAttendDTOList = employeeAttendMapper.getAllUserByMonth(month, dbName); + log.error("employeeAttendDTOList:{}", JSON.toJSONString(employeeAttendDTOList)); + for (EmployeeAttendDTO employeeAttendDTO : employeeAttendDTOList) { + log.error("employeeAttendDTO:{}", JSON.toJSONString(employeeAttendDTO)); + Long employee = employeeAttendDTO.getEmployee(); + SimpleEmployee user = hrmCommonUtil.getSimpleEmployee(employee); + EmployeeAttendDTO modeIdByUserId = employeeAttendMapper.getModeIdByUserId(employee, lastDay, dbName); + if (modeIdByUserId == null) { + failUser.add(employee); + } else { + String pcUrl = domain + "/sp/ebdfpage/card/0/1152452803526967297/" + employeeAttendDTO.getId() + "?layoutId=" + modeIdByUserId.getConfirmModelId(); + String mobileUrl = domain + "/mobile/ebdfpage/card/0/1152452803526967297/" + employeeAttendDTO.getId() + "?layoutId=" + modeIdByUserId.getConfirmModelId(); + //发系统消息 + WeaResult weaResult = sendMessage(text, title, content, pcUrl, mobileUrl, modeIdByUserId, user); + sendToFeiShuBotTodo(operatorMobile, employeeAttendDTO.getId().toString(), text, title, content, pcUrl, mobileUrl, user); + sendToFeiShuTodo(operatorMobile, employeeAttendDTO.getId().toString(), text, title, content, pcUrl, mobileUrl, user); + log.error("weaResult:{}", JSON.toJSONString(weaResult)); + if (weaResult != null & weaResult.getCode() == 200) { + employeeAttendMapper.updateStatueById(employeeAttendDTO.getId(), Constant.CONFIRM_ISSUED, null); + } + } + } + log.error("failUser:{}", JSON.toJSONString(failUser)); + } + return WeaResult.success(params); + } + + private void sendToFeiShuTodo(String operatorMobile, String dataId, String text, String title, String content, String pcUrl, String mobileUrl, SimpleEmployee receiver) { + String token = (String) baseCache.get(Constant.MODULE_KEY, Constant.FEI_SHU_TOKEN_KEY); + if (StringUtils.isEmpty(token)) { + token = esb2FeishuTokenUtil.getToken(); + baseCache.set(Constant.MODULE_KEY, Constant.FEI_SHU_TOKEN_KEY, token, 6000); + } + Map userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(operatorMobile); + String operator_open_id = String.valueOf(userMap.get(operatorMobile)); + long currentTimeStamp = System.currentTimeMillis(); + //接收人openid + Map receiverMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(receiver.getMobile()); + String receiver_open_id = String.valueOf(receiverMap.get(receiver.getMobile())); + + String status = "PENDING"; + JSONObject bodyJson = new JSONObject(); + bodyJson.put("approval_code", Constants.approvalCode); + bodyJson.put("status", status); + bodyJson.put("instance_id", dataId); + JSONObject linksJson = new JSONObject(); + linksJson.put("pc_link", pcUrl); + linksJson.put("mobile_link", mobileUrl); + bodyJson.put("links", linksJson); + bodyJson.put("title", "@i18n@title"); + bodyJson.put("open_id", operator_open_id); + bodyJson.put("start_time", currentTimeStamp); + bodyJson.put("end_time", 0); + bodyJson.put("update_time", currentTimeStamp); + bodyJson.put("display_method", Constants.browser); + bodyJson.put("update_mode", Constants.updateMode); + + JSONArray i18nResourcesTextsArray = new JSONArray(); + JSONObject i18nResourcesTextsJson = new JSONObject(); + i18nResourcesTextsJson.put("key", "@i18n@title"); + i18nResourcesTextsJson.put("value", title); + i18nResourcesTextsArray.add(i18nResourcesTextsJson); + + JSONArray formArray = new JSONArray(); + JSONObject formJson1 = new JSONObject(); + String key_key = "@i18n@k" + 0; + String val_key = "@i18n@v" + 0; + + formJson1.put("name", key_key); + formJson1.put("value", val_key); + + formArray.add(formJson1); + bodyJson.put("form", formArray); + + JSONObject keyI18 = new JSONObject(); + keyI18.put("key", key_key); + keyI18.put("value", text); + i18nResourcesTextsArray.add(keyI18); + JSONObject vauleI18 = new JSONObject(); + vauleI18.put("key", val_key); + vauleI18.put("value", content); + i18nResourcesTextsArray.add(vauleI18); + + JSONObject i18nResourcesJson = new JSONObject(); + i18nResourcesJson.put("locale", "zh-CN"); + i18nResourcesJson.put("texts", i18nResourcesTextsArray); + i18nResourcesJson.put("is_default", "true"); + JSONArray i18nResourcesArray = new JSONArray(); + i18nResourcesArray.add(i18nResourcesJson); + bodyJson.put("i18n_resources", i18nResourcesArray); + + JSONArray taskListArray = new JSONArray(); + JSONObject taskListJson = new JSONObject(); + taskListJson.put("task_id", dataId + "_" + receiver.getId()); + taskListJson.put("open_id", receiver_open_id); + taskListJson.put("title", "@i18n@title"); + taskListJson.put("links", linksJson); + taskListJson.put("status", status); + taskListJson.put("create_time", currentTimeStamp); + + taskListJson.put("end_time", 0); + taskListJson.put("update_time", String.valueOf(System.currentTimeMillis())); + taskListJson.put("display_method", Constants.browser); + taskListJson.put("exclude_statistics", Constants.excludeStatistics); + taskListArray.add(taskListJson); + bodyJson.put("task_list", taskListArray); + log.error("sendToFeiShuTodo-bodyJson:{}", bodyJson.toJSONString()); + String sendResult = esb2FeishuSendTodoUtil.doPostSendMessage(bodyJson.toJSONString(), token); + if (StringUtils.isNotBlank(sendResult)) { + JSONObject returnData = JSONObject.parseObject(sendResult); + if (returnData.containsKey("code")) { + String code = returnData.getString("code"); + if (!"0".equals(code)) { + log.error("todoOpenIdList:{}", "创建飞书待办异常" + receiver.getName() + dataId); + } + } + } + } + + private void sendToFeiShuBotTodo(String operatorMobile, String dataId, String text, String title, String content, String pcUrl, String mobileUrl, SimpleEmployee receiver) { + Map userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(operatorMobile); + String operator_open_id = String.valueOf(userMap.get(operatorMobile)); + + String token = (String) baseCache.get(Constant.MODULE_KEY, Constant.FEI_SHU_TOKEN_KEY); + if (StringUtils.isEmpty(token)) { + token = esb2FeishuTokenUtil.getToken(); + baseCache.set(Constant.MODULE_KEY, Constant.FEI_SHU_TOKEN_KEY, token, 6000); + } + long currentTimeStamp = System.currentTimeMillis(); + //接收人openid + Map receiverMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(receiver.getMobile()); + String receiver_open_id = String.valueOf(receiverMap.get(receiver.getMobile())); + + + JSONObject bodyJson = new JSONObject(); + bodyJson.put("template_id", Constants.botTemplateId); + bodyJson.put("open_id", receiver_open_id); + bodyJson.put("approval_name", "@i18n@title"); + + JSONArray summariesArray = new JSONArray(); + JSONObject summariesObject = new JSONObject(); + summariesObject.put("summary", "@i18n@summary"); + summariesArray.add(summariesObject); + + JSONObject contentJson = new JSONObject(); + contentJson.put("summaries", summariesArray); + bodyJson.put("content", contentJson); + + JSONArray actionsArray = new JSONArray(); + JSONObject actionsObject = new JSONObject(); + actionsObject.put("action_name", "DETAIL"); + actionsObject.put("url", mobileUrl); + actionsObject.put("android_url", mobileUrl); + actionsObject.put("ios_url", mobileUrl); + actionsObject.put("pc_url", pcUrl); + actionsArray.add(actionsObject); + bodyJson.put("actions", actionsArray); + + JSONObject i18nResourcesTextsJson = new JSONObject(); + i18nResourcesTextsJson.put("@i18n@title",title); + i18nResourcesTextsJson.put("@i18n@summary",text); + JSONObject i18nResourcesJson = new JSONObject(); + i18nResourcesJson.put("locale","zh-CN"); + i18nResourcesJson.put("texts",i18nResourcesTextsJson); + i18nResourcesJson.put("is_default",true); + JSONArray i18nResourcesArray = new JSONArray(); + i18nResourcesArray.add(i18nResourcesJson); + bodyJson.put("i18n_resources",i18nResourcesArray); + + log.error("sendToFeiShuTodo-bodyJson:{}", bodyJson.toJSONString()); + String sendResult = esb2FeishuBotTodoUtil.doSendPost(bodyJson.toJSONString(), token); + if (StringUtils.isNotBlank(sendResult)) { + JSONObject returnData = JSONObject.parseObject(sendResult); + if (returnData.containsKey("code")) { + String code = returnData.getString("code"); + if (!"0".equals(code)) { + log.error("todoOpenIdList:{}", "创建飞书bot待办异常" + receiver.getName() + dataId); + } + } + } + } + + + private WeaResult sendMessage(String text, String title, String content, String pcUrl, String mobileUrl, EmployeeAttendDTO modeIdByUserId, SimpleEmployee user) { + //发送系统消息 + SendMessageEntity smg = SystemMessageUtil.buildSmgEntity(text, title, content, user, pcUrl, mobileUrl); + log.error("SendMessageEntity:{}", JSON.toJSONString(smg)); + WeaResult weaResult = asyncSystemMessageRest.sendMsg(smg); + return weaResult; + } +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/UrgingAction.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/UrgingAction.java new file mode 100644 index 0000000..a5e01c7 --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/action/UrgingAction.java @@ -0,0 +1,124 @@ +package com.weaver.seconddev.chapanda.action; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.weaver.common.base.entity.result.WeaResult; +import com.weaver.common.hrm.util.HrmCommonUtil; +import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface; +import com.weaver.seconddev.chapanda.entity.po.UnOperator; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuBotCreateTodoUtil; +import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil; +import com.weaver.seconddev.portal.constant.ApplicationConfigConstant; +import com.weaver.seconddev.portal.util.PapiUtil; +import com.weaver.teams.client.utils.HttpUtils; +import com.weaver.teams.domain.user.SimpleEmployee; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +@Service("urgingAction") +public class UrgingAction implements EsbServerlessRpcRemoteInterface { + @Autowired + Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil; + @Autowired + Esb2FeishuBotCreateTodoUtil esb2FeishuBotCreateTodoUtil; + + @Autowired + private HrmCommonUtil hrmCommonUtil; + + @Override + public WeaResult> execute(Map params) { + // 在动作流中配置的输入参数可从 params 中读取 + log.error("urgingAction-params: {}", JSON.toJSONString(params)); + String datas = (String) params.get("datas"); + String operator = (String) params.get("operator"); + if (StringUtils.isNotEmpty(datas)) { + ObjectMapper mapper = new ObjectMapper(); + try { + //催办基本请求参数 + HashMap requestMap = getWeaverBaseMap(operator); + String urgingUrl = ApplicationConfigConstant.APP_URL + "/papi/openapi/api/workflow/core/paService/v1/requestSupervise"; + String unOperateUrl = ApplicationConfigConstant.APP_URL + "/papi/openapi/api/workflow/core/paService/v1/getNodeOperator"; + List> dataList = mapper.readValue(datas, List.class); + for (Map item : dataList) { + try { + String requestName = item.get("requestname"); + String requestId = item.get("requestid"); + String creatorId = item.get("userid"); + //发送bot消息给流程当前节点未操作人 + sendUnOperatedToBotMsg(unOperateUrl, requestId, requestName, creatorId, operator, mapper); + //发送系统催办 + requestMap.put("requestId", requestId); + String weaverR = HttpUtils.httpJsonPost(urgingUrl, JSON.toJSONString(requestMap)); + } catch (Exception e) { + log.error("urgingE:{}", e.getMessage()); + } + } + } catch (JsonProcessingException e) { + log.error("JsonProcessingException:{}", e.getMessage()); + } + } + return WeaResult.success(params); + } + + private void sendUnOperatedToBotMsg(String unOperateUrl, String requestId, String requestName, String creatorId, String operator, ObjectMapper mapper) throws JsonProcessingException { + //流程创建人飞书openid + SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(Long.valueOf(creatorId)); + Map creatorMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorEmployee.getMobile()); + String create_open_id = String.valueOf(creatorMap.get(creatorEmployee.getMobile())); + + String papiCode = PapiUtil.getPapiCode(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.CORP_ID, "A1a"); + String papiToken = PapiUtil.getPapiToken(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.ORGANIZATION_APP_KEY, ApplicationConfigConstant.ORGANIZATION_APP_SECRET, papiCode); + //流程当前节点未操作人查询 + HashMap requestMap = new HashMap<>(); + requestMap.put("access_token", papiToken); + requestMap.put("userid", operator); + requestMap.put("requestId", requestId); + requestMap.put("onlyOperator", true); + String jsonStr = HttpUtils.httpJsonPost(unOperateUrl, JSONObject.toJSONString(requestMap)); + UnOperator response = mapper.readValue(jsonStr, UnOperator.class); + response.getData().forEach((nodeId, nodeData) -> { + List operatorUsers = nodeData.getOperatorUsers(); + if (operatorUsers != null) { + operatorUsers.forEach(user -> { + //流程未操作人飞书openid + SimpleEmployee unOperator = hrmCommonUtil.getSimpleEmployee(Long.valueOf(user.getUserId())); + Map unMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(unOperator.getMobile()); + String unOperator_open_id = String.valueOf(unMap.get(unOperator.getMobile())); + String mobileurl = "/mobile/workflow/flowpage/view/" + requestId; + String pcurl = "/sp/workflow/flowpage/view/" + requestId; + //发送bot消息 + esb2FeishuBotCreateTodoUtil.senBotTodoMessage( + requestId, requestName, "", + create_open_id, unOperator_open_id, unOperator_open_id, + mobileurl, pcurl); + + }); + } + + }); + } + + private static HashMap getWeaverBaseMap(String operator) { + String papiCode = PapiUtil.getPapiCode(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.CORP_ID, "A1a"); + String papiToken = PapiUtil.getPapiToken(ApplicationConfigConstant.APP_URL, ApplicationConfigConstant.ORGANIZATION_APP_KEY, ApplicationConfigConstant.ORGANIZATION_APP_SECRET, papiCode); + + HashMap requestMap = new HashMap<>(); + HashMap otherParam = new HashMap<>(); + otherParam.put("currentOperator", 1); + otherParam.put("doneOperator", 0); + requestMap.put("otherParam", otherParam); + + requestMap.put("access_token", papiToken); + requestMap.put("userId", operator); + return requestMap; + } +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/constant/Constant.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/constant/Constant.java index a585988..9b7bacd 100644 --- a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/constant/Constant.java +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/constant/Constant.java @@ -14,11 +14,18 @@ public class Constant { * 模块标识 */ public static final String MODULE = "secondev"; + public static final String MODULE_KEY = "SECOND_DEV_KEY"; + public static final String FEI_SHU_TOKEN_KEY = "feishu_token_key"; /** *租户 */ public static final String TENANT_KEY = "tma3ktp1q7"; + /** + * + */ + public static final int CONFIRM_ISSUED = 1; + } diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/AttendStatusDetailDTO.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/AttendStatusDetailDTO.java new file mode 100644 index 0000000..2d3ccb0 --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/AttendStatusDetailDTO.java @@ -0,0 +1,67 @@ +package com.weaver.seconddev.chapanda.entity.dto; + +import java.util.Date; + +public class AttendStatusDetailDTO { + private Long id; + private Date attendDate; + private Long employee; + private Long attendConfig; + private Integer deleteType; + private String tenantKey; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Date getAttendDate() { + return attendDate; + } + + public void setAttendDate(Date attendDate) { + this.attendDate = attendDate; + } + + public Long getEmployee() { + return employee; + } + + public void setEmployee(Long employee) { + this.employee = employee; + } + + public Long getAttendConfig() { + return attendConfig; + } + + public void setAttendConfig(Long attendConfig) { + this.attendConfig = attendConfig; + } + + public Integer getDeleteType() { + return deleteType; + } + + public void setDeleteType(Integer deleteType) { + this.deleteType = deleteType; + } + + public String getTenantKey() { + return tenantKey; + } + + public void setTenantKey(String tenantKey) { + this.tenantKey = tenantKey; + } + + @Override + public String toString() { + return "AttendStatusDetail{" + "id=" + id + ", attendDate=" + attendDate + ", employee='" + employee + '\'' + + ", attendConfig='" + attendConfig + '\'' + ", deleteType=" + deleteType + ", tenantKey='" + tenantKey + + '\'' + '}'; + } +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/DemoSearchConditionDTO.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/DemoSearchConditionDTO.java deleted file mode 100644 index f5334e1..0000000 --- a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/DemoSearchConditionDTO.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.weaver.seconddev.chapanda.entity.dto; - -import com.weaver.common.component.search.item.WeaSearchConditionItemType; -import com.weaver.seconddev.chapanda.annotation.SearchCondition; -import com.weaver.seconddev.chapanda.annotation.SearchConditionItem; -import com.weaver.seconddev.chapanda.constant.Constant; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DemoSearchConditionDTO { - - @SearchCondition( - label = "创建人", - labelId = 0, - needQuickSearch = true, - quickSearchKey = "username", - items = { - @SearchConditionItem(itemType = WeaSearchConditionItemType.INPUT, name = "username"), - } - ) - private String username; - - @SearchCondition( - label = "部门", - labelId = 0, - needQuickSearch = true, - items = { - @SearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, - browserType = "department", browserMultiple = true, name = "department"), - } - ) - private String department; - - @SearchCondition( - label = "工单类型", - labelId = 0, - items = @SearchConditionItem(itemType = WeaSearchConditionItemType.BROWSER, - browserType = "orderTypeBrowser", name = "orderType", browserModule = Constant.MODULE) - ) - private String orderType; - - - @SearchCondition( - label = "创建日期", - labelId = 0, - items = { - @SearchConditionItem(itemType = WeaSearchConditionItemType.DATEPICKER, name = "createTime"), - } - ) - private String createTime; - -} diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/EmployeeAttendDTO.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/EmployeeAttendDTO.java new file mode 100644 index 0000000..1d0a226 --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/dto/EmployeeAttendDTO.java @@ -0,0 +1,32 @@ +package com.weaver.seconddev.chapanda.entity.dto; + +public class EmployeeAttendDTO { + private Long id; + private Long employee; + private Long confirmModelId; + + // Getters and Setters + public Long getEmployee() { + return employee; + } + + public void setEmployee(Long employee) { + this.employee = employee; + } + + public Long getConfirmModelId() { + return confirmModelId; + } + + public void setConfirmModelId(Long confirmModelId) { + this.confirmModelId = confirmModelId; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/po/UnOperator.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/po/UnOperator.java new file mode 100644 index 0000000..24f2821 --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/entity/po/UnOperator.java @@ -0,0 +1,35 @@ +package com.weaver.seconddev.chapanda.entity.po; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class UnOperator { + private Message message; + private Map data; // Key 是 nodeId,Value 是节点数据 + + @Data + public static class Message { + private String errcode; + private String errmsg; + } + + @Data + public static class NodeData { + private String nodeId; + private String nodeName; + private List operatorUsers; + } + + @Data + public static class OperatorUser { + private String userId; + private String userName; + private String mainUserId; + private String departMentId; + private int isRemark; + private String status; + } +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/mapper/AttendStatusDetailMapper.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/mapper/AttendStatusDetailMapper.java new file mode 100644 index 0000000..11ff2aa --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/mapper/AttendStatusDetailMapper.java @@ -0,0 +1,21 @@ +package com.weaver.seconddev.chapanda.mapper; + +import com.weaver.seconddev.chapanda.entity.dto.AttendStatusDetailDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +@Mapper +public interface AttendStatusDetailMapper { + /** + * + * @param tenantKey + * @param attendDate + * @param deleteType + * @return + */ + List selectByCondition(@Param("tenantKey") String tenantKey, + @Param("attendDate") Date attendDate, @Param("deleteType") Integer deleteType,@Param("dbName") String dbName); +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/mapper/EmployeeAttendMapper.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/mapper/EmployeeAttendMapper.java new file mode 100644 index 0000000..e0b3943 --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/mapper/EmployeeAttendMapper.java @@ -0,0 +1,21 @@ +package com.weaver.seconddev.chapanda.mapper; + +import com.weaver.seconddev.chapanda.entity.dto.EmployeeAttendDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +@Mapper +public interface EmployeeAttendMapper { + EmployeeAttendDTO getModeIdByUserId( + @Param("employeeId") Long employeeId, + @Param("yearMonth") Date yearMonth, + @Param("dbName") String dbName + ); + + List getAllUserByMonth(@Param("month") String month, @Param("dbName") String dbName); + + void updateStatueById(@Param("id") Long id,@Param("statue") int statue, @Param("dbName")String dbName); +} \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/trigger/AttendConfChangeEscheduler.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/trigger/AttendConfChangeEscheduler.java new file mode 100644 index 0000000..862e683 --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/trigger/AttendConfChangeEscheduler.java @@ -0,0 +1,276 @@ +package com.weaver.seconddev.chapanda.trigger; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.weaver.common.distribution.genid.IdGenerator; +import com.weaver.ebuilder.form.client.entity.data.EBDataReqOperation; +import com.weaver.ebuilder.form.client.entity.data.EBDataReqOperationInfo; +import com.weaver.ebuilder.form.client.entity.data.EBDataUpdateType; +import com.weaver.seconddev.chapanda.entity.dto.AttendStatusDetailDTO; +import com.weaver.seconddev.chapanda.mapper.AttendStatusDetailMapper; +import org.apache.commons.collections.CollectionUtils; +import org.apache.logging.log4j.util.Base64Util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.weaver.common.cache.tablecache.impl.ComInfoCache; +import com.weaver.common.escheduler.context.ESchedulerJobHelper; +import com.weaver.common.escheduler.handler.annotation.ESchedulerHandler; +import com.weaver.common.hrm.cache.HrmEmployeeComInfo; +import com.weaver.eb.common.util.TimeUtils; +import com.weaver.ebuilder.form.client.entity.data.EBDataChangeReqDto; +import com.weaver.ebuilder.form.client.entity.data.EBDataChangeResult; +import com.weaver.ebuilder.form.client.entity.data.EBDataReqDetailDto; +import com.weaver.ebuilder.form.client.entity.data.EBDataReqDto; +import com.weaver.ebuilder.form.client.entity.data.EBDataReqHeader; +import com.weaver.ebuilder.form.client.entity.field.FieldsQueryDto; +import com.weaver.ebuilder.form.client.entity.field.ModuleField; +import com.weaver.ebuilder.form.client.service.data.RemoteSimpleDataService; +import com.weaver.ebuilder.form.client.service.emobile.IEtFormDatasetService; +import com.weaver.ebuilder.teams.etform.base.query.ConditionTreeDto; +import com.weaver.ebuilder.teams.etform.base.query.Query; +import com.weaver.ebuilder.teams.etform.org.bean.EBSimpleEmployee; +import com.weaver.framework.util.JsonUtil; +import com.weaver.publishkit.api.util.PublishKitRuntimeUtil; + +/** + * 监控考勤规则变动,存在变动的写入eb台账表 + */ +@Service +public class AttendConfChangeEscheduler { + + private static final Logger log = LoggerFactory.getLogger(AttendConfChangeEscheduler.class); + + @Autowired + private AttendStatusDetailMapper attendStatusDetailMapper; + + @Autowired + private ComInfoCache comInfoCache; + @Autowired + private PublishKitRuntimeUtil publishKitRuntimeUtil; + + @Value("#{'${attend.opensyncEbTable.tenantKey:tk9x0xdor1}'.split(',')}") + private List tenantKeyList; + + /** + * value: 考勤规则同步eb表单 cron: cron表达式自定义执行时间 + * + * @throws Exception + */ + @ESchedulerHandler(value = "AttendConfChangeEscheduler", cron = "0/10 * * * * ?") + public void demoJobHandler() throws Exception { + log.error("AttendConfChangeEscheduler runnint"); + try { + + // 获取页面上配置的任务参数 + final String jobParam = ESchedulerJobHelper.getJobParam(); + // eb表单id,eb表单姓名字段fieldId,eb表单是否生效中字段fieldId,操作人id + String[] jobParamSplit = jobParam.split(","); + Date preDayDate = + TimeUtils.getString2Date(TimeUtils.dateAdd(TimeUtils.getCurrentTimeString(), -1), "yyyy-MM-dd"); + + IEtFormDatasetService iEtFormDatasetService = + publishKitRuntimeUtil.buildRpcService(IEtFormDatasetService.class, "ebuilderform", "defaultAppId"); + RemoteSimpleDataService remoteSimpleDataService = + publishKitRuntimeUtil.buildRpcService(RemoteSimpleDataService.class, "ebuilderform", "defaultAppId"); + // 开启此功能的租户 + for (String tenantKey : tenantKeyList) { + // 不同租户eb表字段对应的id + Map fieldMap = extracted(jobParamSplit, iEtFormDatasetService, tenantKey, jobParamSplit[1]); + log.error("AttendConfChangeEscheduler-fieldMap:{}", JSON.toJSONString(fieldMap)); + + // 查询昨天人员对应的考勤规则与eb台账最新的生效考勤规则对比 + try { + EBDataChangeReqDto ebReqDto = new EBDataChangeReqDto(); + ebReqDto.setHeader(new EBDataReqHeader(jobParamSplit[0], jobParamSplit[1], tenantKey)); + + List statusDetailDtos = + attendStatusDetailMapper.selectByCondition(tenantKey, preDayDate, 0, null); + for (AttendStatusDetailDTO statusDetailDto : statusDetailDtos) { + List> oldAttendRuleEbList = queryResult(iEtFormDatasetService, + statusDetailDto.getEmployee(), tenantKey, jobParamSplit, fieldMap, true); + ArrayList insertDataReqDtos = new ArrayList<>(); + EBDataReqDto InsertEbDataReqDto = new EBDataReqDto(); + List mainData1 = new ArrayList<>(); + mainData1.add(new EBDataReqDetailDto(fieldMap.get("xm"), + String.valueOf(statusDetailDto.getEmployee()))); + HrmEmployeeComInfo hrmEmployeeInfo = + comInfoCache.getCacheById(HrmEmployeeComInfo.class, statusDetailDto.getEmployee()); + mainData1.add(new EBDataReqDetailDto(fieldMap.get("fb"), + String.valueOf(hrmEmployeeInfo.getSubcompanyId()))); + mainData1.add(new EBDataReqDetailDto(fieldMap.get("bm"), + String.valueOf(hrmEmployeeInfo.getDepartment()))); + mainData1.add(new EBDataReqDetailDto(fieldMap.get("bdrq"), + DateUtil.format(preDayDate, "yyyy-MM-dd"))); + mainData1.add(new EBDataReqDetailDto(fieldMap.get("sxkqgz"), + String.valueOf(statusDetailDto.getAttendConfig()))); + mainData1.add(new EBDataReqDetailDto(fieldMap.get("sfsxz"), "0")); + //有历史数据 + if (CollectionUtils.isEmpty(oldAttendRuleEbList)) { +// mainData1.add(new EBDataReqDetailDto(fieldMap.get("shxkqgz"), String.valueOf(statusDetailDto.getAttendConfig()))); + InsertEbDataReqDto.setMainDatas(mainData1); + log.error("empty-insertResult:{}", JSON.toJSONString(mainData1)); + insertDataReqDtos.add(InsertEbDataReqDto); + ebReqDto.setDatas(insertDataReqDtos); + remoteSimpleDataService.saveFormData(ebReqDto); + } else { + Map oldAttendRuleEb = oldAttendRuleEbList.get(0); + // 生效考勤规则变动,失效之前的考勤规则,并新增一条记录 + ArrayList> sxkqgz = + (ArrayList>) oldAttendRuleEb.get(fieldMap.get("sxkqgz")); + Map sxkqgzMap = sxkqgz.get(0); + if (!String.valueOf(statusDetailDto.getAttendConfig()).equals(sxkqgzMap.get("id"))) { + mainData1.add(new EBDataReqDetailDto(fieldMap.get("shxkqgz"), (String) sxkqgzMap.get("id"))); + InsertEbDataReqDto.setMainDatas(mainData1); + insertDataReqDtos.add(InsertEbDataReqDto); + // 失效老数据 + updateExtracted(remoteSimpleDataService, fieldMap, ebReqDto, oldAttendRuleEb); + ebReqDto.setDatas(insertDataReqDtos); + EBDataChangeResult insertResult = remoteSimpleDataService.saveFormData(ebReqDto); + log.error("insertResult:{}", JSON.toJSONString(insertResult)); + } + } + } + } catch (Exception e) { + log.error("AttendConfChangeEscheduler,tenantKey" + tenantKey, e); + + } + } + } catch (Exception e) { + log.error("AttendConfChangeEscheduler runnint error", e); + } + } + + private static void updateExtracted(RemoteSimpleDataService remoteSimpleDataService, Map fieldMap, + EBDataChangeReqDto ebReqDto, Map oldAttendRuleEb) { + try { + // 请求操作信息 + EBDataReqOperation ebDataReqOperation = new EBDataReqOperation(); + ebDataReqOperation.setUpdateType(EBDataUpdateType.conditions); + // 若数据写入后就要从前台看到数据或者立即操作本次写入的数据, 需要调整后置处理为同步 权限处理完成再返回 + ebDataReqOperation.setAsyncPostProcess(false);// 更新条件构造 + // 操作明细 + EBDataReqOperationInfo ebDataReqOperationInfo = new EBDataReqOperationInfo(); + // 数据没有找到的时候是否新增数据 + ebDataReqOperationInfo.setNeedAdd(false); + ConditionTreeDto conditionTreeDto = new ConditionTreeDto(); + conditionTreeDto.setIsParent(false); + conditionTreeDto.setConditionId("id"); + conditionTreeDto.setCompareType("eq"); + conditionTreeDto.setConditionValue((String) oldAttendRuleEb.get("id")); + ebDataReqOperationInfo.setConditionTreeDto(conditionTreeDto); + ebDataReqOperation.setMainData(ebDataReqOperationInfo); + ebReqDto.setOperation(ebDataReqOperation); + // 数据 + EBDataReqDto ebDataReqDto = new EBDataReqDto(); + List mainData = new ArrayList<>(); + mainData.add(new EBDataReqDetailDto(fieldMap.get("sfsxz"), "1")); + ebDataReqDto.setMainDatas(mainData); + ebReqDto.setDatas(Collections.singletonList(ebDataReqDto)); + EBDataChangeResult ebDataChangeResult = remoteSimpleDataService.updateFormData(ebReqDto); + } catch (Exception e) { + log.error("updateExtracted-" + oldAttendRuleEb.get("id"), e); + } + } + + private static Map extracted(String[] jobParamSplit, IEtFormDatasetService iEtFormDatasetService, + String tenantKey, String userId) { + Map fieldMap = new HashMap<>(); + EBSimpleEmployee ebSimpleEmployee = new EBSimpleEmployee(); + ebSimpleEmployee.setEmployeeId(userId); + ebSimpleEmployee.setTenantKey(tenantKey); + FieldsQueryDto fieldsQueryDto = new FieldsQueryDto(); + fieldsQueryDto.setEbSimpleEmployee(ebSimpleEmployee); + fieldsQueryDto.setObjId(Long.valueOf(jobParamSplit[0])); + List fields = iEtFormDatasetService.getFields(fieldsQueryDto); + log.error("ModuleField:{}", JSON.toJSONString(fields)); + fields.stream().forEach(item -> { + fieldMap.put(item.getDataKey(), item.getFieldId()); + }); + return fieldMap; + } + + private List> queryResult(IEtFormDatasetService iEtFormDatasetService, Long userId, + String tenantKey, String[] paramSplit, Map fieldMap, boolean schedulerSource) { + List> records = new ArrayList<>(); + try { + Query query = new Query(); + EBSimpleEmployee ebSimpleEmployee = new EBSimpleEmployee(); + ebSimpleEmployee.setEmployeeId("-1"); + ebSimpleEmployee.setTenantKey(tenantKey); + query.setEbSimpleEmployee(ebSimpleEmployee); + + // 搜索条件树 + + ConditionTreeDto rootNode = new ConditionTreeDto(); + rootNode.setKey(String.valueOf(IdGenerator.generate())); + rootNode.setRelationship("1"); + rootNode.setIsParent(true); + rootNode.setConditionList(Lists.newArrayList()); + + ConditionTreeDto leaf1Node = new ConditionTreeDto(); + leaf1Node.setIsParent(true); + leaf1Node.setKey(String.valueOf(IdGenerator.generate())); + leaf1Node.setParentNode(rootNode.getKey()); + leaf1Node.setRelationship("1"); + leaf1Node.setConditionList(Lists.newArrayList()); + rootNode.getConditionList().add(leaf1Node); + + ConditionTreeDto leaf4Node = new ConditionTreeDto(); + leaf4Node.setCompareType("eq"); + leaf4Node.setConditionId(fieldMap.get("xm")); + leaf4Node.setConditionType("employee"); + leaf4Node.setConditionValue(userId.toString()); + leaf4Node.setIsParent(false); + leaf4Node.setKey(String.valueOf(IdGenerator.generate())); + leaf4Node.setObjId(paramSplit[0]); + leaf4Node.setParentNode(leaf1Node.getKey()); + leaf1Node.getConditionList().add(leaf4Node); + + ConditionTreeDto leaf5Node = new ConditionTreeDto(); + leaf5Node.setCompareType("eq"); + leaf5Node.setConditionId(fieldMap.get("sfsxz")); + leaf5Node.setConditionType("Select"); + leaf5Node.setConditionValue("0"); + leaf5Node.setIsParent(false); + leaf5Node.setKey(String.valueOf(IdGenerator.generate())); + leaf5Node.setObjId(paramSplit[0]); + leaf5Node.setParentNode(leaf1Node.getKey()); + leaf1Node.getConditionList().add(leaf5Node); + + // 权限相关 + Map ebuilderDataConfig = Maps.newHashMap(); + Map dataSetup = Maps.newHashMap(); + dataSetup.put("dataPermission", "ALL"); + ebuilderDataConfig.put("dataSetup", dataSetup); + query.setEbuilderDataConfig(ebuilderDataConfig); + + if (rootNode != null) { + query.setConditionTrees(rootNode); + } + String encodeStr = Base64Util.encode(JsonUtil.toJsonString(query)); + Map ebFormDataMap = + iEtFormDatasetService.getDatas(Long.valueOf(paramSplit[0]), "", encodeStr, null); + if (ebFormDataMap != null && ebFormDataMap.size() > 0) { + if (ebFormDataMap.containsKey("list")) { + records = (List>) ebFormDataMap.getOrDefault("list", Collections.emptyList()); + } + } + } catch (Exception e) { + log.error("AttendConfChangeEscheduler-queryResult-", e); + } + return records; + } +} diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/util/FormUtil.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/util/FormUtil.java new file mode 100644 index 0000000..ca31fea --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/util/FormUtil.java @@ -0,0 +1,25 @@ +package com.weaver.seconddev.chapanda.util; + +import com.weaver.teams.domain.user.SimpleEmployee; +import com.weaver.workflow.common.entity.org.WeaUser; + +/** + * @version 1.0 + * @Company 泛微软件 + * @CreateDate 2025/7/31 + * @Description ${description} + * @Author 李栋 + */ +public class FormUtil { + public static WeaUser getFlowWeaUser(SimpleEmployee currentUser) { + WeaUser weaUser = new WeaUser(); + weaUser.setAdmin(currentUser.isAdmin()); + weaUser.setAvatar(currentUser.getAvatarId()); + weaUser.setUserId(currentUser.getId()); + weaUser.setDepartMentId(currentUser.getDepartmentId()); + weaUser.setJobId(currentUser.getPositionId()); + weaUser.setTenantKey(currentUser.getTenantKey()); + weaUser.setUserName(currentUser.getName()); + return weaUser; + } +} diff --git a/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/util/SystemMessageUtil.java b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/util/SystemMessageUtil.java new file mode 100644 index 0000000..cd9335d --- /dev/null +++ b/secondev-chapanda-attend/src/main/java/com/weaver/seconddev/chapanda/util/SystemMessageUtil.java @@ -0,0 +1,56 @@ +package com.weaver.seconddev.chapanda.util; + +import com.weaver.mc.api.entity.Entity; +import com.weaver.mc.api.entity.MessageEvent; +import com.weaver.mc.api.entity.MessageModule; +import com.weaver.mc.api.entity.SendMessageEntity; +import com.weaver.mc.api.entity.UserEntity; +import com.weaver.teams.domain.user.SimpleEmployee; +import dm.jdbc.util.IDGenerator; + +import java.util.Collections; + +/** + * @version 1.0 + * @Company 泛微软件 + * @CreateDate 2025/7/22 + * @Description 系统消息推送工具类 + * @Author 李栋 + */ + +public class SystemMessageUtil { + + + /** + * 构建消息发送类对象 + * @param text + * @param title + * @param content + * @param user + * @param senPcUrl + * @param senAppUrl + * @return + */ + public static SendMessageEntity buildSmgEntity(String text, String title, String content, SimpleEmployee user, String senPcUrl, String senAppUrl) { + SendMessageEntity smg = new SendMessageEntity(); + smg.setModule(MessageModule.EBUILDER); + smg.setEvent(MessageEvent.NOTIFY); + smg.setSender(UserEntity.SYSTEM_USER); + smg.setReceivers(Collections.singletonList(new UserEntity().setEmployeeId(user.getId()).setTenantKey(user.getTenantKey()))); + smg.setText(text); + smg.setTitle(title); + smg.setContent(content); + + Entity entity = new Entity(); + entity.setId(IDGenerator.generateId()); + entity.setModule("task"); + entity.setName(title); + entity.setPcLinkeType(2); + entity.setPcUrl(senPcUrl); + entity.setH5LinkeType(2); + entity.setH5Url(senAppUrl); + smg.setEntity(entity); + return smg; + } + +} diff --git a/secondev-chapanda-attend/src/main/resources/mapper/com/weaver/seconddev/dao/AttendStatusDetailMapper .xml b/secondev-chapanda-attend/src/main/resources/mapper/com/weaver/seconddev/dao/AttendStatusDetailMapper .xml new file mode 100644 index 0000000..0191534 --- /dev/null +++ b/secondev-chapanda-attend/src/main/resources/mapper/com/weaver/seconddev/dao/AttendStatusDetailMapper .xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/secondev-chapanda-attend/src/main/resources/mapper/com/weaver/seconddev/dao/EmployeeAttendMapper.xml b/secondev-chapanda-attend/src/main/resources/mapper/com/weaver/seconddev/dao/EmployeeAttendMapper.xml new file mode 100644 index 0000000..3fcd431 --- /dev/null +++ b/secondev-chapanda-attend/src/main/resources/mapper/com/weaver/seconddev/dao/EmployeeAttendMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + update + + + #{dbName}.uf_kqtotal + + + e10_common.uf_kqtotal + + + set zt= #{statue} + where ID = #{id} + + + + + + \ No newline at end of file