极兔登录消息查询、mapper修改

main
youHong.ai 2023-02-27 11:55:12 +08:00
parent 80d9200fdf
commit 4a54e7f5c7
9 changed files with 620 additions and 351 deletions

View File

@ -536,3 +536,34 @@ $(() => {
})
})
/* ******************* 流程明细字段包含某个字符串时给某个字段赋值为某个东西end ******************* */
/* ******************* 提交外出流程 ******************* */
(function start() {
function fillNum(n) {
if (n < 10) {
return "0" + n;
} else {
return n;
}
}
let date = new Date()
let month = date.getMonth() + 1
let year = date.getFullYear();
let n = window.prompt("请输入日期:", date.getDate().toString())
let workDate = year + "-" + fillNum(month) + "-" + fillNum(n)
n = fillNum(n)
WfForm.changeFieldValue("field607", {value: workDate})
let workflowTitle = WfForm.getFieldValue("field-1");
WfForm.changeFieldValue("field-1", {value: workflowTitle.substring(0, workflowTitle.length - 2) + n})
WfForm.changeFieldValue("field609", {value: workDate})
WfForm.changeFieldValue("field608", {value: "00:00"})
WfForm.changeFieldValue("field610", {value: "23:59"})
WfForm.changeFieldValue("field30038", {value: 0})
WfForm.changeFieldValue("field611", {value: "出差"})
WfForm.changeFieldValue("field8715", {value: "2"})
$("button[ecid='_Route@vmt0lk_Comp@upn4fo_FormContent@g9f33k_MainLayout@kdmfyn_LayoutTr@ds2cqb@main_0_CellType@27chqt@main_17_10_FieldContent@r045n3_BrowserElement@2mq6lm_WeaBrowser@j1zg9h_WrappedComponent@i9q2c5_Component@iiw91q_Associative@zt8qgk_Button@ztqsd2_button@xq1ea3']").trigger("click")
})()
/* ******************* 提交外出流程 ******************* */

View File

@ -16,25 +16,37 @@ import java.lang.reflect.Field;
public class DoubleTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
String string = Util.null2String(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
if ("".equals(string)) {
return null;
}
return Double.parseDouble(string);
}
@Override
public Object getValue(RecordSet rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "0.0");
String string = Util.null2String(rs.getString(index));
if ("".equals(string)) {
return null;
}
return Double.parseDouble(string);
}
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
String string = Util.null2String(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
if ("".equals(string)) {
return null;
}
return Double.parseDouble(string);
}
@Override
public Object getValue(RecordSetTrans rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "0.0");
String string = Util.null2String(rs.getString(index));
if ("".equals(string)) {
return null;
}
return Double.parseDouble(string);
}

View File

@ -16,25 +16,37 @@ import java.lang.reflect.Field;
public class FloatTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
String string = Util.null2String(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
if ("".equals(string)) {
return null;
}
return Float.parseFloat(string);
}
@Override
public Object getValue(RecordSet rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "0.0");
String string = Util.null2String(rs.getString(index), "0.0");
if ("".equals(string)) {
return null;
}
return Float.parseFloat(string);
}
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
String string = Util.null2String(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
if ("".equals(string)) {
return null;
}
return Float.parseFloat(string);
}
@Override
public Object getValue(RecordSetTrans rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "0.0");
String string = Util.null2String(rs.getString(index));
if ("".equals(string)) {
return null;
}
return Float.parseFloat(string);
}

View File

@ -14,7 +14,10 @@ import java.lang.reflect.Field;
public class IntegerTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "-1");
String string = Util.null2String(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
if ("".equals(string)) {
return null;
}
if (string.contains(".")) {
string = string.substring(0, string.indexOf("."));
}
@ -23,7 +26,10 @@ public class IntegerTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "-1");
String string = Util.null2String(rs.getString(index));
if ("".equals(string)) {
return null;
}
if (string.contains(".")) {
string = string.substring(0, string.indexOf("."));
}
@ -32,7 +38,10 @@ public class IntegerTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "-1");
String string = Util.null2String(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
if ("".equals(string)) {
return null;
}
if (string.contains(".")) {
string = string.substring(0, string.indexOf("."));
}
@ -41,7 +50,10 @@ public class IntegerTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSetTrans rs, int index, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(index), "-1");
String string = Util.null2String(rs.getString(index));
if ("".equals(string)) {
return null;
}
if (string.contains(".")) {
string = string.substring(0, string.indexOf("."));
}

View File

@ -0,0 +1,64 @@
package com.api.youhong.ai.jitu.hrmlogintip.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.youhong.ai.jitu.hrmlogintip.service.HrmLoinTipService;
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;
/**
* <h1></h1>
*
* <p>create: 2023/2/27 10:29</p>
*
* @author youHong.ai
*/
@Path("aiyh/hrm-login/tip")
public class HrmLoinTipController {
private final Logger log = Util.getLogger();
private final HrmLoinTipService service = new HrmLoinTipService();
@Path("/get/message")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String getMessage(@QueryParam("userAccount") String userAccount) {
try {
return ApiResult.success(service.getMessage(userAccount));
} catch (Exception e) {
log.error("get login before show message error! " + Util.getErrString(e));
return ApiResult.error("get message error!");
}
}
@Path("/get/message")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String readMessage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("userAccount") String userAccount) {
User user = null;
try {
user = HrmUserVarify.getUser(request, response);
} catch (Exception ignore) {
}
try {
return ApiResult.success(service.updateMessageStatus(user, userAccount));
} catch (Exception e) {
log.error("update login before show message status error!" + Util.getErrString(e));
return ApiResult.error("update message status error");
}
}
}

View File

@ -0,0 +1,64 @@
package com.api.youhong.ai.jitu.hrmlogintip.mapper;
import aiyh.utils.annotation.recordset.*;
/**
* <h1></h1>
*
* <p>create: 2023/2/27 10:53</p>
*
* @author youHong.ai
*/
@SqlMapper
public interface HrmLoinTipMapper {
/**
* <h2>id</h2>
*
* @param account loginid
* @return id
*/
@Select("select id from hrmresource where loginid = #{account}")
Integer getUserIdByAccount(String account);
/**
* <h2></h2>
*
* @param showStatusField
* @param userId id
* @return
*/
@Select("select $t{showStatusField} from cus_fielddata where scope = 'HrmCustomFieldByInfoType'\n" +
" and scopeid = -1 and id = #{userId}")
Integer getMessageStatus(@ParamMapper("showStatusField") String showStatusField,
@ParamMapper("userId") Integer userId);
/**
* <h2></h2>
*
* @param showStatusField
* @param userId id
* @return
*/
@Update("update cus_fielddata set $t{showStatusField} = 1 where scope = 'HrmCustomFieldByInfoType'\n" +
" and scopeid = -1 and id = #{userId} ")
boolean updateStatus(@ParamMapper("showStatusField") String showStatusField,
@ParamMapper("userId") Integer userId);
/**
* <h2></h2>
*
* @param showStatusField
* @param userId id
* @return
*/
@Insert("insert into cus_fielddata (scope, scopeid, id, $t{showStatusField})\n" +
"values ('HrmCustomFieldByInfoType',-1,#{userId},0)")
boolean insertStatus(@ParamMapper("showStatusField") String showStatusField,
@ParamMapper("userId") Integer userId);
@Select("select SEQORDER from cus_fielddata where scope = 'HrmCustomFieldByInfoType'\n" +
" and scopeid = -1 and id = #{userId}")
Integer getMessageStatusId(@ParamMapper("userId") Integer userId);
}

View File

@ -0,0 +1,61 @@
package com.api.youhong.ai.jitu.hrmlogintip.service;
import aiyh.utils.Util;
import aiyh.utils.tool.Assert;
import com.api.youhong.ai.jitu.hrmlogintip.mapper.HrmLoinTipMapper;
import weaver.hrm.User;
import java.util.Objects;
/**
* <h1></h1>
*
* <p>create: 2023/2/27 10:33</p>
*
* @author youHong.ai
*/
public class HrmLoinTipService {
private final HrmLoinTipMapper mapper = Util.getMapper(HrmLoinTipMapper.class);
/**
* <h2></h2>
*
* @param userAccount
* @return
*/
public String getMessage(String userAccount) {
Integer userId = mapper.getUserIdByAccount(userAccount);
String showStatusField = Util.getCusConfigValue("LOGIN_BEFORE_SHOW_MESSAGE_FIELD");
Assert.notEmpty(showStatusField, "can not query config by only mark [LOGIN_BEFORE_SHOW_MESSAGE_FIELD](登录前显示消息状态字段_人员卡片自定义字段基本信息字段) on table [uf_cus_dev_config]");
Integer showStatus = mapper.getMessageStatus(showStatusField, userId);
// 没有展示过
if (Objects.isNull(showStatus) || showStatus <= 0) {
String loginBeforeShowMessage = Util.getCusConfigValue("LOGIN_BEFORE_SHOW_MESSAGE");
Assert.notEmpty(loginBeforeShowMessage, "can not query config by only mark [LOGIN_BEFORE_SHOW_MESSAGE](登录前显示消息) on table [uf_cus_dev_config]");
return loginBeforeShowMessage;
}
return null;
}
/**
* <h2></h2>
*
* @param user
* @param userAccount
* @return
*/
public boolean updateMessageStatus(User user, String userAccount) {
Integer userId = null;
if (Objects.isNull(user)) {
userId = mapper.getUserIdByAccount(userAccount);
}
String showStatusField = Util.getCusConfigValue("LOGIN_BEFORE_SHOW_MESSAGE_FIELD");
Assert.notEmpty(showStatusField, "can not query config by only mark [LOGIN_BEFORE_SHOW_MESSAGE_FIELD](登录前显示消息状态字段_人员卡片自定义字段基本信息字段) on table [uf_cus_dev_config]");
Integer id = mapper.getMessageStatusId(userId);
if (!Objects.isNull(id)) {
return mapper.updateStatus(showStatusField, userId);
}
return mapper.insertStatus(showStatusField, userId);
}
}

View File

@ -2,6 +2,8 @@ package weaver.youhong.ai.haripijiu.action.sapdocking.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import weaver.general.GCONST;
import weaver.youhong.ai.haripijiu.action.sapdocking.config.dto.SapVoucher;
@ -32,6 +34,9 @@ public class VoucherPayableService {
private final SapConfigService configService = new SapConfigService();
private final Logger logger = Util.getLogger();
@NotNull
private static String getFilePath() {
String sysFilePath = GCONST.getSysFilePath();
@ -69,6 +74,7 @@ public class VoucherPayableService {
public String sendSapVoucher(String onlyMark, String requestId, String billTable) {
SapVoucher voucherData = configService.getVoucherData(onlyMark, requestId, billTable);
logger.info("查询的凭证配置数据: " + JSON.toJSONString(voucherData));
/* ******************* 整理数据 ******************* */
StringBuilder voucherHeadBuilder = new StringBuilder();
List<VoucherItem> voucherHead = voucherData.getVoucherHead();
@ -77,6 +83,7 @@ public class VoucherPayableService {
.append("\t");
}
String voucherHeadStr = voucherHeadBuilder.substring(0, voucherHeadBuilder.lastIndexOf("\t")) + "\r\n";
logger.info("凭证头:" + voucherHeadStr);
StringBuilder voucherDetailBuilder = new StringBuilder();
List<List<VoucherItem>> voucherDetail = voucherData.getVoucherDetail();
for (List<VoucherItem> voucherItems : voucherDetail) {
@ -84,6 +91,7 @@ public class VoucherPayableService {
.append("\r\n");
}
String voucherDetailStr = voucherDetailBuilder.substring(0, voucherDetailBuilder.lastIndexOf("\r\n"));
logger.info("凭证数据:" + voucherHeadStr);
String filePath = getFilePath();
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
@ -102,6 +110,7 @@ public class VoucherPayableService {
public String sendReceiptVoucher(String onlyMark, String requestId, String billTable) {
SapVoucher voucherData = configService.getReceiptPaymentData(onlyMark, requestId, billTable);
logger.info("查询的凭证配置数据: " + JSON.toJSONString(voucherData));
/* ******************* 整理数据 ******************* */
StringBuilder voucherHeadBuilder = new StringBuilder();
List<List<VoucherItem>> voucherDetail = voucherData.getVoucherDetail();
@ -128,13 +137,15 @@ public class VoucherPayableService {
.substring(0, voucherHeadBuilder.lastIndexOf("\t")) + "");
}
}
String voucherHaredStr = voucherHeadBuilder.toString();
logger.info("凭证数据:" + voucherHaredStr);
String filePath = getFilePath();
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
Files.newOutputStream(Paths.get(filePath))
));
writer.write(voucherHeadBuilder.toString());
writer.write(voucherHaredStr);
writer.flush();
writer.close();
} catch (IOException e) {
@ -147,6 +158,7 @@ public class VoucherPayableService {
public List<String> sendPaymentVoucher(String onlyMark, String requestId, String billTable) {
SapVoucher voucherData = configService.getReceiptPaymentData(onlyMark, requestId, billTable);
logger.info("配置数据:" + JSON.toJSONString(voucherData));
List<String> filePathList = new ArrayList<>();
/* ******************* 整理数据 ******************* */
StringBuilder voucherHeadBuilder = new StringBuilder();
@ -165,13 +177,14 @@ public class VoucherPayableService {
}
voucherHeadBuilder = new StringBuilder(voucherHeadBuilder
.substring(0, voucherHeadBuilder.lastIndexOf("\t")) + "");
String voucherHeadStr = voucherHeadBuilder.toString();
logger.info("凭证数据:" + voucherHeadStr);
String filePath = getFilePath();
try {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
Files.newOutputStream(Paths.get(filePath))
));
writer.write(voucherHeadBuilder.toString());
writer.write(voucherHeadStr);
writer.flush();
writer.close();
} catch (IOException e) {