Compare commits

..

27 Commits

Author SHA1 Message Date
Chengliang 358853f9a5 东方骏驰 考勤异常统计报表 7 months ago
Chengliang 48ca746685 补充 人员考勤数据到建模台账 uf_kqgs (人员排班在打卡之后导致) 7 months ago
Chengliang 5bcb90b643 补充 人员考勤数据到建模台账 uf_kqgs (人员排班在打卡之后导致) 7 months ago
Chengliang fd5b0a9c1e 东方骏驰人花名册快照状态存储文本 9 months ago
Chengliang bd91ee4b56 东方骏驰人事花名册增加高级搜索功能 9 months ago
Chengliang 879b10ebf6 东方骏驰人事花名册导出功能 9 months ago
Chengliang b487fd6087 东方骏驰人事花名册导出功能 9 months ago
Chengliang 97f0edc056 东方骏驰人事花名册功能 9 months ago
Chengliang 05d0a85816 东方骏驰花名册快照修复功能 9 months ago
Chengliang a029071999 东方骏驰工价计算历史人员相关代码同步 9 months ago
Chengliang 80b285ce56 东方骏驰工价计算历史人员相关代码同步 9 months ago
Chengliang 933fcd2e37 东方骏驰花名册快照table,及台账导出功能 9 months ago
Chengliang cfcc208fc4 东方骏驰花名册快照table,及台账导出功能 9 months ago
Chengliang c3cb0dceec 东方骏驰花名册快照定时任务 9 months ago
Chengliang db81a00b41 东方骏驰日期改造 10 months ago
Chengliang 33775509af sql bug修复 1 year ago
Chengliang e72c2f98f2 批量调整工时 流程明细带入 1 year ago
Chengliang 5b4ff6612e 这个人这天的班次有没有设置休息时长,设置了的扣1小时再向下取整,没有设置休息时长的,不扣减1小时,直接向下取整 1 year ago
Chengliang 939758db45 增加按照月份和部门自定义同步 1 year ago
Chengliang bca7c6eb0e 增加按照月份和部门自定义同步 1 year ago
Chengliang 0a9c52769d 1、调整实际工时时长
2、状态为锁定时,手动同步及定时任务更新均不改变原来的数据
3、增加出差时长统计
1 year ago
Chengliang 98b7843757 嵌入他人开发文件基础上增加二开需求 1 year ago
Chengliang e88632d12f 修复打卡数据同步考勤月 1 year ago
Chengliang 945c64e80b 盛世科技插入需求 刷新人员安全级别 2 years ago
Chengliang 52595871dd 东方骏驰bug修复 2 years ago
Chengliang b851526e98 东方骏驰打卡数据 补卡数据更新建模表 2 years ago
Chengliang fe7fde8ac0 东方骏驰打卡数据 补卡数据更新建模表 2 years ago

1
.gitignore vendored

@ -8,6 +8,7 @@ target/
.idea
/test
/src/test/
/src/rebel.xml
/src/META-INF
/WEB-INF/config

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

@ -0,0 +1,16 @@
#东方骏驰花名册快照自定义字段
#银行卡号
account=field31
#银行名称
bankField=field34
#户籍地址
regresidentplace=field18
#首次参保日期
femdate=field11
#建模快照数据模块id
modeId=77
#考勤工时统计台账模块id
kqModeid=77

@ -0,0 +1,711 @@
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.conn.RecordSetDataSource" %>
<%@ page import="cn.hutool.core.date.DateUtil" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="com.wbi.util.StringUtil" %>
<%@ page import="java.math.BigDecimal" %>
<%@ page import="java.math.RoundingMode" %>
<%@ page import="java.util.stream.Collectors" %>
<%@ page import="weaver.formmode.setup.ModeRightInfo" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.interfaces.dfjc.entity.ProWagDetPO" %>
<%@ page import="com.google.gson.Gson" %>
<%@ page import="java.time.format.DateTimeFormatter" %>
<%@ page import="java.time.LocalDate" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
out.print("-----------SyncDfjcUatBatch start-------------");
BaseBean basebean = new BaseBean();
String fromdate = request.getParameter("fromdate");
String todate = request.getParameter("todate");
RecordSetDataSource rsds = new RecordSetDataSource();
RecordSet rs = new RecordSet();
//获取当前年月日
String today = DateUtil.format(new Date(),"yyyy-MM-dd");
// //获取当前年月
// String nowMonth = DateUtil.format(new Date(),"yyyy-MM");
// //获取当前年
// String nowYear = DateUtil.format(new Date(),"yyyy");
try {
basebean.writeLog("------------SyncDfjcUatBatch Try-----------");
//计算出开始日期和结束日期之间的每个日期
List<String> everyDate = getEveryDate(fromdate, todate);
for ( String syncdate : everyDate ) {
basebean.writeLog("syncdate: " + syncdate);
//2023-11-22
String nowYear = syncdate.substring(0,4);
basebean.writeLog("nowYear: " + nowYear);
String nowMonth = syncdate.substring(0,7);
basebean.writeLog("nowMonth: " + nowMonth);
//获取基础数据
List<Map<String, String>> baseDatasList = new ArrayList<>();
Map<String, String> baseDataMap = new HashMap<>();
//// String acqBaseDatasSql = " select lhid, rksl from uf_u9dddj where rksj = ?";
//String acqBaseDatasSql = " SELECT Item, EligibleQty from MO_CompleteRpt WHERE CAST(ActualRcvTime AS DATE) = ? and DocState = 3";
String acqBaseDatasSql = " SELECT a.id,a.docstate,a.HandleDept, a.item,a.ActualRcvTime,a.EligibleQty,b.BusinessType FROM MO_CompleteRpt a LEFT JOIN MO_CompleteRptDocType b ON a.CompleteDocType=b.ID WHERE b.BusinessType<>48 and CAST(ActualRcvTime AS DATE) = ? and DocState = 3";
//// rs.executeQuery(acqBaseDatasSql,nowDate);
rsds.executeQueryWithDatasource( acqBaseDatasSql, "u9", syncdate);
while (rsds.next()) {
String lhid = Util.null2String(rsds.getString("Item"));//料号id
String rksl = Util.null2String(rsds.getString("EligibleQty"));//入库数量
if ( StringUtil.isNotBlank(lhid) && StringUtil.isNotBlank(rksl)) {
baseDataMap = new HashMap<>();
baseDataMap.put("lhid",lhid);
baseDataMap.put("rksl",rksl);
baseDatasList.add(baseDataMap);
}
}
basebean.writeLog("------baseDatasList.size: " + baseDatasList.size() );
basebean.writeLog("------baseDatasList: " + baseDatasList );
//获取产品单价台账
Map<String, Map<String, String>> unitPricesMap = new HashMap<>();
Map<String, String> unitPriceMap = new HashMap<>();
// String scqunitPriceSql = "select id, lhid, lh, lp, cx, xncx, rklbz1, dj, rklbz2, dj2, rklbz3, dj3 from uf_cpdjb where djnd = ?";
String scqunitPriceSql = "select id, lhid, lh, lp, cx, xncx, rklbz1, dj, rklbz2, dj2, rklbz3, dj3 from uf_cpdjb ";
boolean b = rs.executeQuery( scqunitPriceSql);
basebean.writeLog("------b: " + b );
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));//产品单价id
String lhid = Util.null2String(rs.getString("lhid"));//料号id
String lh = Util.null2String(rs.getString("lh"));//料号
String lp = Util.null2String(rs.getString("lp"));//料品
String cx = Util.null2String(rs.getString("cx"));//产线
String xncx = Util.null2String(rs.getString("xncx"));//虚拟产线
String rklbz1 = Util.null2String(rs.getString("rklbz1"));//入库量标准1
String dj = Util.null2String(rs.getString("dj"));//单价1
String rklbz2 = Util.null2String(rs.getString("rklbz2"));//入库量标准2
String dj2 = Util.null2String(rs.getString("dj2"));//单价2
String rklbz3 = Util.null2String(rs.getString("rklbz3"));//入库量标准3
String dj3 = Util.null2String(rs.getString("dj3"));//单价3
if ( StringUtil.isNotBlank(lhid) && StringUtil.isNotBlank(cx) && StringUtil.isNotBlank(lp) ) {
unitPriceMap = new HashMap<>();
unitPriceMap.put("id",id);
unitPriceMap.put("lhid",lhid);
unitPriceMap.put("lh",lh);
unitPriceMap.put("lp",lp);
unitPriceMap.put("cx",cx);
unitPriceMap.put("xncx",xncx);
unitPriceMap.put("rklbz1",rklbz1);
unitPriceMap.put("dj",dj);
unitPriceMap.put("rklbz2",rklbz2);
unitPriceMap.put("dj2",dj2);
unitPriceMap.put("rklbz3",rklbz3);
unitPriceMap.put("dj3",dj3);
unitPricesMap.put(lhid,unitPriceMap);
}
}
basebean.writeLog("------unitPricesMap: " + new Gson().toJson(unitPricesMap));
//获取料号和各单价的对应关系
Map<String, Map<String, String>> lpToDjMap = new HashMap<>();
for (Map.Entry<String, Map<String, String>> entry : unitPricesMap.entrySet()) {
String lp = entry.getValue().get("lp");
String dj = entry.getValue().get("dj");
String dj2 = entry.getValue().get("dj2");
String dj3 = entry.getValue().get("dj3");
if (lpToDjMap.containsKey(lp)) {
Map<String, String> djMap = lpToDjMap.get(lp);
djMap.put("dj", dj);
djMap.put("dj2", dj2);
djMap.put("dj3", dj3);
} else {
Map<String, String> djMap = new HashMap<>();
djMap.put("dj", dj);
djMap.put("dj2", dj2);
djMap.put("dj3", dj3);
lpToDjMap.put(lp, djMap);
}
}
//获取虚拟产线和料品的对应关系
Map<String, List<String>> xncxToLpMap = new HashMap<>();
for (Map.Entry<String, Map<String, String>> entry : unitPricesMap.entrySet()) {
String xncx = entry.getValue().get("xncx");
String lp = entry.getValue().get("lp");
if (StringUtil.isNotBlank(xncx)) {
if (xncxToLpMap.containsKey(xncx)) {
List<String> lpList = xncxToLpMap.get(xncx);
lpList.add(lp);
} else {
List<String> lpList = new ArrayList<>();
lpList.add(lp);
xncxToLpMap.put(xncx, lpList);
}
}
}
//获取产线工价台账
// String checkProSql = "select count(*) as number from uf_cxgj where cxmc = ? and scyf = ? ";
//产线工价主表
String acqProMainSql = "select id from uf_cxgj where cxmc = ? and scyf = ?";
String acqProMainByMonthSql = "select id from uf_cxgj where scyf = ?";
//产线工价明细表
// String acqProDetSql = "select id, lh, lp, rkrq, cpdj, rkcl, rkje from uf_cxgj_dt1 where mainId = ?";
String acqProDetBatSql = "select id, mainid, lh, lp, rkrq, cpdj, rkcl, rkje from uf_cxgj_dt1 where mainid in ";
//产线工价明细表插入
String addProDetSql = "insert into uf_cxgj_dt1 ( mainid, lh, lp, rkrq, cpdj, rkcl, rkje ) values ( ?, ?, ?, ?, ?, ?, ? )";
//产线工价明细表修改
String editProDetSql = "update uf_cxgj_dt1 set cpdj = ? ,rkje = ? where id = ? ";
//获取当前月份的产线工价数据
// out.print("------getProDets start");
List<ProWagDetPO> proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
// out.print("------proDetList: " + proDetList );
//根据料号id处理
for ( Map<String,String> baseData:baseDatasList) {
basebean.writeLog("=================== " );
basebean.writeLog("------baseData: " + baseData );
String lhid = baseData.get("lhid");//料号id
String rksl = baseData.get("rksl");//入库数量
Map<String, String> unitPriceTmpMap = unitPricesMap.get(lhid);
if ( unitPriceTmpMap == null || unitPriceTmpMap.isEmpty() ) {
continue;
}
String id = unitPriceTmpMap.get("id");//产品单价id
String lp = unitPriceTmpMap.get("lp");//料品
String lh = unitPriceTmpMap.get("lh");//料号
String cx = unitPriceTmpMap.get("cx");//产线
String xncx = unitPriceTmpMap.get("xncx");//虚拟产线
String rklbz1 = unitPriceTmpMap.get("rklbz1");//标准1
String rklbz2 = unitPriceTmpMap.get("rklbz2");//标准2
String rklbz3 = unitPriceTmpMap.get("rklbz3");//标准3
String dj = unitPriceTmpMap.get("dj");//单价1
String dj2 = unitPriceTmpMap.get("dj2");//单价2
String dj3 = unitPriceTmpMap.get("dj3");//单价3
//是否阶梯单价
boolean stepUnitPriceFlag = true;
if ( StringUtil.isBlank(rklbz2) && StringUtil.isBlank(rklbz3)) {
stepUnitPriceFlag = false;
}
basebean.writeLog("------stepUnitPriceFlag: " + stepUnitPriceFlag );
//是否虚拟产线
boolean virProLineFlag = true;
if ( StringUtil.isBlank(xncx)) {
virProLineFlag = false;
}
basebean.writeLog("------virProLineFlag: " + virProLineFlag );
Integer mainId = -1;
rs.executeQuery( acqProMainSql, cx, nowMonth);
while (rs.next()) {
mainId = Util.getIntValue( Util.null2String( rs.getString("id")));
}
basebean.writeLog("------mainId: " + mainId );
Integer tempMainId = -1;
if ( mainId == -1) {//主表没有该产线的数据
mainId = Util.getIntValue( addProMainData(cx, nowMonth, rs));
if (cx.equals("13")) {
tempMainId = mainId;
}
}
basebean.writeLog("------mainId: " + mainId );
if ( !stepUnitPriceFlag ) {//非阶梯单价--直接插入一行明细
if ( tempMainId > 0 ) {
out.print("--dj:" + dj + "--");
out.print("--dj2:" + dj2 + "--");
out.print("--dj3:" + dj3 + "--");
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtil.isNotBlank(rksl) && StringUtil.isNotBlank(dj)) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(dj);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, dj, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {//阶梯单价
//虚拟产线
if ( !virProLineFlag ) {
//非虚拟产线,找同料号的明细
if ( proDetList.isEmpty()) {//明细表没有数据
Double unPr= 0.0;
if ( StringUtil.isBlank(dj2) ) {
unPr = Double.valueOf(dj);
} else {
if ( Double.parseDouble(rksl) < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz1)) && ( StringUtil.isNotBlank(rklbz2) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtil.isNotBlank(rksl) && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {
String finalMainId = Util.null2String(mainId);
List<ProWagDetPO> proWList = proDetList.stream()
// .filter(pro -> pro.getMainId().equals(finalMainId) && pro.getLp() != null && pro.getLp().equals(lp))
.filter(pro -> pro.getMainId().equals(finalMainId) )
.collect(Collectors.toList());
// if ( proWList.isEmpty()) {//没有同产线的明细
// Double unPr= 0.0;
// if ( StringUtil.isBlank(dj2) ) {
// unPr = Double.valueOf(dj);
// } else {
// if (Double.parseDouble(rksl) < Double.parseDouble(rklbz1)) {
// unPr = Double.valueOf(dj);
// } else if ((Double.parseDouble(rksl) >= Double.parseDouble(rklbz1)) && (StringUtil.isNotBlank(rklbz2) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz2)))) {
// unPr = Double.valueOf(dj2);
// } else if ((Double.parseDouble(rksl) >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz3)))) {
// unPr = Double.valueOf(dj3);
// }
// }
// //计算入库金额
// BigDecimal depAmount = new BigDecimal(0);
// if ( StringUtil.isNotBlank(rksl) && unPr > 0 ) {
// BigDecimal depNum = new BigDecimal(rksl);
// BigDecimal uniPri = new BigDecimal(unPr);
// depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
// }
// rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
// proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
//
// } else {
// 存在同产线的明细
Double unPr= 0.0;
List<String> rkcls = proWList.stream()
.map(pro -> pro.getStorageNumber())
.collect(Collectors.toList());
Double rkclSum = rkcls.stream()
.map(str -> Double.parseDouble(str))
.reduce(0.0, Double::sum);
rkclSum = rkclSum + Double.parseDouble(rksl);
if ( StringUtil.isBlank(dj2) ) {
unPr = Double.valueOf(dj);
} else {
if (rkclSum < Double.parseDouble(rklbz1)) {
unPr = Double.valueOf(dj);
} else if ((rkclSum >= Double.parseDouble(rklbz1)) && (StringUtil.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2)))) {
unPr = Double.valueOf(dj2);
} else if ((rkclSum >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( Double.parseDouble(rksl) > 0 && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
//处理历史明细
List<List> oldDetDatas = new ArrayList<>();
List<String> detIds = proWList.stream()
.map(pro -> pro.getId())
.collect(Collectors.toList());
Map<String, String> StoNumMap = proWList.stream()
.filter(pro -> detIds.contains(pro.getId()))
.collect(Collectors.toMap(
ProWagDetPO::getId,
ProWagDetPO::getStorageNumber
));
for (String detId : detIds) {
Integer stoNum = Util.getIntValue(StoNumMap.get(detId));
//同产线的总量 rkclSum
//获取该料品的入库数量标准和单价
for (ProWagDetPO pro : proWList) {
if (pro.getId().equals(detId)) {
pro.getLhid();
}
}
unitPriceTmpMap = unitPricesMap.get(lhid);
if ( unitPriceTmpMap == null || unitPriceTmpMap.isEmpty() ) {
continue;
}
id = unitPriceTmpMap.get("id");//产品单价id
lp = unitPriceTmpMap.get("lp");//料品
lh = unitPriceTmpMap.get("lh");//料号
cx = unitPriceTmpMap.get("cx");//产线
xncx = unitPriceTmpMap.get("xncx");//虚拟产线
rklbz1 = unitPriceTmpMap.get("rklbz1");//标准1
rklbz2 = unitPriceTmpMap.get("rklbz2");//标准2
rklbz3 = unitPriceTmpMap.get("rklbz3");//标准3
dj = unitPriceTmpMap.get("dj");//单价1
dj2 = unitPriceTmpMap.get("dj2");//单价2
dj3 = unitPriceTmpMap.get("dj3");//单价3
if ( StringUtil.isBlank(dj2) ) {
unPr = Double.valueOf(dj);
} else {
if (rkclSum < Double.parseDouble(rklbz1)) {
unPr = Double.valueOf(dj);
} else if ((rkclSum >= Double.parseDouble(rklbz1)) && (StringUtil.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2)))) {
unPr = Double.valueOf(dj2);
} else if ((rkclSum >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
}
//计算入库金额
depAmount = new BigDecimal(0);
if ( stoNum > 0 && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(stoNum);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
List tempList = new ArrayList<>();
tempList.add(unPr);
tempList.add(depAmount);
tempList.add(detId);
oldDetDatas.add(tempList);
// }
rs.executeBatchSql( editProDetSql, oldDetDatas);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
}
}
} else {
if ( proDetList.isEmpty()) {
Double unPr= 0.0;
if ( Double.parseDouble(rksl) < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz1)) && ( StringUtil.isNotBlank(rklbz2) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtil.isNotBlank(rksl) && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {
String finalMainId = Util.null2String(mainId);
List<String> lpTmpList = xncxToLpMap.get(xncx);
List<ProWagDetPO> proWList = proDetList.stream()
.filter(pro -> pro.getMainId().equals(finalMainId) && pro.getLp() != null && lpTmpList.contains(pro.getLp()))
// .filter(pro -> pro.getMainId().equals(finalMainId))
.collect(Collectors.toList());
if ( proWList.isEmpty()) {//没有同虚拟产线的明细
Double unPr= 0.0;
if ( Double.parseDouble(rksl) < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz1)) && ( StringUtil.isNotBlank(rklbz2) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtil.isNotBlank(rksl) && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {//存在同虚拟产线
Double unPr= 0.0;
String stage = "dj";
List<String> rkcls = proWList.stream()
.map(pro -> pro.getStorageNumber())
.collect(Collectors.toList());
Double rkclSum = rkcls.stream()
.map(str -> Double.parseDouble(str))
.reduce(0.0, Double::sum);
rkclSum = rkclSum + Double.parseDouble(rksl);
if ( rkclSum < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (rkclSum >= Double.parseDouble(rklbz1)) && ( StringUtil.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
stage = "dj2";
} else if ( (rkclSum >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
stage = "dj3";
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( Double.parseDouble(rksl) > 0 && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
//处理历史明细
List<List> oldDetDatas = new ArrayList<>();
List<String> detIds = proWList.stream()
.map(pro -> pro.getId())
.collect(Collectors.toList());
Map<String, Map<String, Object>> idToLpStoNumMap = proWList.stream()
.filter(proWagDetPO -> detIds.contains(proWagDetPO.getId()))
.collect(Collectors.toMap(
proWagDetPO -> proWagDetPO.getId(),
proWagDetPO -> {
Map<String, Object> innerMap = new HashMap<>();
innerMap.put("lp", proWagDetPO.getLp());
innerMap.put("storageNumber", proWagDetPO.getStorageNumber());
return innerMap;
}
));
for (String detId : detIds) {
Map<String, Object> innerMap = idToLpStoNumMap.get(detId);
//计算入库金额
depAmount = new BigDecimal(0);
String lpTmp = Util.null2String(innerMap.get("lp"));
Integer stoNumTmp = Util.getIntValue( Util.null2String(innerMap.get("storageNumber")));
// Map<String, String> djTmpMap = lpToDjMap.get(lpTmp);
// Double unPrTmp = Util.getDoubleValue(djTmpMap.get(stage));
//获取该料品的入库数量标准和单价
for (ProWagDetPO pro : proWList) {
if (pro.getId().equals(detId)) {
pro.getLhid();
}
}
unitPriceTmpMap = unitPricesMap.get(lhid);
if ( unitPriceTmpMap == null || unitPriceTmpMap.isEmpty() ) {
continue;
}
id = unitPriceTmpMap.get("id");//产品单价id
lp = unitPriceTmpMap.get("lp");//料品
lh = unitPriceTmpMap.get("lh");//料号
cx = unitPriceTmpMap.get("cx");//产线
xncx = unitPriceTmpMap.get("xncx");//虚拟产线
rklbz1 = unitPriceTmpMap.get("rklbz1");//标准1
rklbz2 = unitPriceTmpMap.get("rklbz2");//标准2
rklbz3 = unitPriceTmpMap.get("rklbz3");//标准3
dj = unitPriceTmpMap.get("dj");//单价1
dj2 = unitPriceTmpMap.get("dj2");//单价2
dj3 = unitPriceTmpMap.get("dj3");//单价3
Double unPrTmp = 0.00;
if ( StringUtil.isBlank(dj2) ) {
unPrTmp = Double.valueOf(dj);
} else {
if (rkclSum < Double.parseDouble(rklbz1)) {
unPrTmp = Double.valueOf(dj);
} else if ((rkclSum >= Double.parseDouble(rklbz1)) && (StringUtil.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2)))) {
unPrTmp = Double.valueOf(dj2);
} else if ((rkclSum >= Double.parseDouble(rklbz2)) && (StringUtil.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPrTmp = Double.valueOf(dj3);
}
}
if ( stoNumTmp > 0 && unPrTmp > 0 ) {
BigDecimal depNum = new BigDecimal(stoNumTmp);
BigDecimal uniPri = new BigDecimal(unPrTmp);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
List tempList = new ArrayList<>();
tempList.add(unPrTmp);
tempList.add(depAmount);
tempList.add(detId);
oldDetDatas.add(tempList);
}
rs.executeBatchSql( editProDetSql, oldDetDatas);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
}
}
}
}
}
List<String> mainidList = new ArrayList<>();
rs.executeQuery( acqProMainByMonthSql, nowMonth);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtil.isNotBlank(id)) {
mainidList.add(id);
}
}
if ( !mainidList.isEmpty()) {
String editProMainSql = "update uf_cxgj set lrrq = ? , cxzgj = (SELECT sum( rkje ) AS cxzgj FROM uf_cxgj_dt1 WHERE mainid = ?), rkzcl = (SELECT sum( rkcl ) AS rkzcl FROM uf_cxgj_dt1 WHERE mainid = ?) where id = ?";
for (String mainid:mainidList) {
rs.executeUpdate( editProMainSql, today, mainid, mainid, mainid);
}
}
}
}catch (Exception e) {
basebean.writeLog("SyncDfjcUatBatch Exception: " + e);
out.print("-----SyncDfjcUatBatch Exception: " + e);
}
out.print("=========SyncDfjcUatBatch End==========");
%>
<%!
BaseBean basebean = new BaseBean();
public List<String> getEveryDate(String fromDate, String toDate) {
List<String> everyDate = new ArrayList<>();
// 创建一个格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 将字符串转换为 LocalDate 对象
LocalDate startLocalDate = LocalDate.parse(fromDate, formatter);
LocalDate endLocalDate = LocalDate.parse(toDate, formatter);
// 创建一个列表来存储日期
List<LocalDate> dates = new ArrayList<>();
// 计算并添加所有日期
for (LocalDate date = startLocalDate; date.isBefore(endLocalDate.plusDays(1)); date = date.plusDays(1)) {
dates.add(date);
}
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
for (LocalDate date : dates) {
everyDate.add(date.format(df));
}
return everyDate;
}
public String addProMainData(String cx, String nowMonth, RecordSet rs){
String result = "";
String addProMainSql = "insert into uf_cxgj (lrr,lrrq,cxmc,scyf,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,modeuuid) " +
" values (?,?,?,?,?,?,?,?,?,?)";
String acqMainIdSql = "select id from uf_cxgj where modeuuid = ? ";
String formmodeid = "48";
String nowDate = DateUtil.format(new Date(),"yyyy-MM-dd");
String nowTime = DateUtil.format(new Date(),"HH:mm:ss");
UUID uuid = UUID.randomUUID();
String modeuuid = uuid.toString();
boolean addFlag = rs.executeUpdate( addProMainSql, 1, nowDate, cx, nowMonth, formmodeid, 1, 0, nowDate, nowTime, modeuuid);
if ( addFlag) {
rs.executeQuery( acqMainIdSql, modeuuid);
while ( rs.next()) {
result = Util.null2String( rs.getString("id"));
}
}
//权限重构
ModeRightInfo modeRightInfo = new ModeRightInfo();
modeRightInfo.setNewRight(true);
modeRightInfo.editModeDataShare( 1, Integer.parseInt(formmodeid), Integer.parseInt(result));
return result;
}
public List<ProWagDetPO> getProDets(String acqProMainByMonthSql, String acqProDetBatSql, String nowMonth, Map<String, Map<String, String>> unitPricesMap, RecordSet rs) {
List<String> proMainList = new ArrayList<>();
List<ProWagDetPO> proDetList = new ArrayList<>();
try {
rs.executeQuery(acqProMainByMonthSql, nowMonth);
while ( rs.next()) {
String id = Util.null2String(rs.getString("id"));
if ( StringUtil.isNotBlank(id)) {
proMainList.add(id);
}
}
basebean.writeLog("============getProDets proMainList:"+ proMainList);
basebean.writeLog("============getProDets proMainList:"+ proMainList.size());
if ( !proMainList.isEmpty()) {
ProWagDetPO po = null;
String sqlWhere = String.join(",",proMainList);
acqProDetBatSql = acqProDetBatSql + "( " + sqlWhere + " )";
rs.executeQuery(acqProDetBatSql);
while ( rs.next()) {
String id = Util.null2String(rs.getString("id"));//明细ID
String mainid = Util.null2String(rs.getString("mainid"));
String lhid = Util.null2String(rs.getString("lh"));
String lp = Util.null2String(rs.getString("lp"));
String rkrq = Util.null2String(rs.getString("rkrq"));
String cpdj = Util.null2String(rs.getString("cpdj"));
String rkcl = Util.null2String(rs.getString("rkcl"));//入库产量
String rkje = Util.null2String(rs.getString("rkje"));
if ( StringUtil.isNotBlank(mainid) && StringUtil.isNotBlank(lhid)) {
po = new ProWagDetPO();
po.setId(id);
po.setMainId(mainid);
po.setLhid(lhid);
po.setLp(lp);
po.setStorageDate(rkrq);
po.setUnitPrice(cpdj);
po.setStorageNumber(rkcl);
po.setStorageAmount(rkje);
Map<String, String> tmpMap = unitPricesMap.get(lhid);
if ( tmpMap != null && !tmpMap.isEmpty()) {
String lh = tmpMap.get("lh");
po.setLh(lh);
}
proDetList.add(po);
}
}
}
}catch (Exception e) {
basebean.writeLog("getProDets exception: " + e);
}
return proDetList;
}
%>

@ -0,0 +1,206 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.time.LocalDate" %>
<%@ page import="weaver.general.TimeUtil" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.alibaba.fastjson.JSON" %>
<%@ page import="java.util.UUID" %>
<%@ page import="weaver.formmode.setup.ModeRightInfo" %>
<%@ page import="com.engine.kq.biz.KQReportBiz" %>
<%@ page import="com.engine.kq.util.KQDurationCalculatorUtil" %>
<%@ page import="weaver.interfaces.dfjc.entity.KqMonthDataPO" %>
<%
Map<String, Object> data = new HashMap<>();
String ids = Util.null2String(request.getParameter("ids"));
RecordSet rs = new RecordSet();
rs.execute(" select xm,status,bm,gw,kqy from uf_ydgs a,hrmresource b where a.xm=b.id and a.id in ("+ids+") ");
while(rs.next()){
String xm = Util.null2String(rs.getString("xm"));
String zt = Util.null2String(rs.getString("status"));
String bm = Util.null2String(rs.getString("bm"));
String gw = Util.null2String(rs.getString("gw"));
String kqy = Util.null2String(rs.getString("kqy"));
LocalDate localDate = LocalDate.parse(kqy+"-01");
String fromDate = localDate.toString();
String toDate = localDate.withDayOfMonth(localDate.lengthOfMonth()).toString();
Map<String,Object> flowData = getKqOvertimeData(fromDate,toDate,xm);
double psjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|workingDayOvertime_nonleave"))),0);
double xxrjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|restDayOvertime_nonleave"))),0);
double jjrjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|holidayOvertime_nonleave"))),0);
double dkzgs = Util.getDoubleValue(Util.null2String(getWorkHours(fromDate,toDate,xm)),0);
//获取出差时长
double ccxs = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|businessLeave"))),0);
double zgs = psjbbdx+xxrjbbdx+jjrjbbdx+dkzgs+ccxs;
KqMonthDataPO kqMonthDataPO = KqMonthDataPO.builder()
.resourceId(xm)
.status(zt)
.departmentId(bm)
.jobTitle(gw)
.psjbbdx(psjbbdx)
.xxrjbbdx(xxrjbbdx)
.jjrjbbdx(jjrjbbdx)
.dkzgs(dkzgs)
.zgs(zgs)
.ccxs(ccxs)
.build();
System.out.println("KqMonthReportSynByUser==>"+JSON.toJSONString(kqMonthDataPO));
saveData(kqMonthDataPO,kqy);
}
data.put("success",true);
out.println(JSON.toJSONString(data));
%>
<%!
/**
* 获取加班数据
* @param fromDate
* @param toDate
* @return
*/
public Map<String,Object> getKqOvertimeData(String fromDate,String toDate,String resourceId){
User user = User.getUser(1,0);
Map<String,Object> params = new HashMap<>();
JSONObject jsonObject = new JSONObject();
jsonObject.put("isNoAccount","1");
jsonObject.put("attendanceSerial","");
jsonObject.put("status","9");
jsonObject.put("viewScope","0");
jsonObject.put("typeselect","6");
jsonObject.put("fromDate",fromDate);
jsonObject.put("toDate",toDate);
jsonObject.put("resourceId",resourceId);
params.put("data",jsonObject);
KQReportBiz kqReportBiz = new KQReportBiz();
Map<String,Object> flowData = kqReportBiz.getFlowData(params,user);
return flowData;
}
/**
* 获取实际打卡时长
* @param fromDate
* @param toDate
* @return
*/
public String getWorkHours(String fromDate,String toDate,String xm){
String workhours = "";
RecordSet rs = new RecordSet();
String sql = " select xm,sum(sjgssc) workhours from uf_kqgs where kqrq>=? and kqrq<=? and xm=? group by xm ";
rs.executeQuery(sql,fromDate,toDate,xm);
while (rs.next()){
workhours = Util.null2String(rs.getString("workhours"));
}
return workhours;
}
/**
* 同步数据到建模表
* @param kqMonthDataPO
* @param month
*/
public void saveData(KqMonthDataPO kqMonthDataPO,String month){
RecordSet rs = new RecordSet();
int formmodeid = getModeIdByTableName("uf_ydgs");
int modedatacreater = 1;
String xm = kqMonthDataPO.getResourceId();
String zt = kqMonthDataPO.getStatus();
String bm = kqMonthDataPO.getDepartmentId();
String gw = kqMonthDataPO.getJobTitle();
Double dkzgs = kqMonthDataPO.getDkzgs();
Double psjbbdx = kqMonthDataPO.getPsjbbdx();
Double xxrjbbdx = kqMonthDataPO.getXxrjbbdx();
Double jjrjbbdx = kqMonthDataPO.getJjrjbbdx();
Double zgs = kqMonthDataPO.getZgs();
Double ccxs = kqMonthDataPO.getCcxs();
boolean exist = isExist(month,kqMonthDataPO.getResourceId());
if(exist){
//更新
String updateSql = " update uf_ydgs set dkzgs=?, psjbbdx=?, xxrjbbdx=?, jjrjbbdx=?, zgs=?, zt=?, ccxs=? where xm=? and kqy=? ";
rs.executeUpdate(updateSql,new Object[]{dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,xm,month});
}else{
//插入
String modeuuid = UUID.randomUUID().toString();
String modedatacreatedate = TimeUtil.getCurrentDateString();
String modedatacreatetime = TimeUtil.getOnlyCurrentTimeString();
String insertSql = " insert into uf_ydgs(xm,bm,gw,kqy,dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,"+
"formmodeid,modedatacreater,modedatacreatedate,modedatacreatetime,modeuuid) " +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
rs.executeUpdate(insertSql,new Object[]{xm,bm,gw,month,dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,
formmodeid,modedatacreater,modedatacreatedate,modedatacreatetime,modeuuid});
rs.executeQuery("select id from uf_ydgs where modeuuid=?",modeuuid);
rs.next();
int id = rs.getInt("id");
if(id>0){
ModeRightInfo right = new ModeRightInfo();
right.editModeDataShare(1, formmodeid, id);
}
}
}
/**
* 判断数据是否存在
* @param month
* @param userid
* @return
*/
public boolean isExist(String month,String userid){
RecordSet rs = new RecordSet();
String sql = " select 1 from uf_ydgs where kqy=? and xm=? ";
rs.executeQuery(sql,month,userid);
return rs.next();
}
/**
* 根据建模表名获取建模id,建模权限同步的使用
* @param tableName 建模表名
* @return int 建模id
*/
public static int getModeIdByTableName(String tableName){
RecordSet rs = new RecordSet();
String sql = " select a.id from modeinfo a,workflow_bill b where a.formid=b.id and b.tablename =? ";
rs.executeQuery(sql, tableName);
if (rs.next()) {
return rs.getInt("id");
}
return -1;
}
%>

@ -0,0 +1,37 @@
<%@ page import="com.engine.kq.entity.WorkTimeEntity" %>
<%@ page import="com.weaver.general.Util" %>
<%@ page import="com.engine.kq.biz.KQWorkTime" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="com.engine.kq.biz.KQShiftManagementComInfo" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%
String id = Util.null2String(request.getParameter("id"));
String gzrq = Util.null2String(request.getParameter("gzrq"));
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(id, gzrq);
String serialId = workTimeEntity.getSerialId();
if (StringUtils.isBlank(serialId) || "-1".equals(serialId)) {
kqWorkTime.setIsFormat(true);
workTimeEntity = kqWorkTime.getWorkTime(id, gzrq);
serialId = workTimeEntity.getSerialId();
}
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
String isRestTimeOpen = kqShiftManagementComInfo.getIsresttimeopen(serialId);
//1表示开启
out.println(isRestTimeOpen);
%>

@ -0,0 +1,14 @@
package com.api.kqsolution.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2024/9/2 10:17 AM
* @Description: TODO
* @Version 1.0
*/
@Path("/kqsolution/projectPrice")
public class ProjectPriceAction extends com.engine.kqsolution.web.ProjectPriceAction {
}

@ -0,0 +1,14 @@
package com.api.kqsolution.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2024/8/29 9:22 AM
* @Description: TODO
* @Version 1.0
*/
@Path("/kqsolution/resource")
public class ResourceSnipAction extends com.engine.kqsolution.web.ResourceSnipAction {
}

@ -0,0 +1,13 @@
package com.api.kqsolution.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2023/9/18 11:42 AM
* @Description:
* @Version 1.0
*/
@Path("/kqsolution/cube")
public class SignDataSummaryAction extends com.engine.kqsolution.web.SignDataSummaryAction{
}

@ -0,0 +1,26 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/5/22 3:05 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CustomSignDataParam {
private String departments;
private String month;
}

@ -0,0 +1,69 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/8/28 10:05 AM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HistoryResourcePO {
private Integer resourceId;
private String workcode;
private String lastName;
private String birthday;
private String sex;
private String subCompany;
private String department;
private String managerId;
private String companyStartDate;
private String createDate;
private String accumfundAccount;
private String accountId;
private String bankName;
private String firstEnrollmentDate;
private String startdate;
private String endDate;
private String jobTitle;
private String status;
private String educationlevel;
private String mobile;
private String certificatenum;
private String nativeplace;
private String regresidentplace;
private String changeDate;
}

@ -0,0 +1,26 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/9/11 9:45 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HrmStatusPO {
private Integer resourceId;
private String changeDate;
private Integer typeN;
}

@ -0,0 +1,45 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/11/14 10:47 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class KqExceptionVo {
private Integer resourceId;
private String lastName;
private String wordcode;
private String subCompanyName;
private String departmentName;
private String jobTitleName;
private Integer belate;
private Integer gravebelate;
private Integer leaveeearly;
private Integer graveleaveearly;
private Integer absenteeism;
private Integer forgotcheck;
private String kqResult;
}

@ -0,0 +1,52 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/9/18 2:22 PM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SignDataPO {
private Integer id;
private String attendanceMonth;
private String attendanceDate;
private Integer resourceId;
private Integer company;
private Integer department;
private Integer jobTitle;
private String signInDate;
private String signInTime;
private String signOutDate;
private String signOutTime;
private String signMins;
private Double signHours;
private Double workHours;
private Integer status;
}

@ -0,0 +1,38 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import weaver.general.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2023/9/18 2:14 PM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SignDataParams {
private String attendanceDate;
private String formModeId;
private String ids;
public List<Integer> getIds() {
if(StringUtil.isEmpty(ids)){
return new ArrayList<>();
}
return Arrays.stream(ids.split(",")).map(Integer::parseInt).collect(Collectors.toList());
}
}

@ -0,0 +1,30 @@
package com.engine.kqsolution.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/5/27 10:04 AM
* @Description: TODO
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WorkflowDetailVO {
private Integer id;
private String attendanceDate;
private Integer personId;
private String personName;
private Double workHours;
}

@ -0,0 +1,31 @@
package com.engine.kqsolution.service;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/9/2 10:19 AM
* @Description: TODO
* @Version 1.0
*/
public interface ProjectPriceService {
/**
* @Description: 线
* @Author: liang.cheng
* @Date: 2024/9/2 10:30 AM
* @param: [params]
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String,Object> signData(Map<String, Object> params);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/9/3 10:22 AM
* @param: [month, cx]
* @return: void
*/
void deleteHData(String month,String cx);
}

@ -0,0 +1,55 @@
package com.engine.kqsolution.service;
import com.engine.kqsolution.entity.HistoryResourcePO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/8/29 9:26 AM
* @Description: TODO
* @Version 1.0
*/
public interface ResourceSnipService {
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/8/29 9:58 AM
* @param: [monthDate, companyStartDate]
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String,Object> resourceSnip(String monthDate, String companyStartDate);
/**
*
* @param request
* @param response
* @param monthDate
* @param companyStartDate
* @return
*/
XSSFWorkbook snipshotExport(HttpServletRequest request, HttpServletResponse response, String monthDate, String companyStartDate);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/9/10 5:35 PM
* @param: [companyStartDate]
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String, List<HistoryResourcePO>> hrResource(Map<String, Object> param);
/**
* @Description
* @Author: liang.cheng
* @Date: 2024/9/11 3:18 PM
* @param: [request, response, companyStartDate]
* @return: org.apache.poi.xssf.usermodel.XSSFWorkbook
*/
XSSFWorkbook hrResourceExport(HttpServletRequest request, HttpServletResponse response, Map<String, Object> param);
}

@ -0,0 +1,55 @@
package com.engine.kqsolution.service;
import com.engine.kqsolution.entity.CustomSignDataParam;
import com.engine.kqsolution.entity.KqExceptionVo;
import com.engine.kqsolution.entity.SignDataParams;
import com.engine.kqsolution.entity.WorkflowDetailVO;
import java.util.List;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2023/9/18 11:44 AM
* @Description: TODO
* @Version 1.0
*/
public interface SignDataSummaryService {
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/9/18 2:18 PM
* @param: [signDataParams]
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String,Object> recordSignData(SignDataParams signDataParams);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/5/22 3:25 PM
* @param: [customSignDataParam]
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String,Object> customSignData(CustomSignDataParam customSignDataParam);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/5/27 10:23 AM
* @param: [ids]
* @return: java.util.List<com.engine.kqsolution.entity.WorkflowDetailVO>
*/
List<WorkflowDetailVO> workflowDetail(String ids);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/11/14 10:41 AM
* @param: [request2Map]
* @return: j
*/
Map<String, Object> kqExceptionReport(Map<String, Object> request2Map);
}

@ -0,0 +1,707 @@
package com.engine.kqsolution.service.impl;
import cn.hutool.core.date.DateUtil;
import com.engine.core.impl.Service;
import com.engine.kqsolution.service.ProjectPriceService;
import com.weaver.general.BaseBean;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetDataSource;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.Util;
import weaver.interfaces.dfjc.entity.ProWagDetPO;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2024/9/2 10:19 AM
* @Description: SyncDfjcUatBatch.jsp
* @Version 1.0
*/
public class ProjectPriceServiceImpl extends Service implements ProjectPriceService {
@Override
public Map<String, Object> signData(Map<String, Object> params) {
RecordSetDataSource rsds = new RecordSetDataSource();
Map<String, Object> result = new HashMap<>();
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String projectValue = Util.null2String(params.get("projectValue"));
String fromdate = Util.null2String(params.get("fromdate"));
String todate = Util.null2String(params.get("todate"));
String month = Util.null2String(params.get("month"));
String today = DateUtil.format(new Date(),"yyyy-MM-dd");
try {
//根据条线筛选更新数据(台账按钮操作)
List<String> lhidList = new ArrayList<>();
if (StringUtils.isNotEmpty(projectValue)) {
//根据条线删除历史数据
deleteHData(month,projectValue);
rs.executeQuery("select lhid from uf_cpdjb where cx = ?",projectValue);
while (rs.next()) {
lhidList.add(Util.null2String(rs.getString("lhid")));
}
}
result.put("lhids",lhidList);
//计算出开始日期和结束日期之间的每个日期
List<String> everyDate = getEveryDate(fromdate, todate);
for ( String syncdate : everyDate ) {
String nowYear = syncdate.substring(0,4);
String nowMonth = syncdate.substring(0,7);
//获取基础数据
List<Map<String, String>> baseDatasList = new ArrayList<>();
Map<String, String> baseDataMap = new HashMap<>();
String acqBaseDatasSql = " SELECT a.id,a.docstate,a.HandleDept, a.item,a.ActualRcvTime,a.EligibleQty,b.BusinessType FROM MO_CompleteRpt a LEFT JOIN MO_CompleteRptDocType b ON a.CompleteDocType=b.ID WHERE b.BusinessType<>48 and CAST(ActualRcvTime AS DATE) = ? and DocState = 3";
if (CollectionUtils.isNotEmpty(lhidList)) {
List<String> quotedList = lhidList.stream()
.map(s -> "'" + s + "'")
.collect(Collectors.toList());
String str = String.join(",", quotedList);
acqBaseDatasSql = acqBaseDatasSql + " and a.item in ("+str+")";
}
rsds.executeQueryWithDatasource( acqBaseDatasSql, "u9", syncdate);
while (rsds.next()) {
String lhid = Util.null2String(rsds.getString("Item"));//料号id
String rksl = Util.null2String(rsds.getString("EligibleQty"));//入库数量
if ( StringUtils.isNotBlank(lhid) && StringUtils.isNotBlank(rksl)) {
baseDataMap = new HashMap<>();
baseDataMap.put("lhid",lhid);
baseDataMap.put("rksl",rksl);
baseDatasList.add(baseDataMap);
}
}
result.put("data",baseDatasList);
//获取产品单价台账
Map<String, Map<String, String>> unitPricesMap = new HashMap<>();
Map<String, String> unitPriceMap = new HashMap<>();
String scqunitPriceSql = "select id, lhid, lh, lp, cx, xncx, rklbz1, dj, rklbz2, dj2, rklbz3, dj3 from uf_cpdjb ";
rs.executeQuery( scqunitPriceSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));//产品单价id
String lhid = Util.null2String(rs.getString("lhid"));//料号id
String lh = Util.null2String(rs.getString("lh"));//料号
String lp = Util.null2String(rs.getString("lp"));//料品
String cx = Util.null2String(rs.getString("cx"));//产线
String xncx = Util.null2String(rs.getString("xncx"));//虚拟产线
String rklbz1 = Util.null2String(rs.getString("rklbz1"));//入库量标准1
String dj = Util.null2String(rs.getString("dj"));//单价1
String rklbz2 = Util.null2String(rs.getString("rklbz2"));//入库量标准2
String dj2 = Util.null2String(rs.getString("dj2"));//单价2
String rklbz3 = Util.null2String(rs.getString("rklbz3"));//入库量标准3
String dj3 = Util.null2String(rs.getString("dj3"));//单价3
if ( StringUtils.isNotBlank(lhid) && StringUtils.isNotBlank(cx) && StringUtils.isNotBlank(lp) ) {
unitPriceMap = new HashMap<>();
unitPriceMap.put("id",id);
unitPriceMap.put("lhid",lhid);
unitPriceMap.put("lh",lh);
unitPriceMap.put("lp",lp);
unitPriceMap.put("cx",cx);
unitPriceMap.put("xncx",xncx);
unitPriceMap.put("rklbz1",rklbz1);
unitPriceMap.put("dj",dj);
unitPriceMap.put("rklbz2",rklbz2);
unitPriceMap.put("dj2",dj2);
unitPriceMap.put("rklbz3",rklbz3);
unitPriceMap.put("dj3",dj3);
unitPricesMap.put(lhid,unitPriceMap);
}
}
//获取料号和各单价的对应关系
Map<String, Map<String, String>> lpToDjMap = new HashMap<>();
for (Map.Entry<String, Map<String, String>> entry : unitPricesMap.entrySet()) {
String lp = entry.getValue().get("lp");
String dj = entry.getValue().get("dj");
String dj2 = entry.getValue().get("dj2");
String dj3 = entry.getValue().get("dj3");
if (lpToDjMap.containsKey(lp)) {
Map<String, String> djMap = lpToDjMap.get(lp);
djMap.put("dj", dj);
djMap.put("dj2", dj2);
djMap.put("dj3", dj3);
} else {
Map<String, String> djMap = new HashMap<>();
djMap.put("dj", dj);
djMap.put("dj2", dj2);
djMap.put("dj3", dj3);
lpToDjMap.put(lp, djMap);
}
}
//获取虚拟产线和料品的对应关系
Map<String, List<String>> xncxToLpMap = new HashMap<>();
for (Map.Entry<String, Map<String, String>> entry : unitPricesMap.entrySet()) {
String xncx = entry.getValue().get("xncx");
String lp = entry.getValue().get("lp");
if (StringUtils.isNotBlank(xncx)) {
if (xncxToLpMap.containsKey(xncx)) {
List<String> lpList = xncxToLpMap.get(xncx);
lpList.add(lp);
} else {
List<String> lpList = new ArrayList<>();
lpList.add(lp);
xncxToLpMap.put(xncx, lpList);
}
}
}
//获取产线工价台账
// String checkProSql = "select count(*) as number from uf_cxgj where cxmc = ? and scyf = ? ";
//产线工价主表
String acqProMainSql = "select id from uf_cxgj where cxmc = ? and scyf = ?";
String acqProMainByMonthSql = "select id from uf_cxgj where scyf = ?";
//产线工价明细表
// String acqProDetSql = "select id, lh, lp, rkrq, cpdj, rkcl, rkje from uf_cxgj_dt1 where mainId = ?";
String acqProDetBatSql = "select id, mainid, lh, lp, rkrq, cpdj, rkcl, rkje from uf_cxgj_dt1 where mainid in ";
//产线工价明细表插入
String addProDetSql = "insert into uf_cxgj_dt1 ( mainid, lh, lp, rkrq, cpdj, rkcl, rkje ) values ( ?, ?, ?, ?, ?, ?, ? )";
//产线工价明细表修改
String editProDetSql = "update uf_cxgj_dt1 set cpdj = ? ,rkje = ? where id = ? ";
//获取当前月份的产线工价数据
List<ProWagDetPO> proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
//根据料号id处理
for ( Map<String,String> baseData:baseDatasList) {
String lhid = baseData.get("lhid");//料号id
String rksl = baseData.get("rksl");//入库数量
Map<String, String> unitPriceTmpMap = unitPricesMap.get(lhid);
if ( unitPriceTmpMap == null || unitPriceTmpMap.isEmpty() ) {
continue;
}
String id = unitPriceTmpMap.get("id");//产品单价id
String lp = unitPriceTmpMap.get("lp");//料品
String lh = unitPriceTmpMap.get("lh");//料号
String cx = unitPriceTmpMap.get("cx");//产线
String xncx = unitPriceTmpMap.get("xncx");//虚拟产线
String rklbz1 = unitPriceTmpMap.get("rklbz1");//标准1
String rklbz2 = unitPriceTmpMap.get("rklbz2");//标准2
String rklbz3 = unitPriceTmpMap.get("rklbz3");//标准3
String dj = unitPriceTmpMap.get("dj");//单价1
String dj2 = unitPriceTmpMap.get("dj2");//单价2
String dj3 = unitPriceTmpMap.get("dj3");//单价3
//是否阶梯单价
boolean stepUnitPriceFlag = true;
if ( StringUtils.isBlank(rklbz2) && StringUtils.isBlank(rklbz3)) {
stepUnitPriceFlag = false;
}
//是否虚拟产线
boolean virProLineFlag = true;
if ( StringUtils.isBlank(xncx)) {
virProLineFlag = false;
}
Integer mainId = -1;
rs.executeQuery( acqProMainSql, cx, nowMonth);
while (rs.next()) {
mainId = Util.getIntValue( Util.null2String( rs.getString("id")));
}
Integer tempMainId = -1;
if ( mainId == -1) {//主表没有该产线的数据
mainId = Util.getIntValue( addProMainData(cx, nowMonth, rs));
if (cx.equals("13")) {
tempMainId = mainId;
}
}
if ( !stepUnitPriceFlag ) {//非阶梯单价--直接插入一行明细
if ( tempMainId > 0 ) {
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtils.isNotBlank(rksl) && StringUtils.isNotBlank(dj)) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(dj);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, dj, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {//阶梯单价
//虚拟产线
if ( !virProLineFlag ) {
//非虚拟产线,找同料号的明细
if ( proDetList.isEmpty()) {//明细表没有数据
Double unPr= 0.0;
if ( StringUtils.isBlank(dj2) ) {
unPr = Double.valueOf(dj);
} else {
if ( Double.parseDouble(rksl) < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz1)) && ( StringUtils.isNotBlank(rklbz2) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz2)) && (StringUtils.isNotBlank(rklbz3) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtils.isNotBlank(rksl) && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {
String finalMainId = Util.null2String(mainId);
List<ProWagDetPO> proWList = proDetList.stream()
.filter(pro -> pro.getMainId().equals(finalMainId) )
.collect(Collectors.toList());
Double unPr= 0.0;
List<String> rkcls = proWList.stream()
.map(pro -> pro.getStorageNumber())
.collect(Collectors.toList());
Double rkclSum = rkcls.stream()
.map(str -> Double.parseDouble(str))
.reduce(0.0, Double::sum);
rkclSum = rkclSum + Double.parseDouble(rksl);
if ( StringUtils.isBlank(dj2) ) {
unPr = Double.valueOf(dj);
} else {
if (rkclSum < Double.parseDouble(rklbz1)) {
unPr = Double.valueOf(dj);
} else if ((rkclSum >= Double.parseDouble(rklbz1)) && (StringUtils.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2)))) {
unPr = Double.valueOf(dj2);
} else if ((rkclSum >= Double.parseDouble(rklbz2)) && (StringUtils.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( Double.parseDouble(rksl) > 0 && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
//处理历史明细
List<List> oldDetDatas = new ArrayList<>();
List<String> detIds = proWList.stream()
.map(pro -> pro.getId())
.collect(Collectors.toList());
Map<String, String> StoNumMap = proWList.stream()
.filter(pro -> detIds.contains(pro.getId()))
.collect(Collectors.toMap(
ProWagDetPO::getId,
ProWagDetPO::getStorageNumber
));
for (String detId : detIds) {
Integer stoNum = Util.getIntValue(StoNumMap.get(detId));
//同产线的总量 rkclSum
//获取该料品的入库数量标准和单价
for (ProWagDetPO pro : proWList) {
if (pro.getId().equals(detId)) {
pro.getLhid();
}
}
unitPriceTmpMap = unitPricesMap.get(lhid);
if ( unitPriceTmpMap == null || unitPriceTmpMap.isEmpty() ) {
continue;
}
id = unitPriceTmpMap.get("id");//产品单价id
lp = unitPriceTmpMap.get("lp");//料品
lh = unitPriceTmpMap.get("lh");//料号
cx = unitPriceTmpMap.get("cx");//产线
xncx = unitPriceTmpMap.get("xncx");//虚拟产线
rklbz1 = unitPriceTmpMap.get("rklbz1");//标准1
rklbz2 = unitPriceTmpMap.get("rklbz2");//标准2
rklbz3 = unitPriceTmpMap.get("rklbz3");//标准3
dj = unitPriceTmpMap.get("dj");//单价1
dj2 = unitPriceTmpMap.get("dj2");//单价2
dj3 = unitPriceTmpMap.get("dj3");//单价3
if ( StringUtils.isBlank(dj2) ) {
unPr = Double.valueOf(dj);
} else {
if (rkclSum < Double.parseDouble(rklbz1)) {
unPr = Double.valueOf(dj);
} else if ((rkclSum >= Double.parseDouble(rklbz1)) && (StringUtils.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2)))) {
unPr = Double.valueOf(dj2);
} else if ((rkclSum >= Double.parseDouble(rklbz2)) && (StringUtils.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
}
//计算入库金额
depAmount = new BigDecimal(0);
if ( stoNum > 0 && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(stoNum);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
List tempList = new ArrayList<>();
tempList.add(unPr);
tempList.add(depAmount);
tempList.add(detId);
oldDetDatas.add(tempList);
// }
rs.executeBatchSql( editProDetSql, oldDetDatas);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
}
}
} else {
if ( proDetList.isEmpty()) {
Double unPr= 0.0;
if ( Double.parseDouble(rksl) < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz1)) && ( StringUtils.isNotBlank(rklbz2) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz2)) && (StringUtils.isNotBlank(rklbz3) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtils.isNotBlank(rksl) && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {
String finalMainId = Util.null2String(mainId);
List<String> lpTmpList = xncxToLpMap.get(xncx);
List<ProWagDetPO> proWList = proDetList.stream()
.filter(pro -> pro.getMainId().equals(finalMainId) && pro.getLp() != null && lpTmpList.contains(pro.getLp()))
// .filter(pro -> pro.getMainId().equals(finalMainId))
.collect(Collectors.toList());
if ( proWList.isEmpty()) {//没有同虚拟产线的明细
Double unPr= 0.0;
if ( Double.parseDouble(rksl) < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz1)) && ( StringUtils.isNotBlank(rklbz2) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
} else if ( (Double.parseDouble(rksl) >= Double.parseDouble(rklbz2)) && (StringUtils.isNotBlank(rklbz3) && (Double.parseDouble(rksl) < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( StringUtils.isNotBlank(rksl) && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
} else {//存在同虚拟产线
Double unPr= 0.0;
String stage = "dj";
List<String> rkcls = proWList.stream()
.map(pro -> pro.getStorageNumber())
.collect(Collectors.toList());
Double rkclSum = rkcls.stream()
.map(str -> Double.parseDouble(str))
.reduce(0.0, Double::sum);
rkclSum = rkclSum + Double.parseDouble(rksl);
if ( rkclSum < Double.parseDouble(rklbz1) ) {
unPr = Double.valueOf(dj);
} else if ( (rkclSum >= Double.parseDouble(rklbz1)) && ( StringUtils.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2))) ) {
unPr = Double.valueOf(dj2);
stage = "dj2";
} else if ( (rkclSum >= Double.parseDouble(rklbz2)) && (StringUtils.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPr = Double.valueOf(dj3);
stage = "dj3";
}
//计算入库金额
BigDecimal depAmount = new BigDecimal(0);
if ( Double.parseDouble(rksl) > 0 && unPr > 0 ) {
BigDecimal depNum = new BigDecimal(rksl);
BigDecimal uniPri = new BigDecimal(unPr);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
rs.executeUpdate( addProDetSql, mainId, id, lp, syncdate, unPr, rksl, depAmount);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
//处理历史明细
List<List> oldDetDatas = new ArrayList<>();
List<String> detIds = proWList.stream()
.map(pro -> pro.getId())
.collect(Collectors.toList());
Map<String, Map<String, Object>> idToLpStoNumMap = proWList.stream()
.filter(proWagDetPO -> detIds.contains(proWagDetPO.getId()))
.collect(Collectors.toMap(
proWagDetPO -> proWagDetPO.getId(),
proWagDetPO -> {
Map<String, Object> innerMap = new HashMap<>();
innerMap.put("lp", proWagDetPO.getLp());
innerMap.put("storageNumber", proWagDetPO.getStorageNumber());
return innerMap;
}
));
for (String detId : detIds) {
Map<String, Object> innerMap = idToLpStoNumMap.get(detId);
//计算入库金额
depAmount = new BigDecimal(0);
String lpTmp = Util.null2String(innerMap.get("lp"));
Integer stoNumTmp = Util.getIntValue( Util.null2String(innerMap.get("storageNumber")));
// Map<String, String> djTmpMap = lpToDjMap.get(lpTmp);
// Double unPrTmp = Util.getDoubleValue(djTmpMap.get(stage));
//获取该料品的入库数量标准和单价
for (ProWagDetPO pro : proWList) {
if (pro.getId().equals(detId)) {
pro.getLhid();
}
}
unitPriceTmpMap = unitPricesMap.get(lhid);
if ( unitPriceTmpMap == null || unitPriceTmpMap.isEmpty() ) {
continue;
}
id = unitPriceTmpMap.get("id");//产品单价id
lp = unitPriceTmpMap.get("lp");//料品
lh = unitPriceTmpMap.get("lh");//料号
cx = unitPriceTmpMap.get("cx");//产线
xncx = unitPriceTmpMap.get("xncx");//虚拟产线
rklbz1 = unitPriceTmpMap.get("rklbz1");//标准1
rklbz2 = unitPriceTmpMap.get("rklbz2");//标准2
rklbz3 = unitPriceTmpMap.get("rklbz3");//标准3
dj = unitPriceTmpMap.get("dj");//单价1
dj2 = unitPriceTmpMap.get("dj2");//单价2
dj3 = unitPriceTmpMap.get("dj3");//单价3
Double unPrTmp = 0.00;
if ( StringUtils.isBlank(dj2) ) {
unPrTmp = Double.valueOf(dj);
} else {
if (rkclSum < Double.parseDouble(rklbz1)) {
unPrTmp = Double.valueOf(dj);
} else if ((rkclSum >= Double.parseDouble(rklbz1)) && (StringUtils.isNotBlank(rklbz2) && (rkclSum < Double.parseDouble(rklbz2)))) {
unPrTmp = Double.valueOf(dj2);
} else if ((rkclSum >= Double.parseDouble(rklbz2)) && (StringUtils.isNotBlank(rklbz3) && (rkclSum < Double.parseDouble(rklbz3)))) {
unPrTmp = Double.valueOf(dj3);
}
}
if ( stoNumTmp > 0 && unPrTmp > 0 ) {
BigDecimal depNum = new BigDecimal(stoNumTmp);
BigDecimal uniPri = new BigDecimal(unPrTmp);
depAmount = depNum.multiply(uniPri).setScale(2, RoundingMode.HALF_UP);
}
List tempList = new ArrayList<>();
tempList.add(unPrTmp);
tempList.add(depAmount);
tempList.add(detId);
oldDetDatas.add(tempList);
}
rs.executeBatchSql( editProDetSql, oldDetDatas);
proDetList = getProDets(acqProMainByMonthSql, acqProDetBatSql, nowMonth, unitPricesMap, rs);
}
}
}
}
}
List<String> mainidList = new ArrayList<>();
rs.executeQuery( acqProMainByMonthSql, nowMonth);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
mainidList.add(id);
}
}
if ( !mainidList.isEmpty()) {
String editProMainSql = "update uf_cxgj set lrrq = ? , cxzgj = (SELECT sum( rkje ) AS cxzgj FROM uf_cxgj_dt1 WHERE mainid = ?), rkzcl = (SELECT sum( rkcl ) AS rkzcl FROM uf_cxgj_dt1 WHERE mainid = ?) where id = ?";
for (String mainid:mainidList) {
rs.executeUpdate( editProMainSql, today, mainid, mainid, mainid);
}
}
}
}catch (Exception e) {
e.printStackTrace();
}
return result;
}
@Override
public void deleteHData(String month, String cx) {
RecordSet rs = new RecordSet();
StringBuilder sb = new StringBuilder();
sb.append("select id from uf_cxgj where scyf = ?");
if (StringUtils.isNotEmpty(cx)) {
sb.append(" and cxmc = ").append(cx);
}
rs.executeQuery(sb.toString(),month);
List<String> ids = new ArrayList<>();
while (rs.next()) {
ids.add(Util.null2String(rs.getString("id")));
}
if (CollectionUtils.isNotEmpty(ids)) {
for (String id : ids) {
rs.executeUpdate("delete from uf_cxgj whee scyf = ?",month);
rs.executeUpdate("delete from uf_cxgj_dt1 where mainid = ?",id);
}
}
}
public List<String> getEveryDate(String fromDate, String toDate) {
List<String> everyDate = new ArrayList<>();
// 创建一个格式化器
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 将字符串转换为 LocalDate 对象
LocalDate startLocalDate = LocalDate.parse(fromDate, formatter);
LocalDate endLocalDate = LocalDate.parse(toDate, formatter);
// 创建一个列表来存储日期
List<LocalDate> dates = new ArrayList<>();
// 计算并添加所有日期
for (LocalDate date = startLocalDate; date.isBefore(endLocalDate.plusDays(1)); date = date.plusDays(1)) {
dates.add(date);
}
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
for (LocalDate date : dates) {
everyDate.add(date.format(df));
}
return everyDate;
}
public String addProMainData(String cx, String nowMonth, RecordSet rs){
String result = "";
String addProMainSql = "insert into uf_cxgj (lrr,lrrq,cxmc,scyf,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,modeuuid) " +
" values (?,?,?,?,?,?,?,?,?,?)";
String acqMainIdSql = "select id from uf_cxgj where modeuuid = ? ";
String formmodeid = "48";
String nowDate = DateUtil.format(new Date(),"yyyy-MM-dd");
String nowTime = DateUtil.format(new Date(),"HH:mm:ss");
UUID uuid = UUID.randomUUID();
String modeuuid = uuid.toString();
boolean addFlag = rs.executeUpdate( addProMainSql, 1, nowDate, cx, nowMonth, formmodeid, 1, 0, nowDate, nowTime, modeuuid);
if ( addFlag) {
rs.executeQuery( acqMainIdSql, modeuuid);
while ( rs.next()) {
result = Util.null2String( rs.getString("id"));
}
}
//权限重构
ModeRightInfo modeRightInfo = new ModeRightInfo();
modeRightInfo.setNewRight(true);
modeRightInfo.editModeDataShare( 1, Integer.parseInt(formmodeid), Integer.parseInt(result));
return result;
}
public List<ProWagDetPO> getProDets(String acqProMainByMonthSql, String acqProDetBatSql, String nowMonth, Map<String, Map<String, String>> unitPricesMap, RecordSet rs) {
List<String> proMainList = new ArrayList<>();
List<ProWagDetPO> proDetList = new ArrayList<>();
try {
rs.executeQuery(acqProMainByMonthSql, nowMonth);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
proMainList.add(id);
}
}
if (!proMainList.isEmpty()) {
ProWagDetPO po = null;
String sqlWhere = String.join(",", proMainList);
acqProDetBatSql = acqProDetBatSql + "( " + sqlWhere + " )";
rs.executeQuery(acqProDetBatSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));//明细ID
String mainid = Util.null2String(rs.getString("mainid"));
String lhid = Util.null2String(rs.getString("lh"));
String lp = Util.null2String(rs.getString("lp"));
String rkrq = Util.null2String(rs.getString("rkrq"));
String cpdj = Util.null2String(rs.getString("cpdj"));
String rkcl = Util.null2String(rs.getString("rkcl"));//入库产量
String rkje = Util.null2String(rs.getString("rkje"));
if (StringUtils.isNotBlank(mainid) && StringUtils.isNotBlank(lhid)) {
po = new ProWagDetPO();
po.setId(id);
po.setMainId(mainid);
po.setLhid(lhid);
po.setLp(lp);
po.setStorageDate(rkrq);
po.setUnitPrice(cpdj);
po.setStorageNumber(rkcl);
po.setStorageAmount(rkje);
Map<String, String> tmpMap = unitPricesMap.get(lhid);
if (tmpMap != null && !tmpMap.isEmpty()) {
String lh = tmpMap.get("lh");
po.setLh(lh);
}
proDetList.add(po);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return proDetList;
}
}

@ -0,0 +1,453 @@
package com.engine.kqsolution.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cloudstore.dev.api.service.Service_DevTable;
import com.cloudstore.eccom.constant.WeaBoolAttr;
import com.cloudstore.eccom.pc.table.WeaTable;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.pc.table.WeaTableType;
import com.engine.core.impl.Service;
import com.engine.kqsolution.entity.HistoryResourcePO;
import com.engine.kqsolution.entity.HrmStatusPO;
import com.engine.kqsolution.service.ResourceSnipService;
import com.engine.kqsolution.util.ExcelUtil;
import com.engine.kqsolution.util.ResourceSnipUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.PageIdConst;
import com.cloudstore.eccom.result.WeaResultMsg;
import weaver.general.StringUtil;
import weaver.general.Util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2024/8/29 9:27 AM
* @Description: TODO
* @Version 1.0
*/
public class ResourceSnipServiceImpl extends Service implements ResourceSnipService {
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Override
public Map<String, Object> resourceSnip(String monthDate, String companyStartDate) {
Map<String, Object> resultMap = new HashMap<>(4);
//当前花名册
if("".equals(monthDate)){
BaseBean bb = new BaseBean();
String account = bb.getPropValue("jcsecond", "account");
String bankField = bb.getPropValue("jcsecond", "bankField");
String regresidentplace = bb.getPropValue("jcsecond", "regresidentplace");
String femdate = bb.getPropValue("jcsecond", "femdate");
WeaTable table = new WeaTable();
String pageId = "73ed858b37304757987724e81d096ff2";
table.setPageID(pageId);
table.setPageUID(String.format("%s_%s",pageId,user.getUID()));
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
table.setPagesize(pageSize);
String fields = "a.id,a.workcode,a.lastname,a.birthday,a.sex,a.subcompanyid1,a.departmentid,a.managerid,a.companystartdate," +
" a.createdate,a.accumfundaccount,b."+account+" as account,b."+bankField+" as bankname,c."+femdate+" as femdate," +
" a.startdate,a.enddate,a.jobtitle,a.status,a.educationlevel,a.mobile,a.certificatenum," +
" a.nativeplace,b."+regresidentplace+" as regresidentplace";
table.setBackfields(fields);
String fromSql = " from hrmresource a\n" +
" left join cus_fielddata b on a.id = b.id and b.scopeid = 1\n" +
" left join cus_fielddata c on a.id = c.id and c.scopeid = -1\n";
table.setSqlform(fromSql);
if (!"".equals(companyStartDate)){
String sqlWhere = " where 1=1 and a.status < 4 ";
table.setSqlwhere(sqlWhere);
}
table.setSqlprimarykey("a.id");
table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "编号", "workcode"));
table.getColumns().add(new WeaTableColumn("10%", "姓名", "lastname"));
table.getColumns().add(new WeaTableColumn("10%", "出生日期", "birthday"));
table.getColumns().add(new WeaTableColumn("10%", "性别", "sex").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectSexName"));
table.getColumns().add(new WeaTableColumn("10%", "分部", "subcompanyid1").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectSubCompanyName"));
table.getColumns().add(new WeaTableColumn("10%", "部门", "departmentid").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectDeptName"));
table.getColumns().add(new WeaTableColumn("10%", "直接上级", "managerid").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectResourceName"));
table.getColumns().add(new WeaTableColumn("10%", "入职日期", "companystartdate"));
table.getColumns().add(new WeaTableColumn("10%", "创建日期", "createdate"));
table.getColumns().add(new WeaTableColumn("10%", "公积金账户", "accumfundaccount"));
table.getColumns().add(new WeaTableColumn("10%", "工资账户", "account").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "工资银行", "bankname").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectBankName").setOtherpara(bankField));
table.getColumns().add(new WeaTableColumn("10%", "首次参保时间", "femdate").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "合同开始日期", "startdate").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "合同结束日期", "enddate").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "岗位", "jobtitle").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectJobName"));
table.getColumns().add(new WeaTableColumn("10%", "状态", "status").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectStatusName"));
table.getColumns().add(new WeaTableColumn("10%", "学历", "educationlevel").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectEducName"));
table.getColumns().add(new WeaTableColumn("10%", "电话", "mobile").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "身份证号", "certificatenum").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "籍贯", "nativeplace").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "户口所在地", "regresidentplace").setDisplay(WeaBoolAttr.FALSE));
table.setTableType(WeaTableType.NONE);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
resultMap.putAll(result.getResultMap());
return resultMap;
}else {
//历史花名册
WeaTable table = new WeaTable();
String pageId = "89093fe16a7c4a38b26d4a47de791859";
table.setPageID(pageId);
table.setPageUID(String.format("%s_%s",pageId,user.getUID()));
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
table.setPagesize(pageSize);
String fields = "t.id,t.gh,t.xm,t.csrq,t.xb,t.fb,t.bm,t.zjsj,t.rzrq,t.cjrq,t.gjjzh,t.gzzh,t.gzyx,t.sccbsj," +
" t.htksrq,t.htjsrq,t.gw,t.zt,t.xl,t.dh,t.sfzh,t.jg,t.hkszd,t.cdrq,t.lzrq";
table.setBackfields(fields);
String fromSql = " from uf_hmckz t";
table.setSqlform(fromSql);
String sqlWhere = " where 1=1 and t.cdrq = '"+monthDate+"' and t.zt < 4";
table.setSqlwhere(sqlWhere);
table.setSqlprimarykey("id");
table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "编号", "gh"));
table.getColumns().add(new WeaTableColumn("10%", "姓名", "xm"));
table.getColumns().add(new WeaTableColumn("10%", "出生日期", "csrq"));
table.getColumns().add(new WeaTableColumn("10%", "性别", "xb"));
table.getColumns().add(new WeaTableColumn("10%", "分部", "fb"));
table.getColumns().add(new WeaTableColumn("10%", "部门", "bm"));
table.getColumns().add(new WeaTableColumn("10%", "直接上级", "zjsj"));
table.getColumns().add(new WeaTableColumn("10%", "入职日期", "rzrq"));
table.getColumns().add(new WeaTableColumn("10%", "创建日期", "cjrq"));
table.getColumns().add(new WeaTableColumn("10%", "公积金账户", "gjjzh"));
table.getColumns().add(new WeaTableColumn("10%", "工资账户", "gzzh").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "工资银行", "gzyx").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "首次参保时间", "sccbsj").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "合同开始日期", "htksrq").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "合同结束日期", "htjsrq").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "岗位", "gw").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "状态", "zt").setDisplay(WeaBoolAttr.FALSE).setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectStatusName"));
table.getColumns().add(new WeaTableColumn("10%", "学历", "xl").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "电话", "dh").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "身份证号", "sfzh").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "籍贯", "jg").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "户口所在地", "hkszd").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("10%", "离职日期", "lzrq").setDisplay(WeaBoolAttr.FALSE));
table.setTableType(WeaTableType.NONE);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
resultMap.putAll(result.getResultMap());
return resultMap;
}
}
@Override
public XSSFWorkbook snipshotExport(HttpServletRequest request, HttpServletResponse response, String monthDate, String companyStartDate) {
BaseBean bb = new BaseBean();
String bankField = bb.getPropValue("jcsecond", "bankField");
//全字段导出
List<Object> headerList = Arrays.asList("编号","姓名","出生日期","性别","分部","部门","直接上级","入职日期","创建日期","公积金账户","工资账户","工资银行","首次参保时间",
"合同开始日期","合同结束日期","岗位","状态","学历","电话","身份证号","籍贯","户口所在地","离职日期");
Map<String, Object> map = resourceSnip(monthDate, companyStartDate);
String dataKey = Util.null2String(map.get("datas"));
String getcounts = new Service_DevTable().getcounts(request, response, dataKey);
JSONObject jsonObject = JSON.parseObject(getcounts);
String count = jsonObject.getString("count");
String datas = new Service_DevTable().datas(request, response, dataKey, count, "[]", "", "", "1", "");
jsonObject = JSON.parseObject(datas);
List<Map<String, String>> snipshotList = (List<Map<String, String>>) jsonObject.get("datas");
List<List<Object>> rows = new LinkedList<>();
boolean table = "".equals(monthDate);
for (Map<String, String> snip : snipshotList) {
List<Object> row = new LinkedList<>();
row.add(table ? snip.get("workcodespan") : snip.get("gh"));
row.add(table ? snip.get("lastnamespan") : snip.get("xm"));
row.add(table ? snip.get("birthdayspan") : snip.get("csrq"));
row.add(table ? snip.get("sexspan") : snip.get("xb"));
row.add(table ? ResourceSnipUtils.selectSubCompanyName(snip.get("subcompanyid1")) : snip.get("fb"));
row.add(table ? ResourceSnipUtils.selectDeptName(snip.get("departmentid")) : snip.get("bm"));
row.add(table ? ResourceSnipUtils.selectResourceName(snip.get("managerid")) : snip.get("zjsj"));
row.add(table ? snip.get("companystartdatespan") : snip.get("rzrq"));
row.add(table ? snip.get("createdatespan") : snip.get("cjrq"));
row.add(table ? snip.get("accumfundaccountspan") : snip.get("gjjzh"));
row.add(table ? snip.get("accountspan") : snip.get("gzzh"));
row.add(table ? ResourceSnipUtils.selectBankName(snip.get("subcompanyid1"),bankField) : snip.get("gzyx"));
row.add(table ? snip.get("femdatespan") : snip.get("sccbsj"));
row.add(table ? snip.get("startdatespan") : snip.get("htksrq"));
row.add(table ? snip.get("enddatespan") : snip.get("htjsrq"));
row.add(table ? ResourceSnipUtils.selectJobName(snip.get("jobtitle")) : snip.get("gw"));
row.add(table ? ResourceSnipUtils.selectStatusName(snip.get("status")) : snip.get("zt"));
row.add(table ? ResourceSnipUtils.selectEducName(snip.get("educationlevel")) : snip.get("xl"));
row.add(table ? snip.get("mobilespan") : snip.get("dh"));
row.add(table ? snip.get("certificatenumspan") : snip.get("sfzh"));
row.add(table ? snip.get("nativeplacespan") : snip.get("jg"));
row.add(table ? snip.get("regresidentplacespan") : snip.get("hkszd"));
row.add(table ? snip.get("changedate") : snip.get("lzrq"));
rows.add(row);
}
List<List<Object>> excelSheetData = new ArrayList<>();
excelSheetData.add(headerList);
excelSheetData.addAll(rows);
String sheetName = "花名册快照"+monthDate;
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
}
@Override
public Map<String, List<HistoryResourcePO>> hrResource(Map<String, Object> param) {
String companyStartDate = Util.null2String(param.get("companyStartDate"));
String status = Util.null2String(param.get("status"));
String subcompanyId = Util.null2String(param.get("subcompanyId"));
String departmentId = Util.null2String(param.get("departmentId"));
Map<String, List<HistoryResourcePO>> resultMap = new HashMap<>(4);
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
String account = bb.getPropValue("jcsecond", "account");
String bankField = bb.getPropValue("jcsecond", "bankField");
String regresidentplace = bb.getPropValue("jcsecond", "regresidentplace");
String femdate = bb.getPropValue("jcsecond", "femdate");
LocalDate firstDayOfMonth = LocalDate.parse(companyStartDate + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate firstDay = firstDayOfMonth.withDayOfMonth(1);
LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
// 转换为字符串并打印结果
String firstDayStr = firstDay.format(DATE_FORMATTER);
String lastDayStr = lastDay.format(DATE_FORMATTER);
String sql = "select a.id,a.workcode,a.lastname,a.birthday,a.sex,a.subcompanyid1,a.departmentid,a.managerid,a.companystartdate,\n" +
"a.createdate,a.accumfundaccount,b."+account+" as account,b."+bankField+" as bankname,c."+femdate+" as femdate,\n" +
"a.startdate,a.enddate,a.jobtitle,a.status,a.educationlevel,a.mobile,a.certificatenum,\n" +
"a.nativeplace,b."+regresidentplace+" as regresidentplace from hrmresource a\n" +
"left join cus_fielddata b on a.id = b.id and b.scopeid = 1\n" +
"left join cus_fielddata c on a.id = c.id and c.scopeid = -1\n" +
"where a.companystartdate <= '"+lastDayStr+"'";
if (!StringUtil.isEmpty(subcompanyId) && !StringUtil.isEmpty(departmentId)) {
sql += " and (a.subcompanyid1 = "+subcompanyId+" or a.departmentid ="+departmentId+")";
} else if (!StringUtil.isEmpty(subcompanyId)) {
sql += " and a.subcompanyid1 ="+subcompanyId;
}else if (!StringUtil.isEmpty(departmentId)) {
sql += " and a.departmentid ="+departmentId;
}
if (!"9".equals(status)) {
//在职
if ("8".equals(status)) {
sql += " and a.status < 4";
}else {
sql += " and a.status = "+status;
}
}
rs.executeQuery(sql);
List<HistoryResourcePO> historyResourceList = new ArrayList<>();
while (rs.next()) {
HistoryResourcePO build = HistoryResourcePO.builder()
.resourceId(Util.getIntValue(rs.getString("id")))
.workcode(Util.null2String(rs.getString("workcode")))
.lastName(Util.null2String(rs.getString("lastname")))
.birthday(Util.null2String(rs.getString("birthday")))
.sex("0".equals(Util.null2String(rs.getString("sex"))) ? "男" : "女")
.subCompany(ResourceSnipUtils.selectSubCompanyName(Util.null2String(rs.getString("subcompanyid1"))))
.department(ResourceSnipUtils.selectDeptName(Util.null2String(rs.getString("departmentid"))))
.managerId(ResourceSnipUtils.selectResourceName(Util.null2String(rs.getString("managerid"))))
.companyStartDate(Util.null2String(rs.getString("companystartdate")))
.createDate(Util.null2String(rs.getString("createdate")))
.accumfundAccount(Util.null2String(rs.getString("accumfundaccount")))
.accountId(Util.null2String(rs.getString("account")))
.bankName(ResourceSnipUtils.selectBankName(Util.null2String(rs.getString("bankname")),bankField))
.firstEnrollmentDate(Util.null2String(rs.getString("femdate")))
.startdate(Util.null2String(rs.getString("startdate")))
.endDate(Util.null2String(rs.getString("enddate")))
.jobTitle(ResourceSnipUtils.selectJobName(Util.null2String(rs.getString("jobtitle"))))
.status(ResourceSnipUtils.selectStatusName(Util.null2String(rs.getString("status"))))
.educationlevel(ResourceSnipUtils.selectEducName(Util.null2String(rs.getString("educationlevel"))))
.mobile(Util.null2String(rs.getString("mobile")))
.certificatenum(Util.null2String(rs.getString("certificatenum")))
.nativeplace(Util.null2String(rs.getString("nativeplace")))
.regresidentplace(Util.null2String(rs.getString("regresidentplace")))
.build();
historyResourceList.add(build);
}
//todo 数据处理
//3.花名册年月 选择 2024-09 查询数据 2024-9.30 之前所有入职人员 去掉离职日期是2024年9.01之前的数据(注意返聘情况)
//3.1 选择日期前离职数据
List<HrmStatusPO> leaveList = new ArrayList<>();
rs.executeQuery("select resourceid,type_n,changedate from hrmstatushistory where type_n = 5 and changedate < '"+firstDayStr+"'");
while (rs.next()){
Integer resourceId = Util.getIntValue(rs.getString("resourceid"));
Integer typeN = Util.getIntValue(rs.getString("type_n"));
String changeDate = Util.null2String(rs.getString("changedate"));
leaveList.add(HrmStatusPO.builder().resourceId(resourceId).typeN(typeN).changeDate(changeDate).build());
}
List<HrmStatusPO> leaveResult = filterList(leaveList);
//3.2 返聘数据
List<HrmStatusPO> returnList = new ArrayList<>();
rs.executeQuery("select resourceid,type_n,changedate from hrmstatushistory where type_n = 7");
while(rs.next()) {
Integer resourceId = Util.getIntValue(rs.getString("resourceid"));
Integer typeN = Util.getIntValue(rs.getString("type_n"));
String changeDate = Util.null2String(rs.getString("changedate"));
returnList.add(HrmStatusPO.builder().resourceId(resourceId).typeN(typeN).changeDate(changeDate).build());
}
List<HrmStatusPO> returnResult = filterList(returnList);
//3.3 移除离职数据中存在返聘情况的人员 (返聘日期>离职日期)
List<HrmStatusPO> compareList = compareList(leaveResult, returnResult);
//3.4 查询数据中过滤人员
List<HistoryResourcePO> filteredList = historyResourceList.stream()
.filter(hrpo -> compareList.stream()
.noneMatch(hspo -> hspo.getResourceId().equals(hrpo.getResourceId())))
.collect(Collectors.toList());
//3.4 当月离职数据保留显示
List<HrmStatusPO> leaveMonthList = new ArrayList<>();
RecordSet rs1 = new RecordSet();
rs1.executeQuery("select resourceid,type_n,changedate from hrmstatushistory where type_n = 5 \n" +
"and changedate >= '"+firstDayStr+"' and changedate <= '"+lastDayStr+"'");
while (rs1.next()) {
Integer resourceId = Util.getIntValue(rs1.getString("resourceid"));
Integer typeN = Util.getIntValue(rs1.getString("type_n"));
String changeDate = Util.null2String(rs1.getString("changedate"));
leaveMonthList.add(HrmStatusPO.builder().resourceId(resourceId).typeN(typeN).changeDate(changeDate).build());
}
List<HrmStatusPO> leaveMonthResult = filterList(leaveMonthList);
Map<Integer, String> leaveMonthMap = leaveMonthResult.stream()
.collect(Collectors.toMap(HrmStatusPO::getResourceId, HrmStatusPO::getChangeDate));
filteredList.forEach(hrpo -> {
String newDate = leaveMonthMap.get(hrpo.getResourceId());
if (newDate != null) {
hrpo.setChangeDate(newDate);
}
});
resultMap.put("data",filteredList);
return resultMap;
}
@Override
public XSSFWorkbook hrResourceExport(HttpServletRequest request, HttpServletResponse response, Map<String, Object> param) {
BaseBean bb = new BaseBean();
String companyStartDate = Util.null2String(param.get("companyStartDate"));
//全字段导出
List<Object> headerList = Arrays.asList("编号","姓名","出生日期","性别","分部","部门","岗位","直接上级","入职日期","离职日期","状态","创建日期","公积金账户","工资账户","工资银行","首次参保时间",
"合同开始日期","合同结束日期","学历","电话","身份证号","籍贯","户口所在地");
Map<String, List<HistoryResourcePO>> stringMap = hrResource(param);
List<HistoryResourcePO> historyResourcePOS = stringMap.get("data");
List<List<Object>> rows = new LinkedList<>();
for (HistoryResourcePO hr : historyResourcePOS) {
List<Object> row = new LinkedList<>();
row.add(hr.getWorkcode());
row.add(hr.getLastName());
row.add(hr.getBirthday());
row.add(hr.getSex());
row.add(hr.getSubCompany());
row.add(hr.getDepartment());
row.add(hr.getJobTitle());
row.add(hr.getManagerId());
row.add(hr.getCompanyStartDate());
row.add(hr.getChangeDate());
row.add(hr.getStatus());
row.add(hr.getCreateDate());
row.add(hr.getAccumfundAccount());
row.add(hr.getAccountId());
row.add(hr.getBankName());
row.add(hr.getFirstEnrollmentDate());
row.add(hr.getStartdate());
row.add(hr.getEndDate());
row.add(hr.getEducationlevel());
row.add(hr.getMobile());
row.add(hr.getCertificatenum());
row.add(hr.getNativeplace());
row.add(hr.getRegresidentplace());
rows.add(row);
}
List<List<Object>> excelSheetData = new ArrayList<>();
excelSheetData.add(headerList);
excelSheetData.addAll(rows);
String sheetName = "花名册快照"+companyStartDate;
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
}
private List<HrmStatusPO> filterList(List<HrmStatusPO> list) {
return list.stream()
.collect(Collectors.groupingBy(
HrmStatusPO::getResourceId,
Collectors.maxBy(Comparator.comparing(
po -> LocalDate.parse(po.getChangeDate(), DATE_FORMATTER)
))
))
.values()
.stream()
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
}
private List<HrmStatusPO> compareList(List<HrmStatusPO> leaveResult,List<HrmStatusPO> returnResult) {
Map<String, LocalDate> returnResultMap = returnResult.stream()
.collect(Collectors.toMap(
po -> po.getResourceId().toString(),
po -> LocalDate.parse(po.getChangeDate(), DATE_FORMATTER)
));
// 2. 更新 leaveResult移除不符合条件的条目
return leaveResult.stream()
.filter(leavePo -> {
LocalDate leaveDate = LocalDate.parse(leavePo.getChangeDate(), DATE_FORMATTER);
LocalDate returnDate = returnResultMap.get(leavePo.getResourceId().toString());
return returnDate == null || leaveDate.isAfter(returnDate);
})
.collect(Collectors.toList());
}
}

@ -0,0 +1,446 @@
package com.engine.kqsolution.service.impl;
import cn.hutool.core.thread.ThreadUtil;
import com.alibaba.fastjson.JSON;
import com.cloudstore.eccom.constant.WeaBoolAttr;
import com.cloudstore.eccom.pc.table.WeaTable;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.pc.table.WeaTableType;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.core.impl.Service;
import com.engine.kq.biz.KQShiftManagementComInfo;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kqsolution.entity.*;
import com.engine.kqsolution.service.SignDataSummaryService;
import lombok.SneakyThrows;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import weaver.common.DateUtil;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.general.BaseBean;
import weaver.general.PageIdConst;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2023/9/18 11:45 AM
* @Description:
* @Version 1.0
*/
public class SignDataSummaryServiceImpl extends Service implements SignDataSummaryService {
public static final DateTimeFormatter MONTH_FORMATTER_PATTERN = DateTimeFormatter.ofPattern("yyyy-MM");
@Override
public Map<String, Object> recordSignData(SignDataParams signDataParams) {
List<SignDataPO> list = buildSignData(signDataParams);
return saveSignData(list,signDataParams);
}
@Override
public Map<String, Object> customSignData(CustomSignDataParam param) {
Map<String,Object> data = new HashMap<>(4);
List<Integer> idList = new ArrayList<>();
//获取部门下人员id
RecordSet rs = new RecordSet();
rs.executeQuery("select id from hrmresource where departmentid in ("+param.getDepartments()+")");
while (rs.next()) {
idList.add(Util.getIntValue(rs.getString("id")));
}
if (CollectionUtils.isEmpty(idList)){
data.put("msg","部门下未存在人员");
return data;
}
LocalDate localDate = LocalDate.parse(param.getMonth()+"-01");
String fromDate = localDate.toString();
String toDate = localDate.withDayOfMonth(localDate.lengthOfMonth()).toString();
String ids = StringUtils.join(idList,",");
rs.executeQuery("select kqdate,resourceid,signindate,signintime,signoutdate,signouttime,signMins from kq_format_detail \n" +
" where kqdate >= ? and kqdate <= ?" +
" and resourceid in ("+ids+")",fromDate,toDate);
List<SignDataPO> pos = new ArrayList<>();
DecimalFormat decimalFormat = new DecimalFormat("0.00");
while (rs.next()) {
String signInTime = Util.null2String(rs.getString("signintime"));
String signOutTime = Util.null2String(rs.getString("signouttime"));
if (!"".equals(signInTime)){
signInTime = signInTime.substring(0,5);
}
if (!"".equals(signOutTime)){
signOutTime = signOutTime.substring(0,5);
}
Integer signMins = Util.getIntValue(Util.null2String(rs.getString("signMins")),0);
int resourceid = Util.getIntValue(rs.getString("resourceid"));
String kqdate = Util.null2String(rs.getString("kqdate"));
double hours = (double) signMins / 60;
double workHours;
if (hours <= 4.0) {
workHours = hours;
} else {
workHours = Math.floor(hours);
String kqRestTime = checkKqRestTime(String.valueOf(resourceid), kqdate);
if ("1".equals(kqRestTime)) {
workHours = Math.floor(hours - 1.0);
}
}
SignDataPO build = SignDataPO.builder()
.resourceId(resourceid)
.attendanceDate(kqdate)
.signInDate(Util.null2String(rs.getString("signindate")))
.signInTime(signInTime)
.signOutDate(Util.null2String(rs.getString("signoutdate")))
.signOutTime(signOutTime)
.signHours(Double.parseDouble(decimalFormat.format(hours)))
.workHours(Double.parseDouble(decimalFormat.format(workHours)))
.build();
pos.add(build);
}
RecordSetTrans rst = new RecordSetTrans();
if (CollectionUtils.isNotEmpty(pos)) {
try {
rst.setAutoCommit(false);
for (SignDataPO item : pos) {
rst.executeUpdate("update uf_kqgs set qdrq = ?,qdsj = ?,qtrq = ?,qtsj = ?,dkgssc = ?,sjgssc = ? where kqrq = ? and xm=? and zt = 0",item.getSignInDate(),
item.getSignInTime(),item.getSignOutDate(),item.getSignOutTime(),item.getSignHours(),item.getWorkHours(),item.getAttendanceDate(),item.getResourceId());
}
rst.commit();
}catch (Exception e) {
rst.rollback();
}
}
return data;
}
@SneakyThrows
@Override
public List<WorkflowDetailVO> workflowDetail(String ids) {
RecordSet rs = new RecordSet();
List<WorkflowDetailVO> data = new ArrayList<>();
ResourceComInfo comInfo = new ResourceComInfo();
rs.executeQuery("select id,kqrq,xm,sjgssc from uf_kqgs where id in ("+ids+")");
while (rs.next()) {
String personName = comInfo.getLastname(Util.null2String(rs.getString("xm")));
data.add(WorkflowDetailVO.builder()
.id(Util.getIntValue(rs.getString("id")))
.attendanceDate(Util.null2String(rs.getString("kqrq")))
.personId(Util.getIntValue(rs.getString("xm")))
.personName(personName)
.workHours(Util.getDoubleValue(rs.getString("sjgssc")))
.build());
}
return data;
}
@Override
public Map<String, Object> kqExceptionReport(Map<String, Object> params) {
RecordSet rs = new RecordSet();
Map<String, Object> resultMap = new HashMap<>(4);
String date = Util.null2String(params.get("date"));
String subCompanyId = Util.null2String(params.get("subCompanyId"));
String departmentId = Util.null2String(params.get("departmentId"));
String resourceId = Util.null2String(params.get("resourceId"));
String firstDay = firstDayOfMonth(date);
String lastDay = lastDayOfMonth(date);
WeaTable table = new WeaTable();
String pageId = "1f44e9bc-70e0-4f8b-abb5-fcd2ada5bd98";
table.setPageID(pageId);
table.setPageUID(String.format("%s_%s",pageId,user.getUID()));
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
table.setPagesize(pageSize);
String fields = "a.resourceid,b.workcode,b.subcompanyid1,b.departmentid,b.jobtitle," +
" CAST(ISNULL(SUM(belate), 0) AS VARCHAR) + '/' + \n" +
" CAST(ISNULL(SUM(gravebelate), 0) AS VARCHAR) + '/' + \n" +
" CAST(ISNULL(SUM(leaveeearly), 0) AS VARCHAR) + '/' + \n" +
" CAST(ISNULL(SUM(graveleaveearly), 0) AS VARCHAR) + '/' + \n" +
" CAST(ISNULL(SUM(absenteeism), 0) AS VARCHAR) + '/' + \n" +
" CAST(ISNULL(SUM(forgotcheck), 0) AS VARCHAR) AS result\n ";
table.setBackfields(fields);
String fromSql = " from kq_format_total a left join hrmresource b on a.resourceid = b.id";
table.setSqlform(fromSql);
String sqlWhere = " where kqdate >= '"+firstDay+"' and kqdate <= '"+lastDay+"' ";
if (StringUtils.isNotEmpty(subCompanyId)) {
sqlWhere += " and b.subcompanyid1 in ("+subCompanyId+")";
}
if (StringUtils.isNotEmpty(departmentId)) {
sqlWhere += " and b.departmentid in ("+departmentId+")";
}
if (StringUtils.isNotEmpty(resourceId)) {
sqlWhere += " and a.resourceid in ("+resourceId+")";
}
sqlWhere += " group by a.resourceid,b.workcode,b.subcompanyid1,b.departmentid,b.jobtitle";
table.setSqlwhere(sqlWhere);
table.setSqlprimarykey("a.resourceid");
table.getColumns().add(new WeaTableColumn("10%", "姓名", "resourceid").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectResourceName"));
table.getColumns().add(new WeaTableColumn("10%", "工号", "workcode"));
table.getColumns().add(new WeaTableColumn("10%", "分部", "subcompanyid1").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectSubCompanyName"));
table.getColumns().add(new WeaTableColumn("10%", "部门", "departmentid").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectDeptName"));
table.getColumns().add(new WeaTableColumn("10%", "岗位", "jobtitle").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectJobName"));
table.getColumns().add(new WeaTableColumn("10%", "考勤结果", "result").setTransmethod("com.engine.kqsolution.util.ResourceSnipUtils.selectKqResult"));
table.setTableType(WeaTableType.NONE);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
resultMap.putAll(result.getResultMap());
return resultMap;
}
private String firstDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate firstDayOfMonth = yearMonth.atDay(1);
return firstDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
private String lastDayOfMonth(String yearMonthStr) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
YearMonth yearMonth = YearMonth.parse(yearMonthStr, formatter);
LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
return lastDayOfMonth.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
@SneakyThrows
private Map<String, Object> saveSignData(List<SignDataPO> list,SignDataParams signDataParams){
Map<String,Object> data = new HashMap<>(4);
BaseBean bb = new BaseBean();
DecimalFormat decimalFormat = new DecimalFormat("0.00");
RecordSetTrans rst = new RecordSetTrans();
RecordSet rs = new RecordSet();
ResourceComInfo rcom = new ResourceComInfo();
int corePoolSize = 5;
int maxPoolSize = 10;
int batchSize = 200;
List<List<SignDataPO>> splittedLists = splitList(list,batchSize);
// 创建线程池
ExecutorService executorService = ThreadUtil.newExecutor(corePoolSize, maxPoolSize);
for (List<SignDataPO> subList : splittedLists) {
executorService.submit(() -> {
for (SignDataPO signDataPo : subList) {
String resourceId = String.valueOf(signDataPo.getResourceId());
Integer signMins = Util.getIntValue(signDataPo.getSignMins(),0);
double hours = (double) signMins / 60;
double workHours;
if (hours <= 4.0) {
workHours = hours;
} else {
workHours = Math.floor(hours);
String kqRestTime = checkKqRestTime(resourceId, signDataPo.getAttendanceDate());
if ("1".equals(kqRestTime)) {
workHours = Math.floor(hours - 1.0);
}
}
signDataPo.setCompany(Integer.parseInt(rcom.getSubCompanyID(resourceId)));
signDataPo.setDepartment(Integer.parseInt(rcom.getDepartmentID(resourceId)));
signDataPo.setJobTitle(Integer.parseInt(rcom.getJobTitle(resourceId)));
signDataPo.setSignHours(Double.parseDouble(decimalFormat.format(hours)));
signDataPo.setWorkHours(Double.parseDouble(decimalFormat.format(workHours)));
}
});
}
// 关闭线程池
executorService.shutdown();
while (!executorService.isTerminated()) {
}
try {
rst.setAutoCommit(false);
if (CollectionUtils.isNotEmpty(signDataParams.getIds())) {
for (SignDataPO item : list) {
rst.executeUpdate("update uf_kqgs set qdrq = ?,qdsj = ?,qtrq = ?,qtsj = ?,dkgssc = ?,sjgssc = ? where id = ? and zt = 0",item.getSignInDate(),
item.getSignInTime(),item.getSignOutDate(),item.getSignOutTime(),item.getSignHours(),item.getWorkHours(),item.getId());
}
}else {
//同一考勤日期执行多次
rst.executeUpdate("delete from uf_kqgs where kqrq = ? and zt = 0",signDataParams.getAttendanceDate());
//获取锁定状态数据
List<Integer> idList = new ArrayList<>();
rs.executeQuery(" select xm from uf_kqgs where kqrq = ?",signDataParams.getAttendanceDate());
while (rs.next()) {
idList.add(Util.getIntValue(rs.getString("xm")));
}
list = list.stream()
.filter(p -> !idList.contains(p.getResourceId()))
.collect(Collectors.toList());
for (SignDataPO item : list) {
rst.executeUpdate("insert into uf_kqgs(formmodeid,xm,kqy,kqrq,zt,fb,bm,gw,qdrq,qdsj,qtrq,qtsj,dkgssc,sjgssc) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", signDataParams.getFormModeId(), item.getResourceId(),
item.getAttendanceMonth(), item.getAttendanceDate(), item.getStatus(), item.getCompany(), item.getDepartment(),
item.getJobTitle(), item.getSignInDate(), item.getSignInTime(), item.getSignOutDate(), item.getSignOutTime(),
item.getSignHours(), item.getWorkHours());
}
}
rst.commit();
bb.writeLog("定时任务同步全部执行成功");
data.put("count",list.size());
}catch (Exception e) {
rst.rollback();
}
return data;
}
/**
*
* @param signDataParams
* @return
*/
private List<SignDataPO> buildSignData(SignDataParams signDataParams) {
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
List<SignDataPO> pos = new ArrayList<>();
String formatYearMonth = getFormatLocalDate(LocalDate.now(),MONTH_FORMATTER_PATTERN);
if (StringUtils.isNotEmpty(signDataParams.getAttendanceDate())) {
formatYearMonth = signDataParams.getAttendanceDate().substring(0,7);
}
if (CollectionUtils.isNotEmpty(signDataParams.getIds())) {
String ids = StringUtils.join(signDataParams.getIds(),",");
rs.executeQuery("select u.id,u.xm,u.kqrq,u.kqy,k.signindate,k.signintime,k.signoutdate,k.signouttime,k.signMins from uf_kqgs u inner join kq_format_detail k" +
" on u.xm = k.resourceid and u.kqrq = k.kqdate and u.zt = 0 and u.id in ("+ids+")");
while (rs.next()) {
String signInTime = Util.null2String(rs.getString("signintime"));
String signOutTime = Util.null2String(rs.getString("signouttime"));
if (!"".equals(signInTime)){
signInTime = signInTime.substring(0,5);
}
if (!"".equals(signOutTime)){
signOutTime = signOutTime.substring(0,5);
}
SignDataPO build = SignDataPO.builder()
.id(Util.getIntValue(rs.getString("id")))
.resourceId(Util.getIntValue(rs.getString("xm")))
.attendanceMonth(Util.null2String(rs.getString("kqy")))
.attendanceDate(Util.null2String(rs.getString("kqrq")))
.signInDate(Util.null2String(rs.getString("signindate")))
.signInTime(signInTime)
.signOutDate(Util.null2String(rs.getString("signoutdate")))
.signOutTime(signOutTime)
.signMins(Util.null2String(rs.getString("signMins")))
.build();
pos.add(build);
}
}else {
rs.executeQuery("select resourceid,kqdate,signindate,signintime,signoutdate,signouttime,signMins from kq_format_detail where kqdate = ?",signDataParams.getAttendanceDate());
while (rs.next()) {
String signInTime = Util.null2String(rs.getString("signintime"));
String signOutTime = Util.null2String(rs.getString("signouttime"));
if (!"".equals(signInTime)){
signInTime = signInTime.substring(0,5);
}
if (!"".equals(signOutTime)){
signOutTime = signOutTime.substring(0,5);
}
SignDataPO build = SignDataPO.builder()
.resourceId(Util.getIntValue(rs.getString("resourceid")))
.attendanceMonth(formatYearMonth)
.attendanceDate(Util.null2String(rs.getString("kqdate")))
.status(0)
.signInDate(Util.null2String(rs.getString("signindate")))
.signInTime(signInTime)
.signOutDate(Util.null2String(rs.getString("signoutdate")))
.signOutTime(signOutTime)
.signMins(Util.null2String(rs.getString("signMins")))
.build();
bb.writeLog("同步数据详情"+ JSON.toJSONString(build));
pos.add(build);
}
}
//日志
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
String formattedDateTime = now.format(formatter);
bb.writeLog("打卡数据同步执行时间:"+formattedDateTime+"==数据size:"+ pos.size());
return pos;
}
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/9/13 2:46 PM
* @param: [list, batchSize]
* @return: java.util.List<java.util.List<T>>
*/
private <T> List<List<T>> splitList(List<T> list, int batchSize) {
List<List<T>> splittedLists = new ArrayList<>();
for (int i = 0; i < list.size(); i += batchSize) {
int endIndex = Math.min(i + batchSize, list.size());
List<T> subList = list.subList(i, endIndex);
splittedLists.add(subList);
}
return splittedLists;
}
private String checkKqRestTime(String id,String gzrq) {
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(id, gzrq);
String serialId = workTimeEntity.getSerialId();
if (StringUtils.isBlank(serialId) || "-1".equals(serialId)) {
kqWorkTime.setIsFormat(true);
workTimeEntity = kqWorkTime.getWorkTime(id, gzrq);
serialId = workTimeEntity.getSerialId();
}
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
return kqShiftManagementComInfo.getIsresttimeopen(serialId);
}
public String getFormatLocalDate(LocalDate localDate,DateTimeFormatter type) {
if (localDate == null) {
return StringUtils.EMPTY;
}
try {
return localDate.format(type);
} catch (Exception e) {
return StringUtils.EMPTY;
}
}
}

@ -0,0 +1,69 @@
package com.engine.kqsolution.util;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.xssf.usermodel.*;
import java.util.List;
public class ExcelUtil {
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.setFontName("仿宋");
titleFont.setFontHeightInPoints((short) 15);
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
titleCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());//背景色
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// 设置主体样式
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 10);// 设置字体大小
cellStyle.setFont(font);// 选择需要用到的字体格式
cellStyle.setWrapText(true);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(25);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
List<Object> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex);
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
XSSFCell cell = row.createCell(cellIndex);
if (rowIndex == 0) {
cell.setCellStyle(titleCellStyle);
} else {
cell.setCellStyle(cellStyle);
}
Object o = infoList.get(cellIndex);
if (o instanceof String) {
cell.setCellType(CellType.STRING);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Boolean) {
cell.setCellType(CellType.BOOLEAN);
cell.setCellValue(String.valueOf(o));
} else {
cell.setCellType(CellType.STRING);
cell.setCellValue(o == null ? "" : o.toString());
}
}
}
return workbook;
}
}

@ -0,0 +1,143 @@
package com.engine.kqsolution.util;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.EducationLevelComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.resource.ResourceComInfo;
import java.util.Arrays;
/**
* @Author liang.cheng
* @Date 2024/8/28 2:35 PM
* @Description:
* @Version 1.0
*/
public class ResourceSnipUtils {
/**
*
* @param subcompanyid
* @return
*/
public static String selectSubCompanyName(String subcompanyid) {
SubCompanyComInfo sub = new SubCompanyComInfo();
return sub.getSubCompanyname(subcompanyid);
}
/**
*
* @param departmentId
* @return
*/
public static String selectDeptName(String departmentId) {
DepartmentComInfo dept = new DepartmentComInfo();
try {
return dept.getDepartmentName(departmentId);
} catch (Exception e) {
return "";
}
}
/**
*
* @param jobId
* @return
*/
public static String selectJobName(String jobId) {
JobTitlesComInfo jc = new JobTitlesComInfo();
return jc.getJobTitlesname(jobId);
}
/**
*
* @param resourceId
* @return
*/
public static String selectResourceName(String resourceId) {
try {
ResourceComInfo rc = new ResourceComInfo();
return rc.getLastname(resourceId);
} catch (Exception e) {
return "";
}
}
/**
*
* @param sex
* @return
*/
public static String selectSexName(String sex) {
return "0".equals(sex) ? "男" : "女";
}
/**
*
* @return
*/
public static String selectKqResult(String value) {
boolean flag = Arrays.stream(value.split("/"))
.mapToInt(Integer::parseInt)
.anyMatch(n -> n > 0);
return flag ? "异常" :"正常";
}
/**
*
* @param fieldId
* @param value
* @return
*/
public static String selectBankName(String value,String fieldId){
RecordSet rs = new RecordSet();
String id = fieldId.substring(Math.min(5, fieldId.length()));
rs.executeQuery("select selectname from cus_selectitem where fieldid = ? and selectvalue = ?",id,value);
rs.next();
return Util.null2String(rs.getString("selectname"));
}
/**
*
* @param status
* @return
*/
public static String selectStatusName(String status) {
switch (status) {
case "0":
return "试用";
case "1":
return "正式";
case "2":
return "临时";
case "3":
return "试用延期";
case "4":
return "解聘";
case "5":
return "离职";
case "6":
return "退休";
case "7":
return "无效";
default :
return "";
}
}
/**
*
* @param educLevel
* @return
*/
public static String selectEducName(String educLevel){
EducationLevelComInfo educ = new EducationLevelComInfo();
return educ.getEducationLevelname(educLevel);
}
}

@ -0,0 +1,50 @@
package com.engine.kqsolution.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.kqsolution.service.ProjectPriceService;
import com.engine.kqsolution.service.impl.ProjectPriceServiceImpl;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 2024/9/2 10:18 AM
* @Description:
* @Version 1.0
*/
public class ProjectPriceAction {
private ProjectPriceService getService(User user) {
return ServiceUtil.getService(ProjectPriceServiceImpl.class, user);
}
@POST
@Path("/sign")
@Produces(MediaType.TEXT_PLAIN)
public String customSignData(@Context HttpServletRequest request, @Context HttpServletResponse response){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
data.putAll(getService(user).signData(map));
data.put("status", true);
} catch (Exception e) {
data.put("status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
}

@ -0,0 +1,117 @@
package com.engine.kqsolution.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.kqsolution.service.ResourceSnipService;
import com.engine.kqsolution.service.impl.ResourceSnipServiceImpl;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/8/29 9:22 AM
* @Description: TODO
* @Version 1.0
*/
public class ResourceSnipAction {
private ResourceSnipService getService(User user) {
return ServiceUtil.getService(ResourceSnipServiceImpl.class, user);
}
@GET
@Path("/snipshot")
@Produces(MediaType.TEXT_PLAIN)
public String resourceSnip(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("monthDate") String monthDate,@QueryParam("companyStartDate") String companyStartDate){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("datas",getService(user).resourceSnip(monthDate,companyStartDate));
data.put("api_status", true);
} catch (Exception e) {
data.put("api_status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
@GET
@Path("/snipshot/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response snipshotExport(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("monthDate") String monthDate,@QueryParam("companyStartDate") String companyStartDate) {
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getService(user).snipshotExport(request, response, monthDate,companyStartDate);
String fileName = "花名册快照" + monthDate;
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
StreamingOutput output = outputStream -> {
workbook.write(outputStream);
outputStream.flush();
};
response.setContentType("application/octet-stream");
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
}
@GET
@Path("/hrResource")
@Produces(MediaType.TEXT_PLAIN)
public String hrResource(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("companyStartDate") String companyStartDate){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> param = ParamUtil.request2Map(request);
data.put("datas",getService(user).hrResource(param));
data.put("api_status", true);
} catch (Exception e) {
data.put("api_status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
@GET
@Path("/hrResource/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response hrResourceExport(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("companyStartDate") String companyStartDate) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> param = ParamUtil.request2Map(request);
XSSFWorkbook workbook = getService(user).hrResourceExport(request, response, param);
String fileName = "人事花名册";
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
StreamingOutput output = outputStream -> {
workbook.write(outputStream);
outputStream.flush();
};
response.setContentType("application/octet-stream");
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
}
}

@ -0,0 +1,102 @@
package com.engine.kqsolution.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.kqsolution.entity.CustomSignDataParam;
import com.engine.kqsolution.entity.SignDataParams;
import com.engine.kqsolution.service.SignDataSummaryService;
import com.engine.kqsolution.service.impl.SignDataSummaryServiceImpl;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2023/9/18 11:43 AM
* @Description:
* @Version 1.0
*/
public class SignDataSummaryAction {
private SignDataSummaryService getService(User user) {
return ServiceUtil.getService(SignDataSummaryServiceImpl.class, user);
}
@POST
@Path("/recordSignData")
@Produces(MediaType.TEXT_PLAIN)
public String recordSignData(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody SignDataParams signDataParams){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.putAll(getService(user).recordSignData(signDataParams));
data.put("status", true);
} catch (Exception e) {
data.put("status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
@POST
@Path("/customSignData")
@Produces(MediaType.TEXT_PLAIN)
public String customSignData(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody CustomSignDataParam customSignDataParam){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.putAll(getService(user).customSignData(customSignDataParam));
data.put("status", true);
} catch (Exception e) {
data.put("status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
@GET
@Path("/workflowDetail")
@Produces(MediaType.TEXT_PLAIN)
public String workflowDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam("ids") String ids){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("datas",getService(user).workflowDetail(ids));
data.put("status", true);
} catch (Exception e) {
data.put("status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
@GET
@Path("/kqExceptionReport")
@Produces(MediaType.TEXT_PLAIN)
public String kqExceptionReport(@Context HttpServletRequest request, @Context HttpServletResponse response){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("datas",getService(user).kqExceptionReport(ParamUtil.request2Map(request)));
data.put("api_status", true);
} catch (Exception e) {
data.put("api_status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
}

@ -1,5 +1,13 @@
package test;
import weaver.common.DateUtil;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
/**
* @Author weaver_cl
* @Description:
@ -9,6 +17,14 @@ package test;
public class MainTest {
public static void main(String[] args) {
String lastDayOfMonthToString = DateUtil.getLastDayOfMonthToString(new Date());
String firstDayOfMonthToString = DateUtil.getFirstDayOfMonthToString(new Date());
System.out.println(lastDayOfMonthToString);
System.out.println(firstDayOfMonthToString);
}
}

@ -0,0 +1,42 @@
package weaver.interfaces.dfjc.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class KqMonthDataPO {
private Integer id;
private String attendanceMonth;
private String status;
private String resourceId;
private String departmentId;
private String jobTitle;
private Double psjbbdx;
private Double xxrjbbdx;
private Double jjrjbbdx;
private Double dkzgs;
private Double zgs;
private Double ccxs;
}

@ -0,0 +1,24 @@
package weaver.interfaces.dfjc.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProWagDetPO {
private String mainId;
private String id;
private String lhid;
private String lh;
private String lp;
private String unitPrice;
private String storageDate;
private String storageNumber;
private String storageAmount;
}

@ -0,0 +1,237 @@
package weaver.interfaces.dfjc.job;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.util.KQDurationCalculatorUtil;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.dfjc.entity.KqMonthDataPO;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author wanxq
* @date 2024011709:53:08
* @desc
*/
public class KqMonthReportSynJob extends BaseCronJob {
private BaseBean log = new BaseBean();
private String synType;
public String getSynType() {
return synType;
}
public void setSynType(String synType) {
this.synType = synType;
}
@Override
public void execute() {
String fromDate = TimeUtil.getLastMonthBeginDay();
String toDate = TimeUtil.getLastMonthEndDay();
if("1".equals(synType)){
fromDate = DateUtil.getFirstDayOfMonthToString();
toDate = DateUtil.getLastDayOfMonthToString();
}
String currentMonth = fromDate.substring(0,7);
Map<String,Object> flowData = getKqOvertimeData(fromDate,toDate);
Map<String,Object> signData = getSignData(fromDate,toDate);
RecordSet rs = new RecordSet();
String sql = " select a.id,a.departmentid,a.jobtitle,a.status from hrmresource a,kq_format_total b " +
" where a.id= b.resourceid and b.kqdate >=? and b.kqdate <=? " +
" and a.subcompanyid1 =6 " +
" group by a.id,a.departmentid,a.jobtitle,a.status ";
rs.executeQuery(sql,fromDate,toDate);
while(rs.next()){
String userid = Util.null2String(rs.getString("id"));
String departmentid = Util.null2String(rs.getString("departmentid"));
String jobtitle = Util.null2String(rs.getString("jobtitle"));
String status = Util.null2String(rs.getString("status"));
double psjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(userid+"|workingDayOvertime_nonleave"))),0);
double xxrjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(userid+"|restDayOvertime_nonleave"))),0);
double jjrjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(userid+"|holidayOvertime_nonleave"))),0);
double dkzgs = Util.getDoubleValue(Util.null2String(signData.get(userid)),0);
//获取出差时长
double ccxs = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(userid+"|businessLeave"))),0);
double zgs = psjbbdx+xxrjbbdx+jjrjbbdx+dkzgs+ccxs;
KqMonthDataPO kqMonthDataPO = KqMonthDataPO.builder()
.resourceId(userid)
.status(status)
.departmentId(departmentid)
.jobTitle(jobtitle)
.psjbbdx(psjbbdx)
.xxrjbbdx(xxrjbbdx)
.jjrjbbdx(jjrjbbdx)
.dkzgs(dkzgs)
.zgs(zgs)
.ccxs(ccxs)
.build();
log.writeLog("KqMonthReportSynJob==>"+JSON.toJSONString(kqMonthDataPO));
saveData(kqMonthDataPO,currentMonth);
}
}
/**
*
* @param fromDate
* @param toDate
* @return
*/
public Map<String,Object> getKqOvertimeData(String fromDate,String toDate){
User user = User.getUser(1,0);
Map<String,Object> params = new HashMap<>();
JSONObject jsonObject = new JSONObject();
jsonObject.put("isNoAccount","1");
jsonObject.put("attendanceSerial","");
jsonObject.put("status","9");
jsonObject.put("viewScope","0");
jsonObject.put("typeselect","6");
jsonObject.put("fromDate",fromDate);
jsonObject.put("toDate",toDate);
params.put("data",jsonObject);
KQReportBiz kqReportBiz = new KQReportBiz();
Map<String,Object> flowData = kqReportBiz.getFlowData(params,user);
return flowData;
}
/**
*
* @param fromDate
* @param toDate
* @return
*/
public Map<String,Object> getSignData(String fromDate,String toDate){
Map<String,Object> signData = new HashMap<>();
RecordSet rs = new RecordSet();
String sql = " select xm,sum(sjgssc) workhours from uf_kqgs where kqrq>=? and kqrq<=? and fb=6 group by xm ";
rs.executeQuery(sql,fromDate,toDate);
while (rs.next()){
String xm = Util.null2String(rs.getString("xm"));
String workhours = Util.null2String(rs.getString("workhours"));
signData.put(xm,workhours);
}
return signData;
}
/**
*
* @param kqMonthDataPO
* @param month
*/
public void saveData(KqMonthDataPO kqMonthDataPO,String month){
RecordSet rs = new RecordSet();
int formmodeid = getModeIdByTableName("uf_ydgs");
int modedatacreater = 1;
String xm = kqMonthDataPO.getResourceId();
String zt = kqMonthDataPO.getStatus();
String bm = kqMonthDataPO.getDepartmentId();
String gw = kqMonthDataPO.getJobTitle();
Double dkzgs = kqMonthDataPO.getDkzgs();
Double psjbbdx = kqMonthDataPO.getPsjbbdx();
Double xxrjbbdx = kqMonthDataPO.getXxrjbbdx();
Double jjrjbbdx = kqMonthDataPO.getJjrjbbdx();
Double zgs = kqMonthDataPO.getZgs();
Double ccxs = kqMonthDataPO.getCcxs();
boolean exist = isExist(month,kqMonthDataPO.getResourceId());
if(exist){
//更新
String updateSql = " update uf_ydgs set dkzgs=?, psjbbdx=?, xxrjbbdx=?, jjrjbbdx=?, zgs=?, zt=?, ccxs=? where xm=? and kqy=? ";
rs.executeUpdate(updateSql,new Object[]{dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,xm,month});
}else{
//插入
String modeuuid = UUID.randomUUID().toString();
String modedatacreatedate = TimeUtil.getCurrentDateString();
String modedatacreatetime = TimeUtil.getOnlyCurrentTimeString();
String insertSql = " insert into uf_ydgs(xm,bm,gw,kqy,dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,"+
"formmodeid,modedatacreater,modedatacreatedate,modedatacreatetime,modeuuid) " +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
rs.executeUpdate(insertSql,new Object[]{xm,bm,gw,month,dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,
formmodeid,modedatacreater,modedatacreatedate,modedatacreatetime,modeuuid});
rs.executeQuery("select id from uf_ydgs where modeuuid=?",modeuuid);
rs.next();
int id = rs.getInt("id");
if(id>0){
ModeRightInfo right = new ModeRightInfo();
right.editModeDataShare(1, formmodeid, id);
}
}
}
/**
*
* @param month
* @param userid
* @return
*/
public boolean isExist(String month,String userid){
RecordSet rs = new RecordSet();
String sql = " select 1 from uf_ydgs where kqy=? and xm=? ";
rs.executeQuery(sql,month,userid);
return rs.next();
}
/**
* id,使
* @param tableName
* @return int id
*/
public static int getModeIdByTableName(String tableName){
RecordSet rs = new RecordSet();
String sql = " select a.id from modeinfo a,workflow_bill b where a.formid=b.id and b.tablename =? ";
rs.executeQuery(sql, tableName);
if (rs.next()) {
return rs.getInt("id");
}
return -1;
}
}

@ -0,0 +1,136 @@
package weaver.interfaces.hostar.action;
import com.engine.kq.biz.KQFormatBiz;
import com.engine.kq.wfset.util.SplitActionUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
public class OutSignSyncAction implements Action {
BaseBean bb = new BaseBean();
@Override
public String execute(RequestInfo requestInfo) {
bb.writeLog("OutSignSyncAction-start");
String startDate = "";
String endDate = "";
String resourceid = "";
String nbtxr = "";
String sjjsrq = "";
try {
Property[] properties = requestInfo.getMainTableInfo().getProperty();
for (Property property : properties) {
if ("ksrq".equals(property.getName())) {
startDate = Util.null2String(property.getValue());
}
if ("yjjsrq".equals(property.getName())) {
endDate = Util.null2String(property.getValue());
}
if ("sjccr".equals(property.getName())) {
resourceid = Util.null2String(property.getValue());
}
if ("nbtxr".equals(property.getName())) {
nbtxr = Util.null2String(property.getValue());
}
if ("sjjsrq".equals(property.getName())) {
sjjsrq = Util.null2String(property.getValue());
}
}
// 如果实际结束日期不为空,则用实际结束日期
if (StringUtils.isNotBlank(sjjsrq)) {
endDate = sjjsrq;
}
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate) && StringUtils.isNotBlank(resourceid)) {
// 内部同行人也要考虑
if (StringUtils.isNotBlank(nbtxr)) {
resourceid = resourceid + "," + nbtxr;
}
RecordSet rs = new RecordSet();
List<String> infos = new ArrayList<>();
String acqOutSignSql = "select a.id, c.signinfo " +
"from mobile_sign a " +
"left join uf_outsigntype c " +
"on c.outsignid = a.id " +
"where operate_date > '" + startDate + "' and operate_date < '" + endDate + "' and operater in (?) ";
rs.executeQuery(acqOutSignSql, resourceid);
while (rs.next()) {
String signinfo = Util.null2String(rs.getString("signinfo"));
infos.add(signinfo);
}
for (String inf : infos) {
if (inf != null) {
Map<String, Object> in = mapStringToMap(inf);
String userId = Util.null2String(in.get("userId"));
String userType = Util.null2String(in.get("userType"));
String signType = Util.null2String(in.get("signType"));
String signDate = Util.null2String(in.get("signDate"));
String signTime = Util.null2String(in.get("signTime"));
String clientAddress = Util.null2String(in.get("clientAddress"));
String isInCom = Util.null2String(in.get("isInCom"));
String timeZone = Util.null2String(in.get("timeZone"));
String belongdate = Util.null2String(in.get("belongdate"));
String signfrom = Util.null2String(in.get("signfrom"));
String longitude = Util.null2String(in.get("longitude"));
String latitude = Util.null2String(in.get("latitude"));
String address = Util.null2String(in.get("address"));
String deviceInfo = Util.null2String(in.get("deviceInfo"));
String belongdateIsNull = Util.null2String(in.get("belongdateIsNull"));
String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,isdev) " +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
boolean isok = rs.executeUpdate(punchSql, resourceid, userType, signType, signDate, signTime, clientAddress, isInCom,
timeZone, belongdate, signfrom, longitude, latitude, address, deviceInfo, "1");
bb.writeLog("isok: " + isok);
//同步更新考勤数据到考勤报表
if ("true".equals(belongdateIsNull)) {
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + DateUtil.getYesterday());
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
}
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
if (belongdate.length() == 0) {
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
}
new KQFormatBiz().formatDate("" + userId, (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
//外勤签到转的考勤 处理加班规则
SplitActionUtil.pushOverTimeTasksAll(belongdate, belongdate, "" + userId);
}
}
}
} catch (Exception e) {
bb.writeLog("OutSignSyncAction Exception: " + e);
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
public static Map<String, Object> mapStringToMap(String str) {
str = str.substring(1, str.length() - 1);
String[] strs = str.split(",");
Map<String, Object> map = new HashMap<>();
for (String string : strs) {
String key = string.split("=")[0];
String value = string.split("=")[1];
// 去掉头部空格
String key1 = key.trim();
String value1 = value.trim();
map.put(key1, value1);
}
return map;
}
}

@ -0,0 +1,50 @@
package weaver.interfaces.kqsolution.crob;
import com.engine.kqsolution.service.impl.ProjectPriceServiceImpl;
import weaver.conn.RecordSet;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2024/9/2 10:08 AM
* @Description: 线
* @Version 1.0
*/
public class ProjectPriceCrob extends BaseCronJob {
@Override
public void execute() {
RecordSet rs = new RecordSet();
ProjectPriceServiceImpl project = new ProjectPriceServiceImpl();
LocalDate today = LocalDate.now();
LocalDate firstDayOfMonth = today.withDayOfMonth(1);
LocalDate lastDayOfMonth = today.withDayOfMonth(today.lengthOfMonth());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String firstDay = firstDayOfMonth.format(formatter);
String lastDay = lastDayOfMonth.format(formatter);
Map<String,Object> params = new HashMap<>();
params.put("fromdate",firstDay);
params.put("todate",lastDay);
//todo 执行前先删除历史数据 主表 明细表
// 获取当前月份的格式化字符串
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM");
String currentMonth = today.format(formatter1);
project.deleteHData(currentMonth,"");
project.signData(params);
}
}

@ -0,0 +1,117 @@
package weaver.interfaces.kqsolution.crob;
import com.engine.kqsolution.entity.HistoryResourcePO;
import com.engine.kqsolution.util.ResourceSnipUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2024/8/28 9:12 AM
* @Description:
* @Version 1.0
*/
public class ResourceSnipCrob extends BaseCronJob {
@Override
public void execute() {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
String account = bb.getPropValue("jcsecond", "account");
String bankField = bb.getPropValue("jcsecond", "bankField");
String regresidentplace = bb.getPropValue("jcsecond", "regresidentplace");
String femdate = bb.getPropValue("jcsecond", "femdate");
//1.获取数据
List<HistoryResourcePO> snipList = new ArrayList<>();
rs.executeQuery("select a.id,a.workcode,a.lastname,a.birthday,a.sex,a.subcompanyid1,a.departmentid,a.managerid,a.companystartdate,\n" +
"a.createdate,a.accumfundaccount,b."+account+" as account,b."+bankField+" as bankname,c."+femdate+" as femdate,\n" +
"a.startdate,a.enddate,a.jobtitle,a.status,a.educationlevel,a.mobile,a.certificatenum,\n" +
"a.nativeplace,b."+regresidentplace+" as regresidentplace from hrmresource a\n" +
"left join cus_fielddata b on a.id = b.id and b.scopeid = 1\n" +
"left join cus_fielddata c on a.id = c.id and c.scopeid = -1\n" +
"where a.status < 4");
while (rs.next()) {
HistoryResourcePO build = HistoryResourcePO.builder()
.resourceId(Util.getIntValue(rs.getString("id")))
.workcode(Util.null2String(rs.getString("workcode")))
.lastName(Util.null2String(rs.getString("lastname")))
.birthday(Util.null2String(rs.getString("birthday")))
.sex("0".equals(Util.null2String(rs.getString("sex"))) ? "男" : "女")
.subCompany(ResourceSnipUtils.selectSubCompanyName(Util.null2String(rs.getString("subcompanyid1"))))
.department(ResourceSnipUtils.selectDeptName(Util.null2String(rs.getString("departmentid"))))
.managerId(ResourceSnipUtils.selectResourceName(Util.null2String(rs.getString("managerid"))))
.companyStartDate(Util.null2String(rs.getString("companystartdate")))
.createDate(Util.null2String(rs.getString("createdate")))
.accumfundAccount(Util.null2String(rs.getString("accumfundaccount")))
.accountId(Util.null2String(rs.getString("account")))
.bankName(ResourceSnipUtils.selectBankName(Util.null2String(rs.getString("bankname")),bankField))
.firstEnrollmentDate(Util.null2String(rs.getString("femdate")))
.startdate(Util.null2String(rs.getString("startdate")))
.endDate(Util.null2String(rs.getString("enddate")))
.jobTitle(ResourceSnipUtils.selectJobName(Util.null2String(rs.getString("jobtitle"))))
.status(ResourceSnipUtils.selectStatusName(Util.null2String(rs.getString("status"))))
.educationlevel(ResourceSnipUtils.selectEducName(Util.null2String(rs.getString("educationlevel"))))
.mobile(Util.null2String(rs.getString("mobile")))
.certificatenum(Util.null2String(rs.getString("certificatenum")))
.nativeplace(Util.null2String(rs.getString("nativeplace")))
.regresidentplace(Util.null2String(rs.getString("regresidentplace")))
.build();
snipList.add(build);
}
//获取当前月格式2024-08
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
String currentMonth = LocalDate.now().format(formatter);
String modeId = bb.getPropValue("jcsecond", "modeId");
String currentDate = TimeUtil.getCurrentDateString();
String onlyCurrentTime = TimeUtil.getOnlyCurrentTimeString();
//2.存储快照
//区分是否数据存在List存在部分更新未存在数据新增
List<Integer> hList = new ArrayList<>();
rs.executeQuery("select ryid from uf_hmckz where cdrq = ?",currentMonth);
while (rs.next()) {
hList.add(Util.getIntValue(rs.getString("ryid")));
}
//已存在数据
List<HistoryResourcePO> uList = snipList.stream()
.filter(item -> hList.contains(item.getResourceId()))
.collect(Collectors.toList());
//未存在数据
List<HistoryResourcePO> iList = snipList.stream()
.filter(item -> !hList.contains(item.getResourceId()))
.collect(Collectors.toList());
for (HistoryResourcePO i : uList) {
rs.executeUpdate("update uf_hmckz set gh = ?,xm = ?,csrq = ?,xb = ?,fb = ?,bm = ?,zjsj = ?,rzrq = ?,cjrq = ?,gjjzh = ?," +
" gzzh = ?,gzyx = ?, sccbsj = ?,htksrq = ?,htjsrq = ?,gw = ?,zt = ?,xl = ?,dh = ?,sfzh = ?,jg = ?," +
" hkszd = ?, lzrq = ? where id = ? and cdrq = ?",i.getWorkcode(),i.getLastName(),i.getBirthday(),
i.getSex(),i.getSubCompany(),i.getDepartment(), i.getManagerId(),i.getCompanyStartDate(),i.getCreateDate(),i.getAccumfundAccount(),
i.getAccountId(),i.getBankName(),i.getFirstEnrollmentDate(),i.getStartdate(),i.getEndDate(),i.getJobTitle(),i.getStatus(),i.getEducationlevel(),
i.getMobile(),i.getCertificatenum(),i.getNativeplace(),i.getRegresidentplace(),i.getChangeDate(),i.getResourceId(),currentMonth);
}
for (HistoryResourcePO i : iList) {
rs.executeUpdate("insert into uf_hmckz(ryid,gh,xm,csrq,xb,fb,bm,zjsj,rzrq,cjrq,gjjzh,gzzh,gzyx,sccbsj,htksrq,htjsrq,gw,zt,xl,dh,sfzh,jg,hkszd,cdrq,lzrq,formmodeid,modedatacreatedate,modedatacreatetime) " +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",i.getResourceId(),i.getWorkcode(),i.getLastName(),i.getBirthday(),
i.getSex(),i.getSubCompany(),i.getDepartment(), i.getManagerId(),i.getCompanyStartDate(),i.getCreateDate(),i.getAccumfundAccount(),
i.getAccountId(),i.getBankName(),i.getFirstEnrollmentDate(),i.getStartdate(),i.getEndDate(),i.getJobTitle(),i.getStatus(),i.getEducationlevel(),
i.getMobile(),i.getCertificatenum(),i.getNativeplace(),i.getRegresidentplace(),currentMonth,i.getChangeDate(),modeId,currentDate,onlyCurrentTime);
}
}
}

@ -0,0 +1,71 @@
package weaver.interfaces.kqsolution.crob;
import com.alibaba.fastjson.JSON;
import com.engine.kqsolution.entity.SignDataParams;
import com.engine.kqsolution.service.impl.SignDataSummaryServiceImpl;
import com.weaver.general.BaseBean;
import weaver.common.DateUtil;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
/**
* @Author liang.cheng
* @Date 2023/9/18 11:46 AM
* @Description:
* @Version 1.0
*/
public class SignDataSummaryCrob extends BaseCronJob {
public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private String attendanceDate;
private String formModeId;
public String getFormModeId() {
return formModeId;
}
public void setFormModeId(String formModeId) {
this.formModeId = formModeId;
}
public String getAttendanceDate() {
return attendanceDate;
}
public void setAttendanceDate(String attendanceDate) {
this.attendanceDate = attendanceDate;
}
@Override
public void execute() {
SignDataSummaryServiceImpl summaryService = new SignDataSummaryServiceImpl();
BaseBean bb = new BaseBean();
// bb.writeLog("同步考勤数据原始参数:"+attendanceDate);
//
//
// if (Objects.isNull(attendanceDate)) {
// attendanceDate = DateUtil.getYesterday();
// }
String attendanceDateNew = DateUtil.getYesterday();
SignDataParams build = SignDataParams.builder()
.formModeId(formModeId)
.attendanceDate(attendanceDateNew)
.build();
bb.writeLog("同步考勤数据参数:"+JSON.toJSONString(build));
summaryService.recordSignData(build);
}
}

@ -0,0 +1,113 @@
package weaver.interfaces.kqsolution.crob;
import com.amazonaws.util.CollectionUtils;
import com.engine.kqsolution.entity.SignDataPO;
import com.weaver.general.Util;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.common.DateUtil;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2024/11/13 11:28 AM
* @Description: uf_kqgs
* @Version 1.0
*/
public class SuppleKqDataCrob extends BaseCronJob {
@Override
public void execute() {
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
//上个月第一天
String firstDay = firstDayOfPreviousMonth();
//本月最后一天
String lastDay = DateUtil.getLastDayOfMonthToString();
List<String> ids = new ArrayList<>();
//1.人力资源表近2月入职人员id数据
rs.executeQuery("select id from hrmresource where companystartdate >='"+firstDay+"' and companystartdate <= '"+lastDay+"'");
while (rs.next()) {
ids.add(Util.null2String(rs.getString("id")));
}
//2.近2月返聘人员数据
rs.executeQuery("select resourceid from hrmstatushistory where type_n = 7 and changedate >='"+firstDay+"' and changedate <= '"+lastDay+"'");
while (rs.next()) {
ids.add(Util.null2String(rs.getString("resourceid")));
}
//3.根据人员id获取考勤明细表近2月数据
List<String> distinctIds = ids.stream()
.distinct()
.collect(Collectors.toList());
String join = CollectionUtils.join(distinctIds, ",");
bb.writeLog("近2月入职和返聘人员 =>"+join);
//4.根据人员ids获取考勤明细表近2月数据
List<SignDataPO> signDataList = new ArrayList<>();
rs.executeQuery("select resourceid,kqdate from kq_format_detail where kqdate >='"+firstDay+"' and kqdate <= '"+lastDay+"' and resourceid in ("+join+")");
while (rs.next()) {
signDataList.add(SignDataPO.builder()
.resourceId(Util.getIntValue(rs.getString("resourceid")))
.attendanceDate(Util.null2String(rs.getString("kqdate")))
.build());
}
//5.比较考勤建模台账哪些数据缺失 todo 线程处理
List<SignDataPO> suppleData = new ArrayList<>();
signDataList.forEach(e -> {
rs.executeQuery("select count(1) as nums from uf_kqgs where xm = ? and kqrq = '"+e.getAttendanceDate()+"'",e.getResourceId());
rs.next();
if (Util.getIntValue(rs.getString("nums")) == 0) {
suppleData.add(e);
}
});
bb.writeLog("本次执行建模台账缺失数据集合size =>"+suppleData.size());
//6.考勤建模台账 uf_kqgs 数据补充
String formModeid = bb.getPropValue("jcsecond", "kqModeid");
try {
//方案1
ResourceComInfo rcom = new ResourceComInfo();
suppleData.forEach(e -> {
String resourceId = String.valueOf(e.getResourceId());
String formatYearMonth = e.getAttendanceDate().substring(0,7);
e.setCompany(Integer.parseInt(rcom.getSubCompanyID(resourceId)));
e.setDepartment(Integer.parseInt(rcom.getDepartmentID(resourceId)));
e.setJobTitle(Integer.parseInt(rcom.getJobTitle(resourceId)));
rs.executeUpdate("insert into uf_kqgs(formmodeid,xm,kqy,kqrq,zt,fb,bm,gw) values(?,?,?,?,?,?,?,?)", formModeid, e.getResourceId(),
formatYearMonth, e.getAttendanceDate(), 0, e.getCompany(), e.getDepartment(), e.getJobTitle());
});
//方案2
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
* @return
*/
private String firstDayOfPreviousMonth() {
LocalDate now = LocalDate.now();
YearMonth previousMonth = YearMonth.from(now).minusMonths(1);
LocalDate firstDayOfPreviousMonth = previousMonth.atDay(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return firstDayOfPreviousMonth.format(formatter);
}
}

@ -0,0 +1,54 @@
package weaver.interfaces.sskj.crob;
import com.engine.integration.util.StringUtils;
import org.apache.commons.collections.CollectionUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.ArrayList;
import java.util.List;
/**
* @Author liang.cheng
* @Date 2023/11/28 3:53 PM
* @Description:
* @Version 1.0
*/
public class RefreshHrmSecLevelCrob extends BaseCronJob {
@Override
public void execute() {
List<ReleationPO> releationList = new ArrayList<>();
RecordSet rs = new RecordSet();
rs.executeQuery("select zwlb,aqjb from uf_aqjbdygxb");
while (rs.next()) {
releationList.add(ReleationPO.builder()
.jobGroups(Util.getIntValue(rs.getString("zwlb")))
.secLevel(Util.getIntValue(rs.getString("aqjb")))
.build());
}
releationList.forEach(releationPo -> {
List<Integer> jobTitles = new ArrayList<>();
selectJobTitlesByJobGroup(jobTitles,releationPo.getJobGroups());
if (CollectionUtils.isNotEmpty(jobTitles)) {
rs.executeUpdate("update hrmresource a set a.seclevel = ? where " +
" a.jobtitle in ("+StringUtils.join(jobTitles, ",")+")",releationPo.getSecLevel());
}
});
}
private List<Integer> selectJobTitlesByJobGroup(List<Integer> jobTitles,Integer jobGroup){
RecordSet rs = new RecordSet();
rs.executeQuery("select a.id from hrmjobtitles a join hrmjobactivities b on a.jobactivityid = b.id\n" +
" join hrmjobgroups c on b.jobgroupid = c.id where c.id = ?",jobGroup);
while (rs.next()) {
jobTitles.add(Util.getIntValue(rs.getString("id")));
}
return jobTitles;
}
}

@ -0,0 +1,23 @@
package weaver.interfaces.sskj.crob;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2023/11/28 4:24 PM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ReleationPO {
private Integer jobGroups;
private Integer secLevel;
}
Loading…
Cancel
Save