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

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();
@Override
public Map<String, Object> addAllowanceRecords(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
try {
//获取modeId考勤方案的modeId
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<>();
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<>();
for (Map<String, Object> map : bcData) {
String bcArr = map.get("sydbc").toString();
String allowanceId = map.get("id").toString();
allowanceIdWithKqxmInfo.put(allowanceId, map);
List<String> bcList = Arrays.asList(bcArr.split(","));
targetBcIdList.addAll(bcList);
bcList.forEach(f -> {
List<String> values = new ArrayList<>();
if (bcWithAllowanceInfo.get(f) == null) {
values.add(allowanceId);
bcWithAllowanceInfo.put(f, values);
} else {
bcWithAllowanceInfo.get(f).add(allowanceId);
}
});
if (targetAllowanceIdList.size() > 0) {
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);
for (Map<String, Object> map : bcData) {
String bcArr = map.get("sydbc").toString();
String allowanceId = map.get("id").toString();
allowanceIdWithKqxmInfo.put(allowanceId, map);
List<String> bcList = Arrays.asList(bcArr.split(","));
targetBcIdList.addAll(bcList);
bcList.forEach(f -> {
List<String> values = new ArrayList<>();
if (bcWithAllowanceInfo.get(f) == null) {
values.add(allowanceId);
bcWithAllowanceInfo.put(f, values);
} else {
bcWithAllowanceInfo.get(f).add(allowanceId);
}
});
}
}
//获取出勤结果,遍历处理津贴信息
String startDate = Util.null2String(params.get("startDate"));
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 +"'"
+ " and bc in ("+String.join(",",targetBcIdList) + ")";
List<Map<String, Object>> cqData = DbTools.getSqlToList(cqSql);
List<Map<String, Object>> cqData = new ArrayList<>();
if (targetEmpIdList.size() > 0 && targetBcIdList.size() > 0) {
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("empIdWithAllowanceInfo : " + empIdWithAllowanceInfo);
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);
bs.writeLog("allowanceInfoList_size : " + allowanceInfoList.size());
//新增津贴数据,先删后加
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) + ")";
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(?,?,?,?,?,?)";
for (Map<String, String> map : allowanceInfoList) {
List<String> list = new ArrayList<>();
list.add(map.get("szjg"));
list.add(map.get("yg"));
list.add(map.get("rq"));
list.add(map.get("bc"));
list.add(map.get("jtlx"));
list.add(map.get("sc"));
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) + ")";
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(?,?,?,?,?,?)";
for (Map<String, String> map : allowanceInfoList) {
List<String> list = new ArrayList<>();
list.add(map.get("szjg"));
list.add(map.get("yg"));
list.add(map.get("rq"));
list.add(map.get("bc"));
list.add(map.get("jtlx"));
list.add(map.get("sc"));
dataList.add(list);
}
bs.writeLog("dataList_size : " + dataList.size());
if(dataList.size() > 0){
RecordSet rs = new RecordSet();
bs.writeLog("津贴数据记录入库开始---");
boolean insertSign =rs.executeBatchSql(insertSql,dataList);
bs.writeLog("insertSign : " + insertSign);
dataList.add(list);
}
bs.writeLog("dataList_size : " + dataList.size());
if(dataList.size() > 0){
RecordSet rs = new RecordSet();
bs.writeLog("津贴数据记录入库开始---");
boolean insertSign =rs.executeBatchSql(insertSql,dataList);
bs.writeLog("insertSign : " + insertSign);
result.put("result", insertSign);
}
}
} catch (Exception 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

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

Loading…
Cancel
Save