考勤,出勤津贴数据生成逻辑优化

zm_dev
sy 1 year ago
parent 5b933ca3bf
commit 892d22415e

@ -24,6 +24,8 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
BaseBean bs = new BaseBean(); BaseBean bs = new BaseBean();
@Override @Override
public Map<String, Object> addAllowanceRecords(Map<String, Object> params) { public Map<String, Object> addAllowanceRecords(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
try { try {
//获取modeId考勤方案的modeId //获取modeId考勤方案的modeId
Map<String,String> formmodeIdMap = Utils.getFormmodeIdMap(); Map<String,String> formmodeIdMap = Utils.getFormmodeIdMap();
@ -64,31 +66,37 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
} }
//构建班次和津贴映射关系 //构建班次和津贴映射关系
Map<String, Map<String, Object>> allowanceIdWithKqxmInfo = new HashMap<>(); Map<String, Map<String, Object>> allowanceIdWithKqxmInfo = new HashMap<>();
String bcSql = "select * from uf_jcl_kq_kqxm where id in ("+String.join(",",targetAllowanceIdList) + ") and sydbc is not null ";
List<Map<String, Object>> bcData = DbTools.getSqlToList(bcSql);
Map<String, List<String>> bcWithAllowanceInfo = new HashMap<>(); Map<String, List<String>> bcWithAllowanceInfo = new HashMap<>();
for (Map<String, Object> map : bcData) { if (targetAllowanceIdList.size() > 0) {
String bcArr = map.get("sydbc").toString(); String bcSql = "select * from uf_jcl_kq_kqxm where id in ("+String.join(",",targetAllowanceIdList) + ") and sydbc is not null ";
String allowanceId = map.get("id").toString(); List<Map<String, Object>> bcData = DbTools.getSqlToList(bcSql);
allowanceIdWithKqxmInfo.put(allowanceId, map); for (Map<String, Object> map : bcData) {
List<String> bcList = Arrays.asList(bcArr.split(",")); String bcArr = map.get("sydbc").toString();
targetBcIdList.addAll(bcList); String allowanceId = map.get("id").toString();
bcList.forEach(f -> { allowanceIdWithKqxmInfo.put(allowanceId, map);
List<String> values = new ArrayList<>(); List<String> bcList = Arrays.asList(bcArr.split(","));
if (bcWithAllowanceInfo.get(f) == null) { targetBcIdList.addAll(bcList);
values.add(allowanceId); bcList.forEach(f -> {
bcWithAllowanceInfo.put(f, values); List<String> values = new ArrayList<>();
} else { if (bcWithAllowanceInfo.get(f) == null) {
bcWithAllowanceInfo.get(f).add(allowanceId); values.add(allowanceId);
} bcWithAllowanceInfo.put(f, values);
}); } else {
bcWithAllowanceInfo.get(f).add(allowanceId);
}
});
}
} }
//获取出勤结果,遍历处理津贴信息 //获取出勤结果,遍历处理津贴信息
String startDate = Util.null2String(params.get("startDate")); String startDate = Util.null2String(params.get("startDate"));
String endDate = Util.null2String(params.get("endDate")); String endDate = Util.null2String(params.get("endDate"));
String cqSql = "select * from uf_jcl_kq_cqjg where ygid in ("+String.join(",",targetEmpIdList) + ") and rq >= '" + startDate +"'" + " and rq <= '" + endDate +"'" List<Map<String, Object>> cqData = new ArrayList<>();
+ " and bc in ("+String.join(",",targetBcIdList) + ")"; if (targetEmpIdList.size() > 0 && targetBcIdList.size() > 0) {
List<Map<String, Object>> cqData = DbTools.getSqlToList(cqSql); String cqSql = "select * from uf_jcl_kq_cqjg where ygid in ("+String.join(",",targetEmpIdList) + ") and rq >= '" + startDate +"'" + " and rq <= '" + endDate +"'"
+ " and bc in ("+String.join(",",targetBcIdList) + ")";
cqData = DbTools.getSqlToList(cqSql);
}
bs.writeLog("cqData_size : " + cqData.size()); bs.writeLog("cqData_size : " + cqData.size());
bs.writeLog("empIdWithAllowanceInfo : " + empIdWithAllowanceInfo); bs.writeLog("empIdWithAllowanceInfo : " + empIdWithAllowanceInfo);
bs.writeLog("bcWithAllowanceInfo : " + bcWithAllowanceInfo); bs.writeLog("bcWithAllowanceInfo : " + bcWithAllowanceInfo);
@ -96,36 +104,40 @@ public class AllowanceServiceImpl extends Service implements AllowanceService {
//获取待新增的津贴数据 //获取待新增的津贴数据
List<Map<String, String>> allowanceInfoList = createAllowanceInfo(cqData, empIdWithAllowanceInfo, bcWithAllowanceInfo, allowanceIdWithKqxmInfo); List<Map<String, String>> allowanceInfoList = createAllowanceInfo(cqData, empIdWithAllowanceInfo, bcWithAllowanceInfo, allowanceIdWithKqxmInfo);
bs.writeLog("allowanceInfoList_size : " + allowanceInfoList.size()); bs.writeLog("allowanceInfoList_size : " + allowanceInfoList.size());
//新增津贴数据,先删后加 if (allowanceInfoList.size() > 0) {
String delSql = "delete from uf_jcl_kq_cqjt where rq >= '" + startDate +"'" + " and rq <= '" + endDate +"'" //新增津贴数据,先删后加
+ " and yg in (" + String.join(",",targetEmpIdList) + ") and bc in (" + String.join(",",targetBcIdList) + ")"; String delSql = "delete from uf_jcl_kq_cqjt where rq >= '" + startDate +"'" + " and rq <= '" + endDate +"'"
boolean delSign = DbTools.update(delSql); + " and yg in (" + String.join(",",targetEmpIdList) + ") and bc in (" + String.join(",",targetBcIdList) + ")";
bs.writeLog("delSign : " + delSign + ", delSql : " + delSql); boolean delSign = DbTools.update(delSql);
//插入津贴数据 bs.writeLog("delSign : " + delSign + ", delSql : " + delSql);
List<List> dataList = new ArrayList<>(); //插入津贴数据
String insertSql = " insert into uf_jcl_kq_cqjt(szjg,yg,rq,bc,jtlx,sc) values(?,?,?,?,?,?)"; List<List> dataList = new ArrayList<>();
for (Map<String, String> map : allowanceInfoList) { String insertSql = " insert into uf_jcl_kq_cqjt(szjg,yg,rq,bc,jtlx,sc) values(?,?,?,?,?,?)";
List<String> list = new ArrayList<>(); for (Map<String, String> map : allowanceInfoList) {
list.add(map.get("szjg")); List<String> list = new ArrayList<>();
list.add(map.get("yg")); list.add(map.get("szjg"));
list.add(map.get("rq")); list.add(map.get("yg"));
list.add(map.get("bc")); list.add(map.get("rq"));
list.add(map.get("jtlx")); list.add(map.get("bc"));
list.add(map.get("sc")); list.add(map.get("jtlx"));
list.add(map.get("sc"));
dataList.add(list); dataList.add(list);
} }
bs.writeLog("dataList_size : " + dataList.size()); bs.writeLog("dataList_size : " + dataList.size());
if(dataList.size() > 0){ if(dataList.size() > 0){
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
bs.writeLog("津贴数据记录入库开始---"); bs.writeLog("津贴数据记录入库开始---");
boolean insertSign =rs.executeBatchSql(insertSql,dataList); boolean insertSign =rs.executeBatchSql(insertSql,dataList);
bs.writeLog("insertSign : " + insertSign); bs.writeLog("insertSign : " + insertSign);
result.put("result", insertSign);
}
} }
} catch (Exception e) { } catch (Exception e) {
bs.errorLog("catch error :{}",e); bs.errorLog("catch error :{}",e);
} }
return null; return result;
} }
private List<Map<String, String>> createAllowanceInfo(List<Map<String, Object>> cqData, Map<String, List<String>> empIdWithAllowanceInfo, Map<String private List<Map<String, String>> createAllowanceInfo(List<Map<String, Object>> cqData, Map<String, List<String>> empIdWithAllowanceInfo, Map<String

@ -282,7 +282,7 @@ public class CommonUtil {
String minSecurityLevel = map.get("minSecurityLevel"); String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel"); String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息 //查询目标人员信息
String querySql = "select * from hrmresouorce where id = " + id; String querySql = "select * from hrmresource where id = " + id;
if (!minSecurityLevel.equals("")) { if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel; querySql = querySql + " and seclevel >= " +minSecurityLevel;
} }
@ -301,17 +301,20 @@ public class CommonUtil {
String maxSecurityLevel = map.get("maxSecurityLevel"); String maxSecurityLevel = map.get("maxSecurityLevel");
//获取分组包含人员id //获取分组包含人员id
List<String> empIdsByGroup = getEmpGroupUserIds(id); List<String> empIdsByGroup = getEmpGroupUserIds(id);
log.info("empGroupId : " + id + ", empIdsByGroup : " + empIdsByGroup);
//查询目标人员信息 //查询目标人员信息
String querySql = "select * from hrmresouorce where id = in ("+String.join(",",empIdsByGroup)+")"; if (empIdsByGroup.size() > 0) {
if (!minSecurityLevel.equals("")) { String querySql = "select * from hrmresource where id = in ("+String.join(",",empIdsByGroup)+")";
querySql = querySql + " and seclevel >= " +minSecurityLevel; if (!minSecurityLevel.equals("")) {
} querySql = querySql + " and seclevel >= " +minSecurityLevel;
if (!maxSecurityLevel.equals("")) { }
querySql = querySql + " and seclevel <= " +maxSecurityLevel; if (!maxSecurityLevel.equals("")) {
} querySql = querySql + " and seclevel <= " +maxSecurityLevel;
List<Map<String,Object>> datas = DbTools.getSqlToList(querySql); }
if (datas.size() > 0) { List<Map<String,Object>> datas = DbTools.getSqlToList(querySql);
datas.forEach(f -> empIdList.add(f.get("id").toString())); if (datas.size() > 0) {
datas.forEach(f -> empIdList.add(f.get("id").toString()));
}
} }
} }
//部门类型 //部门类型
@ -320,7 +323,7 @@ public class CommonUtil {
String minSecurityLevel = map.get("minSecurityLevel"); String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel"); String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息 //查询目标人员信息
String querySql = "select * from hrmresouorce where departmentid = " + id; String querySql = "select * from hrmresource where departmentid = " + id;
if (!minSecurityLevel.equals("")) { if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel; querySql = querySql + " and seclevel >= " +minSecurityLevel;
} }
@ -338,7 +341,7 @@ public class CommonUtil {
String minSecurityLevel = map.get("minSecurityLevel"); String minSecurityLevel = map.get("minSecurityLevel");
String maxSecurityLevel = map.get("maxSecurityLevel"); String maxSecurityLevel = map.get("maxSecurityLevel");
//查询目标人员信息 //查询目标人员信息
String querySql = "select * from hrmresouorce where subcompanyid1 = " + id; String querySql = "select * from hrmresource where subcompanyid1 = " + id;
if (!minSecurityLevel.equals("")) { if (!minSecurityLevel.equals("")) {
querySql = querySql + " and seclevel >= " +minSecurityLevel; querySql = querySql + " and seclevel >= " +minSecurityLevel;
} }

Loading…
Cancel
Save