You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
238 lines
8.1 KiB
Java
238 lines
8.1 KiB
Java
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 2024年01月17日09: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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|