Compare commits
10 Commits
f81928788c
...
2945eba36c
| Author | SHA1 | Date |
|---|---|---|
|
|
2945eba36c | |
|
|
00a557fe97 | |
|
|
f83dcf20f3 | |
|
|
29029caf1d | |
|
|
28051ff61f | |
|
|
52473e77f4 | |
|
|
51213c23cb | |
|
|
29e6efeac6 | |
|
|
1e146c826e | |
|
|
aae717c314 |
|
|
@ -1,15 +1,11 @@
|
|||
/weaver-develop.iml
|
||||
/out/
|
||||
.idea/
|
||||
|
||||
HELP.md
|
||||
target/
|
||||
|
||||
.idea
|
||||
|
||||
/target/
|
||||
/test
|
||||
/src/rebel.xml
|
||||
/src/META-INF
|
||||
/WEB-INF/config
|
||||
|
||||
/log
|
||||
/log
|
||||
/src/META-INF/
|
||||
/src/test/
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="weaver-develop:jar">
|
||||
<output-path>$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib</output-path>
|
||||
<root id="archive" name="weaver-develop.jar">
|
||||
<element id="module-output" name="weaver-develop" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="classbean">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/../../../../weaver/ecology/classbean" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="lib">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: test.MainTest
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.api.xmgsecond.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/16 15:13
|
||||
* @Description: 考勤关账
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Path("/xmgsecond/kq/cube")
|
||||
public class KqCloseAccountAction extends com.engine.xmgsecond.web.KqCloseAccountAction{
|
||||
}
|
||||
|
|
@ -0,0 +1,293 @@
|
|||
package com.engine.kq.cmd.balanceofleave;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.biz.SimpleBizLogger;
|
||||
import com.engine.common.constant.BizLogSmallType4Hrm;
|
||||
import com.engine.common.constant.BizLogType;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.kq.biz.KQLeaveRulesComInfo;
|
||||
import com.engine.kq.biz.KQLeaveRulesDetailComInfo;
|
||||
import com.engine.kq.biz.KQUsageHistoryBiz;
|
||||
import com.engine.kq.entity.KQUsageHistoryEntity;
|
||||
import com.engine.kq.jucailin.util.KQDateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 假期余额--保存
|
||||
*/
|
||||
public class SaveBalanceOfLeaveCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
private SimpleBizLogger logger;
|
||||
|
||||
public SaveBalanceOfLeaveCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
this.logger = new SimpleBizLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
try {
|
||||
boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限
|
||||
if (!canEdit) {
|
||||
resultMap.put("status", "-1");
|
||||
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
|
||||
return resultMap;
|
||||
}
|
||||
//假期类型的ID
|
||||
String leaveRulesId = Util.null2String(params.get("ruleId"));
|
||||
//搜索条件中的年份
|
||||
String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值
|
||||
String searchYear = Util.null2String(params.get("searchYear"));//年份
|
||||
if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) {
|
||||
searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4);
|
||||
}
|
||||
//人员和余额数据(JSON字符串)
|
||||
String datas = Util.null2String(params.get("datas"));
|
||||
//获取当前日期,当前时间
|
||||
Calendar today = Calendar.getInstance();
|
||||
//当前日期
|
||||
String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" +
|
||||
Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" +
|
||||
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
|
||||
//当前时间
|
||||
String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" +
|
||||
Util.add0(today.get(Calendar.MINUTE), 2) + ":" +
|
||||
Util.add0(today.get(Calendar.SECOND), 2);
|
||||
//人力资源缓存类
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
//获取假期类型的缓存类
|
||||
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
|
||||
//请假最小单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假
|
||||
String minimumUnit = kqLeaveRulesComInfo.getMinimumUnit(leaveRulesId);
|
||||
//获取假期规则的缓存类
|
||||
KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo();
|
||||
|
||||
/**********************************************************************************************************/
|
||||
|
||||
String insertOrUpdate = "";
|
||||
KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity();//员工假期余额变更记录实体类
|
||||
List<KQUsageHistoryEntity> usageHistoryEntityList = new ArrayList<KQUsageHistoryEntity>();//员工假期余额变更记录集合
|
||||
|
||||
String oldBaseAmount = "0";
|
||||
String oldUsedAmount = "0";
|
||||
String oldExtraAmount = "0";
|
||||
String oldBaseAmount2 = "0";
|
||||
String oldUsedAmount2 = "0";
|
||||
String oldExtraAmount2 = "0";
|
||||
|
||||
String newBaseAmount = "0";
|
||||
String newUsedAmount = "0";
|
||||
String newExtraAmount = "0";
|
||||
String newBaseAmount2 = "0";
|
||||
String newUsedAmount2 = "0";
|
||||
String newExtraAmount2 = "0";
|
||||
|
||||
//哪些人已经在数据库中有记录了
|
||||
RecordSet recordSet = new RecordSet();
|
||||
RecordSet tmpSet = new RecordSet();
|
||||
String searchSql = "select * from kq_BalanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=? order by id";
|
||||
|
||||
//修改了哪些人的假期余额
|
||||
List<String> resourceIdList = new ArrayList<String>();
|
||||
JSONArray dataArr = JSONArray.parseArray(datas);
|
||||
for (int i = 0; i < dataArr.size(); i++) {
|
||||
JSONObject jsonObject = dataArr.getJSONObject(i);
|
||||
String resourceId = jsonObject.getString("randomFieldId");
|
||||
if (resourceId.equals("")) {
|
||||
continue;
|
||||
}
|
||||
if (!resourceIdList.contains(resourceId)) {
|
||||
resourceIdList.add(resourceId);
|
||||
}
|
||||
}
|
||||
//记录右键操作日志
|
||||
if (resourceIdList.size() > 0) {
|
||||
String resourceIdStr = String.join(",", resourceIdList);
|
||||
BizLogContext bizLogContext = new BizLogContext();
|
||||
bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型
|
||||
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//所属大类型
|
||||
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//当前小类型
|
||||
bizLogContext.setParams(params);//当前request请求参数
|
||||
logger.setUser(user);//当前操作人
|
||||
String mainSql = "select * from kq_balanceOfleave where resourceId in (" + resourceIdStr + ") and leaveRulesId=" + leaveRulesId;
|
||||
logger.setMainSql(mainSql, "id");//主表sql
|
||||
logger.setMainPrimarykey("id");//主日志表唯一key
|
||||
logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4Balance");
|
||||
logger.setMethodOtherParams("column:resourceId+column:leaveRulesId");
|
||||
logger.before(bizLogContext);
|
||||
}
|
||||
|
||||
java.sql.Timestamp date = KQDateUtil.getUpdateTimeStamp();
|
||||
boolean flag = true;//记录SQL操作是否成功
|
||||
String updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,update_time=? where leaveRulesId=? and resourceId=? and belongYear=?";
|
||||
String insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,leaveRulesId,resourceId,belongYear,create_time,update_time,creator) values(?,?,?,?,?,?,?,?,?,?,?,?) ";
|
||||
String delSql = "delete from kq_BalanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=? and id !=? ";
|
||||
// List<String> existdata = new ArrayList<String>();
|
||||
if (recordSet.getDBType().equals("postgresql")) {
|
||||
updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,update_time=?::timestamp where leaveRulesId=? and resourceId=? and belongYear=?";
|
||||
insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,leaveRulesId,resourceId,belongYear,create_time,update_time,creator) values(?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) ";
|
||||
}
|
||||
Map<String,String> existmap = new HashMap<String,String>();
|
||||
JSONArray jsonArray = JSONArray.parseArray(datas);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String resourceId = jsonObject.getString("randomFieldId");
|
||||
String baseAmount = "" + Util.getDoubleValue(jsonObject.getString("baseAmountspan"), 0);
|
||||
String extraAmount = "" + Util.getDoubleValue(jsonObject.getString("extraAmountspan"), 0);
|
||||
String usedAmount = "" + Util.getDoubleValue(jsonObject.getString("usedAmountspan"), 0);
|
||||
String baseAmount2 = "" + Util.getDoubleValue(jsonObject.getString("baseAmount2span"), 0);
|
||||
String extraAmount2 = "" + Util.getDoubleValue(jsonObject.getString("extraAmount2span"), 0);
|
||||
String usedAmount2 = "" + Util.getDoubleValue(jsonObject.getString("usedAmount2span"), 0);
|
||||
//获取人员相关信息
|
||||
if (resourceId.equals("")) {
|
||||
continue;
|
||||
}
|
||||
String lastName = resourceComInfo.getLastname(resourceId);
|
||||
String subcompanyId = resourceComInfo.getSubCompanyID(resourceId);
|
||||
String departmentId = resourceComInfo.getDepartmentID(resourceId);
|
||||
/*目前没有为该人员所在分部或者总部设置任何假期规则,不允许保存*/
|
||||
if (Util.getIntValue(detailComInfo.getId(leaveRulesId, subcompanyId,departmentId, resourceId), 0) <= 0) {
|
||||
resultMap.put("sign", "-1");
|
||||
resultMap.put("message", ""+ SystemEnv.getHtmlLabelName(10004211,weaver.general.ThreadVarLanguage.getLang())+"" + lastName + ""+ SystemEnv.getHtmlLabelName(10005331,weaver.general.ThreadVarLanguage.getLang())+"");//保存失败
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
//最近有遇到一些假期余额人员重复的问题,单独优化下,重复垃圾数据,保留id小的
|
||||
//加下面的逻辑是因为当有重复的垃圾数据时,前端传过来的数据也是重复,即使遍历的第一次有删除多余的垃圾,后面的重复数据会覆盖掉前面的id小的数据
|
||||
String key = resourceId+"#"+leaveRulesId+"#"+searchYear;
|
||||
if(existmap!=null && existmap.containsKey(key)){
|
||||
continue;
|
||||
}else{
|
||||
existmap.put(key,key);
|
||||
}
|
||||
|
||||
//在数据库里是否已经存在记录了
|
||||
recordSet.executeQuery(searchSql, leaveRulesId, resourceId, searchYear);
|
||||
int datacount = recordSet.getCounts();
|
||||
if (recordSet.next()) {
|
||||
String tmpid = Util.null2String(recordSet.getString("id"));
|
||||
if(datacount>1){//最近有遇到一些假期余额人员重复的问题,单独优化下
|
||||
tmpSet.executeUpdate(delSql, leaveRulesId, resourceId, searchYear,tmpid);
|
||||
}
|
||||
oldBaseAmount = "" + Util.getDoubleValue(recordSet.getString("baseAmount"), 0);
|
||||
oldExtraAmount = "" + Util.getDoubleValue(recordSet.getString("extraAmount"), 0);
|
||||
oldUsedAmount = "" + Util.getDoubleValue(recordSet.getString("usedAmount"), 0);
|
||||
oldBaseAmount2 = "" + Util.getDoubleValue(recordSet.getString("baseAmount2"), 0);
|
||||
oldExtraAmount2 = "" + Util.getDoubleValue(recordSet.getString("extraAmount2"), 0);
|
||||
oldUsedAmount2 = "" + Util.getDoubleValue(recordSet.getString("usedAmount2"), 0);
|
||||
|
||||
newBaseAmount = baseAmount == null ? oldBaseAmount : baseAmount;
|
||||
newExtraAmount = extraAmount == null ? oldExtraAmount : extraAmount;
|
||||
newUsedAmount = usedAmount == null ? oldUsedAmount : usedAmount;
|
||||
newBaseAmount2 = baseAmount2 == null ? oldBaseAmount2 : baseAmount2;
|
||||
newExtraAmount2 = extraAmount2 == null ? oldExtraAmount2 : extraAmount2;
|
||||
newUsedAmount2 = usedAmount2 == null ? oldUsedAmount2 : usedAmount2;
|
||||
|
||||
if (oldBaseAmount.equals(newBaseAmount) && oldExtraAmount.equals(newExtraAmount) && oldUsedAmount.equals(newUsedAmount)
|
||||
&& oldBaseAmount2.equals(newBaseAmount2) && oldExtraAmount2.equals(newExtraAmount2) && oldUsedAmount2.equals(newUsedAmount2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*更新员工假期余额 start*/
|
||||
flag = recordSet.executeUpdate(updateSql, newBaseAmount, newExtraAmount, newUsedAmount, newBaseAmount2, newExtraAmount2, newUsedAmount2,date, leaveRulesId, resourceId, searchYear);
|
||||
if (!flag) {
|
||||
resultMap.put("sign", "-1");
|
||||
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
|
||||
return resultMap;
|
||||
}
|
||||
/*更新员工假期余额 end*/
|
||||
} else {
|
||||
oldBaseAmount = "0";
|
||||
oldExtraAmount = "0";
|
||||
oldUsedAmount = "0";
|
||||
oldBaseAmount2 = "0";
|
||||
oldExtraAmount2 = "0";
|
||||
oldUsedAmount2 = "0";
|
||||
|
||||
newBaseAmount = baseAmount == null ? "0" : baseAmount;
|
||||
newExtraAmount = extraAmount == null ? "0" : extraAmount;
|
||||
newUsedAmount = usedAmount == null ? "0" : usedAmount;
|
||||
newBaseAmount2 = baseAmount2 == null ? "0" : baseAmount2;
|
||||
newExtraAmount2 = extraAmount2 == null ? "0" : extraAmount2;
|
||||
newUsedAmount2 = usedAmount2 == null ? "0" : usedAmount2;
|
||||
|
||||
/*新增员工假期余额 start*/
|
||||
flag = recordSet.executeUpdate(insertSql, newBaseAmount, newExtraAmount, newUsedAmount, newBaseAmount2, newExtraAmount2, newUsedAmount2, leaveRulesId, resourceId, searchYear,date,date,Util.getIntValue(resourceId));
|
||||
if (!flag) {
|
||||
resultMap.put("sign", "-1");
|
||||
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
|
||||
return resultMap;
|
||||
}
|
||||
/*新增员工假期余额 end*/
|
||||
}
|
||||
|
||||
/*员工假期余额变更记录 start*/
|
||||
usageHistoryEntity = new KQUsageHistoryEntity();
|
||||
usageHistoryEntity.setLeaveRulesId(leaveRulesId);
|
||||
usageHistoryEntity.setRelatedId(resourceId);
|
||||
usageHistoryEntity.setOperator("" + user.getUID());
|
||||
usageHistoryEntity.setOperateDate(currentDate);
|
||||
usageHistoryEntity.setOperateTime(currentTime);
|
||||
usageHistoryEntity.setOperateType("5");
|
||||
usageHistoryEntity.setBelongYear(searchYear);
|
||||
usageHistoryEntity.setOldBaseAmount(oldBaseAmount);
|
||||
usageHistoryEntity.setNewBaseAmount(newBaseAmount);
|
||||
usageHistoryEntity.setOldExtraAmount(oldExtraAmount);
|
||||
usageHistoryEntity.setNewExtraAmount(newExtraAmount);
|
||||
usageHistoryEntity.setOldUsedAmount(oldUsedAmount);
|
||||
usageHistoryEntity.setNewUsedAmount(newUsedAmount);
|
||||
usageHistoryEntity.setOldBaseAmount2(oldBaseAmount2);
|
||||
usageHistoryEntity.setNewBaseAmount2(newBaseAmount2);
|
||||
usageHistoryEntity.setOldExtraAmount2(oldExtraAmount2);
|
||||
usageHistoryEntity.setNewExtraAmount2(newExtraAmount2);
|
||||
usageHistoryEntity.setOldUsedAmount2(oldUsedAmount2);
|
||||
usageHistoryEntity.setNewUsedAmount2(newUsedAmount2);
|
||||
usageHistoryEntity.setOldMinimumUnit(minimumUnit);
|
||||
usageHistoryEntity.setNewMinimumUnit(minimumUnit);
|
||||
usageHistoryEntity.setInsertOrUpdate(insertOrUpdate);
|
||||
|
||||
usageHistoryEntityList.add(usageHistoryEntity);
|
||||
}
|
||||
|
||||
//记录使用记录
|
||||
if (usageHistoryEntityList.size() > 0) {
|
||||
KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz();
|
||||
flag = usageHistoryBiz.save(usageHistoryEntityList);
|
||||
if (!flag) {
|
||||
resultMap.put("sign", "-1");
|
||||
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("sign", "1");
|
||||
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
|
||||
} catch (Exception e) {
|
||||
writeLog(e);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BizLogContext> getLogContexts() {
|
||||
return logger.getBizLogContexts();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,718 @@
|
|||
package com.engine.kq.cmd.report;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.kq.biz.*;
|
||||
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
|
||||
import com.engine.kq.util.ExcelUtil;
|
||||
import com.engine.kq.util.KQDurationCalculatorUtil;
|
||||
import com.engine.xmgsecond.util.KqCalulateUtil;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.company.SubCompanyComInfo;
|
||||
import weaver.hrm.job.JobTitlesComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
private List<String> lsFieldDataKey;
|
||||
|
||||
public ExportDailyExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
this.lsFieldDataKey = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String, Object> retmap = new HashMap<String, Object>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
try {
|
||||
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
|
||||
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
|
||||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||||
KQReportBiz kqReportBiz = new KQReportBiz();
|
||||
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
|
||||
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
|
||||
String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0");
|
||||
|
||||
new KQReportBiz().insertKqReportExportLog(params, user);
|
||||
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
|
||||
String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial"));
|
||||
String fromDate = Util.null2String(jsonObj.get("fromDate"));
|
||||
String toDate = Util.null2String(jsonObj.get("toDate"));
|
||||
String typeselect =Util.null2String(jsonObj.get("typeselect"));
|
||||
if(typeselect.length()==0)typeselect = "3";
|
||||
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
|
||||
if(typeselect.equals("1")){
|
||||
fromDate = TimeUtil.getCurrentDateString();
|
||||
toDate = TimeUtil.getCurrentDateString();
|
||||
}else{
|
||||
fromDate = TimeUtil.getDateByOption(typeselect,"0");
|
||||
toDate = TimeUtil.getDateByOption(typeselect,"1");
|
||||
}
|
||||
}
|
||||
//人员状态
|
||||
String status = Util.null2String(jsonObj.get("status"));
|
||||
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
|
||||
String departmentId = Util.null2String(jsonObj.get("departmentId"));
|
||||
String resourceId = Util.null2String(jsonObj.get("resourceId"));
|
||||
String allLevel = Util.null2String(jsonObj.get("allLevel"));
|
||||
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
|
||||
String viewScope = Util.null2String(jsonObj.get("viewScope"));
|
||||
List<String> showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")),",");
|
||||
showColumns.add("lastname");
|
||||
showColumns.add("kqdate");
|
||||
showColumns.add("serialid");
|
||||
showColumns.removeIf(showColumn->showColumn.trim().equals(""));
|
||||
|
||||
List<String> tmpShowColumns = new ArrayList<>();
|
||||
for(String showColumn:showColumns){
|
||||
tmpShowColumns.add(showColumn);
|
||||
String cascadekey = "";
|
||||
if(showColumn.equals("signin1")){
|
||||
cascadekey = "signout1";
|
||||
}else if(showColumn.equals("signin2")){
|
||||
cascadekey = "signout2";
|
||||
}else if(showColumn.equals("signin3")){
|
||||
cascadekey = "signout3";
|
||||
}else if(showColumn.equals("beLate")){
|
||||
cascadekey = "beLateMins";
|
||||
}else if(showColumn.equals("leaveEearly")){
|
||||
cascadekey = "leaveEarlyMins";
|
||||
}else if(showColumn.equals("graveBeLate")){
|
||||
cascadekey = "graveBeLateMins";
|
||||
}else if(showColumn.equals("graveLeaveEarly")){
|
||||
cascadekey = "graveLeaveEarlyMins";
|
||||
}else if(showColumn.equals("absenteeism")){
|
||||
cascadekey = "absenteeismMins";
|
||||
}else if(showColumn.equals("overtime")){
|
||||
tmpShowColumns.add("overtime_4leave");
|
||||
tmpShowColumns.add("overtime_nonleave");
|
||||
tmpShowColumns.add("workingDayOvertime_nonleave");
|
||||
tmpShowColumns.add("workingDayOvertime_4leave");
|
||||
tmpShowColumns.add("restDayOvertime_nonleave");
|
||||
tmpShowColumns.add("restDayOvertime_4leave");
|
||||
tmpShowColumns.add("holidayOvertime_4leave");
|
||||
tmpShowColumns.add("holidayOvertime_nonleave");
|
||||
}
|
||||
if(cascadekey.length()>0){
|
||||
tmpShowColumns.add(cascadekey);
|
||||
}
|
||||
}
|
||||
showColumns = tmpShowColumns;
|
||||
|
||||
String today = DateUtil.getCurrentDate();
|
||||
if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天
|
||||
toDate = today;
|
||||
}
|
||||
|
||||
String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a");
|
||||
|
||||
LinkedHashMap<String, Object> workbook = new LinkedHashMap<>();
|
||||
List<Object> lsSheet = new ArrayList<>();
|
||||
Map<String, Object> sheet = null;
|
||||
List<Object> titleList = new ArrayList<>();
|
||||
Map<String,Object> title = null;
|
||||
List<List<Object>> dataList = new ArrayList<>();
|
||||
List<Object> data = null;
|
||||
List<Map<String,Object>> constraintList = null;
|
||||
Map<String,Object> constraint = null;
|
||||
|
||||
sheet = new HashMap<>();
|
||||
sheet.put("sheetName", SystemEnv.getHtmlLabelName( 390352, user.getLanguage()));
|
||||
sheet.put("sheetTitle", SystemEnv.getHtmlLabelName( 390352, user.getLanguage()));
|
||||
|
||||
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
|
||||
|
||||
Map<String,Object> mapChildColumnInfo = null;
|
||||
List<Object> childColumns = null;
|
||||
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
|
||||
while (kqReportFieldComInfo.next()){
|
||||
if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue;
|
||||
if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))continue;
|
||||
if (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue;
|
||||
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){
|
||||
continue;
|
||||
}
|
||||
title = new HashMap<>();
|
||||
String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user);
|
||||
if(unitType.length()>0){
|
||||
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")");
|
||||
}else{
|
||||
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
|
||||
}
|
||||
title.put("width",30*256);
|
||||
this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname());
|
||||
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user);
|
||||
childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
|
||||
if(childColumns.size()>0) {//跨列width取子列的width
|
||||
title.put("children", childColumns);
|
||||
title.put("colSpan",childColumns.size());
|
||||
}else{
|
||||
title.put("rowSpan", 3);
|
||||
}
|
||||
titleList.add(title);
|
||||
}
|
||||
sheet.put("titleList", titleList);
|
||||
|
||||
// 没有权限的人最大只支持查询本季
|
||||
Map<String, String> getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "2");
|
||||
fromDate = getRealDate.get("fromDate");
|
||||
toDate = getRealDate.get("toDate");
|
||||
if("-1".equals(fromDate) || "-1".equals(toDate)) {
|
||||
retmap.put("status", "1");
|
||||
return retmap;
|
||||
}
|
||||
List<List> paramLists = new ArrayList<>();
|
||||
List<Object> paramList = null;
|
||||
String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck ";
|
||||
|
||||
if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")) {
|
||||
forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) ";
|
||||
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
|
||||
forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) ";
|
||||
}else {
|
||||
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
|
||||
}
|
||||
|
||||
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
|
||||
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins,b.beLate," +
|
||||
" b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins,b.graveLeaveEarly," +
|
||||
" b.graveLeaveEarlyMins,b.absenteeism,b.signdays,b.signmins, "+
|
||||
" b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck ";
|
||||
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
|
||||
String sqlWhere = rightSql;
|
||||
if(subCompanyId.length()>0){
|
||||
sqlWhere +=" and a.subcompanyid1 in("+KQReportBiz.splitParamStr(subCompanyId)+") ";
|
||||
for(String bean : subCompanyId.split(",")) {
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(bean);
|
||||
paramLists.add(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
if(departmentId.length()>0){
|
||||
sqlWhere +=" and a.departmentid in("+KQReportBiz.splitParamStr(departmentId)+") ";
|
||||
for(String bean : departmentId.split(",")) {
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(bean);
|
||||
paramLists.add(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
if(resourceId.length()>0){
|
||||
sqlWhere +=" and a.id in("+KQReportBiz.splitParamStr(resourceId)+") ";
|
||||
for(String bean : resourceId.split(",")) {
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(bean);
|
||||
paramLists.add(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
if(viewScope.equals("4")){//我的下属
|
||||
if(allLevel.equals("1")){//所有下属
|
||||
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
|
||||
}else{
|
||||
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
|
||||
}
|
||||
}
|
||||
if (!"1".equals(isNoAccount)) {
|
||||
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
|
||||
}
|
||||
|
||||
if(status.length()>0){
|
||||
if (!status.equals("8") && !status.equals("9")) {
|
||||
sqlWhere += " and a.status = ?";
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(status);
|
||||
paramLists.add(paramList);
|
||||
}else if (status.equals("8")) {
|
||||
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
|
||||
}
|
||||
}
|
||||
String orderBy = " order by a.dsporder asc, a.lastname asc , b.kqDate asc ";
|
||||
String descOrderBy = " order by a.dsporder desc, a.lastname desc ";
|
||||
sql = "select "+backFields + sqlFrom + sqlWhere+orderBy;
|
||||
|
||||
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
|
||||
String fullPathMainKey = "show_full_path";
|
||||
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
|
||||
|
||||
Map<String,String> serialdata = new HashMap<>();
|
||||
boolean isneedcal = KQSettingsBiz.getKqformatAccurate();
|
||||
params.put("isneedcal",isneedcal?"1":"0");
|
||||
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
|
||||
rs.executeQuery(sql, paramLists);
|
||||
while (rs.next()) {
|
||||
data = new ArrayList<>();
|
||||
String id = rs.getString("id");
|
||||
String kqdate = rs.getString("kqdate");
|
||||
String tmpkey = id+"|"+kqdate+"|";
|
||||
// Map<String,Object> signDetailInfo = this.getSignDetailInfo(id,kqdate);
|
||||
|
||||
for (int fieldDataKeyIdx =0;fieldDataKeyIdx<lsFieldDataKey.size();fieldDataKeyIdx++) {
|
||||
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
|
||||
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
|
||||
String fieldValue = "";
|
||||
if(fieldName.equals("subcompany")){
|
||||
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
|
||||
if(tmpSubcompanyId.length()==0){
|
||||
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
|
||||
}
|
||||
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") :
|
||||
subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
|
||||
|
||||
// fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
|
||||
}else if(fieldName.equals("department")){
|
||||
String tmpDepartmentId = Util.null2String(rs.getString("departmentid"));
|
||||
if(tmpDepartmentId.length()==0){
|
||||
tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id));
|
||||
}
|
||||
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") :
|
||||
departmentComInfo.getDepartmentname(tmpDepartmentId);
|
||||
|
||||
// fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId);
|
||||
}else if(fieldName.equals("jobtitle")){
|
||||
String tmpJobtitleId = Util.null2String(rs.getString("jobtitle"));
|
||||
if(tmpJobtitleId.length()==0){
|
||||
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
|
||||
}
|
||||
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
|
||||
}else if("kqGroup".equals(fieldName)){
|
||||
//QC3685035 每日考勤报表增加所属所属考勤组
|
||||
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
String groupId = kqGroupMemberComInfo.getKQGroupId(id, kqdate);
|
||||
fieldValue = kqGroupComInfo.getGroupname(groupId);
|
||||
}else if("nigntWork".equals(fieldName)){
|
||||
//QC3685035 每日考勤报表增加夜班次数
|
||||
fieldValue = String.valueOf(KqCalulateUtil.nightWorkSums(id,kqdate,kqdate));
|
||||
} else if(fieldName.equals("serialid")){
|
||||
String serialid = Util.null2String(rs.getString("serialid"));
|
||||
if(serialid.length()>0){
|
||||
// fieldValue = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage()));
|
||||
|
||||
if(null != serialdata && serialdata.containsKey(serialid)){
|
||||
fieldValue = serialdata.get(serialid);
|
||||
}else{
|
||||
String tmpserialname = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage()));
|
||||
fieldValue = tmpserialname;
|
||||
serialdata.put(serialid,tmpserialname);
|
||||
}
|
||||
}
|
||||
} else if(fieldName.equals("signin1")){
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signintime1"));
|
||||
data.add(fieldValue);
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus1"));
|
||||
data.add(fieldValue);
|
||||
continue;
|
||||
} else if(fieldName.equals("signin2")){
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signintime2"));
|
||||
data.add(fieldValue);
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus2"));
|
||||
data.add(fieldValue);
|
||||
continue;
|
||||
} else if(fieldName.equals("signin3")){
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signintime3"));
|
||||
data.add(fieldValue);
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus3"));
|
||||
data.add(fieldValue);
|
||||
continue;
|
||||
} else if(fieldName.equals("signout1")){
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime1"));
|
||||
data.add(fieldValue);
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus1"));
|
||||
data.add(fieldValue);
|
||||
continue;
|
||||
} else if(fieldName.equals("signout2")){
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime2"));
|
||||
data.add(fieldValue);
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus2"));
|
||||
data.add(fieldValue);
|
||||
continue;
|
||||
} else if(fieldName.equals("signout3")){
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime3"));
|
||||
data.add(fieldValue);
|
||||
fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus3"));
|
||||
data.add(fieldValue);
|
||||
continue;
|
||||
} else if(fieldName.equals("leave")){
|
||||
//请假
|
||||
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
|
||||
if (("1").equals(leavetype_is_on)) {
|
||||
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
|
||||
for (int i = allLeaveRules.size() - 1; i >= 0; i--) {
|
||||
Map<String, Object> leaveRule = allLeaveRules.get(i);
|
||||
String leaveId = Util.null2String(leaveRule.get("id"));
|
||||
boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId);
|
||||
if (flag) {
|
||||
allLeaveRules.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> leaveRule = null;
|
||||
for(int i=0;allLeaveRules!=null&&i<allLeaveRules.size();i++){
|
||||
leaveRule = (Map<String, Object>)allLeaveRules.get(i);
|
||||
String flowType = Util.null2String("leaveType_"+leaveRule.get("id"));
|
||||
fieldValue = Util.null2String(flowData.get(id+"|"+kqdate+"|"+flowType));
|
||||
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
|
||||
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowLeaveBackType)), "0.0");
|
||||
String b_flowLeaveData = "";
|
||||
String flowLeaveData = "";
|
||||
try {
|
||||
//以防止出现精度问题
|
||||
if (fieldValue.length() == 0) {
|
||||
fieldValue = "0.0";
|
||||
}
|
||||
if (leavebackData.length() == 0) {
|
||||
leavebackData = "0.0";
|
||||
}
|
||||
BigDecimal b_leaveData = new BigDecimal(fieldValue);
|
||||
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
|
||||
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
|
||||
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
|
||||
b_flowLeaveData = "0.0";
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
writeLog("ExportDailyExcelCmd:fieldValue" + fieldValue + ":leavebackData:" + leavebackData + ":" + e);
|
||||
}
|
||||
//考虑下冻结的数据
|
||||
if (b_flowLeaveData.length() > 0) {
|
||||
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
|
||||
} else {
|
||||
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(fieldValue, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
|
||||
}
|
||||
fieldValue = flowLeaveData;
|
||||
|
||||
data.add(fieldValue);
|
||||
}
|
||||
}else if(fieldName.equals("overtime")){
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_nonleave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_nonleave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_nonleave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_4leave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_4leave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_4leave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave"))));
|
||||
|
||||
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_4leave")));
|
||||
workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
|
||||
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_4leave")));
|
||||
restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
|
||||
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_4leave")));
|
||||
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
|
||||
|
||||
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_nonleave")));
|
||||
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
|
||||
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_nonleave")));
|
||||
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
|
||||
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_nonleave")));
|
||||
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
|
||||
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal"))));
|
||||
continue;
|
||||
}else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
|
||||
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+fieldName)),"0.0");
|
||||
String backType = fieldName+"_back";
|
||||
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+backType)),"0.0");
|
||||
String businessLeave = "";
|
||||
try{
|
||||
//以防止出现精度问题
|
||||
if(businessLeaveData.length() == 0){
|
||||
businessLeaveData = "0.0";
|
||||
}
|
||||
if(businessLeavebackData.length() == 0){
|
||||
businessLeavebackData = "0.0";
|
||||
}
|
||||
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
|
||||
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
|
||||
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
|
||||
if(Util.getDoubleValue(businessLeave, -1) < 0){
|
||||
businessLeave = "0.0";
|
||||
}
|
||||
}catch (Exception e){
|
||||
}
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
|
||||
}else if(fieldName.equals("kqdate")){
|
||||
fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate));
|
||||
} else {
|
||||
fieldValue = Util.null2String(rs.getString(fieldName));
|
||||
fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid));
|
||||
}
|
||||
|
||||
if(!fieldName.equals("leave")) {
|
||||
fieldValue = Util.formatMultiLang(fieldValue, "" + user.getLanguage());
|
||||
data.add(fieldValue);
|
||||
}
|
||||
}
|
||||
dataList.add(data);
|
||||
}
|
||||
sheet.put("dataList", dataList);
|
||||
sheet.put("constraintList",constraintList);
|
||||
sheet.put("createFile", "1");
|
||||
lsSheet.add(sheet);
|
||||
|
||||
workbook.put("sheet", lsSheet);
|
||||
String fileName = SystemEnv.getHtmlLabelName(390352, user.getLanguage())+" "+fromDate+" "+toDate;;
|
||||
workbook.put("fileName", fileName);
|
||||
ExcelUtil ExcelUtil = new ExcelUtil();
|
||||
Map<String,Object> exportMap= ExcelUtil.export(workbook,request,response);
|
||||
retmap.putAll(exportMap);
|
||||
retmap.put("status", "1");
|
||||
} catch (Exception e) {
|
||||
retmap.put("status", "-1");
|
||||
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
|
||||
writeLog(e);
|
||||
}
|
||||
return retmap;
|
||||
}
|
||||
|
||||
private Map<String,Object> getChildColumnsInfo(String parentid, User user){
|
||||
Map<String,Object> returnMap = new HashMap<>();
|
||||
List<Object> titleList = new ArrayList<>();
|
||||
Map<String,Object> title = null;
|
||||
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
|
||||
String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0");
|
||||
if(parentid.equals("leave")){
|
||||
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
|
||||
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
|
||||
if (("1").equals(leavetype_is_on)) {
|
||||
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
|
||||
for (int i = leaveRules.size() - 1; i >= 0; i--) {
|
||||
Map<String, Object> leaveRule = leaveRules.get(i);
|
||||
String leaveId = Util.null2String(leaveRule.get("id"));
|
||||
boolean flag = kqLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId);
|
||||
if (flag) {
|
||||
leaveRules.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
|
||||
Map<String, Object> leaveRule = leaveRules.get(i);
|
||||
String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")),""+user.getLanguage());
|
||||
String unitType = Util.null2String(leaveRule.get("unitType"));
|
||||
title = new HashMap<>();
|
||||
title.put("title",name+"("+
|
||||
((KQUnitBiz.isLeaveHour(unitType))?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()))+")");
|
||||
title.put("width",30*256);
|
||||
titleList.add(title);
|
||||
|
||||
}
|
||||
}else if(parentid.equals("overtime")){
|
||||
String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"};
|
||||
for(int i=0;i<overtimeChild.length;i++){
|
||||
String id = overtimeChild[i];
|
||||
title = new HashMap();
|
||||
String fieldlabel = "";
|
||||
if("overtime_nonleave".equalsIgnoreCase(id)){
|
||||
fieldlabel = "125805";
|
||||
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
|
||||
title.put("rowSpan","2");
|
||||
}else if("overtime_4leave".equalsIgnoreCase(id)){
|
||||
fieldlabel = "125804";
|
||||
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
|
||||
title.put("rowSpan","2");
|
||||
}else{
|
||||
fieldlabel = "523";
|
||||
title.put("showDetial","1");
|
||||
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
|
||||
String unitTypeName = "";
|
||||
if(Util.null2String(unitType).length()>0){
|
||||
if(unitType.equals("1")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
|
||||
}else if(unitType.equals("2")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
|
||||
}else if(unitType.equals("3")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
|
||||
}
|
||||
}
|
||||
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")");
|
||||
}
|
||||
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
|
||||
int childWidth = 65;
|
||||
List<Object> childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
|
||||
if(childColumns.size()>0) {//跨列width取子列的width
|
||||
title.put("children", childColumns);
|
||||
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65);
|
||||
}
|
||||
title.put("width", childWidth+"");
|
||||
titleList.add(title);
|
||||
}
|
||||
} else{
|
||||
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
|
||||
while (kqReportFieldComInfo.next()){
|
||||
if(kqReportFieldComInfo.getParentid().equals(parentid)) {
|
||||
if(!kqReportFieldComInfo.getReportType().equals("daily"))continue;
|
||||
title = new HashMap<>();
|
||||
title.put("title",SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+
|
||||
(KQReportBiz.getUnitType(kqReportFieldComInfo, user).length()>0?"("+ KQReportBiz.getUnitType(kqReportFieldComInfo, user)+")":""));
|
||||
title.put("width",30*256);
|
||||
titleList.add(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
returnMap.put("childColumns",titleList);
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
public Map<String, Object> getSignDetailInfo(String resourceId, String kqDate){
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
Map<String,Object> signStatusInfo = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||||
try{
|
||||
sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " +
|
||||
" workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" +
|
||||
" attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," +
|
||||
" leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" +
|
||||
" from kq_format_detail b \n" +
|
||||
" where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" +
|
||||
" order by serialnumber \n";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
String resourceid = Util.null2String(rs.getString("resourceid"));
|
||||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||||
String serialid = Util.null2String(rs.getString("serialid"));
|
||||
int serialnumber = rs.getInt("serialnumber")+1;
|
||||
String workbegindate = Util.null2String(rs.getString("workbegindate")).trim();
|
||||
String workbegintime = Util.null2String(rs.getString("workbegintime")).trim();
|
||||
String workenddate = Util.null2String(rs.getString("workenddate")).trim();
|
||||
String workendtime = Util.null2String(rs.getString("workendtime")).trim();
|
||||
int workMins = rs.getInt("workMins");
|
||||
String signintime = Util.null2String(rs.getString("signintime")).trim();
|
||||
String signouttime = Util.null2String(rs.getString("signouttime")).trim();
|
||||
int attendanceMins = rs.getInt("attendanceMins");
|
||||
String beLateMins = Util.null2String(rs.getString("beLateMins")).trim();
|
||||
String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim();
|
||||
String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim();
|
||||
String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim();
|
||||
String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim();
|
||||
String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim();
|
||||
String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim();
|
||||
String signinid = Util.null2String(rs.getString("signinid")).trim();
|
||||
String signoutid = Util.null2String(rs.getString("signoutid")).trim();
|
||||
int leaveMins = rs.getInt("leaveMins");
|
||||
String leaveInfo = Util.null2String(rs.getString("leaveInfo"));
|
||||
int evectionMins = rs.getInt("evectionMins");
|
||||
int outMins = rs.getInt("outMins");
|
||||
|
||||
|
||||
if(serialid.length()>0){
|
||||
if (workbegintime.length() > 0) {
|
||||
signStatusInfo = new HashMap();
|
||||
signStatusInfo.put("workdate",workbegindate);
|
||||
signStatusInfo.put("worktime",workbegintime);
|
||||
signStatusInfo.put("beLateMins",beLateMins);
|
||||
signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins);
|
||||
signStatusInfo.put("graveBeLateMins",graveBeLateMins);
|
||||
signStatusInfo.put("absenteeismMins",absenteeismMins);
|
||||
signStatusInfo.put("leaveMins",leaveMins);
|
||||
signStatusInfo.put("leaveInfo",leaveInfo);
|
||||
signStatusInfo.put("evectionMins",evectionMins);
|
||||
signStatusInfo.put("outMins",outMins);
|
||||
|
||||
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
|
||||
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
|
||||
}
|
||||
|
||||
if (workendtime.length() > 0) {
|
||||
signStatusInfo = new HashMap();
|
||||
signStatusInfo.put("workdate",workenddate);
|
||||
signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime));
|
||||
signStatusInfo.put("leaveEarlyMins",leaveEarlyMins);
|
||||
signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins);
|
||||
signStatusInfo.put("forgotCheckMins",forgotCheckMins);
|
||||
signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins);
|
||||
signStatusInfo.put("absenteeismMins",absenteeismMins);
|
||||
signStatusInfo.put("leaveMins",leaveMins);
|
||||
signStatusInfo.put("leaveInfo",leaveInfo);
|
||||
signStatusInfo.put("evectionMins",evectionMins);
|
||||
signStatusInfo.put("outMins",outMins);
|
||||
|
||||
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
|
||||
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
|
||||
}
|
||||
}else{
|
||||
if(workMins>0){
|
||||
//弹性工时打卡时间取自签到签退数据
|
||||
}
|
||||
signStatusInfo = new HashMap();
|
||||
signStatusInfo.put("leaveMins",leaveMins);
|
||||
signStatusInfo.put("leaveInfo",leaveInfo);
|
||||
signStatusInfo.put("evectionMins",evectionMins);
|
||||
signStatusInfo.put("outMins",outMins);
|
||||
|
||||
if(signinid.length() > 0){
|
||||
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
|
||||
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
|
||||
if(signoutid.length() > 0){
|
||||
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
|
||||
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
|
||||
}
|
||||
}else{
|
||||
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
writeLog(e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private String getFieldValueByUnitType(String fieldValue,String unittype){
|
||||
if (Util.null2String(unittype).length() > 0) {
|
||||
if (fieldValue.length() == 0) {
|
||||
fieldValue = "0";
|
||||
} else {
|
||||
if (unittype.equals("2")) {
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return fieldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,8 @@ import com.engine.kq.biz.*;
|
|||
import com.engine.kq.util.ExcelUtil;
|
||||
import com.engine.kq.util.KQDurationCalculatorUtil;
|
||||
import com.engine.kq.util.UtilKQ;
|
||||
import com.engine.xmgsecond.entity.KqFormatTotal;
|
||||
import com.engine.xmgsecond.util.KqCalulateUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
|
|
@ -346,7 +348,21 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|||
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
|
||||
}
|
||||
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
|
||||
} else if (fieldName.equals("attendanceSerial")) {
|
||||
} else if("kqGroup".equals(fieldName)){
|
||||
//QC3685035 考勤月度报表增加所属所属考勤组
|
||||
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
String groupId = kqGroupMemberComInfo.getKQGroupId(id, toDate);
|
||||
fieldValue = kqGroupComInfo.getGroupname(groupId);
|
||||
// fieldValue = kqGroupComInfo.getGroupname(Util.null2String(rs.getString("groupid")));
|
||||
}else if("absenteeismDays".equals(fieldName)){
|
||||
//QC3685035 考勤月度报表增加缺勤天数
|
||||
List<KqFormatTotal> kqFormatTotalList = KqCalulateUtil.abnormalAttendance(id, fromDate, toDate);
|
||||
fieldValue = String.format("%.1f", kqFormatTotalList.stream().mapToDouble(KqFormatTotal::getAbsenceDays).sum());
|
||||
}else if("nigntWork".equals(fieldName)){
|
||||
//QC3685035 考勤月度报表增加夜班次数
|
||||
fieldValue = String.valueOf(KqCalulateUtil.nightWorkSums(id,fromDate,toDate));
|
||||
}else if (fieldName.equals("attendanceSerial")) {
|
||||
List<String> serialIds = null;
|
||||
if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) {
|
||||
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ",");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,748 @@
|
|||
package com.engine.kq.cmd.report;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.kq.biz.*;
|
||||
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
|
||||
import com.engine.kq.entity.WorkTimeEntity;
|
||||
import com.engine.kq.log.KQLog;
|
||||
import com.engine.kq.util.KQDurationCalculatorUtil;
|
||||
import com.engine.kq.util.PageUidFactory;
|
||||
import com.engine.xmgsecond.entity.KqFormatTotal;
|
||||
import com.engine.xmgsecond.util.KqCalulateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.company.SubCompanyComInfo;
|
||||
import weaver.hrm.job.JobTitlesComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
private KQLog kqLog = new KQLog();
|
||||
|
||||
public GetKQDailyReportCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String,Object> retmap = new HashMap<String,Object>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
try{
|
||||
String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport");
|
||||
|
||||
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||||
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
|
||||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||||
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
|
||||
KQReportBiz kqReportBiz = new KQReportBiz();
|
||||
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
|
||||
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
|
||||
String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0");
|
||||
|
||||
String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a");
|
||||
|
||||
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
|
||||
String fromDate = Util.null2String(jsonObj.get("fromDate"));
|
||||
String toDate = Util.null2String(jsonObj.get("toDate"));
|
||||
String typeselect =Util.null2String(jsonObj.get("typeselect"));
|
||||
if(typeselect.length()==0)typeselect = "3";
|
||||
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
|
||||
if(typeselect.equals("1")){
|
||||
fromDate = TimeUtil.getCurrentDateString();
|
||||
toDate = TimeUtil.getCurrentDateString();
|
||||
}else{
|
||||
fromDate = TimeUtil.getDateByOption(typeselect,"0");
|
||||
toDate = TimeUtil.getDateByOption(typeselect,"1");
|
||||
}
|
||||
}
|
||||
//人员状态
|
||||
String status = Util.null2String(jsonObj.get("status"));
|
||||
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
|
||||
String departmentId = Util.null2String(jsonObj.get("departmentId"));
|
||||
String resourceId = Util.null2String(jsonObj.get("resourceId"));
|
||||
String allLevel = Util.null2String(jsonObj.get("allLevel"));
|
||||
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
|
||||
String viewScope = Util.null2String(jsonObj.get("viewScope"));
|
||||
if(typeselect.length()==0)typeselect = "3";
|
||||
int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1);
|
||||
int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")),pageUid,user.getUID());
|
||||
int count = 0;
|
||||
int pageCount = 0;
|
||||
int isHavePre = 0;
|
||||
int isHaveNext = 0;
|
||||
|
||||
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
|
||||
List<Object> columns = new ArrayList();
|
||||
Map<String,Object> column = null;
|
||||
List<Object> datas = new ArrayList();
|
||||
Map<String,Object> data = null;
|
||||
Map<String,Object> mapChildColumnInfo = null;
|
||||
List<Object> childColumns = null;
|
||||
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
|
||||
while (kqReportFieldComInfo.next()){
|
||||
//QC3685035 考勤每日表去除严重迟到,严重早退(+对应时长) + 缺勤天数 5列
|
||||
if ("graveBeLate".equals(kqReportFieldComInfo.getFieldname())) continue;
|
||||
if ("graveLeaveEarly".equals(kqReportFieldComInfo.getFieldname())) continue;
|
||||
if ("graveBeLateMins".equals(kqReportFieldComInfo.getFieldname())) continue;
|
||||
if ("graveLeaveEarlyMins".equals(kqReportFieldComInfo.getFieldname())) continue;
|
||||
if ("absenteeismDays".equals(kqReportFieldComInfo.getFieldname())) continue;
|
||||
|
||||
if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue;
|
||||
boolean isDaily = kqReportFieldComInfo.getReportType().equals("daily");
|
||||
if(!kqReportFieldComInfo.getReportType().equals("all") && !isDaily)continue;
|
||||
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){
|
||||
continue;
|
||||
}
|
||||
column = new HashMap();
|
||||
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
|
||||
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
|
||||
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
|
||||
column.put("key", kqReportFieldComInfo.getFieldname());
|
||||
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user);
|
||||
childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
|
||||
if(childColumns.size()>0) {//跨列width取子列的width
|
||||
column.put("rowSpan", 1);
|
||||
column.put("width", mapChildColumnInfo.get("sumChildColumnWidth"));
|
||||
column.put("children", childColumns);
|
||||
}else{
|
||||
column.put("rowSpan", 3);
|
||||
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
|
||||
}
|
||||
if(kqReportFieldComInfo.getReportType1().equals("daily")){
|
||||
column.put("isdaily", "1");
|
||||
}
|
||||
column.put("showDetial",kqReportFieldComInfo.getShowDetial());
|
||||
columns.add(column);
|
||||
}
|
||||
|
||||
// String today = DateUtil.getCurrentDate();
|
||||
// if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天
|
||||
// toDate = today;
|
||||
// if(DateUtil.compDate(today, fromDate)>0){
|
||||
// fromDate = today;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 没有权限的人最大只支持查询本季
|
||||
Map<String, String> getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "2");
|
||||
fromDate = getRealDate.get("fromDate");
|
||||
toDate = getRealDate.get("toDate");
|
||||
|
||||
String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck ";
|
||||
List<List> paramLists = new ArrayList<>();
|
||||
List<Object> paramList = null;
|
||||
|
||||
if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")&&!Util.null2String(rs.getOrgindbtype()).equals("jc")) {
|
||||
forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) ";
|
||||
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
|
||||
forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) ";
|
||||
}else {
|
||||
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
|
||||
}
|
||||
|
||||
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
|
||||
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins," +
|
||||
" b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," +
|
||||
" b.signdays,b.signmins, "+
|
||||
" b.graveLeaveEarly,b.graveLeaveEarlyMins,b.absenteeism ,b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck ";
|
||||
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
|
||||
String sqlWhere = rightSql;
|
||||
if(subCompanyId.length()>0){
|
||||
sqlWhere +=" and a.subcompanyid1 in("+KQReportBiz.splitParamStr(subCompanyId)+") ";
|
||||
for(String bean : subCompanyId.split(",")) {
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(bean);
|
||||
paramLists.add(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
if(departmentId.length()>0){
|
||||
sqlWhere +=" and a.departmentid in("+KQReportBiz.splitParamStr(departmentId)+") ";
|
||||
for(String bean : departmentId.split(",")) {
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(bean);
|
||||
paramLists.add(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
if(resourceId.length()>0){
|
||||
sqlWhere +=" and a.id in("+KQReportBiz.splitParamStr(resourceId)+") ";
|
||||
for(String bean : resourceId.split(",")) {
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(bean);
|
||||
paramLists.add(paramList);
|
||||
}
|
||||
}
|
||||
|
||||
if(viewScope.equals("4")){//我的下属
|
||||
if(allLevel.equals("1")){//所有下属
|
||||
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
|
||||
}else{
|
||||
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
|
||||
}
|
||||
}
|
||||
if (!"1".equals(isNoAccount)) {
|
||||
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
|
||||
}
|
||||
if(status.length()>0){
|
||||
if (!status.equals("8") && !status.equals("9")) {
|
||||
sqlWhere += " and a.status = ?";
|
||||
paramList = new ArrayList<>();
|
||||
paramList.add(status);
|
||||
paramLists.add(paramList);
|
||||
}else if (status.equals("8")) {
|
||||
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
|
||||
}
|
||||
}
|
||||
if("-1".equals(fromDate) || "-1".equals(toDate)) {
|
||||
sqlWhere += " and 1=2 ";
|
||||
}
|
||||
|
||||
sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+") t";
|
||||
rs.executeQuery(sql, paramLists);
|
||||
if (rs.next()){
|
||||
count = rs.getInt("c");
|
||||
}
|
||||
|
||||
if (count <= 0) {
|
||||
pageCount = 0;
|
||||
}
|
||||
|
||||
pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0);
|
||||
|
||||
isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0;
|
||||
|
||||
isHavePre = (pageIndex - 1 >= 1) ? 1 : 0;
|
||||
|
||||
String orderBy = " order by a.dsporder asc, a.lastname asc, b.kqdate asc ";
|
||||
String descOrderBy = " order by a.dsporder desc, a.lastname desc, b.kqdate desc ";
|
||||
sql = backFields + sqlFrom + sqlWhere + orderBy;
|
||||
|
||||
if (pageIndex > 0 && pageSize > 0) {
|
||||
if (rs.getDBType().equals("oracle")) {
|
||||
sql = " select " + sql;
|
||||
sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= "
|
||||
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
|
||||
} else if (rs.getDBType().equals("mysql")) {
|
||||
sql = " select " + sql;
|
||||
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
|
||||
}
|
||||
else if (rs.getDBType().equals("postgresql")) {
|
||||
sql = " select " + sql;
|
||||
sql = "select t1.* from (" + sql + ") t1 limit " + pageSize+ " offset " + ((pageIndex - 1) * pageSize);
|
||||
}
|
||||
else {
|
||||
orderBy = " order by dsporder asc, lastname asc, kqdate asc ";
|
||||
descOrderBy = " order by dsporder desc, lastname desc, kqdate desc ";
|
||||
if (pageIndex > 1) {
|
||||
int topSize = pageSize;
|
||||
if (pageSize * pageIndex > count) {
|
||||
topSize = count - (pageSize * (pageIndex - 1));
|
||||
}
|
||||
sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top "
|
||||
+ (pageIndex * pageSize) + sql+" ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
|
||||
} else {
|
||||
sql = " select top " + pageSize + sql;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sql = " select " + sql;
|
||||
}
|
||||
boolean isneedcal = KQSettingsBiz.getKqformatAccurate();
|
||||
params.put("isneedcal",isneedcal?"1":"0");
|
||||
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
|
||||
Map<String,String> serialdata = new HashMap<>();
|
||||
|
||||
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
|
||||
String fullPathMainKey = "show_full_path";
|
||||
|
||||
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
|
||||
|
||||
rs.executeQuery(sql, paramLists);
|
||||
while (rs.next()) {
|
||||
String id = rs.getString("id");
|
||||
String kqdate = rs.getString("kqdate");
|
||||
WorkTimeEntity workTime = kqWorkTime.getWorkTime(id, kqdate);
|
||||
data = new HashMap<>();
|
||||
kqReportFieldComInfo.setTofirstRow();
|
||||
while (kqReportFieldComInfo.next()) {
|
||||
if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue;
|
||||
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))
|
||||
continue;
|
||||
String fieldName = kqReportFieldComInfo.getFieldname();
|
||||
String fieldValue = "";
|
||||
if (fieldName.equals("subcompany")) {
|
||||
String fieldValueID = rs.getString("subcompanyid");
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") :
|
||||
subCompanyComInfo.getSubCompanyname(fieldValueID);
|
||||
|
||||
//fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID);
|
||||
|
||||
if (fieldValue.length() == 0) {
|
||||
fieldValueID = resourceComInfo.getSubCompanyID(id);
|
||||
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") :
|
||||
subCompanyComInfo.getSubCompanyname(fieldValueID);
|
||||
|
||||
// fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID);
|
||||
}
|
||||
data.put(fieldName + "Id", fieldValueID);
|
||||
data.put(fieldName, fieldValue);
|
||||
} else if (fieldName.equals("department")) {
|
||||
String fieldValueID = rs.getString("departmentid");
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") :
|
||||
departmentComInfo.getDepartmentname(fieldValueID);
|
||||
//fieldValue = departmentComInfo.getDepartmentname(fieldValueID);
|
||||
|
||||
if (fieldValue.length() == 0) {
|
||||
fieldValueID = resourceComInfo.getDepartmentID(id);
|
||||
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") :
|
||||
departmentComInfo.getDepartmentname(fieldValueID);
|
||||
|
||||
// fieldValue = departmentComInfo.getDepartmentname(fieldValueID);
|
||||
}
|
||||
data.put(fieldName + "Id", fieldValueID);
|
||||
data.put(fieldName, fieldValue);
|
||||
} else if (fieldName.equals("jobtitle")) {
|
||||
String fieldValueID = rs.getString("jobtitle");
|
||||
fieldValue = jobTitlesComInfo.getJobTitlesname(rs.getString("jobtitle"));
|
||||
if (fieldValue.length() == 0) {
|
||||
fieldValueID = resourceComInfo.getJobTitle(id);
|
||||
fieldValue = jobTitlesComInfo.getJobTitlesname(fieldValueID);
|
||||
}
|
||||
data.put(fieldName + "Id", fieldValueID);
|
||||
data.put(fieldName, fieldValue);
|
||||
}else if("kqGroup".equals(fieldName)){
|
||||
//QC3685035 每日考勤报表增加所属所属考勤组
|
||||
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
|
||||
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
String groupId = kqGroupMemberComInfo.getKQGroupId(id, kqdate);
|
||||
fieldValue = kqGroupComInfo.getGroupname(groupId);
|
||||
data.put(fieldName, fieldValue);
|
||||
}else if("nigntWork".equals(fieldName)){
|
||||
//QC3685035 每日考勤报表增加夜班次数
|
||||
fieldValue = String.valueOf(KqCalulateUtil.nightWorkSums(id,kqdate,kqdate));
|
||||
data.put(fieldName, fieldValue);
|
||||
} else if (kqReportFieldComInfo.getParentid().equals("overtime") || kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
|
||||
|| kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) {
|
||||
if (fieldName.equals("overtimeTotal")) {
|
||||
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_4leave")));
|
||||
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
|
||||
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_4leave")));
|
||||
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
|
||||
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_4leave")));
|
||||
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
|
||||
|
||||
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_nonleave")));
|
||||
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
|
||||
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_nonleave")));
|
||||
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
|
||||
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_nonleave")));
|
||||
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
|
||||
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
|
||||
} else {
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|" + kqdate + "|" + fieldName)));
|
||||
}
|
||||
data.put(fieldName, fieldValue);
|
||||
} else if (fieldName.equals("serialid")) {
|
||||
fieldValue = Util.null2String(rs.getString(fieldName));
|
||||
if (fieldValue.length()>0) {//弹性工作制没有班次
|
||||
// data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage()));
|
||||
|
||||
if(null != serialdata && serialdata.containsKey(fieldValue)){
|
||||
data.put("serialid", serialdata.get(fieldValue));
|
||||
}else{
|
||||
String tmpserialname = shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage());
|
||||
serialdata.put(fieldValue,tmpserialname);
|
||||
data.put("serialid", tmpserialname);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
fieldValue = Util.null2String(rs.getString(fieldName));
|
||||
if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) {
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
|
||||
}
|
||||
data.put(fieldName, fieldValue);
|
||||
}
|
||||
}
|
||||
data.putAll(this.getSignDetailInfo(id, kqdate));
|
||||
|
||||
//请假
|
||||
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
|
||||
if (("1").equals(leavetype_is_on)) {
|
||||
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
|
||||
for (int i = allLeaveRules.size() - 1; i >= 0; i--) {
|
||||
Map<String, Object> leaveRule = allLeaveRules.get(i);
|
||||
String leaveId = Util.null2String(leaveRule.get("id"));
|
||||
boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId);
|
||||
if (flag) {
|
||||
allLeaveRules.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> leaveRule = null;
|
||||
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
|
||||
leaveRule = (Map<String, Object>) allLeaveRules.get(i);
|
||||
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
|
||||
String leaveData = Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowType));
|
||||
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
|
||||
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowLeaveBackType)), "0.0");
|
||||
String b_flowLeaveData = "";
|
||||
String flowLeaveData = "";
|
||||
try {
|
||||
//以防止出现精度问题
|
||||
if (leaveData.length() == 0) {
|
||||
leaveData = "0.0";
|
||||
}
|
||||
if (leavebackData.length() == 0) {
|
||||
leavebackData = "0.0";
|
||||
}
|
||||
BigDecimal b_leaveData = new BigDecimal(leaveData);
|
||||
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
|
||||
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
|
||||
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
|
||||
b_flowLeaveData = "0.0";
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
kqLog.info("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
|
||||
}
|
||||
|
||||
//考虑下冻结的数据
|
||||
if (b_flowLeaveData.length() > 0) {
|
||||
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
|
||||
} else {
|
||||
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
|
||||
}
|
||||
data.put(flowType, flowLeaveData);
|
||||
}
|
||||
|
||||
data.put("resourceId", id);
|
||||
data.put("kqdate", kqdate);
|
||||
datas.add(data);
|
||||
}
|
||||
|
||||
List<Object> lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate);
|
||||
retmap.put("holidays", lsHolidays);
|
||||
retmap.put("columns",columns);
|
||||
retmap.put("datas",datas);
|
||||
retmap.put("pagesize", pageSize);
|
||||
retmap.put("pageindex", pageIndex);
|
||||
retmap.put("count", count);
|
||||
retmap.put("pagecount", pageCount);
|
||||
retmap.put("ishavepre", isHavePre);
|
||||
retmap.put("ishavenext", isHaveNext);
|
||||
}catch (Exception e){
|
||||
writeLog(e);
|
||||
}
|
||||
return retmap;
|
||||
}
|
||||
|
||||
|
||||
private String getUnitType(String unitType, User user){
|
||||
String unitTypeName = "";
|
||||
if(Util.null2String(unitType).length()>0){
|
||||
if(unitType.equals("1")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
|
||||
}else if(unitType.equals("2")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
|
||||
}else if(unitType.equals("3")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
|
||||
}
|
||||
}
|
||||
return unitTypeName;
|
||||
}
|
||||
|
||||
private Map<String,Object> getChildColumnsInfo(String parentid, User user){
|
||||
Map<String,Object> returnMap = new HashMap<>();
|
||||
List<Object> lsChildColumns = new ArrayList<>();
|
||||
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
|
||||
String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0");
|
||||
Map column = null;
|
||||
int sumChildColumnWidth = 0;
|
||||
if(parentid.equals("leave")){
|
||||
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
|
||||
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
|
||||
if (("1").equals(leavetype_is_on)) {
|
||||
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
|
||||
for (int i = leaveRules.size() - 1; i >= 0; i--) {
|
||||
Map<String, Object> leaveRule = leaveRules.get(i);
|
||||
String leaveId = Util.null2String(leaveRule.get("id"));
|
||||
boolean flag = kqLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId);
|
||||
if (flag) {
|
||||
leaveRules.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
|
||||
Map<String, Object> leaveRule = leaveRules.get(i);
|
||||
String id = "leaveType_"+Util.null2String(leaveRule.get("id"));
|
||||
String name = Util.null2String(leaveRule.get("name"));
|
||||
String unitType = Util.null2String(leaveRule.get("unitType"));
|
||||
column = new HashMap();
|
||||
column.put("title", name);
|
||||
column.put("unit", KQUnitBiz.isLeaveHour(unitType) ?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()));
|
||||
column.put("width", 65);
|
||||
column.put("dataIndex", id);
|
||||
column.put("key", id);
|
||||
column.put("rowSpan", 2);
|
||||
column.put("colSpan", 1);
|
||||
column.put("showDetial","1");
|
||||
sumChildColumnWidth+=65;
|
||||
lsChildColumns.add(column);
|
||||
}
|
||||
}else if(parentid.equals("overtime")){
|
||||
String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"};
|
||||
for(int i=0;i<overtimeChild.length;i++){
|
||||
String id = overtimeChild[i];
|
||||
column = new HashMap();
|
||||
String fieldlabel = "";
|
||||
column.put("unit", "");
|
||||
if("overtime_nonleave".equalsIgnoreCase(id)){
|
||||
fieldlabel = "125805";
|
||||
}else if("overtime_4leave".equalsIgnoreCase(id)){
|
||||
fieldlabel = "125804";
|
||||
}else{
|
||||
fieldlabel = "523";
|
||||
column.put("showDetial","1");
|
||||
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
|
||||
String unitTypeName = "";
|
||||
if(Util.null2String(unitType).length()>0){
|
||||
if(unitType.equals("1")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
|
||||
}else if(unitType.equals("2")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
|
||||
}else if(unitType.equals("3")){
|
||||
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
|
||||
}
|
||||
}
|
||||
column.put("unit", unitTypeName);
|
||||
}
|
||||
column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
|
||||
column.put("dataIndex", id);
|
||||
column.put("key", id);
|
||||
column.put("rowSpan", 1);
|
||||
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
|
||||
int childWidth = 65;
|
||||
List<Object> childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
|
||||
if(childColumns.size()>0) {//跨列width取子列的width
|
||||
column.put("children", childColumns);
|
||||
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65);
|
||||
}
|
||||
column.put("width", childWidth+"");
|
||||
sumChildColumnWidth+=childWidth;
|
||||
lsChildColumns.add(column);
|
||||
}
|
||||
}else{
|
||||
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
|
||||
while (kqReportFieldComInfo.next()){
|
||||
if(kqReportFieldComInfo.getParentid().equals(parentid)) {
|
||||
if(!kqReportFieldComInfo.getReportType().equals("daily"))continue;
|
||||
column = new HashMap();
|
||||
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
|
||||
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
|
||||
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
|
||||
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
|
||||
column.put("key", kqReportFieldComInfo.getFieldname());
|
||||
column.put("rowSpan", 2);
|
||||
column.put("colSpan", 1);
|
||||
column.put("isdaily", kqReportFieldComInfo.getReportType1().equals("daily")?"1":"0");
|
||||
sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth());
|
||||
lsChildColumns.add(column);
|
||||
}
|
||||
}
|
||||
}
|
||||
returnMap.put("childColumns",lsChildColumns);
|
||||
returnMap.put("sumChildColumnWidth",sumChildColumnWidth);
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
public Map<String, Object> getSignDetailInfo(String resourceId, String kqDate){
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
Map<String,Object> signStatusInfo = null;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
|
||||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||||
try{
|
||||
sql = " select kqdate,resourceid,day_type,serialid,serialnumber,workbegindate,workbegintime, " +
|
||||
" workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" +
|
||||
" attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," +
|
||||
" leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid,flowinfo,on_absenteeismmins,off_absenteeismmins \n" +
|
||||
" from kq_format_detail b \n" +
|
||||
" where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" +
|
||||
" order by serialnumber \n";
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
String resourceid = Util.null2String(rs.getString("resourceid"));
|
||||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||||
String serialid = Util.null2String(rs.getString("serialid"));
|
||||
String dayType = Util.null2s(rs.getString("day_type"),"");
|
||||
int workMins = rs.getInt("workMins");
|
||||
boolean isNonWork = false;
|
||||
if(serialid.length()==0){
|
||||
isNonWork = true;
|
||||
}
|
||||
if(dayType.length() > 0){
|
||||
if("holiday".equals(dayType) || "playday".equals(dayType)){
|
||||
isNonWork = true;
|
||||
}
|
||||
}else{
|
||||
if(workMins<=0){
|
||||
isNonWork = true;
|
||||
}else{
|
||||
if(serialid.length() > 0){
|
||||
String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),"");
|
||||
if("1".equals(isRest)){
|
||||
isNonWork = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int serialnumber = rs.getInt("serialnumber")+1;
|
||||
String workbegindate = Util.null2String(rs.getString("workbegindate")).trim();
|
||||
String workbegintime = Util.null2String(rs.getString("workbegintime")).trim();
|
||||
String workenddate = Util.null2String(rs.getString("workenddate")).trim();
|
||||
String workendtime = Util.null2String(rs.getString("workendtime")).trim();
|
||||
String signintime = Util.null2String(rs.getString("signintime")).trim();
|
||||
String signouttime = Util.null2String(rs.getString("signouttime")).trim();
|
||||
int attendanceMins = rs.getInt("attendanceMins");
|
||||
String beLateMins = Util.null2String(rs.getString("beLateMins")).trim();
|
||||
String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim();
|
||||
String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim();
|
||||
String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim();
|
||||
String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim();
|
||||
String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim();
|
||||
String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim();
|
||||
String signinid = Util.null2String(rs.getString("signinid")).trim();
|
||||
String signoutid = Util.null2String(rs.getString("signoutid")).trim();
|
||||
int leaveMins = rs.getInt("leaveMins");
|
||||
String leaveInfo = Util.null2String(rs.getString("leaveInfo"));
|
||||
String flowinfo = Util.null2String(rs.getString("flowinfo"));
|
||||
String on_absenteeismmins = Util.null2String(rs.getString("on_absenteeismmins"));
|
||||
String off_absenteeismmins = Util.null2String(rs.getString("off_absenteeismmins"));
|
||||
int evectionMins = rs.getInt("evectionMins");
|
||||
int outMins = rs.getInt("outMins");
|
||||
|
||||
|
||||
if(!isNonWork){
|
||||
if (workbegintime.length() > 0) {
|
||||
signStatusInfo = new HashMap();
|
||||
signStatusInfo.put("resourceId",resourceid);
|
||||
signStatusInfo.put("kqdate",kqdate);
|
||||
signStatusInfo.put("workdate",workbegindate);
|
||||
signStatusInfo.put("worktime",workbegintime);
|
||||
signStatusInfo.put("beLateMins",beLateMins);
|
||||
signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins);
|
||||
signStatusInfo.put("graveBeLateMins",graveBeLateMins);
|
||||
signStatusInfo.put("absenteeismMins",absenteeismMins);
|
||||
signStatusInfo.put("leaveMins",leaveMins);
|
||||
signStatusInfo.put("leaveInfo",leaveInfo);
|
||||
signStatusInfo.put("evectionMins",evectionMins);
|
||||
signStatusInfo.put("outMins",outMins);
|
||||
signStatusInfo.put("flowinfo",flowinfo);
|
||||
signStatusInfo.put("on_absenteeismmins",on_absenteeismmins);
|
||||
signStatusInfo.put("off_absenteeismmins",off_absenteeismmins);
|
||||
signStatusInfo.put("workbegintime",workbegintime);
|
||||
signStatusInfo.put("workendtime",workendtime);
|
||||
|
||||
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
|
||||
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
|
||||
}
|
||||
|
||||
if (workendtime.length() > 0) {
|
||||
signStatusInfo = new HashMap();
|
||||
signStatusInfo.put("resourceId",resourceid);
|
||||
signStatusInfo.put("kqdate",kqdate);
|
||||
signStatusInfo.put("workdate",workenddate);
|
||||
signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime));
|
||||
signStatusInfo.put("leaveEarlyMins",leaveEarlyMins);
|
||||
signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins);
|
||||
signStatusInfo.put("forgotCheckMins",forgotCheckMins);
|
||||
signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins);
|
||||
signStatusInfo.put("absenteeismMins",absenteeismMins);
|
||||
signStatusInfo.put("leaveMins",leaveMins);
|
||||
signStatusInfo.put("leaveInfo",leaveInfo);
|
||||
signStatusInfo.put("evectionMins",evectionMins);
|
||||
signStatusInfo.put("outMins",outMins);
|
||||
signStatusInfo.put("flowinfo",flowinfo);
|
||||
signStatusInfo.put("on_absenteeismmins",on_absenteeismmins);
|
||||
signStatusInfo.put("off_absenteeismmins",off_absenteeismmins);
|
||||
signStatusInfo.put("workbegintime",workbegintime);
|
||||
signStatusInfo.put("workendtime",workendtime);
|
||||
|
||||
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
|
||||
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
|
||||
}
|
||||
}else{
|
||||
if(workMins>0){
|
||||
//弹性工时打卡时间取自签到签退数据
|
||||
}
|
||||
signStatusInfo = new HashMap();
|
||||
signStatusInfo.put("resourceId",resourceid);
|
||||
signStatusInfo.put("kqdate",kqdate);
|
||||
signStatusInfo.put("leaveMins",leaveMins);
|
||||
signStatusInfo.put("leaveInfo",leaveInfo);
|
||||
signStatusInfo.put("evectionMins",evectionMins);
|
||||
signStatusInfo.put("outMins",outMins);
|
||||
signStatusInfo.put("flowinfo",flowinfo);
|
||||
signStatusInfo.put("on_absenteeismmins",on_absenteeismmins);
|
||||
signStatusInfo.put("off_absenteeismmins",off_absenteeismmins);
|
||||
signStatusInfo.put("workbegintime",workbegintime);
|
||||
signStatusInfo.put("workendtime",workendtime);
|
||||
|
||||
if(signinid.length() > 0){
|
||||
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
|
||||
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
|
||||
if(signoutid.length() > 0){
|
||||
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
|
||||
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
|
||||
}else{
|
||||
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
|
||||
}
|
||||
}else if (signoutid.length() > 0) {
|
||||
data.put("signouttime" + serialnumber, signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime);
|
||||
data.put("signoutstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "off"));
|
||||
} else{
|
||||
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
|
||||
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
writeLog(e);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|||
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
|
||||
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
|
||||
|
||||
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
|
||||
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle,b.groupid," +
|
||||
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
|
||||
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
|
||||
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
|
||||
|
|
@ -208,7 +208,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|||
}
|
||||
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
|
||||
String sqlWhere = rightSql;
|
||||
String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle ";
|
||||
String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle,b.groupid ";
|
||||
List<List> paramLists = new ArrayList<>();
|
||||
List<Object> paramList = null;
|
||||
if(subCompanyId.length()>0){
|
||||
|
|
@ -412,11 +412,15 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|||
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||||
String groupId = kqGroupMemberComInfo.getKQGroupId(id, toDate);
|
||||
fieldValue = kqGroupComInfo.getGroupname(groupId);
|
||||
// fieldValue = kqGroupComInfo.getGroupname(Util.null2String(rs.getString("groupid")));
|
||||
}else if("absenteeismDays".equals(fieldName)){
|
||||
//QC3685035 考勤月度报表增加缺勤天数
|
||||
List<KqFormatTotal> kqFormatTotalList = KqCalulateUtil.abnormalAttendance(id, fromDate, toDate);
|
||||
fieldValue = String.format("%.1f", kqFormatTotalList.stream().mapToDouble(KqFormatTotal::getAbsenceDays).sum());
|
||||
} else if(fieldName.equals("rlzqqxs")){
|
||||
}else if("nigntWork".equals(fieldName)){
|
||||
//QC3685035 考勤月度报表增加夜班次数
|
||||
fieldValue = String.valueOf(KqCalulateUtil.nightWorkSums(id,fromDate,toDate));
|
||||
}else if(fieldName.equals("rlzqqxs")){
|
||||
String rlzqqxsTime = getXcqts(fromDate,id);
|
||||
fieldValue = rlzqqxsTime;
|
||||
}else if(fieldName.equals("attendanceSerial")){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.engine.xmgsecond.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/21 15:43
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KqCloseRecords {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String subCompanyIds;
|
||||
|
||||
private String departmentIds;
|
||||
|
||||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
private Integer closeStatus;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.engine.xmgsecond.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/21 14:37
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KqCloseSet {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer workflowId;
|
||||
|
||||
private String startDateCode;
|
||||
|
||||
private String endDateCode;
|
||||
|
||||
private String fbCode;
|
||||
|
||||
private String bmCode;
|
||||
|
||||
private Integer createNodeId;
|
||||
|
||||
private Integer endNodeId;
|
||||
|
||||
}
|
||||
|
|
@ -21,8 +21,16 @@ public class KqFormatTotal {
|
|||
|
||||
private Integer absenteeism;
|
||||
|
||||
/**
|
||||
* 下班漏签
|
||||
*/
|
||||
private Integer forgotCheck;
|
||||
|
||||
/**
|
||||
* 上班漏签
|
||||
*/
|
||||
private Integer forgotbeginworkcheck;
|
||||
|
||||
private Integer beLateMins;
|
||||
|
||||
private Integer gravebeLateMins;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.engine.xmgsecond.service;
|
||||
|
||||
import com.engine.workflow.entity.publicApi.PAResponseEntity;
|
||||
import com.engine.xmgsecond.entity.KqCloseSet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/16 15:17
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface KqCloseAccountService {
|
||||
|
||||
List<PAResponseEntity> closeAccount(Map<String, Object> param);
|
||||
|
||||
List<KqCloseSet> getWorkflowList();
|
||||
|
||||
Boolean checkSubmit(Map<String, Object> param);
|
||||
}
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
package com.engine.xmgsecond.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.workflow.entity.publicApi.PAResponseEntity;
|
||||
import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity;
|
||||
import com.engine.workflow.publicApi.WorkflowRequestOperatePA;
|
||||
import com.engine.workflow.publicApi.impl.WorkflowRequestOperatePAImpl;
|
||||
import com.engine.xmgsecond.entity.KqCloseSet;
|
||||
import com.engine.xmgsecond.service.KqCloseAccountService;
|
||||
import com.weaver.general.TimeUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/16 15:18
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class KqCloseAccountServiceImpl extends Service implements KqCloseAccountService {
|
||||
|
||||
private WorkflowRequestOperatePA getRequestOperatePA() {
|
||||
return ServiceUtil.getService(WorkflowRequestOperatePAImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PAResponseEntity> closeAccount(Map<String, Object> param) {
|
||||
|
||||
String billid = Util.null2String(param.get("billid"));
|
||||
RecordSet rs = new RecordSet();
|
||||
String subCompanyIds = "";
|
||||
String departmentIds = "";
|
||||
String startDate = "";
|
||||
String endDate = "";
|
||||
//0 发起 1 归档
|
||||
String type = Util.null2String(param.get("type"));
|
||||
|
||||
rs.executeQuery("select gzfb,gzbm,ksrq,jsrq from uf_kqgzjl where id = ?",billid);
|
||||
if (rs.next()) {
|
||||
subCompanyIds = Util.null2String(rs.getString("gzfb"));
|
||||
departmentIds = Util.null2String(rs.getString("gzbm"));
|
||||
startDate = Util.null2String(rs.getString("ksrq"));
|
||||
endDate = Util.null2String(rs.getString("jsrq"));
|
||||
}
|
||||
|
||||
String currentTime = TimeUtil.getCurrentTimeString();
|
||||
String lastname = user.getLastname();
|
||||
List<PAResponseEntity> paResponseEntities = new ArrayList<>();
|
||||
List<KqCloseSet> workflowList = getWorkflowList();
|
||||
List<Integer> workflowIds = workflowList.stream()
|
||||
.map(KqCloseSet::getWorkflowId)
|
||||
.collect(Collectors.toList());
|
||||
String join = CollectionUtil.join(workflowIds, ",");
|
||||
|
||||
WorkflowRequestOperatePA operatePA = getRequestOperatePA();
|
||||
|
||||
//1.获取系统流程数据,根据关账流程配置中流程id
|
||||
rs.executeQuery("select a.requestid,a.currentnodeid,a.workflowid,a.creater,b.formid from \n" +
|
||||
" workflow_requestbase a left join workflow_base b on a.workflowid = b.id \n" +
|
||||
" where a.workflowid in ("+join+") and a.currentnodetype not in (0,3)");
|
||||
|
||||
//2.根据表单id,及配置字段参数,.获取分部or部门 开始日期和结束日期
|
||||
while (rs.next()) {
|
||||
int requestid = Util.getIntValue(rs.getString("requestid"));
|
||||
int currentnodeid = Util.getIntValue(rs.getString("currentnodeid"));
|
||||
int workflowid = Util.getIntValue(rs.getString("workflowid"));
|
||||
int creater = Util.getIntValue(rs.getString("creater"));
|
||||
int formid = Math.abs(Util.getIntValue(rs.getString("formid")));
|
||||
|
||||
String tableName = "formtable_main_"+formid;
|
||||
KqCloseSet kqCloseSet = workflowList.stream()
|
||||
.filter(k -> Objects.equals(k.getWorkflowId(), workflowid))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
//3 值匹配筛选requestid
|
||||
if (checkRange(kqCloseSet,requestid,tableName,subCompanyIds,departmentIds,startDate,endDate)) {
|
||||
//4.流程干预操作
|
||||
ReqOperateRequestEntity requestParam = new ReqOperateRequestEntity();
|
||||
requestParam.setRequestId(requestid);
|
||||
requestParam.setSrc("intervenor");
|
||||
requestParam.setWorkflowId(workflowid);
|
||||
requestParam.setNodeId(currentnodeid);
|
||||
requestParam.setRemark(currentTime+"-"+lastname+"-于考勤模块统一干预处理。");
|
||||
requestParam.setEnableIntervenor(true);
|
||||
requestParam.setSubmitNodeId("0".equals(type) ? kqCloseSet.getCreateNodeId() : kqCloseSet.getEndNodeId());
|
||||
requestParam.setIntervenorid(String.valueOf(creater));
|
||||
PAResponseEntity paResponseEntity = operatePA.doIntervenor(user, requestParam);
|
||||
paResponseEntity.setExtra(requestid);
|
||||
paResponseEntities.add(paResponseEntity);
|
||||
}
|
||||
}
|
||||
|
||||
//5.更新关账记录表操作者信息
|
||||
currentTime = currentTime.substring(0, currentTime.length() - 3);
|
||||
rs.executeUpdate("update uf_kqgzjl set czr = ?, zhczsj = ? where id = ?",user.getUID(),currentTime,billid);
|
||||
|
||||
return paResponseEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KqCloseSet> getWorkflowList() {
|
||||
|
||||
List<KqCloseSet> kqCloseSets = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id,lclj,ksrqdyzdbm,jsrqdyzdbm,ssfbdyzdbm,ssbmdyzdbm,fqjdid,gdjdid from uf_kqgzpz");
|
||||
while (rs.next()) {
|
||||
kqCloseSets.add(KqCloseSet.builder()
|
||||
.id(Util.getIntValue(rs.getString("id")))
|
||||
.workflowId(Util.getIntValue(rs.getString("lclj")))
|
||||
.startDateCode(Util.null2String(rs.getString("ksrqdyzdbm")))
|
||||
.endDateCode(Util.null2String(rs.getString("jsrqdyzdbm")))
|
||||
.fbCode(Util.null2String(rs.getString("ssfbdyzdbm")))
|
||||
.bmCode(Util.null2String(rs.getString("ssbmdyzdbm")))
|
||||
.createNodeId(Util.getIntValue(rs.getString("fqjdid")))
|
||||
.endNodeId(Util.getIntValue(rs.getString("gdjdid")))
|
||||
.build());
|
||||
}
|
||||
return kqCloseSets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkSubmit(Map<String, Object> param) {
|
||||
|
||||
String subCompanyIds = Util.null2String(param.get("subCompanyIds"));
|
||||
String departmentIds = Util.null2String(param.get("departmentIds"));
|
||||
String startDate = Util.null2String(param.get("startDate"));
|
||||
String endDate = Util.null2String(param.get("endDate"));
|
||||
|
||||
boolean result = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql = "select id from uf_kqgzjl where ksrq <= ? and jsrq >= ? and gbzt in (1,2)";
|
||||
String sql1 = "select id from uf_kqgzjl where ksrq <= ? and jsrq >= ? and gbzt in (1,2)";
|
||||
|
||||
if(!subCompanyIds.isEmpty()) {
|
||||
//like
|
||||
sql += " and gzfb is not null and (','||gzfb||',' like '%,"+subCompanyIds+",%')";
|
||||
rs.executeQuery(sql,endDate,startDate);
|
||||
result = rs.getCounts()>0;
|
||||
}
|
||||
|
||||
if (!departmentIds.isEmpty() && !result) {
|
||||
sql1 += " and gzbm is not null and (','||gzbm||',' like '%,"+departmentIds+",%')";
|
||||
rs.executeQuery(sql1,endDate,startDate);
|
||||
result = rs.getCounts()>0;
|
||||
}
|
||||
rs.writeLog("KqCloseAccountServiceImpl:checkSubmit:"+sql);
|
||||
rs.writeLog("KqCloseAccountServiceImpl:checkSubmit1:"+sql1);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验流程内容 是否属于本条关账范围内
|
||||
* @return
|
||||
*/
|
||||
private Boolean checkRange(KqCloseSet kqCloseSet,int requestid,String tableName,
|
||||
String subCompanyIds,String departmentIds,String startDate,String endDate) {
|
||||
|
||||
boolean result = false;
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String sql = "select id from "+tableName+" where requestid = ? and "+kqCloseSet.getStartDateCode()+" <= ? and "+kqCloseSet.getEndDateCode()+" >= ?";
|
||||
String sql1 = "select id from "+tableName+" where requestid = ? and "+kqCloseSet.getStartDateCode()+" <= ? and "+kqCloseSet.getEndDateCode()+" >= ?";
|
||||
|
||||
if(!subCompanyIds.isEmpty()) {
|
||||
String fbCode = kqCloseSet.getFbCode();
|
||||
sql += " and "+fbCode+" is not null and "+fbCode+" in ("+subCompanyIds+")";
|
||||
rs.executeQuery(sql,requestid,endDate,startDate);
|
||||
result = rs.getCounts()>0;
|
||||
}
|
||||
|
||||
if (!departmentIds.isEmpty() && !result) {
|
||||
String bmCode = kqCloseSet.getBmCode();
|
||||
sql1 += " and "+bmCode+" is not null and "+bmCode+" in ("+departmentIds+")";
|
||||
rs.executeQuery(sql1,requestid,endDate,startDate);
|
||||
result = rs.getCounts()>0;
|
||||
}
|
||||
|
||||
rs.writeLog("KqCloseAccountServiceImpl:checkRange:"+sql);
|
||||
rs.writeLog("KqCloseAccountServiceImpl:checkRange1:"+sql1);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.engine.xmgsecond.util;
|
|||
|
||||
import com.engine.xmgsecond.entity.KqFormatTotal;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -20,7 +19,7 @@ public class KqCalulateUtil {
|
|||
|
||||
|
||||
/**
|
||||
* @Description: 时间范围内 考勤异常汇总成缺勤天数
|
||||
* @Description: 时间范围内 考勤报表 增加缺勤天数
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2025/5/14 16:22
|
||||
* @param: [resourceId, fromDate, toDate]
|
||||
|
|
@ -29,12 +28,13 @@ public class KqCalulateUtil {
|
|||
public static List<KqFormatTotal> abnormalAttendance(String resourceId,String fromDate,String toDate) {
|
||||
RecordSet rs = new RecordSet();
|
||||
List<KqFormatTotal> kqFormatTotalList = new ArrayList<>();
|
||||
rs.executeQuery("select resourceid, forgotCheck, absenteeism, beLateMins, gravebeLateMins, leaveEearly, " +
|
||||
rs.executeQuery("select resourceid, forgotCheck,forgotbeginworkcheck, absenteeism, beLateMins, gravebeLateMins, leaveEearly, " +
|
||||
" graveLeaveEarly from kq_format_total where resourceid = ? and kqdate >= '"+fromDate+"' and kqdate <= '"+toDate+"'",resourceId);
|
||||
while (rs.next()) {
|
||||
boolean isAbsence;
|
||||
int absenteeism = Util.getIntValue(rs.getString("absenteeism"));
|
||||
int forgotCheck = Util.getIntValue(rs.getString("forgotCheck"));
|
||||
int forgotbeginworkcheck = Util.getIntValue(rs.getString("forgotbeginworkcheck"));
|
||||
int beLateMins = Util.getIntValue(rs.getString("beLateMins"),0);
|
||||
int gravebeLateMins = Util.getIntValue(rs.getString("gravebeLateMins"),0);
|
||||
int leaveEearly = Util.getIntValue(rs.getString("leaveEearly"));
|
||||
|
|
@ -43,6 +43,7 @@ public class KqCalulateUtil {
|
|||
//规则1
|
||||
isAbsence = isPositive(absenteeism) ||
|
||||
isPositive(forgotCheck) ||
|
||||
isPositive(forgotbeginworkcheck) ||
|
||||
sumPositive(leaveEearly, graveLeaveEarly) > 0;
|
||||
|
||||
kqFormatTotalList.add(KqFormatTotal.builder()
|
||||
|
|
@ -70,6 +71,59 @@ public class KqCalulateUtil {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 时间范围内 考勤报表 增加夜班天数
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2025/5/16 09:28
|
||||
* @param: [resourceId, fromDate, toDate]
|
||||
* @return: int
|
||||
*/
|
||||
public static int nightWorkSums(String resourceId,String fromDate,String toDate){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
int count = 0;
|
||||
rs.executeQuery(" select a.kqdate,a.serialid,a.belatemins,a.leaveearlymins,a.absenteeismmins,a.forgotcheckMins,a.leaveMins,\n" +
|
||||
" a.evectionMins,a.outMins,b.serial,b.is_rest,b.shiftonoffworkcount from kq_format_total a \n" +
|
||||
" left join kq_ShiftManagement b on a.serialid = b.id where a.resourceid = ? and a.kqdate >= '"+fromDate+"' and a.kqdate <= '"+toDate+"'",resourceId);
|
||||
while (rs.next()) {
|
||||
int serialid = Util.getIntValue(rs.getString("serialid"));
|
||||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||||
if(serialid == -1) {
|
||||
continue;
|
||||
}
|
||||
int isRest = Util.getIntValue(rs.getString("is_rest"));
|
||||
if (isRest == 1) {
|
||||
//1.休息班
|
||||
if (Util.getIntValue(rs.getString("shiftonoffworkcount")) == 1){
|
||||
//一天一次上下班卡
|
||||
if (calculateClockTime(resourceId,kqdate,serialid)){
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
//2.非休息班
|
||||
String serial = Util.null2String(rs.getString("serial"));
|
||||
if (serial.contains("夜班")) {
|
||||
int beLateMins = Util.getIntValue(rs.getString("beLateMins"),0);
|
||||
int leaveearlymins = Util.getIntValue(rs.getString("leaveearlymins"),0);
|
||||
int absenteeismmins = Util.getIntValue(rs.getString("absenteeismmins"),0);
|
||||
int forgotcheckMins = Util.getIntValue(rs.getString("forgotcheckMins"),0);
|
||||
int leaveMins = Util.getIntValue(rs.getString("leaveMins"),0);
|
||||
int evectionMins = Util.getIntValue(rs.getString("evectionMins"),0);
|
||||
int outMins = Util.getIntValue(rs.getString("outMins"),0);
|
||||
if (beLateMins == 0 && leaveearlymins == 0 && absenteeismmins == 0 && forgotcheckMins == 0
|
||||
&& leaveMins == 0 && evectionMins == 0 && outMins == 0) {
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPositive(Integer num) {
|
||||
return Optional.ofNullable(num).orElse(0) > 0;
|
||||
}
|
||||
|
|
@ -94,5 +148,12 @@ public class KqCalulateUtil {
|
|||
return Optional.ofNullable(a).orElse(0) + Optional.ofNullable(b).orElse(0);
|
||||
}
|
||||
|
||||
public static boolean calculateClockTime(String resourceId,String kqDate,int serialid){
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select resourceid,kqdate,signintime,signouttime from kq_format_detail where kqdate = '"+kqDate+"' and signoutdate > '"+kqDate+"' and resourceid = ? and serialid = ? \n" +
|
||||
" and signintime >= '18:00:00' and signintime <= '20:30:00' and signouttime >= '05:30:00'",resourceId,serialid);
|
||||
return rs.getCounts() > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
package com.engine.xmgsecond.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.xmgsecond.service.KqCloseAccountService;
|
||||
import com.engine.xmgsecond.service.impl.KqCloseAccountServiceImpl;
|
||||
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.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/16 15:15
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class KqCloseAccountAction {
|
||||
|
||||
private KqCloseAccountService getService(User user) {
|
||||
return ServiceUtil.getService(KqCloseAccountServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/closeAccount")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String closeAccount(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
Map<String, Object> data = new HashMap<>(8);
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
data.put("data",getService(user).closeAccount(ParamUtil.request2Map(request)));
|
||||
data.put("code", 200);
|
||||
} catch (Exception e) {
|
||||
data.put("code", 500);
|
||||
data.put("msg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/getWorkflowList")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String getWorkflowList(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
Map<String, Object> data = new HashMap<>(8);
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
data.put("data",getService(user).getWorkflowList());
|
||||
data.put("code", 200);
|
||||
} catch (Exception e) {
|
||||
data.put("code", 500);
|
||||
data.put("msg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/checkSubmit")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String checkSubmit(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
Map<String, Object> data = new HashMap<>(8);
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
data.put("data",getService(user).checkSubmit(ParamUtil.request2Map(request)));
|
||||
data.put("code", 200);
|
||||
} catch (Exception e) {
|
||||
data.put("code", 500);
|
||||
data.put("msg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package test;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description:
|
||||
* @Date 2022/10/9
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class MainTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
package weaver.interfaces.xmgsecond;
|
||||
|
||||
import com.engine.kq.biz.KQLeaveRulesComInfo;
|
||||
import com.engine.kq.biz.KQUsageHistoryBiz;
|
||||
import com.engine.kq.entity.KQUsageHistoryEntity;
|
||||
import com.engine.kq.jucailin.util.KQDateUtil;
|
||||
import com.weaver.general.TimeUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/15 14:10
|
||||
* @Description: 新美光假期额度申请流程
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class BalanceOfLeaveAction implements Action{
|
||||
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
String requestid = requestInfo.getRequestid();
|
||||
int formid = Math.abs(requestInfo.getRequestManager().getFormid());
|
||||
RecordSet rs = new RecordSet();
|
||||
String mainTable = String.format("%s%s", "formtable_main_", formid);
|
||||
|
||||
|
||||
String currentDate = TimeUtil.getCurrentDateString();
|
||||
String currentTime = TimeUtil.getOnlyCurrentTimeString();
|
||||
java.sql.Timestamp date = KQDateUtil.getUpdateTimeStamp();
|
||||
// String creator = requestInfo.getRequestManager().getCurrentOperator().;
|
||||
String creator = "1";
|
||||
|
||||
rs.executeQuery("select xm,edssny,qjlx,ewsfed from "+mainTable+" where requestid = ?",requestid);
|
||||
rs.next();
|
||||
//假期类型的ID
|
||||
String leaveRulesId = Util.null2String(rs.getString("qjlx"));
|
||||
String searchYear = Util.null2String(rs.getString("edssny"));
|
||||
String resourceId = Util.null2String(rs.getString("xm"));
|
||||
double extraAmount = Util.getDoubleValue(rs.getString("ewsfed"), 0);
|
||||
//获取假期类型的缓存类
|
||||
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
|
||||
//请假最小单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假
|
||||
String minimumUnit = kqLeaveRulesComInfo.getMinimumUnit(leaveRulesId);
|
||||
String insertOrUpdate = "";
|
||||
String oldBaseAmount = "0";
|
||||
String oldUsedAmount = "0";
|
||||
String oldExtraAmount = "0";
|
||||
String oldBaseAmount2 = "0";
|
||||
String oldUsedAmount2 = "0";
|
||||
String oldExtraAmount2 = "0";
|
||||
|
||||
String newExtraAmount = "0";
|
||||
|
||||
boolean flag = true;
|
||||
//在数据库里是否已经存在记录了
|
||||
rs.executeQuery("select baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2 from kq_BalanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=? order by id", leaveRulesId, resourceId, searchYear);
|
||||
if (rs.next()) {
|
||||
|
||||
oldBaseAmount = "" + Util.getDoubleValue(rs.getString("baseAmount"), 0);
|
||||
oldExtraAmount = "" + Util.getDoubleValue(rs.getString("extraAmount"), 0);
|
||||
oldUsedAmount = "" + Util.getDoubleValue(rs.getString("usedAmount"), 0);
|
||||
|
||||
oldBaseAmount2 = "" + Util.getDoubleValue(rs.getString("baseAmount2"), 0);
|
||||
oldExtraAmount2 = "" + Util.getDoubleValue(rs.getString("extraAmount2"), 0);
|
||||
oldUsedAmount2 = "" + Util.getDoubleValue(rs.getString("usedAmount2"), 0);
|
||||
|
||||
newExtraAmount = String.valueOf(extraAmount + Util.getDoubleValue(rs.getString("extraAmount"), 0));
|
||||
insertOrUpdate = "update";
|
||||
|
||||
|
||||
String updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,update_time=? where leaveRulesId=? and resourceId=? and belongYear=?";
|
||||
flag = rs.executeUpdate(updateSql, oldBaseAmount, newExtraAmount, oldUsedAmount, oldBaseAmount2, oldExtraAmount2, oldUsedAmount2,date, leaveRulesId, resourceId, searchYear);
|
||||
|
||||
if (!flag) {
|
||||
requestInfo.getRequestManager().setMessagecontent("更新员工假期余额失败");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
}else {
|
||||
newExtraAmount = "" + extraAmount;
|
||||
insertOrUpdate = "insert";
|
||||
|
||||
String insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,leaveRulesId,resourceId,belongYear,create_time,update_time,creator) values(?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(insertSql, oldBaseAmount, newExtraAmount, oldUsedAmount, oldBaseAmount2, oldExtraAmount2, oldUsedAmount2, leaveRulesId, resourceId, searchYear,date,date,creator);
|
||||
|
||||
|
||||
|
||||
if (!flag) {
|
||||
requestInfo.getRequestManager().setMessagecontent("新增员工假期余额失败");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
List<KQUsageHistoryEntity> usageHistoryEntityList = new ArrayList<>();
|
||||
KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity();
|
||||
usageHistoryEntity.setLeaveRulesId(leaveRulesId);
|
||||
usageHistoryEntity.setRelatedId(resourceId);
|
||||
usageHistoryEntity.setOperator(creator);
|
||||
usageHistoryEntity.setOperateDate(currentDate);
|
||||
usageHistoryEntity.setOperateTime(currentTime);
|
||||
usageHistoryEntity.setOperateType("5");
|
||||
usageHistoryEntity.setBelongYear(searchYear);
|
||||
usageHistoryEntity.setOldBaseAmount(oldBaseAmount);
|
||||
usageHistoryEntity.setNewBaseAmount(oldBaseAmount);
|
||||
usageHistoryEntity.setOldExtraAmount(oldExtraAmount);
|
||||
usageHistoryEntity.setNewExtraAmount(newExtraAmount);
|
||||
usageHistoryEntity.setOldUsedAmount(oldUsedAmount);
|
||||
usageHistoryEntity.setNewUsedAmount(oldUsedAmount);
|
||||
usageHistoryEntity.setOldBaseAmount2(oldBaseAmount2);
|
||||
usageHistoryEntity.setNewBaseAmount2(oldBaseAmount2);
|
||||
usageHistoryEntity.setOldExtraAmount2(oldExtraAmount2);
|
||||
usageHistoryEntity.setNewExtraAmount2(oldExtraAmount2);
|
||||
usageHistoryEntity.setOldUsedAmount2(oldUsedAmount2);
|
||||
usageHistoryEntity.setNewUsedAmount2(oldUsedAmount2);
|
||||
usageHistoryEntity.setOldMinimumUnit(minimumUnit);
|
||||
usageHistoryEntity.setNewMinimumUnit(minimumUnit);
|
||||
usageHistoryEntity.setInsertOrUpdate(insertOrUpdate);
|
||||
|
||||
usageHistoryEntityList.add(usageHistoryEntity);
|
||||
|
||||
|
||||
if (usageHistoryEntityList.size() > 0) {
|
||||
KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz();
|
||||
flag = usageHistoryBiz.save(usageHistoryEntityList);
|
||||
if (!flag) {
|
||||
requestInfo.getRequestManager().setMessagecontent("员工假期余额变更记录日志失败");
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package weaver.interfaces.xmgsecond;
|
||||
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/5/16 14:25
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class TestWorkAction implements Action {
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
bb.writeLog("TestWorkAction1: 执行流程节点附件操作");
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue