餐补优化
parent
5dbe3ebe2d
commit
99e8691098
@ -0,0 +1,143 @@
|
|||||||
|
package weaver.interfaces.hostar.action;
|
||||||
|
|
||||||
|
import com.engine.hostar.thread.HandleCBDataThread;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.BaseBean;
|
||||||
|
import weaver.general.ThreadPoolUtil;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.interfaces.workflow.action.Action;
|
||||||
|
import weaver.soa.workflow.request.RequestInfo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0
|
||||||
|
* @Title ecology-9
|
||||||
|
* @Company 泛微软件
|
||||||
|
* @CreateDate 2024/8/30
|
||||||
|
* @Description 处理餐补通用action
|
||||||
|
* @Author AdminZm
|
||||||
|
*/
|
||||||
|
public class HandleCBCommonAction implements Action {
|
||||||
|
|
||||||
|
BaseBean baseBean = new BaseBean();
|
||||||
|
|
||||||
|
private String ryField;
|
||||||
|
|
||||||
|
private String ksrqField;
|
||||||
|
|
||||||
|
private String jsrqField;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String execute(RequestInfo requestInfo) {
|
||||||
|
baseBean.writeLog("HandleCBCommonAction start:" + ryField + "、" + ksrqField + "、" + jsrqField);
|
||||||
|
try {
|
||||||
|
if (StringUtils.isEmpty(ryField) || StringUtils.isEmpty(ksrqField) || StringUtils.isEmpty(jsrqField)) {
|
||||||
|
return Action.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int billid = requestInfo.getRequestManager().getBillid();
|
||||||
|
String requestid = requestInfo.getRequestid();
|
||||||
|
String billTableName = requestInfo.getRequestManager().getBillTableName();
|
||||||
|
baseBean.writeLog("table info:" + billid + "、" + billTableName + "、" + requestid);
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
rs.execute("SELECT * FROM " + billTableName + " WHERE id = " + billid);
|
||||||
|
if (rs.next()) {
|
||||||
|
String ry = rs.getString(ryField);
|
||||||
|
String ksrq = rs.getString(ksrqField);
|
||||||
|
String jsrq = rs.getString(jsrqField);
|
||||||
|
if (StringUtils.isEmpty(ry) || StringUtils.isEmpty(ksrq) || StringUtils.isEmpty(jsrq)) {
|
||||||
|
return Action.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> ryList = Arrays.asList(ry.split(","));
|
||||||
|
List<String> allDates = getAllDates(ksrq, jsrq);
|
||||||
|
if (CollectionUtils.isEmpty(ryList) || CollectionUtils.isEmpty(allDates)) {
|
||||||
|
baseBean.writeLog("no user or date.");
|
||||||
|
return Action.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取责任制、排班次班次
|
||||||
|
Set<String> zrzbcSet = new HashSet<>();
|
||||||
|
Set<String> pbzbcSet = new HashSet<>();
|
||||||
|
String acqSql = "select kqgroup, grouptype from uf_ZeroPointSubSft";
|
||||||
|
rs.executeQuery(acqSql);
|
||||||
|
while (rs.next()) {
|
||||||
|
String kqgroup = Util.null2String(rs.getString("kqgroup"));
|
||||||
|
String grouptype = Util.null2String(rs.getString("grouptype"));
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(kqgroup) && org.apache.commons.lang3.StringUtils.equals(grouptype, "0")) {
|
||||||
|
zrzbcSet.addAll(Arrays.asList(kqgroup.split(",")));
|
||||||
|
}
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(kqgroup) && org.apache.commons.lang3.StringUtils.equals(grouptype, "1")) {
|
||||||
|
pbzbcSet.addAll(Arrays.asList(kqgroup.split(",")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 鸿仁驻点餐补指定人员不享受
|
||||||
|
List<String> removeRes = new ArrayList<>();
|
||||||
|
String acqNoOtherStatAllResSql = "select resourceid from uf_NoOtherStatAllRe where isdelete is null or isdelete = 0 ";
|
||||||
|
rs.executeQuery(acqNoOtherStatAllResSql);
|
||||||
|
while (rs.next()){
|
||||||
|
String resourceid = Util.null2String(rs.getString("resourceid"));
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(resourceid) ) {
|
||||||
|
removeRes.add(resourceid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 驻点餐补指定人员不享受
|
||||||
|
List<String> noRes = new ArrayList<>();
|
||||||
|
String acqNoResSql = "select resourceid from uf_NoStatAllRes where isdelete = 0 or isdelete is null";
|
||||||
|
rs.executeQuery(acqNoResSql);
|
||||||
|
while (rs.next()) {
|
||||||
|
String resourceid = Util.null2String(rs.getString("resourceid"));
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(resourceid)) {
|
||||||
|
noRes.add(resourceid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取夜班班次
|
||||||
|
List<String> nightShiftList = new ArrayList<>();
|
||||||
|
String acqNightShiftSql = "select shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
|
||||||
|
rs.executeQuery(acqNightShiftSql);
|
||||||
|
while (rs.next()) {
|
||||||
|
String shift = Util.null2String(rs.getString("shift"));
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(shift)) {
|
||||||
|
nightShiftList.add(shift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExecutorService executorService = ThreadPoolUtil.getThreadPool("HandleCBDataThreadAction", "20");
|
||||||
|
for (String userId : ryList) {
|
||||||
|
for (String kqDate : allDates) {
|
||||||
|
executorService.execute(new HandleCBDataThread(userId, kqDate, zrzbcSet, pbzbcSet, removeRes, nightShiftList, noRes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baseBean.writeLog("HandleCBCommonAction end.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
baseBean.writeLog("HandleCBCommonAction error:" + e.getMessage());
|
||||||
|
}
|
||||||
|
return Action.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAllDates(String startDate, String endDate) {
|
||||||
|
List<String> result = new ArrayList<>();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
LocalDate start = LocalDate.parse(startDate, formatter);
|
||||||
|
LocalDate end = LocalDate.parse(endDate, formatter);
|
||||||
|
while (!start.isAfter(end)) {
|
||||||
|
result.add(start.format(formatter));
|
||||||
|
start = start.plusDays(1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue