You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
7.7 KiB
Java
168 lines
7.7 KiB
Java
package weaver.interfaces.hostar.action;
|
|
|
|
import com.engine.kq.biz.KQFormatBiz;
|
|
import com.engine.kq.wfset.util.SplitActionUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import weaver.common.DateUtil;
|
|
import weaver.conn.RecordSet;
|
|
import weaver.general.BaseBean;
|
|
import weaver.general.Util;
|
|
import weaver.interfaces.workflow.action.Action;
|
|
import weaver.soa.workflow.request.Property;
|
|
import weaver.soa.workflow.request.RequestInfo;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class OutSignSyncAction implements Action {
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
@Override
|
|
public String execute(RequestInfo requestInfo) {
|
|
bb.writeLog("OutSignSyncAction-start");
|
|
String startDate = "";
|
|
String endDate = "";
|
|
String resourceid = "";
|
|
String nbtxr = "";
|
|
String sjjsrq = "";
|
|
|
|
try {
|
|
|
|
Property[] properties = requestInfo.getMainTableInfo().getProperty();
|
|
for (Property property : properties) {
|
|
if ("ksrq".equals(property.getName())) {
|
|
startDate = Util.null2String(property.getValue());
|
|
}
|
|
if ("yjjsrq".equals(property.getName())) {
|
|
endDate = Util.null2String(property.getValue());
|
|
}
|
|
if ("sjccr".equals(property.getName())) {
|
|
resourceid = Util.null2String(property.getValue());
|
|
}
|
|
if ("nbtxr".equals(property.getName())) {
|
|
nbtxr = Util.null2String(property.getValue());
|
|
}
|
|
if ("sjjsrq".equals(property.getName())) {
|
|
sjjsrq = Util.null2String(property.getValue());
|
|
}
|
|
}
|
|
// 如果实际结束日期不为空,则用实际结束日期
|
|
if (StringUtils.isNotBlank(sjjsrq)) {
|
|
endDate = sjjsrq;
|
|
}
|
|
bb.writeLog("start to handle data.");
|
|
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate) && StringUtils.isNotBlank(resourceid)) {
|
|
// 内部同行人也要考虑
|
|
if (StringUtils.isNotBlank(nbtxr)) {
|
|
resourceid = resourceid + "," + nbtxr;
|
|
}
|
|
RecordSet rs = new RecordSet();
|
|
List<String> infos = new ArrayList<>();
|
|
String acqOutSignSql = "select a.id, c.signinfo " +
|
|
"from mobile_sign a " +
|
|
"left join uf_outsigntype c " +
|
|
"on c.outsignid = a.id " +
|
|
"where operate_date >= '" + startDate + "' and operate_date <= '" + endDate + "' and operater in (?) ";
|
|
rs.executeQuery(acqOutSignSql, resourceid);
|
|
while (rs.next()) {
|
|
String signinfo = Util.null2String(rs.getString("signinfo"));
|
|
infos.add(signinfo);
|
|
}
|
|
bb.writeLog("infos is:" + infos);
|
|
for (String inf : infos) {
|
|
if (StringUtils.isNotEmpty(inf)) {
|
|
Map<String, Object> in = mapStringToMap(inf);
|
|
String userId = Util.null2String(in.get("userId"));
|
|
String userType = Util.null2String(in.get("userType"));
|
|
String signType = Util.null2String(in.get("signType"));
|
|
String signDate = Util.null2String(in.get("signDate"));
|
|
String signTime = Util.null2String(in.get("signTime"));
|
|
String clientAddress = Util.null2String(in.get("clientAddress"));
|
|
String isInCom = Util.null2String(in.get("isInCom"));
|
|
String timeZone = Util.null2String(in.get("timeZone"));
|
|
String belongdate = Util.null2String(in.get("belongdate"));
|
|
String signfrom = Util.null2String(in.get("signfrom"));
|
|
String longitude = Util.null2String(in.get("longitude"));
|
|
String latitude = Util.null2String(in.get("latitude"));
|
|
String address = Util.null2String(in.get("address"));
|
|
String deviceInfo = Util.null2String(in.get("deviceInfo"));
|
|
String belongdateIsNull = Util.null2String(in.get("belongdateIsNull"));
|
|
|
|
String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,isdev) " +
|
|
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
boolean isok = rs.executeUpdate(punchSql, resourceid, userType, signType, signDate, signTime, clientAddress, isInCom,
|
|
timeZone, belongdate, signfrom, longitude, latitude, address, deviceInfo, "1");
|
|
bb.writeLog("isok: " + isok);
|
|
//同步更新考勤数据到考勤报表
|
|
if ("true".equals(belongdateIsNull)) {
|
|
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
|
|
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + DateUtil.getYesterday());
|
|
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
|
|
}
|
|
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
|
|
if (belongdate.length() == 0) {
|
|
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
|
|
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
|
|
}
|
|
new KQFormatBiz().formatDate("" + userId, (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
|
|
//外勤签到转的考勤 处理加班规则
|
|
SplitActionUtil.pushOverTimeTasksAll(belongdate, belongdate, "" + userId);
|
|
}
|
|
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
bb.writeLog("OutSignSyncAction Exception: " + e.getMessage());
|
|
return Action.FAILURE_AND_CONTINUE;
|
|
}
|
|
|
|
return Action.SUCCESS;
|
|
}
|
|
|
|
public static Map<String, Object> mapStringToMap(String str) {
|
|
str = str.substring(1, str.length() - 1);
|
|
List<String> strs = splitString(str);
|
|
Map<String, Object> map = new HashMap<>();
|
|
for (String string : strs) {
|
|
String[] splits = string.split("=");
|
|
String key = splits[0];
|
|
String value = "";
|
|
if (splits.length > 1) {
|
|
value = splits[1];
|
|
}
|
|
// 去掉头部空格
|
|
String key1 = key.trim();
|
|
String value1 = value.trim();
|
|
map.put(key1, value1);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
public static List<String> splitString(String input) {
|
|
List<String> result = new ArrayList<>();
|
|
int braceLevel = 0;
|
|
int startIndex = 0;
|
|
|
|
for (int i = 0; i < input.length(); i++) {
|
|
char ch = input.charAt(i);
|
|
if (ch == '{') {
|
|
braceLevel++;
|
|
} else if (ch == '}') {
|
|
braceLevel--;
|
|
} else if (ch == ',' && braceLevel == 0) {
|
|
result.add(input.substring(startIndex, i));
|
|
startIndex = i + 1;
|
|
}
|
|
}
|
|
|
|
if (startIndex < input.length()) {
|
|
result.add(input.substring(startIndex));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|