Compare commits

..

17 Commits

6
.gitignore vendored

@ -1,13 +1,13 @@
/weaver-develop.iml /weaver-develop.iml
/out/ /out/
.idea/ /.idea/
HELP.md HELP.md
target/ target/
.idea /.idea
/test /test/
/src/rebel.xml /src/rebel.xml
/src/META-INF /src/META-INF
/WEB-INF/config /WEB-INF/config

@ -1,6 +1,6 @@
<component name="ArtifactManager"> <component name="ArtifactManager">
<artifact type="jar" name="weaver-develop:jar"> <artifact type="jar" name="weaver-develop:jar">
<output-path>$PROJECT_DIR$/out/artifacts/weaver_develop_jar</output-path> <output-path>$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib</output-path>
<root id="archive" name="weaver-develop.jar"> <root id="archive" name="weaver-develop.jar">
<element id="module-output" name="weaver-develop" /> <element id="module-output" name="weaver-develop" />
</root> </root>

@ -0,0 +1,10 @@
## \u5206\u90E8\u6307\u5B9A
subcompanyid=33
##\u8003\u52E4\u786E\u8BA4\u6D41\u7A0B
workflowId=133
##\u8003\u52E4\u786E\u8BA4\u6D41\u7A0B\u8868\u540D
tableName=formtable_main_567

@ -0,0 +1,13 @@
package com.api.aisin.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2024/11/15 3:04 PM
* @Description: TODO
* @Version 1.0
*/
@Path("/aisin/resource")
public class AccessCustomAction extends com.engine.aisin.web.AccessCustomAction {
}

@ -0,0 +1,34 @@
package com.engine.aisin.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author liang.cheng
* @Date 2024/11/18 10:26 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AccessCustomPo {
private String subCompanyId;
private List<String> checks;
private List<String> subCompanyIds;
private List<String> departmentIds;
private List<String> userIds;
private List<String> roleIds;
}

@ -0,0 +1,34 @@
package com.engine.aisin.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author liang.cheng
* @Date 2024/11/18 10:26 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class KqStatisticsItemVo {
private String name;
private String id;
private String title;
private String type;
private Integer value;
}

@ -0,0 +1,34 @@
package com.engine.aisin.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author liang.cheng
* @Date 2024/11/18 10:26 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class KqStatisticsVo {
private String name;
private String id;
private String title;
private Integer value;
private List<KqStatisticsItemVo> items;
}

@ -0,0 +1,33 @@
package com.engine.aisin.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author liang.cheng
* @Date 2024/11/18 10:26 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourceParam {
private String userId;
private String serialId;
/**
*
*/
private boolean sign;
}

@ -0,0 +1,32 @@
package com.engine.aisin.service;
import com.engine.aisin.entity.KqStatisticsVo;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/11/15 3:16 PM
* @Description: TODO
* @Version 1.0
*/
public interface AccessCustomService {
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/11/15 3:35 PM
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
boolean customAccess(String userId);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/11/28 2:38 PM
* @param: []
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
KqStatisticsVo getKqAccess(Map<String,Object> params);
}

@ -0,0 +1,67 @@
package com.engine.aisin.web;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.aisin.service.AccessCustomService;
import com.engine.aisin.service.impl.AccessCustomServiceImpl;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/11/15 3:05 PM
* @Description: TODO
* @Version 1.0
*/
public class AccessCustomAction {
private AccessCustomService getService(User user) {
return ServiceUtil.getService(AccessCustomServiceImpl.class, user);
}
@GET
@Path("/custom/access")
@Produces(MediaType.TEXT_PLAIN)
public String customAccess(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("userId")String userId){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("datas",getService(user).customAccess(userId));
data.put("api_status", true);
} catch (Exception e) {
data.put("api_status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
@GET
@Path("/kqstatistics/access")
@Produces(MediaType.TEXT_PLAIN)
public String getKqAccess(@Context HttpServletRequest request, @Context HttpServletResponse response){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("datas",getService(user).getKqAccess(ParamUtil.request2Map(request)));
data.put("api_status", true);
} catch (Exception e) {
data.put("api_status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,797 @@
package com.engine.kq.biz;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.wfset.bean.SplitBean;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
/**
*
*/
public class KQFlowDataBiz {
private String resourceid;
private String fromDate;
private String toDate;
private String fromTime;
private String toTime;
private String belongDate;
private String newLeaveType;
private String orderby_sql;
public KQFlowDataBiz(FlowDataParamBuilder build){
this.resourceid = build.resourceid;
this.fromDate = build.fromDate;
this.toDate = build.toDate;
this.fromTime = build.fromTime;
this.toTime = build.toTime;
this.belongDate = build.belongDate;
this.newLeaveType = build.newLeaveType;
this.orderby_sql = build.orderby_sql;
}
/**
*
*
* @param flowMaps
* @param isAll truefalse
* @return
*/
public List<SplitBean> getAllFlowData(Map<String,Object> flowMaps,boolean isAll){
List<SplitBean> allSplitBeans = new ArrayList<>();
Map<String,String> flowDeductCard = getFlowDeductCard();
allSplitBeans.addAll(getLeaveData(flowMaps,flowDeductCard));
allSplitBeans.addAll(getEvectionData(flowMaps,flowDeductCard));
allSplitBeans.addAll(getOutData(flowMaps,flowDeductCard));
if(isAll){
allSplitBeans.addAll(getOverTimeData(flowMaps));
}
allSplitBeans.addAll(getOtherData(flowMaps));
return allSplitBeans;
}
/**
*
*/
public Map<String,String> getFlowDeductCard() {
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
Map<String,String> flowDeductCard = new HashMap<>();
String flowDeductCardSql = "select * from kq_flow_deduct_card t where 1=1 and (isclear is null or isclear<>1) ";
String sqlWhere = sqlFlowCardParamWhere();
if(sqlWhere.length() > 0){
flowDeductCardSql += sqlWhere;
}
rs.execute(flowDeductCardSql);
while(rs.next()){
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String signtype= rs.getString("signtype");
String serialnumber= rs.getString("serialnumber");
String flowtype= rs.getString("flowtype");
String key = requestId+"_"+resourceid+"_"+flowtype;
String serial_signtype = serialnumber+"_"+signtype;
if(flowDeductCard.containsKey(key)){
String tmpSignType = Util.null2String(flowDeductCard.get(key));
flowDeductCard.put(key, tmpSignType+","+serial_signtype);
}else{
flowDeductCard.put(key, serial_signtype);
}
}
return flowDeductCard;
}
/**
*
*/
public List<SplitBean> getLeaveData(Map<String, Object> flowMaps,
Map<String, String> flowDeductCard){
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
leaveSql += sqlWhere;
}
List<SplitBean> splitBeans = new ArrayList<>();
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
int[] initArrays = kqTimesArrayComInfo.getInitArr();
rs.execute(leaveSql);
while(rs.next()){
SplitBean splitBean = new SplitBean();
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String fromdate= rs.getString("fromdate");
String belongdate= rs.getString("belongdate");
String fromtime= rs.getString("fromtime");
String todate= rs.getString("todate");
String totime= rs.getString("totime");
String newleavetype= rs.getString("newleavetype");
String duration= rs.getString("duration");
String durationrule= rs.getString("durationrule");
String leavebackrequestid= Util.null2String(rs.getString("leavebackrequestid"));
String fromtimedb= rs.getString("fromtimedb");
String totimedb= rs.getString("totimedb");
if(Util.getDoubleValue(duration) <= 0){
continue;
}
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.LEAVE.getFlowtype();
String serial_signtype = "";
String serial = "";
String signtype = "";
if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){
serial_signtype = Util.null2String(flowDeductCard.get(card_key));
if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){
serial = serial_signtype.split("_")[0];
signtype = serial_signtype.split("_")[1];
}
}
Map<String,String> infoMap = new HashMap<>();
infoMap.put("requestId", requestId);
infoMap.put(newleavetype, duration);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
infoMap.put("durationrule", durationrule);
if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){
infoMap.put("ishalf", "true");
}else{
infoMap.put("ishalf", "false");
}
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
infoMap.put("newleavetype", newleavetype);
infoMap.put("signtype", signtype);
infoMap.put("serial", serial);
infoMap.put("fromtimedb", fromtimedb);
infoMap.put("totimedb", totimedb);
String key = resourceid+"|"+belongdate;
if(flowMaps != null){
if(flowMaps.get(key) != null){
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
initArrays = kqTimesArrayComInfo.getInitArr();
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
leavebackrequestid = leavebackrequestid.substring(1);
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
rs1.executeQuery(backSql);
while (rs1.next()){
String back_fromtime = rs1.getString("fromtime");
String back_totime = rs1.getString("totime");
String back_duration= rs.getString("duration");
if(Util.getDoubleValue(back_duration) <= 0){
continue;
}
if(back_fromtime.equalsIgnoreCase(fromtime)){
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}else{
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}
}
List<List<String>> backLists = new ArrayList<>();
List<String> backList = new ArrayList<>();
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
if(initArrays[i] == 1){
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
}else{
if(!backList.isEmpty()){
backLists.add(backList);
backList = new ArrayList<>();
}else{
continue;
}
}
}
if(!backList.isEmpty()){
backLists.add(backList);
}
if(backLists != null && !backLists.isEmpty()){
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
for(int j = 0 ; j < backLists.size() ;j++){
List<String> backListTmp = backLists.get(j);
String back_tmp_fromtime = backListTmp.get(0);
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
infoMap = new HashMap<>();
infoMap.put("requestId", requestId);
infoMap.put(newleavetype, duration);
infoMap.put("begintime", back_tmp_fromtime);
infoMap.put("endtime", back_tmp_totime);
infoMap.put("unitType", unitType);
infoMap.put("durationrule", durationrule);
if("2".equals(durationrule)){
infoMap.put("ishalf", "true");
}
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
infoMap.put("newleavetype", newleavetype);
time_list_tmp.add(infoMap);
}
}
}else{
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
time_list_tmp.add(infoMap);
}
}else{
if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){
initArrays = kqTimesArrayComInfo.getInitArr();
int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1);
leavebackrequestid = leavebackrequestid.substring(1);
String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'";
rs1.executeQuery(backSql);
while (rs1.next()){
String back_fromtime = rs1.getString("fromtime");
String back_totime = rs1.getString("totime");
if(back_fromtime.equalsIgnoreCase(fromtime)){
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}else{
if(back_fromtime.compareTo(back_totime) < 0){
Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime), -1);
}
}
}
List<List<String>> backLists = new ArrayList<>();
List<String> backList = new ArrayList<>();
for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){
if(initArrays[i] == 1){
backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i));
}else{
if(!backList.isEmpty()){
backLists.add(backList);
backList = new ArrayList<>();
}else{
continue;
}
}
}
if(!backList.isEmpty()){
backLists.add(backList);
}
if(backLists != null && !backLists.isEmpty()){
List<Map<String,String>> time_list = new ArrayList<>();
for(int j = 0 ; j < backLists.size() ;j++){
List<String> backListTmp = backLists.get(j);
String back_tmp_fromtime = backListTmp.get(0);
String back_tmp_totime = backListTmp.get(backListTmp.size()-1);
infoMap = new HashMap<>();
infoMap.put("requestId", requestId);
infoMap.put(newleavetype, duration);
infoMap.put("begintime", back_tmp_fromtime);
infoMap.put("endtime", back_tmp_totime);
infoMap.put("unitType", unitType);
infoMap.put("durationrule", durationrule);
if("2".equals(durationrule)){
infoMap.put("ishalf", "true");
}
infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType());
infoMap.put("newleavetype", newleavetype);
time_list.add(infoMap);
}
flowMaps.put(key, time_list);
}
}else{
List<Map<String,String>> time_list = new ArrayList<>();
time_list.add(infoMap);
flowMaps.put(key, time_list);
}
}
}
}
return splitBeans;
}
/**
*
*/
public List<SplitBean> getEvectionData(Map<String, Object> flowMaps,
Map<String, String> flowDeductCard){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.EVECTION.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
leaveSql += sqlWhere;
}
List<SplitBean> splitBeans = new ArrayList<>();
rs.execute(leaveSql);
while(rs.next()){
SplitBean splitBean = new SplitBean();
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String fromdate= rs.getString("fromdate");
String belongdate= rs.getString("belongdate");
String fromtime= rs.getString("fromtime");
String todate= rs.getString("todate");
String totime= rs.getString("totime");
String newleavetype= rs.getString("newleavetype");
String duration= rs.getString("duration");
String durationrule= rs.getString("durationrule");
splitBean.setRequestId(requestId);
splitBean.setResourceId(resourceid);
splitBean.setFromDate(fromdate);
splitBean.setFromTime(fromtime);
splitBean.setToDate(todate);
splitBean.setToTime(totime);
splitBean.setNewLeaveType(newleavetype);
splitBean.setDuration(duration);
splitBean.setDurationrule(durationrule);
splitBeans.add(splitBean);
if(Util.getDoubleValue(duration) <= 0){
continue;
}
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.EVECTION.getFlowtype();
String serial_signtype = "";
String serial = "";
String signtype = "";
if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){
serial_signtype = Util.null2String(flowDeductCard.get(card_key));
if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){
serial = serial_signtype.split("_")[0];
signtype = serial_signtype.split("_")[1];
}
}
Map<String,String> infoMap = new HashMap<>();
infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration);
infoMap.put("requestId", requestId);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
infoMap.put("durationrule", durationrule);
if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){
infoMap.put("ishalf", "true");
}else{
infoMap.put("ishalf", "false");
}
infoMap.put("duration", duration);
infoMap.put("flowtype", FlowReportTypeEnum.EVECTION.getFlowType());
infoMap.put("signtype", signtype);
infoMap.put("serial", serial);
String key = resourceid+"|"+belongdate;
if(flowMaps != null){
if(flowMaps.get(key) != null){
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
time_list_tmp.add(infoMap);
}else{
List<Map<String,String>> time_list = new ArrayList<>();
time_list.add(infoMap);
flowMaps.put(key, time_list);
}
}
}
return splitBeans;
}
/**
*
*/
public List<SplitBean> getOutData(Map<String, Object> flowMaps,
Map<String, String> flowDeductCard){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.OUT.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
leaveSql += sqlWhere;
}
List<SplitBean> splitBeans = new ArrayList<>();
rs.execute(leaveSql);
while(rs.next()){
SplitBean splitBean = new SplitBean();
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String fromdate= rs.getString("fromdate");
String belongdate= rs.getString("belongdate");
String fromtime= rs.getString("fromtime");
String todate= rs.getString("todate");
String totime= rs.getString("totime");
String newleavetype= rs.getString("newleavetype");
String duration= rs.getString("duration");
String durationrule= rs.getString("durationrule");
splitBean.setRequestId(requestId);
splitBean.setResourceId(resourceid);
splitBean.setFromDate(fromdate);
splitBean.setFromTime(fromtime);
splitBean.setToDate(todate);
splitBean.setToTime(totime);
splitBean.setNewLeaveType(newleavetype);
splitBean.setDuration(duration);
splitBean.setDurationrule(durationrule);
splitBeans.add(splitBean);
if(Util.getDoubleValue(duration) <= 0){
continue;
}
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.OUT.getFlowtype();
String serial_signtype = "";
String serial = "";
String signtype = "";
if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){
serial_signtype = Util.null2String(flowDeductCard.get(card_key));
if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){
serial = serial_signtype.split("_")[0];
signtype = serial_signtype.split("_")[1];
}
}
Map<String,String> infoMap = new HashMap<>();
infoMap.put(FlowReportTypeEnum.officialBusiness.getFlowType(), duration);
infoMap.put("requestId", requestId);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
infoMap.put("durationrule", durationrule);
if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){
infoMap.put("ishalf", "true");
}else{
infoMap.put("ishalf", "false");
}
infoMap.put("duration", duration);
infoMap.put("flowtype", FlowReportTypeEnum.OUT.getFlowType());
infoMap.put("signtype", signtype);
infoMap.put("serial", serial);
String key = resourceid+"|"+belongdate;
if(flowMaps != null){
if(flowMaps.get(key) != null){
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
time_list_tmp.add(infoMap);
}else{
List<Map<String,String>> time_list = new ArrayList<>();
time_list.add(infoMap);
flowMaps.put(key, time_list);
}
}
}
return splitBeans;
}
/**
*
*/
public List<SplitBean> getOverTimeData(Map<String,Object> flowMaps){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.OVERTIME.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String leaveSql = "select * from ("+tablename+") t where 1=1 ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
leaveSql += sqlWhere;
}
List<SplitBean> splitBeans = new ArrayList<>();
if(orderby_sql.length() > 0){
leaveSql = leaveSql+orderby_sql;
}
new BaseBean().writeLog("加班流程获取Sql=>"+leaveSql);
rs.execute(leaveSql);
while(rs.next()){
SplitBean splitBean = new SplitBean();
String dataid= rs.getString("dataid");
String detailid= rs.getString("detailid");
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String fromdate= rs.getString("fromdate");
String belongdate= rs.getString("belongdate");
new BaseBean().writeLog("是否获取到加班流程及所属日期=>"+belongdate);
String fromtime= rs.getString("fromtime");
String todate= rs.getString("todate");
String totime= rs.getString("totime");
String newleavetype= rs.getString("newleavetype");
String duration= rs.getString("duration");
String durationrule= rs.getString("durationrule");
String changetype= rs.getString("changetype");
String d_mins= rs.getString("d_mins");
String overtime_type= rs.getString("overtime_type");
String fromdatedb= rs.getString("fromdatedb");
String fromtimedb= rs.getString("fromtimedb");
String todatedb= rs.getString("todatedb");
String totimedb= rs.getString("totimedb");
splitBean.setBelongDate(belongdate);
splitBean.setDataId(dataid);
splitBean.setDetailId(detailid);
splitBean.setRequestId(requestId);
splitBean.setResourceId(resourceid);
splitBean.setFromDate(fromdate);
splitBean.setFromTime(fromtime);
splitBean.setToDate(todate);
splitBean.setToTime(totime);
splitBean.setNewLeaveType(newleavetype);
splitBean.setDuration(duration);
splitBean.setDurationrule(durationrule);
splitBean.setChangeType(Util.getIntValue(changetype));
splitBean.setD_Mins(Util.getDoubleValue(d_mins));
splitBean.setOvertime_type(overtime_type);
splitBean.setFromdatedb(fromdatedb);
splitBean.setFromtimedb(fromtimedb);
splitBean.setTodatedb(todatedb);
splitBean.setTotimedb(totimedb);
splitBeans.add(splitBean);
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
unitType = "2".equalsIgnoreCase(durationrule)?"1":"2";
Map<String,String> infoMap = new HashMap<>();
infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
infoMap.put("duration", duration);
infoMap.put("flowtype", FlowReportTypeEnum.OVERTIME.getFlowType());
String key = resourceid+"|"+belongdate;
if(flowMaps != null){
if(flowMaps.get(key) != null){
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
time_list_tmp.add(infoMap);
}else{
List<Map<String,String>> time_list = new ArrayList<>();
time_list.add(infoMap);
flowMaps.put(key, time_list);
}
}
}
return splitBeans;
}
/**
*
*/
public List<SplitBean> getOtherData(Map<String,Object> flowMaps){
RecordSet rs = new RecordSet();
String tablename = "select a.* from "+KqSplitFlowTypeEnum.OTHER.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 ";
String leaveSql = "select * from ("+tablename+") t where 1=1 ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
leaveSql += sqlWhere;
}
List<SplitBean> splitBeans = new ArrayList<>();
rs.execute(leaveSql);
while(rs.next()){
SplitBean splitBean = new SplitBean();
String requestId= rs.getString("requestId");
String resourceid= rs.getString("resourceid");
String fromdate= rs.getString("fromdate");
String belongdate= rs.getString("belongdate");
String fromtime= rs.getString("fromtime");
String todate= rs.getString("todate");
String totime= rs.getString("totime");
String newleavetype= rs.getString("newleavetype");
String duration= rs.getString("duration");
String durationrule= rs.getString("durationrule");
splitBean.setRequestId(requestId);
splitBean.setResourceId(resourceid);
splitBean.setFromDate(fromdate);
splitBean.setFromTime(fromtime);
splitBean.setToDate(todate);
splitBean.setToTime(totime);
splitBean.setNewLeaveType(newleavetype);
splitBean.setDuration(duration);
splitBean.setDurationrule(durationrule);
splitBeans.add(splitBean);
//计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假
String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2";
Map<String,String> infoMap = new HashMap<>();
infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration);
infoMap.put("begintime", fromtime);
infoMap.put("endtime", totime);
infoMap.put("unitType", unitType);
String key = resourceid+"|"+belongdate;
if(flowMaps != null){
if(flowMaps.get(key) != null){
List<Map<String,String>> time_list_tmp = (List<Map<String,String>>)flowMaps.get(key);
time_list_tmp.add(infoMap);
}else{
List<Map<String,String>> time_list = new ArrayList<>();
time_list.add(infoMap);
flowMaps.put(key, time_list);
}
}
}
return splitBeans;
}
/**
*
* @param ruleid
* @return true
*/
public static boolean leaveTypeUsed(String ruleid){
KQFlowDataBiz kqFlowDataBiz = new FlowDataParamBuilder().newLeaveTypeParam(ruleid).build();
List<SplitBean> splitBeans = kqFlowDataBiz.getLeaveData(null, new HashMap<>());
if(!splitBeans.isEmpty()){
return true;
}else{
return false;
}
}
/**
*
* @return
*/
private String sqlParamWhere() {
String sqlWhere = "";
if(resourceid.length() > 0){
sqlWhere += " and resourceid in ( "+resourceid+" )";
}
if(fromDate.length() > 0 && toDate.length() > 0){
sqlWhere += " and ( fromdate between '"+fromDate+"' and '"+toDate+"' or todate between '"+fromDate+"' and '"+toDate+"' )";
}else{
if(fromDate.length() > 0){
sqlWhere += " and fromdate between '"+fromDate+"' and '"+fromDate+"' ";
}
if(toDate.length() > 0){
sqlWhere += " and todate between '"+toDate+"' and '"+toDate+"' ";
}
}
if(belongDate.length() > 0){
sqlWhere += " and belongdate = '"+belongDate+"' ";
}
if(fromTime.length() > 0){
sqlWhere += " and fromtime >= '"+fromTime+"' ";
}
if(toTime.length() > 0){
sqlWhere += " and totime <= '"+toTime+"' ";
}
if(newLeaveType.length() > 0){
sqlWhere += " and newleavetype in ( "+newLeaveType+" )";
}
return sqlWhere;
}
private String sqlFlowCardParamWhere() {
String sqlWhere = "";
if(resourceid.length() > 0){
sqlWhere += " and resourceid in ( "+resourceid+" )";
}
if(fromDate.length() > 0 && toDate.length() > 0){
sqlWhere += " and ( fromdate between '"+fromDate+"' and '"+toDate+"' or todate between '"+fromDate+"' and '"+toDate+"' )";
}else{
if(fromDate.length() > 0){
sqlWhere += " and fromdate between '"+fromDate+"' and '"+fromDate+"' ";
}
if(toDate.length() > 0){
sqlWhere += " and todate between '"+toDate+"' and '"+toDate+"' ";
}
}
if(belongDate.length() > 0){
sqlWhere += " and belongdate = '"+belongDate+"' ";
}
if(fromTime.length() > 0){
sqlWhere += " and fromtime >= '"+fromTime+"' ";
}
if(toTime.length() > 0){
sqlWhere += " and totime <= '"+toTime+"' ";
}
return sqlWhere;
}
/**
* Builder
*/
public static class FlowDataParamBuilder {
private String resourceid = "";
private String fromDate = "";
private String toDate = "";
private String fromTime = "";
private String toTime = "";
private String belongDate = "";
/**
*
*/
private String newLeaveType = "";
private String orderby_sql = "";
public FlowDataParamBuilder() {
this.resourceid = "";
//初始化的时候需要把其他参数先清空下
this.fromDate = "";
this.toDate = "";
this.fromTime = "";
this.toTime = "";
this.newLeaveType = "";
this.belongDate = "";
this.orderby_sql = "";
}
//成员方法返回其自身,所以可以链式调用
public FlowDataParamBuilder resourceidParam(final String resourceid) {
this.resourceid = resourceid;
return this;
}
public FlowDataParamBuilder fromDateParam(final String fromDate) {
this.fromDate = fromDate;
return this;
}
public FlowDataParamBuilder toDateParam(final String toDate) {
this.toDate = toDate;
return this;
}
public FlowDataParamBuilder fromTimeParam(final String fromTime) {
this.fromTime = fromTime;
return this;
}
public FlowDataParamBuilder toTimeParam(final String toTime) {
this.toTime = toTime;
return this;
}
public FlowDataParamBuilder newLeaveTypeParam(final String newLeaveType) {
this.newLeaveType = newLeaveType;
return this;
}
public FlowDataParamBuilder belongDateParam(final String belongDate) {
this.belongDate = belongDate;
return this;
}
public FlowDataParamBuilder orderby_sqlParam(final String orderby_sql) {
this.orderby_sql = orderby_sql;
return this;
}
//Builder的build方法返回外部类的实例
public KQFlowDataBiz build() {
return new KQFlowDataBiz(this);
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,73 @@
package com.engine.kq.wfset.action;
import com.engine.kq.biz.KQFlowActiontBiz;
import com.engine.kq.log.KQLog;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.workflow.WorkflowComInfo;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
/**
* action
*/
public class KqSplitAction extends BaseBean implements Action {
private KQLog kqLog = new KQLog();
@Override
public String execute(RequestInfo request) {
this.writeLog("KqSplitAction", "do action on request:" + request.getRequestid());
String requestid = request.getRequestid();
kqLog.info("do KqSplitAction on request:"+request.getRequestid());
int requestidInt = Util.getIntValue(requestid, 0);
String workflowid = request.getWorkflowid();
String formid = new WorkflowComInfo().getFormId(workflowid);
try {
KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz();
RecordSet rs = new RecordSet();
String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? ";
rs.executeQuery(proc_set_sql, workflowid,formid);
if(rs.next()){
String proc_set_id = rs.getString("id");
//得到这个考勤流程设置是否使用明细
String usedetails = rs.getString("usedetail");
int kqtype = Util.getIntValue(rs.getString("field006"));
kqLog.info("do action on kqtype:" + kqtype+":requestidInt:"+requestidInt);
Map<String, String> map = new HashMap<String, String>();
if(requestidInt > 0){
map.put("requestId", "and t.requestId = " + requestidInt);
map.put("operatorId", ""+request.getRequestManager().getCreater());
}
Map<String,String> result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, requestidInt, kqtype, Util.getIntValue(workflowid), false,false,map);
if(!result.isEmpty()){
String error = Util.null2String(result.get("message"));
request.getRequestManager().setMessageid("666" + request.getRequestid() + "999");
request.getRequestManager().setMessagecontent(error);
return Action.FAILURE_AND_CONTINUE;
}
}
} catch (Exception e) {
kqLog.info("流程数据报错:KqSplitAction:");
StringWriter errorsWriter = new StringWriter();
e.printStackTrace(new PrintWriter(errorsWriter));
kqLog.info(errorsWriter.toString());
request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222");
request.getRequestManager().setMessagecontent("【考勤报表统计action】报错请联系管理员");
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
}

@ -0,0 +1,460 @@
package com.engine.kq.wfset.util;
import com.alibaba.fastjson.JSON;
import com.engine.kq.biz.KQExitRulesBiz;
import com.engine.kq.biz.KQFormatData;
import com.engine.kq.biz.KQLeaveRulesBiz;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.biz.KQTravelRulesBiz;
import com.engine.kq.enums.DurationTypeEnum;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.log.KQLog;
import com.engine.kq.wfset.bean.SplitBean;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;
import weaver.workflow.workflow.WorkflowRequestComInfo;
public class KQFlowUtil {
private KQLog kqLog = new KQLog();
/**
* bean
* @param splitBean
* @param rs1
* @param requestId
* @param rci
* @param workflowId
* @param durationTypeEnum
* @param key
* @param result
* @param datetimeFormatter
* @param uuid
*/
public boolean fillSplitBean(SplitBean splitBean, RecordSet rs1, String requestId,
ResourceComInfo rci, String workflowId, DurationTypeEnum durationTypeEnum, String key,
Map<String, String> result, DateTimeFormatter datetimeFormatter, String uuid){
boolean isFillRight = true;
String concort = "###" ;
int usedetail = Util.getIntValue(key.split(concort)[2], 0);
String tableDetailName= key.split(concort)[1] ;
String tableName= key.split(concort)[0] ;
String prefix = "";
String id = "dataId";
if(usedetail == 1){
prefix = "detail_";
id = "detailId";
}
boolean isLeaveBack = false;
if(durationTypeEnum == DurationTypeEnum.LEAVEBACK){
isLeaveBack = true;
}
boolean isProcessChange = false;
boolean isProcessDrawBack = false;
if(durationTypeEnum == DurationTypeEnum.PROCESSCHANGE){
isProcessChange = true;
String changetype = Util.null2s(rs1.getString("changetype"), "");
if("1".equalsIgnoreCase(changetype)){
//如果是撤销的话,没有开始日期时间和结束日期时间
isProcessDrawBack = true;
}
}
String resourceId = "";
//查询到的requestid
String requestId_rs = "";
String idVal = Util.null2s(rs1.getString(id), "0");
String fromDate = Util.null2s(rs1.getString(prefix+"fromDate"), "");
String toDate = Util.null2s(rs1.getString(prefix+"toDate"), "");
String fromTime = Util.null2s(rs1.getString(prefix+"fromTime"), "");
String toTime = Util.null2s(rs1.getString(prefix+"toTime"), "");
String durationDB = Util.null2s(rs1.getString(prefix+"duration"), "");
if(isLeaveBack || isProcessChange){
resourceId = Util.null2s(rs1.getString("resourceId"), "");
}else{
resourceId = Util.null2s(rs1.getString(prefix+"resourceId"), "");
}
if(Util.getIntValue(requestId,0) <= 0){
requestId_rs = Util.null2s(rs1.getString("requestId"), "0");
}
boolean isVal = checkActionValidate(result, fromDate, toDate, fromTime, toTime, datetimeFormatter);
if(isProcessDrawBack){
result.clear();
result.put("isProcessDrawBack", "1");
isVal = true;
}
if(!isVal){
isFillRight = false;
return isFillRight;
}
if(isLeaveBack){
LocalDateTime localFromDateTime = LocalDateTime.parse(fromDate+" "+fromTime,datetimeFormatter);
LocalDateTime localToDateTime = LocalDateTime.parse(toDate+" "+toTime,datetimeFormatter);
isFillRight = KQFlowLeaveBackUtil.leaveBackCheck(rs1 ,datetimeFormatter,prefix,localFromDateTime,localToDateTime,result);
if(!isFillRight){
return isFillRight;
}
}
if(isProcessChange){
isFillRight = KQFlowProcessChangeUtil.processChangeCheck(rs1 ,requestId_rs,result);
if(!isFillRight){
return isFillRight;
}
}
if(usedetail == 1){
splitBean.setDataId("0");
splitBean.setDetailId(idVal);
splitBean.setTablenamedb(tableDetailName);
}else{
splitBean.setDataId(idVal);
splitBean.setDetailId("0");
splitBean.setTablenamedb(tableName);
}
splitBean.setFromdatedb(fromDate);
splitBean.setFromtimedb(fromTime);
splitBean.setTodatedb(toDate);
splitBean.setTotimedb(toTime);
if(requestId_rs.length() > 0){
WorkflowRequestComInfo workflowRequestComInfo = new WorkflowRequestComInfo();
splitBean.setRequestId(requestId_rs);
splitBean.setWorkflowId(workflowRequestComInfo.getWorkflowId(requestId_rs));
}else{
splitBean.setRequestId(requestId);
splitBean.setWorkflowId(workflowId);
}
splitBean.setUsedetail(""+usedetail);
splitBean.setResourceId(resourceId);
splitBean.setSubcompanyid(Util.null2s(rci.getSubCompanyID(resourceId),"0"));
splitBean.setDepartmentid(Util.null2s(rci.getDepartmentID(resourceId),"0"));
splitBean.setJobtitle(Util.null2s(rci.getJobTitle(resourceId),"0"));
splitBean.setFromDate(fromDate);
splitBean.setFromTime(fromTime);
splitBean.setToDate(toDate);
splitBean.setToTime(toTime);
splitBean.setDurationDB(durationDB);
//默认记录的状态都为0
splitBean.setStatus("0");
splitBean.setDurationTypeEnum(durationTypeEnum);
switch (durationTypeEnum){
case LEAVE:
KQFlowLeaveUtil.bean4Leave(prefix,rs1,splitBean);
break;
case EVECTION:
KQFlowEvectionUtil.bean4Evection(prefix,rs1,splitBean);
break;
case OUT:
KQFlowOutUtil.bean4Out(splitBean);
break;
case OVERTIME:
KQFlowOvertimeUtil.bean4Overtime(prefix,rs1,splitBean);
break;
case LEAVEBACK:
KQFlowLeaveBackUtil.bean4LeaveBack(prefix,rs1,splitBean);
break;
case OTHER:
bean4Other(prefix,rs1,splitBean);
break;
case PROCESSCHANGE:
KQFlowProcessChangeUtil.bean4ProcessChange(prefix,rs1,splitBean);
break;
default:
break;
}
String computingMode = splitBean.getComputingMode();
String newLeaveType = splitBean.getNewLeaveType();
if("2".equalsIgnoreCase(computingMode)){
if(durationTypeEnum == DurationTypeEnum.PROCESSCHANGE){
double oneDayHour = getOneDayHour(splitBean.getDurationTypeEnum(),newLeaveType);
splitBean.setOneDayHour(oneDayHour);
}else{
double oneDayHour = getOneDayHour(durationTypeEnum,newLeaveType);
splitBean.setOneDayHour(oneDayHour);
}
}
return isFillRight;
}
private void bean4Other(String prefix, RecordSet rs1, SplitBean splitBean) {
String minimumUnit = "1";
String computingMode = "1";
splitBean.setDurationrule(minimumUnit);
splitBean.setComputingMode(computingMode);
}
/**
* /
* @param durationTypeEnum
* @param newLeaveType
* @return
*/
public static double getOneDayHour(DurationTypeEnum durationTypeEnum,String newLeaveType){
double oneDayHour = 0.0;
//TODO KQLeaveRulesBiz.getHoursToDay如果单位是小时的时候取不到日折算时长
switch (durationTypeEnum){
case LEAVE:
oneDayHour = Util.getDoubleValue(KQLeaveRulesBiz.getHoursToDay(newLeaveType), 0.0);
break;
case EVECTION:
oneDayHour = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay(), 0.0);
break;
case OUT:
oneDayHour = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay(), 0.0);
break;
case OVERTIME:
oneDayHour = KQOvertimeRulesBiz.getHoursToDay();
break;
case LEAVEBACK:
oneDayHour = Util.getDoubleValue(KQLeaveRulesBiz.getHoursToDay(newLeaveType), 0.0);
break;
default:
}
return oneDayHour;
}
public boolean checkActionValidate(Map<String,String> result,String fromDate,String toDate,String fromTime,String toTime, DateTimeFormatter datetimeFormatter){
boolean isVal = true;
if(Util.null2String(fromDate,"").length() == 0 ||
Util.null2String(toDate,"").length() == 0 ||
Util.null2String(fromTime,"").length() == 0 ||
Util.null2String(toTime,"").length() == 0){
result.put("status", "-1");
result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005411,weaver.general.ThreadVarLanguage.getLang())+"");
isVal = false;
return isVal;
}
if((fromDate+" "+fromTime).length() != 16 || (toDate+" "+toTime).length() != 16){
result.put("status", "-1");
result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005412,weaver.general.ThreadVarLanguage.getLang())+""+(fromDate+" "+fromTime)+":"+(toDate+" "+toTime));
isVal = false;
return isVal;
}
LocalDate localFromDate = LocalDate.parse(fromDate);
LocalDate localToDate = LocalDate.parse(toDate);
LocalDateTime localFromDateTime = LocalDateTime.parse(fromDate+" "+fromTime,datetimeFormatter);
LocalDateTime localToDateTime = LocalDateTime.parse(toDate+" "+toTime,datetimeFormatter);
if(localFromDateTime.isAfter(localToDateTime)){
result.put("status", "-1");
result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(511480,weaver.general.ThreadVarLanguage.getLang())+"");
isVal = false;
return isVal;
}
if (localFromDate.isAfter(localToDate)) {
result.put("status", "-1");
result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005413,weaver.general.ThreadVarLanguage.getLang())+"");
isVal = false;
return isVal;
}
return isVal;
}
/**
*
* @param splitBeans
* @param flowTypeEnum
* @param rci
* @param result
* @param isForce
* @param requestId
* @param workflowId
* @param isUpgrade
* @throws Exception
*/
public void handleSplitFLowActionData(
List<SplitBean> splitBeans, KqSplitFlowTypeEnum flowTypeEnum,
ResourceComInfo rci, Map<String, String> result, boolean isForce, int requestId,
int workflowId,boolean isUpgrade) throws Exception{
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
Map<String,String> custome_map = Maps.newHashMap();
List<String> custome_field = Lists.newArrayList();
if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){
custome_field.add("overtime_type");
}
String batchSql = "insert into "+flowTypeEnum.getTablename()+" ("
+ "requestid,workflowid,dataid,detailid,resourceid,fromdate,fromtime,"
+ "todate,totime,newleavetype,duration,usedetail,durationrule,tablenamedb,fromdatedb,"
+ "fromtimedb,todatedb,totimedb,durationdb,status,belongDate,D_Mins,serialid,"
+ "changeType,subcompanyid,departmentid,jobtitle,companion,iscompanion"+getCustomField(custome_field,"field",null,
custome_map)+")"+
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?"+getCustomField(custome_field,"param",null,
custome_map)+") ";
List<List> params = new ArrayList<List>();
List<String> formateList = new ArrayList<>();
for(SplitBean bean : splitBeans){
List<Object> beanParams = new ArrayList<Object>();
beanParams.add(bean.getRequestId());
beanParams.add(bean.getWorkflowId());
beanParams.add(bean.getDataId());
beanParams.add(bean.getDetailId());
beanParams.add(bean.getResourceId());
beanParams.add(bean.getFromDate());
beanParams.add(bean.getFromTime());
beanParams.add(bean.getToDate());
beanParams.add(bean.getToTime());
beanParams.add(bean.getNewLeaveType());
beanParams.add(Util.null2s(bean.getDuration(),"0"));
beanParams.add(bean.getUsedetail());
beanParams.add(bean.getDurationrule());
beanParams.add(bean.getTablenamedb());
beanParams.add(bean.getFromdatedb());
beanParams.add(bean.getFromtimedb());
beanParams.add(bean.getTodatedb());
beanParams.add(bean.getTotimedb());
beanParams.add(bean.getDurationDB());
beanParams.add(bean.getStatus());
beanParams.add(bean.getBelongDate());
beanParams.add(bean.getD_Mins());
beanParams.add(bean.getSerialid());
beanParams.add(bean.getChangeType());
beanParams.add(bean.getSubcompanyid());
beanParams.add(bean.getDepartmentid());
beanParams.add(bean.getJobtitle());
beanParams.add(bean.getCompanion());
beanParams.add(bean.getIscompanion());
if(!custome_field.isEmpty()){
if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){
custome_map.put("overtime_type", bean.getOvertime_type());
}
getCustomField(custome_field, "value",beanParams,custome_map);
}
String format = bean.getResourceId()+"_"+bean.getBelongDate();
formateList.add(format);
params.add(beanParams);
if(flowTypeEnum == KqSplitFlowTypeEnum.EVECTION && false){
//qc898997 已经改成根据每个人的班次来计算了,这里就屏蔽了
KQFlowEvectionUtil kqFlowEvectionUtil = new KQFlowEvectionUtil();
String companion = Util.null2s(bean.getCompanion(), "");
if(companion.length() > 0){
kqFlowEvectionUtil.splitEvectionCompanion(companion,bean,params,rci,formateList);
}
}
}
if(!params.isEmpty()){
//先根据requestid删除中间表里的数据再做啥插入操作
String delSql = "delete from "+flowTypeEnum.getTablename()+" where requestid = "+requestId;
rs.executeUpdate(delSql);
for(int i = 0 ; i < params.size() ; i++){
List<Object> beanParams = params.get(i);
boolean isOk = rs1.executeUpdate(batchSql, beanParams);
if(!isOk){
delSql = "delete from "+flowTypeEnum.getTablename()+" where requestid = "+requestId;
rs.executeUpdate(delSql);
result.put("status", "-1");
result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005408,weaver.general.ThreadVarLanguage.getLang())+":"+flowTypeEnum.getTablename()+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005414,weaver.general.ThreadVarLanguage.getLang())+"");
kqLog.info("handleSplitFLowActionData:"+flowTypeEnum.getTablename()+"拆分保存失败:"+params);
return ;
}
}
kqLog.info("handleSplitFLowActionData:formateList:"+formateList+":flowTypeEnum:"+flowTypeEnum);
for(String format: formateList){
kqLog.info("handleSplitFLowActionData:format:"+ JSON.toJSONString(format)+":flowTypeEnum:"+flowTypeEnum);
String[] formats = format.split("_");
if(!isUpgrade){
//考勤设置升级的话 流程数据就不需要格式化考勤了
new KQFormatData().formatKqDate(formats[0],formats[1]);
}
}
if(!isUpgrade){
if(isForce){
if(flowTypeEnum == KqSplitFlowTypeEnum.LEAVE){
//先在这里执行扣减动作
SplitActionUtil.handleLeaveAction(splitBeans,""+requestId);
//然后再把扣减的了数据更新下KQ_ATT_VACATION表
String updateFreezeSql = "update KQ_ATT_VACATION set status=0 where requestId=? and workflowId = ? ";
boolean isUpdate = rs.executeUpdate(updateFreezeSql,requestId,""+workflowId);
if(!isUpdate){
result.put("status", "-1");
result.put("message", (""+weaver.systeminfo.SystemEnv.getHtmlLabelName(82823,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+updateFreezeSql+"(0,"+requestId+","+workflowId+")"));
kqLog.info("扣减action保存失败"+updateFreezeSql+"(0,"+requestId+","+workflowId+")");
return ;
}
}else if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){
// 强制归档,加班数据第一第二种规则都需要处理
kqLog.info("强制归档:"+requestId);
SplitActionUtil.handleOverTimeAction(splitBeans, ""+requestId,true, "");
}
}else{
if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){
//正常归档的时候 单独针对加班规则的第一 第二种模式 生成加班数据
kqLog.info("正常归档:"+requestId);
SplitActionUtil.handleOverTimeActionMode2(splitBeans, ""+requestId);
}
}
}else{
if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){
if(!splitBeans.isEmpty()){
for (SplitBean splitBean : splitBeans) {
String sql = "delete from kq_flow_overtime where requestid=? ";
rs.executeUpdate(sql, splitBean.getRequestId());
}
}
kqLog.info("升级方向:"+requestId);
SplitActionUtil.handleOverTimeActionMode2(splitBeans, ""+requestId);
}
}
}else{
rs1.writeLog(flowTypeEnum.getTablename()+"生成的params是空");
return ;
}
}
/**
*
* @param custome_field
* @param key
* @param beanParams
* @param custome_map
* @return
*/
public String getCustomField(List<String> custome_field, String key, List<Object> beanParams,
Map<String, String> custome_map) {
String fieldValue = "";
if(!custome_field.isEmpty()){
for(int i = 0 ; i < custome_field.size() ; i++){
String tmp_value = Util.null2String(custome_field.get(i));
if(tmp_value.length() > 0){
if("field".equalsIgnoreCase(key)){
fieldValue += ","+tmp_value;
}else if("param".equalsIgnoreCase(key)){
fieldValue += ",?";
}else if("value".equalsIgnoreCase(key)){
String value = custome_map.get(tmp_value);
beanParams.add(value);
}
}
}
}
return fieldValue;
}
}

File diff suppressed because it is too large Load Diff

@ -1,5 +1,21 @@
package test; package test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.aisin.entity.KqStatisticsItemVo;
import com.engine.aisin.entity.KqStatisticsVo;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.aisin.cron.KqConfirmWfCrob;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @Author weaver_cl * @Author weaver_cl
* @Description: * @Description:
@ -10,5 +26,28 @@ public class MainTest {
public static void main(String[] args) { public static void main(String[] args) {
String matrixtableName = "matrixtable_41";
int uid = 6189;
String sql = "select rsbm from "+matrixtableName+" where (kc like '%"+uid+"%' or " +
"bz like '%"+uid+"%' or fbc like '%"+uid+"%')";
System.out.println(sql);
}
public static String firstDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate firstDayOfMonth = yearMonth.atDay(1);
return firstDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
public static String lastDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
return lastDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
} }
} }

@ -0,0 +1,53 @@
package weaver.interfaces.aisin.cron;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* @Author liang.cheng
* @Date 2024/11/26 2:44 PM
* @Description: ATBP 1 uf_atbpkqfz
* @Version 1.0
*/
public class KqCloseAccountCreateCrob extends BaseCronJob {
@Override
public void execute() {
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String kqMonth = getKqMonth();
//1.数据是否存在
rs.executeQuery("select count(1) as sums from uf_atbpkqfz where fzny = ?",kqMonth);
rs.next();
int sums = Util.getIntValue(rs.getString("sums"));
String subcompanyid = bb.getPropValue("aisinsecond", "subcompanyid");
String modeId = bb.getPropValue("aisinsecond", "fzModeid");
String personId = bb.getPropValue("aisinsecond", "personId");
String currentDate = TimeUtil.getCurrentDateString();
String currentTime = TimeUtil.getOnlyCurrentTimeString();
//2.若不存在
if (sums == 0) {
rs.executeUpdate("insert into uf_atbpkqfz(sjcjr,fzny,fb,kqjszt,modedatacreater,modedatacreatedate,modedatacreatetime,formmodeid) values(?,?,?,?,?,?,?,?)",
personId,kqMonth,subcompanyid,0,personId,currentDate,currentTime,modeId);
}
}
private String getKqMonth() {
LocalDate currentDate = LocalDate.now();
LocalDate previousMonthDate = currentDate.minusMonths(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
return previousMonthDate.format(formatter);
}
}

@ -0,0 +1,239 @@
package weaver.interfaces.aisin.cron;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.KQTransMethod;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.aisin.cron.entity.CompensatoryLeaveDetail;
import weaver.interfaces.aisin.cron.entity.OffLeaveDetail;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/11/26 2:44 PM
* @Description: ATBP
* @Version 1.0
*/
public class KqCloseAccountUpdateCrob extends BaseCronJob {
@Override
public void execute() {
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String currentDate = TimeUtil.getCurrentDateString();
String kqMonth = getKqMonth();
String jsTableName = bb.getPropValue("aisinsecond", "jsTableName");
String firstDayOfMonth = firstDayOfMonth(kqMonth);
String lastDayOfMonth = lastDayOfMonth(kqMonth);
rs.executeQuery("select id,fzksrq,fzjsrq from uf_atbpkqfz where fzny = ?",kqMonth);
rs.next();
String id = Util.null2String(rs.getString("id"));
String fzksrq = Util.null2String(rs.getString("fzksrq"));
String fzjsrq = Util.null2String(rs.getString("fzjsrq"));
//开始日期 更新结算中
if (currentDate.equals(fzksrq)) {
rs.executeUpdate("update uf_atbpkqfz set kqjszt = 1 where fzny = ?",kqMonth);
}
//结束日期 更新结算完成
if (currentDate.equals(fzjsrq)) {
String subcompanyid = bb.getPropValue("aisinsecond", "subcompanyid");
//防止多次执行,执行前先判断是否已有考勤月明细数据
rs.executeQuery("select count(1) as sums from uf_atbpkqfz_dt1 where mainid = ?",id);
rs.next();
int sums = Util.getIntValue(rs.getString("sums"));
if (sums > 0) {
return;
}
//更新明细表1
List<OffLeaveDetail> offLeaveDetails = new ArrayList<>();
KQReportBiz kqReportBiz = new KQReportBiz();
User user = new User();
user.setUid(1);
String json = String.format("{\"fromDate\":\"%s\",\"toDate\":\"%s\",\"subCompanyId\":\"%s\"}", firstDayOfMonth, lastDayOfMonth,subcompanyid);
Map<String,Object> params = new HashMap<String,Object>(2){{
put("data",json);
}};
Map<String, Object> flowOverTimeDataNew = kqReportBiz.getFlowOverTimeDataNew(params, user);
rs.executeQuery("select id,workcode,departmentid from HrmResource where subcompanyid1 = ? and status < 4",subcompanyid);
while (rs.next()) {
offLeaveDetails.add(OffLeaveDetail.builder()
.resourceId(Util.getIntValue(rs.getString("id")))
.workcode(Util.null2String(rs.getString("workcode")))
.depetId(Util.getIntValue(rs.getString("departmentid")))
.build());
}
offLeaveDetails.forEach(e -> {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowOverTimeDataNew.get(e.getResourceId()+"|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowOverTimeDataNew.get(e.getResourceId()+"|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowOverTimeDataNew.get(e.getResourceId()+"|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowOverTimeDataNew.get(e.getResourceId()+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowOverTimeDataNew.get(e.getResourceId()+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowOverTimeDataNew.get(e.getResourceId()+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
String workDayHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+workingDayOvertime_nonleave));
String restDayHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_4leave+restDayOvertime_nonleave));
String holidayHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_4leave+holidayOvertime_nonleave));
e.setWorkDayHours(workDayHours);
e.setRestDayHours(restDayHours);
e.setHolidayHours(holidayHours);
String salaryHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(
1.5*(workingDayOvertime_4leave+workingDayOvertime_nonleave) + 2*(restDayOvertime_4leave+restDayOvertime_nonleave) + 3*(holidayOvertime_4leave+holidayOvertime_nonleave)
));
e.setSalaryHours(salaryHours);
String usedAmounts = flowWorkMonth(e, kqMonth);
e.setUseHours(usedAmounts);
String salaryRemianHours = subtract(salaryHours,usedAmounts);
e.setSalaryRemianHours(salaryRemianHours);
String flowHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(
(workingDayOvertime_4leave+workingDayOvertime_nonleave) + (restDayOvertime_4leave+restDayOvertime_nonleave) + (holidayOvertime_4leave+holidayOvertime_nonleave)
));
String remainHours = subtract(flowHours,usedAmounts);
e.setRemainHours(remainHours);
rs.executeUpdate("insert into uf_atbpkqfz_dt1 (mainid,yggh,ygxm,bmmc,dyjbxsspr,dyjbxssxr,dyjbxssjjr,hsgzxsshj,ydxxss," +
" syxssgzjs,dydxsyxs) values(?,?,?,?,?,?,?,?,?,?,?)",id,e.getWorkcode(),e.getResourceId(),e.getDepetId(),e.getWorkDayHours(),
e.getRestDayHours(),e.getHolidayHours(),e.getSalaryHours(),e.getUseHours(),e.getSalaryRemianHours(),e.getRemainHours());
});
//更新明细表2
//1.结算申请流程已归档数
List<CompensatoryLeaveDetail> csLeaveDetails = new ArrayList<>();
rs.executeQuery("select ryxm,sum(bcsqjsylxss) as remain from "+jsTableName+" a \n" +
" left join workflow_requestbase b on a.requestId = b.requestid and b.currentnodetype = 3\n" +
" where a.sqrq >= '"+firstDayOfMonth+"' and a.sqrq <= '"+lastDayOfMonth+"' group by ryxm");
while (rs.next()) {
csLeaveDetails.add(CompensatoryLeaveDetail.builder()
.resourceId(Util.getIntValue(rs.getString("ryxm")))
.workflowHours(Util.null2String(rs.getString("remain")))
.build());
}
csLeaveDetails.forEach(e -> {
compensatoryLeave(e,kqMonth);
rs.executeUpdate("insert into uf_atbpkqfz_dt2 (mainid,ygxm,yggh,zylxss,ysyxss,syxss,bysqjsdylxss) values(?,?,?,?,?,?,?)",id,
e.getResourceId(),e.getWorkcode(),e.getAllHours(),e.getUseHours(),e.getRemainHours(),e.getWorkflowHours());
});
rs.executeUpdate("update uf_atbpkqfz set kqjszt = 2 where fzny = ?",kqMonth);
}
}
private String getKqMonth() {
LocalDate currentDate = LocalDate.now();
LocalDate previousMonthDate = currentDate.minusMonths(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
return previousMonthDate.format(formatter);
}
private String firstDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate firstDayOfMonth = yearMonth.atDay(1);
return firstDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
private String lastDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
return lastDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
/**
*
* @param compensatoryLeave
*/
private void compensatoryLeave(CompensatoryLeaveDetail compensatoryLeave,String kqMonth){
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String txRuleId = bb.getPropValue("aisinsecond", "txRuleId");
KQTransMethod kqTransMethod = new KQTransMethod();
String year = kqMonth.substring(0, 4);
String month = kqMonth.substring(5, 7);
rs.executeQuery("select a.baseAmount,a.usedAmount,b.workcode from kq_balanceOfLeave a left join HrmResource b\n" +
" on a.resourceId = b.id where a.leaveRulesId = "+txRuleId+" and (a.isDelete is null or a.isDelete<>1)\n" +
" and a.belongYear = '"+year+"' and a.belongMonth = '"+month+"' and a.resourceId = ?",compensatoryLeave.getResourceId());
if (rs.next()) {
String baseAmount = kqTransMethod.getOriginalShow(Util.null2String(rs.getString("baseAmount")));
String usedAmount = kqTransMethod.getOriginalShow(Util.null2String(rs.getString("usedAmount")));
compensatoryLeave.setWorkcode(Util.null2String(rs.getString("workcode")));
compensatoryLeave.setAllHours(baseAmount);
compensatoryLeave.setUseHours(usedAmount);
compensatoryLeave.setRemainHours(getRemainHours(baseAmount,usedAmount));
}
}
/**
*
*/
private String flowWorkMonth(OffLeaveDetail offLeaveDetail,String kqMonth) {
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String dxRuleId = bb.getPropValue("aisinsecond", "dxRuleId");
String year = kqMonth.substring(0, 4);
String month = kqMonth.substring(5, 7);
String usedAmounts = "0.00";
KQTransMethod kqTransMethod = new KQTransMethod();
rs.executeQuery("select sum(usedAmount) as usedAmounts from kq_balanceOfLeave where leaveRulesId = "+dxRuleId+" and (isDelete is null or isDelete<>1) \n" +
" and belongYear = '"+year+"' and resourceId = ? and belongMonth = '"+month+"' group by resourceId",offLeaveDetail.getResourceId());
if (rs.next()) {
usedAmounts = kqTransMethod.getOriginalShow(Util.null2String(rs.getString("usedAmounts")));
}
return usedAmounts;
}
private String getRemainHours(String baseHour, String usedHour) {
String remainHours = "0.00";
double baseHours = Util.getDoubleValue(baseHour, 0.00);
double usedHours = Util.getDoubleValue(usedHour, 0.00);
remainHours = String.format("%.2f", baseHours - usedHours);
return remainHours;
}
private String subtract(String operand1, String operand2) {
double num1 = Double.parseDouble(operand1);
double num2 = Double.parseDouble(operand2);
double result = num1 - num2;
return String.valueOf(result);
}
}

@ -0,0 +1,391 @@
package weaver.interfaces.aisin.cron;
import cn.hutool.core.collection.CollectionUtil;
import com.engine.integration.util.StringUtils;
import com.engine.kq.biz.*;
import com.engine.kq.entity.WorkTimeEntity;
import com.weaver.general.Util;
import org.apache.commons.collections.CollectionUtils;
import weaver.common.DateUtil;
import weaver.common.util.string.StringUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.interfaces.aisin.cron.entity.*;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.workflow.webservices.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2024/11/22 9:15 AM
* @Description:
* @Version 1.0
*/
public class KqConfirmWfCrob extends BaseCronJob {
@Override
public void execute() {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
WorkflowBaseInfo workflowBaseInfo = new WorkflowBaseInfo();
String subcompanyid = bb.getPropValue("aisinsecond", "subcompanyid");
String workflowId = bb.getPropValue("aisinsecond", "workflowId");
String tableName = bb.getPropValue("aisinsecond", "tableName");
String currentDate = DateUtil.getCurrentDate();
//String kqMonth = getKqMonth();
//测试使用
String kqMonth = "2024-11";
List<MainTableInfo> resourceList = new ArrayList<>();
//1.获取指定分部下 类型为排班制的 考勤组
List<String> groupIds = new ArrayList<>();
rs.executeQuery("select id from kq_group where subcompanyid = ? and kqtype = 2", subcompanyid);
while (rs.next()) {
groupIds.add(Util.null2String(rs.getString("id")));
}
if (CollectionUtils.isEmpty(groupIds)) {
return;
}
KQGroupBiz groupBiz = new KQGroupBiz();
//2.获取考勤组下所有成员
List<String> groupMembers = new ArrayList<>();
groupIds.forEach(e -> groupMembers.addAll(groupBiz.getGroupMembers(e)));
//3.人员存在多个考勤组中去重
List<String> distinctMembers = groupMembers.stream()
.distinct()
.collect(Collectors.toList());
bb.writeLog("需要触发流程的人员 =>" + distinctMembers.toString() + "=>size:" + distinctMembers.size());
// 尽量保持 IN 列表的大小在 1000 个值以内
String join = StringUtils.join(distinctMembers, ",");
String sql = "select id,workcode,departmentid from hrmresource where id in (" + join + ")";
sql = "select id,workcode,departmentid from hrmresource where lastname in ('ATBP人事管理员','韩园园', '测试加班仙女21-男', '测试加班仙女21-女', '测试考勤', '测试-刘1', '测试小朱-男', '测试小朱-女', '陈曦', '陈莹', '范文露', '蒋珊', '开发', '开发测试', '李鹭', '刘辉', '刘长', '田建萍', '王珺', '王可爱', '吴建国', '闫雅杰', '杨勇', '张航', '张宁', '张子识')";
bb.writeLog("sqlmain:" + sql);
rs.executeQuery(sql);
while (rs.next()) {
resourceList.add(MainTableInfo.builder()
.workcode(Util.null2String(rs.getString("workcode")))
.resourceId(Util.null2String(rs.getString("id")))
.departmentId(Util.null2String(rs.getString("departmentid")))
.build());
}
String firstDayOfMonth = firstDayOfMonth(kqMonth);
String lastDayOfMonth = lastDayOfMonth(kqMonth);
KQWorkTime kqWorkTime = new KQWorkTime();
// KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
// String serial = kqShiftManagementComInfo.getSerial("1");
//todo 数据量大时集合拆分 考虑线程处理
for (int i = 0; i < resourceList.size(); i++) {
MainTableInfo e = resourceList.get(i);
//1.创建主流程
workflowBaseInfo.setWorkflowId(workflowId);
WorkflowMainTableInfo workflowMainTableInfo = new WorkflowMainTableInfo();
WorkflowRequestTableField workcode = createWorkflowRequestTableField("rybh", e.getWorkcode(), true);
WorkflowRequestTableField lastname = createWorkflowRequestTableField("ryxm", e.getResourceId(), true);
WorkflowRequestTableField deparyment = createWorkflowRequestTableField("bmmc", e.getDepartmentId(), true);
WorkflowRequestTableField startDate = createWorkflowRequestTableField("sqrq", currentDate, true);
WorkflowRequestTableField month = createWorkflowRequestTableField("kqyf", kqMonth, true);
WorkflowRequestTableField[] workflowRequestTableField = {workcode, lastname, deparyment, startDate, month};
WorkflowRequestTableRecord[] workflowRequestTableRecord = new WorkflowRequestTableRecord[1];
workflowMainTableInfo.setRequestRecords(workflowRequestTableRecord);
workflowRequestTableRecord[0] = new WorkflowRequestTableRecord();
workflowRequestTableRecord[0].setWorkflowRequestTableFields(workflowRequestTableField);
CusWorkflowRequestInfo cusWorkflowRequestInfo = CusWorkflowRequestInfo.builder()
.workflowName("ATBP 考勤确认流程")
.nextFlow("0")
.requestLevel("1")
.canView(true)
.creatorId(e.getResourceId())
.workflowBaseInfo(workflowBaseInfo)
.workflowMainTableInfo(workflowMainTableInfo)
.build();
String requestId = doCreateWorkflow(cusWorkflowRequestInfo);
bb.writeLog("流程创建成功requestId=>" + requestId);
if (Integer.parseInt(requestId) < 0) {
break;
}
//获取主表id
rs.executeQuery("select id from " + tableName + " where requestid = ?", requestId);
rs.next();
Integer mainId = Util.getIntValue(rs.getString("id"));
//2.更新明细表
//2.1 明细表1班次
List<ScheDetailTableInfo> scheDetails = new ArrayList<>();
rs.executeQuery("select kqdate,serialid from kq_shiftschedule where kqdate >= '" + firstDayOfMonth + "' and kqdate <= '" + lastDayOfMonth + "' \n" +
" and resourceid = ? and isdelete = 0 order by kqdate asc", e.getResourceId());
while (rs.next()) {
scheDetails.add(ScheDetailTableInfo.builder().date(Util.null2String(rs.getString("kqdate")))
.serialId(Util.null2String(rs.getString("serialid"))).build());
}
scheDetails.forEach(sche -> rs.executeUpdate("insert into " + tableName + "_dt1 (mainid,pbrq,bc) values(?,?,?)", mainId, sche.getDate(), sche.getSerialId()));
//2.2 明细表2加班
List<FlowDetailTableInfo> flowDetails = new ArrayList<>();
rs.executeQuery("select duration_min,resourceid,ori_belongdate,belongdate,flow_dataid,fromtime,totime from KQ_FLOW_OVERTIME where ori_belongdate >= '" + firstDayOfMonth + "' and ori_belongdate <= '" + lastDayOfMonth + "' \n" +
" and resourceid = ? and (flow_dataid <> '' and flow_dataid is not null) order by ori_belongdate asc", e.getResourceId());
while (rs.next()) {
String belongdate = Util.null2String(rs.getString("belongdate"));
String oriBelongDate = Util.null2String(rs.getString("ori_belongdate"));
String duration_min = Util.null2String(rs.getString("duration_min"));
// WorkTimeEntity workTime = kqWorkTime.getWorkTime(e.getResourceId(), belongdate);
// String serialId = workTime.getSerialId();
//(二次需求直接默认值 0
String serialId = "0";
String flowDataId = Util.null2String(rs.getString("flow_dataid"));
String fromTime = Util.null2String(rs.getString("fromtime"));
String toTime = Util.null2String(rs.getString("totime"));
flowDetails.add(FlowDetailTableInfo.builder()
.belongDate(belongdate)
.oriBelongDate(oriBelongDate)
.serialId(serialId)
.flowDataId(flowDataId)
.fromTime(fromTime)
.toTime(toTime)
.minutes(duration_min)
//.hours(minutesToHours(duration_min))
.build());
}
// 使用Map对flowDataId进行分组
Map<String, List<FlowDetailTableInfo>> groupedByFlowDataId = flowDetails.stream()
.collect(Collectors.groupingBy(FlowDetailTableInfo::getFlowDataId));
// 对分组后的数据进行处理
List<FlowDetailTableInfo> mergedList = new ArrayList<>();
for (Map.Entry<String, List<FlowDetailTableInfo>> entry : groupedByFlowDataId.entrySet()) {
List<FlowDetailTableInfo> group = entry.getValue();
if (group.size() == 1 ) {
// 判断开始时间 结束时间 时长是否符合条件 当天的加班数据不需要 只需要跨天加班
// FlowDetailTableInfo flowDetail = group.get(1);
// String fromTime = flowDetail.getFromTime();
// String toTime = flowDetail.getToTime();
// String minutes = flowDetail.getMinutes();
// String toHours = minutesToHours(minutes);
//
// if (isBeforeTime(fromTime) && isAfterTime(toTime) && isHoursGreaterThanPrecise(toHours,7.5)) {
// flowDetail.setHours(toHours);
// mergedList.add(flowDetail);
// }
} else {
// 处理多条加班数据的情况
// 找到 belongDate 最小和最大的记录
FlowDetailTableInfo minBelongDateRecord = Collections.min(group, Comparator.comparing(FlowDetailTableInfo::getBelongDate));
FlowDetailTableInfo maxBelongDateRecord = Collections.max(group, Comparator.comparing(FlowDetailTableInfo::getBelongDate));
int totalMinutes = group.stream()
.mapToInt(detail -> Integer.parseInt(detail.getMinutes()))
.sum();
String fromTime = minBelongDateRecord.getFromTime();
String toTime = maxBelongDateRecord.getToTime();
String toHours = minutesToHours(String.valueOf(totalMinutes));
// 判断开始时间 结束时间 时长是否符合条件
if (isBeforeTime(fromTime) && isAfterTime(toTime) && isHoursGreaterThanPrecise(toHours,7.5)) {
FlowDetailTableInfo mergedDetail = new FlowDetailTableInfo();
mergedDetail.setOriBelongDate(minBelongDateRecord.getOriBelongDate());
//班次id是前一天还是后一天 (需求直接默认值)
mergedDetail.setSerialId("0");
mergedDetail.setHours(toHours);
// 添加到合并列表中
mergedList.add(mergedDetail);
}
}
}
mergedList.forEach(flow -> rs.executeUpdate("insert into " + tableName + "_dt2 (mainid,jbrq,jbbc,jbxs) values(?,?,?,?)", mainId, flow.getOriBelongDate(),
flow.getSerialId(), flow.getHours()));
//2.3 明细表3请假
List<LeaveDetailTableInfo> leaveDetails = new ArrayList<>();
rs.executeQuery("select belongDate,newleavetype,d_mins,serialid,leavebackrequestid from kq_flow_split_leave where belongDate >= '" + firstDayOfMonth + "' and belongDate <= '" + lastDayOfMonth + "' \n" +
" and resourceid = ? order by belongdate asc", e.getResourceId());
while (rs.next()) {
String belongDate = Util.null2String(rs.getString("belongDate"));
String serialId = Util.null2String(rs.getString("serialid"));
Integer leaveType = Util.getIntValue(rs.getString("newleavetype"));
String d_mins = Util.null2String(rs.getString("d_mins"));
String leavebackrequestid = Util.null2String(rs.getString("leavebackrequestid"));
String leaveBackMins = "0";
//是否存在销假
if (StringUtil.isNotNullAndEmpty(leavebackrequestid)) {
leaveBackMins = leaveBack(leavebackrequestid, e.getResourceId(), belongDate);
}
String reduce = getReduce(d_mins, leaveBackMins);
if (!d_mins.equals(leaveBackMins)) {
leaveDetails.add(LeaveDetailTableInfo.builder()
.date(belongDate)
.serialId(serialId)
.leaveType(leaveType)
.hours(minutesToHours(reduce))
.build());
}
}
leaveDetails.forEach(leave -> rs.executeUpdate("insert into " + tableName + "_dt3 (mainid,qjrq,qjbc,qjlx,qjxs) values(?,?,?,?,?)", mainId,
leave.getDate(), leave.getSerialId(), leave.getLeaveType(), leave.getHours()));
}
}
private String doCreateWorkflow(CusWorkflowRequestInfo cusWq) {
//工作流程请求信息
WorkflowRequestInfo workflowRequestInfo = new WorkflowRequestInfo();
//请求标题
workflowRequestInfo.setRequestName(cusWq.getWorkflowName());
//请求重要级别
workflowRequestInfo.setRequestLevel(cusWq.getRequestLevel());
//显示
workflowRequestInfo.setCanView(cusWq.isCanView());
//创建者id
workflowRequestInfo.setCreatorId(cusWq.getCreatorId());
//工作流信息
workflowRequestInfo.setWorkflowBaseInfo(cusWq.getWorkflowBaseInfo());
//主表
workflowRequestInfo.setWorkflowMainTableInfo(cusWq.getWorkflowMainTableInfo());
//是否提交下一节点
workflowRequestInfo.setIsnextflow(cusWq.getNextFlow());
WorkflowService workflow = new WorkflowServiceImpl();
return workflow.doCreateWorkflowRequest(workflowRequestInfo, Integer.parseInt(cusWq.getCreatorId()));
}
private WorkflowRequestTableField createWorkflowRequestTableField(String fieldName, String fieldValue, boolean view) {
WorkflowRequestTableField tableField = new WorkflowRequestTableField();
tableField.setFieldName(fieldName);
tableField.setFieldValue(fieldValue);
tableField.setView(view);
tableField.setEdit(true);
return tableField;
}
/**
*
*
* @param leavebackrequestid
* @param resourceId
* @param belongDate
* @return
*/
private String leaveBack(String leavebackrequestid, String resourceId, String belongDate) {
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
//leavebackrequestid 格式 ,123456,123467
List<String> strings = Arrays.asList(leavebackrequestid.split(","));
//去除空字符串
List<String> filteredStrings = strings.stream()
.filter(str -> !str.isEmpty())
.collect(Collectors.toList());
String join = CollectionUtil.join(filteredStrings, ",");
bb.writeLog("销假requestid =>" + leavebackrequestid + "=>" + join);
List<Integer> list = new ArrayList<>();
rs.executeQuery("select D_Mins from kq_flow_split_leaveback where resourceid = ? and requestid in (" + join + ") " +
" and belongDate = '" + belongDate + "'", resourceId);
while (rs.next()) {
list.add(Util.getIntValue(rs.getString("D_Mins")));
}
return String.valueOf(list.stream()
.mapToInt(Integer::intValue)
.sum());
}
private String getKqMonth() {
LocalDate currentDate = LocalDate.now();
LocalDate previousMonthDate = currentDate.minusMonths(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
return previousMonthDate.format(formatter);
}
private String firstDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate firstDayOfMonth = yearMonth.atDay(1);
return firstDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
private String lastDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
return lastDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
private String minutesToHours(String minutesStr) {
int minutes = Integer.parseInt(minutesStr);
BigDecimal hours = new BigDecimal(minutes).divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
return hours.toString();
}
private String getReduce(String leaveMins, String leavebackMins) {
String reduceMins;
int leaveMin = Integer.parseInt(leaveMins);
int leavebackMin = Integer.parseInt(leavebackMins);
reduceMins = String.valueOf(leaveMin - leavebackMin);
return reduceMins;
}
private boolean isBeforeTime(String fromTime) {
String timeToMinute = fromTime.substring(0, 5);
LocalTime time = LocalTime.parse(timeToMinute + ":00");
LocalTime targetTime = LocalTime.of(21, 30);
return time.isBefore(targetTime);
}
private boolean isAfterTime(String toTime) {
String timeToMinute = toTime.substring(0, 5);
LocalTime time = LocalTime.parse(timeToMinute + ":00");
LocalTime targetTime = LocalTime.of(6, 0);
return time.isAfter(targetTime);
}
private boolean isHoursGreaterThanPrecise(String hoursStr, double target) {
try {
BigDecimal hours = new BigDecimal(hoursStr);
BigDecimal targetBigDecimal = BigDecimal.valueOf(target);
return hours.compareTo(targetBigDecimal) > 0;
} catch (NumberFormatException e) {
return false;
}
}
}

@ -0,0 +1,31 @@
package weaver.interfaces.aisin.cron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/11/27 9:26 AM
* @Description: 2
* @Version 1.0
*/
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class CompensatoryLeaveDetail {
private String workcode;
private Integer resourceId;
private String allHours;
private String useHours;
private String remainHours;
private String workflowHours;
}

@ -0,0 +1,40 @@
package weaver.interfaces.aisin.cron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import weaver.workflow.webservices.WorkflowBaseInfo;
import weaver.workflow.webservices.WorkflowMainTableInfo;
/**
* @Author liang.cheng
* @Date 2024/4/11 6:10 PM
* @Description:
* @Version 1.0
*/
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class CusWorkflowRequestInfo {
private String workflowName;
private String nextFlow;
private String requestLevel;
private boolean canView;
private String creatorId;
private WorkflowBaseInfo workflowBaseInfo;
private WorkflowMainTableInfo workflowMainTableInfo;
}

@ -0,0 +1,36 @@
package weaver.interfaces.aisin.cron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/11/22 10:02 AM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FlowDetailTableInfo {
private String belongDate;
private String oriBelongDate;
private String serialId;
private String flowDataId;
private String fromTime;
private String toTime;
private String minutes;
private String hours;
}

@ -0,0 +1,27 @@
package weaver.interfaces.aisin.cron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/11/22 10:02 AM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class LeaveDetailTableInfo {
private String date;
private String serialId;
private Integer leaveType;
private String hours;
}

@ -0,0 +1,28 @@
package weaver.interfaces.aisin.cron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/11/22 10:00 AM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MainTableInfo {
private String workcode;
private String resourceId;
private String departmentId;
}

@ -0,0 +1,41 @@
package weaver.interfaces.aisin.cron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/11/27 9:26 AM
* @Description: 1
* @Version 1.0
*/
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class OffLeaveDetail {
private String workcode;
private Integer resourceId;
private Integer depetId;
private String workDayHours;
private String restDayHours;
private String holidayHours;
private String salaryHours;
private String useHours;
private String salaryRemianHours;
private String remainHours;
}

@ -0,0 +1,23 @@
package weaver.interfaces.aisin.cron.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/11/22 10:02 AM
* @Description:
* @Version 1.0
*/
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class ScheDetailTableInfo {
private String date;
private String serialId;
}
Loading…
Cancel
Save