Merge branch 'dev' into dev-chenwnj
commit
1ae17c8ea5
@ -0,0 +1,229 @@
|
|||||||
|
package weaver.haikang.cronjob;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.weaver.file.Prop;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.setup.ModeRightInfo;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.integration.logging.Logger;
|
||||||
|
import weaver.integration.logging.LoggerFactory;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时合计 内推奖励台账 盛世科技
|
||||||
|
*/
|
||||||
|
public class InternalReferralRewardService{
|
||||||
|
private final Logger log = LoggerFactory.getLogger(InternalReferralRewardService.class);
|
||||||
|
|
||||||
|
private static final String ntjljmid = Prop.getPropValue("jiangshixinchou","ntjlhjjmid");
|
||||||
|
|
||||||
|
private static final String ntjltzjmid = Prop.getPropValue("jiangshixinchou","ntjltzjmid");
|
||||||
|
|
||||||
|
public synchronized void execute(String currentYm,String nowNy) {
|
||||||
|
log.error("howec::::::合计内推奖励月份:"+currentYm);
|
||||||
|
RecordSet recordSeta = new RecordSet();
|
||||||
|
RecordSet recordSetb = new RecordSet();
|
||||||
|
RecordSet recordSetc = new RecordSet();
|
||||||
|
RecordSet recordSetd= new RecordSet();
|
||||||
|
RecordSet recordSete = new RecordSet();
|
||||||
|
RecordSet recordSetf = new RecordSet();
|
||||||
|
RecordSet recordSetg = new RecordSet();
|
||||||
|
//内推记录有并且已经入职的人员
|
||||||
|
String sql2 = "select b.id as uid,a.btjrxm,a.sfzhm,a.tjr,a.tjgw,b.companystartdate,c.rz,c.zz,c.rzbn,b.status from uf_ntjl a inner join hrmresource b on a.btjrxm = b.lastname " +
|
||||||
|
"and a.sfzhm = b.certificatenum inner join uf_gwtjjlgz c on a.tjrylb = c.tjgw where b.status in (0,1,2,3) ";
|
||||||
|
recordSeta.executeQuery(sql2);
|
||||||
|
log.error("howec::::::sql2:"+sql2);
|
||||||
|
while (recordSeta.next()) {
|
||||||
|
/**
|
||||||
|
* 奖励类型
|
||||||
|
* 1 入职
|
||||||
|
* 2 转正
|
||||||
|
* 3 入职半年
|
||||||
|
*/
|
||||||
|
String btjrxm = recordSeta.getString("btjrxm");//被推荐人姓名
|
||||||
|
String sfzhm = recordSeta.getString("sfzhm");//被推荐人身份证号
|
||||||
|
String tjr = recordSeta.getString("tjr");//推荐人
|
||||||
|
String tjgw = recordSeta.getString("tjgw");//推荐岗位
|
||||||
|
String companystartdate = recordSeta.getString("companystartdate");//入职日期
|
||||||
|
Double rz = recordSeta.getDouble("rz");//入职
|
||||||
|
Double zz = recordSeta.getDouble("zz");//转正
|
||||||
|
Double rzbn = recordSeta.getDouble("rzbn");//入职半年
|
||||||
|
String uid = recordSeta.getString("uid");
|
||||||
|
|
||||||
|
if(getSums2(recordSete,tjr,currentYm)){//如果存在
|
||||||
|
log.error("当前推荐人:"+tjr+" 在"+currentYm+" 已经执行过合计,一个月合计一次!");
|
||||||
|
}else {
|
||||||
|
Double result = 0d;
|
||||||
|
//判断 当前岗位当前推荐人,被推荐人,当前奖励类型是否已经发放工资
|
||||||
|
//以下奖励 都是针对被推荐人
|
||||||
|
String statusstr = "";
|
||||||
|
//先发一笔入职
|
||||||
|
if(!getJudgeResult(1,tjr,sfzhm,recordSetb)) {//如果不存在,处理
|
||||||
|
result+=rz;
|
||||||
|
statusstr = statusstr+"1,";
|
||||||
|
log.error("howec:::::::::::入职奖励新增");
|
||||||
|
//记录入职奖励
|
||||||
|
insertRzRecord(recordSetc,tjr,1,rz,tjgw,btjrxm,sfzhm);
|
||||||
|
}
|
||||||
|
//判断员工状态是否存在转正,存在则给一笔转正钱
|
||||||
|
if(isExistZz(recordSetg,uid)) {
|
||||||
|
if(!getJudgeResult(2,tjr,sfzhm,recordSetb)) {//如果不存在,处理
|
||||||
|
result+=zz;
|
||||||
|
statusstr = statusstr+"2,";
|
||||||
|
log.error("howec:::::::::::转正奖励新增");
|
||||||
|
//记录转正奖励
|
||||||
|
insertRzRecord(recordSetc,tjr,2,zz,tjgw,btjrxm,sfzhm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断员工在职期间和入职时间差 大于180天则给奖励3
|
||||||
|
if(!getJudgeResult(3,tjr,sfzhm,recordSetb)) {//如果不存在,处理
|
||||||
|
//判断当前日期是否大于180天
|
||||||
|
Date nowTime = parseDateBystr(nowNy);
|
||||||
|
Date beforeTime = parseDateBystr(companystartdate);
|
||||||
|
if(dataCompare(nowTime,beforeTime)){
|
||||||
|
result+=rzbn;
|
||||||
|
statusstr = statusstr+"3,";
|
||||||
|
log.error("howec:::::::::::入职半年新增");
|
||||||
|
insertRzRecord(recordSetc,tjr,3,rzbn,tjgw,btjrxm,sfzhm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(result > 0d) {
|
||||||
|
if(statusstr.length()>0) {
|
||||||
|
log.error("xxxxxxxxxxxxxxxxxxx:"+statusstr);
|
||||||
|
statusstr = statusstr.substring(0,statusstr.length()-1);
|
||||||
|
String zzrq = getZzrq(recordSetf,uid);
|
||||||
|
insertJlRecord(recordSetd,currentYm,tjr,result,uid,companystartdate,zzrq,statusstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据userid获取转正日期
|
||||||
|
private String getZzrq(RecordSet recordSetf,String uid) {
|
||||||
|
String sql = "select count(id) as sums from hrmstatushistory where resourceid = "+uid+" and type_n = 2";
|
||||||
|
log.error("howec::::::sql3:"+sql);
|
||||||
|
recordSetf.executeQuery(sql);
|
||||||
|
recordSetf.next();
|
||||||
|
int sums = recordSetf.getInt("sums");
|
||||||
|
if(sums > 0) {
|
||||||
|
sql = "select changedate from hrmstatushistory where resourceid = "+uid+" and type_n = 2";
|
||||||
|
log.error("howec::::::sql4:"+sql);
|
||||||
|
recordSetf.executeQuery(sql);
|
||||||
|
recordSetf.next();
|
||||||
|
return recordSetf.getString("changedate");
|
||||||
|
}else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断员工是否存在转正
|
||||||
|
private Boolean isExistZz(RecordSet recordSetg, String uid) {
|
||||||
|
String sql = "select count(id) as sums from hrmstatushistory where resourceid = "+uid+" and type_n = 2";
|
||||||
|
log.error("howec::::::sql3:"+sql);
|
||||||
|
recordSetg.executeQuery(sql);
|
||||||
|
recordSetg.next();
|
||||||
|
int sums = recordSetg.getInt("sums");
|
||||||
|
return sums >0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断推荐人 被推荐人 的奖励类型
|
||||||
|
private Boolean getJudgeResult(int type,String tjr,String btjrsfzh,RecordSet recordSetb) {
|
||||||
|
String sql = "select count(id) as nums from uf_neituijiangli where tjr = '"+tjr+"' and jllx = "+type+" and btjrsfzh = '"+btjrsfzh+"'";
|
||||||
|
log.error("howec::::::sql5:"+sql);
|
||||||
|
recordSetb.executeQuery(sql);
|
||||||
|
recordSetb.next();
|
||||||
|
int nums = recordSetb.getInt("nums");
|
||||||
|
return nums> 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增台账合计记录
|
||||||
|
private void insertJlRecord(RecordSet recordSetd,String ny,String tjr,Double jlje,String btjrxm,String rzrq,String zzrq,String bz) {
|
||||||
|
String sql = "insert into uf_ntjlb(ny,tjr,jlje,btjrxm,rzrq,zzrq,bz,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) values(?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
recordSetd.executeUpdate(sql,ny,tjr,jlje,btjrxm,rzrq,zzrq,bz,
|
||||||
|
ntjltzjmid,"1","0", DateUtil.today(),DateUtil.formatTime(new Date()));
|
||||||
|
|
||||||
|
String idSql = "SELECT max(id) as mid from uf_neituijiangli order by id desc";
|
||||||
|
recordSetd.executeQuery(idSql);
|
||||||
|
recordSetd.next();
|
||||||
|
String id = recordSetd.getString("mid");
|
||||||
|
// 权限重构
|
||||||
|
permissionReconstruction(Util.getIntValue(id),Integer.parseInt(ntjltzjmid));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean getSums2(RecordSet recordSetce,String tjr,String currentYm) {
|
||||||
|
String sql = "select count(id) as nums from uf_ntjlb where tjr = '"+tjr+"' and ny = '"+currentYm+"'";
|
||||||
|
log.error("howec::::::sql6:"+sql);
|
||||||
|
recordSetce.executeQuery(sql);
|
||||||
|
recordSetce.next();
|
||||||
|
int sums = recordSetce.getInt("nums");
|
||||||
|
return sums>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertRzRecord(RecordSet recordSetc,String tjr,int jllx,Double jlje,String tjgw,String btjr,String btjrsfzh) {
|
||||||
|
String sql = "insert into uf_neituijiangli(tjr,jllx,jlje,tjgw,btjr,btjrsfzh,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) values(?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
recordSetc.executeUpdate(sql,tjr,jllx,jlje,tjgw,btjr,btjrsfzh,
|
||||||
|
ntjljmid,"1","0", DateUtil.today(),DateUtil.formatTime(new Date()));
|
||||||
|
String idSql = "SELECT max(id) as mid from uf_neituijiangli order by id desc";
|
||||||
|
recordSetc.executeQuery(idSql);
|
||||||
|
recordSetc.next();
|
||||||
|
log.error("howeccccccc:"+idSql);
|
||||||
|
String id = recordSetc.getString("mid");
|
||||||
|
// 权限重构
|
||||||
|
permissionReconstruction(Util.getIntValue(id),Integer.parseInt(ntjljmid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限重构
|
||||||
|
* @param billId
|
||||||
|
*/
|
||||||
|
private void permissionReconstruction(int billId,int jmid) {
|
||||||
|
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
||||||
|
ModeRightInfo.setNewRight(true);
|
||||||
|
ModeRightInfo.editModeDataShare(1, Util.getIntValue(jmid),billId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date parseDateBystr(String str) {
|
||||||
|
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
try {
|
||||||
|
Date date1 = format.parse(str);
|
||||||
|
return date1;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期比较
|
||||||
|
*/
|
||||||
|
public static Boolean dataCompare(Date nowdate, Date beforedate) {
|
||||||
|
// 获取当前日期
|
||||||
|
Calendar currentCalendar = Calendar.getInstance();
|
||||||
|
currentCalendar.setTime(nowdate);
|
||||||
|
Date currentDate = currentCalendar.getTime();
|
||||||
|
// 设置比较日期
|
||||||
|
Calendar compareCalendar = Calendar.getInstance();
|
||||||
|
compareCalendar.setTime(beforedate);
|
||||||
|
Date compareDate = compareCalendar.getTime();
|
||||||
|
|
||||||
|
// 判断当前日期是否大于比较日期半年
|
||||||
|
Calendar halfYearLater = Calendar.getInstance();
|
||||||
|
halfYearLater.setTime(compareDate);
|
||||||
|
halfYearLater.add(Calendar.MONTH, 6); // 增加6个月
|
||||||
|
Date halfYearLaterDate = halfYearLater.getTime();
|
||||||
|
|
||||||
|
if (currentDate.after(halfYearLaterDate)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package weaver.haikang.cronjob;
|
||||||
|
|
||||||
|
import weaver.integration.logging.Logger;
|
||||||
|
import weaver.integration.logging.LoggerFactory;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时合计 内推奖励台账 盛世科技
|
||||||
|
*/
|
||||||
|
public class InternalReferralRewardsCron extends BaseCronJob {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(InternalReferralRewardsCron.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
log.error("内推奖励台账定时任务开启-------");
|
||||||
|
new Thread( ()->{
|
||||||
|
String currentNy = getCurrentNy();
|
||||||
|
String nowNy = getNowNy();
|
||||||
|
InternalReferralRewardService internalReferralRewardService = new InternalReferralRewardService();
|
||||||
|
internalReferralRewardService.execute(currentNy,nowNy);
|
||||||
|
}).start();
|
||||||
|
log.error("内推奖励台账定时任务结束-------");
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取当前时间的上一个月
|
||||||
|
private String getCurrentNy() {
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
LocalDate previousMonth = currentDate.minusMonths(1);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||||
|
String previousMonthString = previousMonth.format(formatter);
|
||||||
|
return previousMonthString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getNowNy() {
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||||
|
String previousMonthString = currentDate.format(formatter);
|
||||||
|
return previousMonthString+"-01";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package weaver.haikang.cronjob;
|
||||||
|
|
||||||
|
import weaver.integration.logging.Logger;
|
||||||
|
import weaver.integration.logging.LoggerFactory;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
/**
|
||||||
|
* @use 定时更新请假汇总 盛世科技
|
||||||
|
*/
|
||||||
|
public class LeaveSummaryCron extends BaseCronJob {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(LeaveSummaryService.class);
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
log.error("定时更新汇总请假开始定时任务开启-------");
|
||||||
|
new Thread( ()->{
|
||||||
|
LeaveSummaryService leaveSummaryService = new LeaveSummaryService();
|
||||||
|
leaveSummaryService.execute();
|
||||||
|
}).start();
|
||||||
|
log.error("定时更新汇总请假开始定时任务结束-------");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
package weaver.haikang.cronjob;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.weaver.file.Prop;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.setup.ModeRightInfo;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.integration.logging.Logger;
|
||||||
|
import weaver.integration.logging.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LeaveSummaryService {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(LeaveSummaryService.class);
|
||||||
|
//销假申请表单
|
||||||
|
private static final String xjshtablename = Prop.getPropValue("leave_summary_cron","xjshtablename");
|
||||||
|
//销假申请表单明细
|
||||||
|
private static final String xjshtablenamemx = Prop.getPropValue("leave_summary_cron","xjshtablenamemx");
|
||||||
|
private static final String nianjia = Prop.getPropValue("leave_summary_cron","nianjia");
|
||||||
|
private static final String tiaoxiu = Prop.getPropValue("leave_summary_cron","tiaoxiu");
|
||||||
|
private static final String shijia = Prop.getPropValue("leave_summary_cron","shijia");
|
||||||
|
private static final String bingjia = Prop.getPropValue("leave_summary_cron","bingjia");
|
||||||
|
private static final String chanjia = Prop.getPropValue("leave_summary_cron","chanjia");
|
||||||
|
private static final String peichanjia = Prop.getPropValue("leave_summary_cron","peichanjia");
|
||||||
|
private static final String hunjia = Prop.getPropValue("leave_summary_cron","hunjia");
|
||||||
|
private static final String sangjia = Prop.getPropValue("leave_summary_cron","sangjia");
|
||||||
|
private static final String burujia = Prop.getPropValue("leave_summary_cron","burujia");
|
||||||
|
private static final String qjhztablename = Prop.getPropValue("leave_summary_cron","qjhztablename");
|
||||||
|
private static final String jmid = Prop.getPropValue("leave_summary_cron","jmid");
|
||||||
|
|
||||||
|
|
||||||
|
public synchronized void execute() {
|
||||||
|
log.error("定时任务:更新请假汇总begin");
|
||||||
|
RecordSet recordSeta = new RecordSet();
|
||||||
|
RecordSet recordSetb = new RecordSet();
|
||||||
|
RecordSet recordSetc = new RecordSet();
|
||||||
|
RecordSet recordSetd = new RecordSet();
|
||||||
|
RecordSet recordSete = new RecordSet();
|
||||||
|
//年份人员组合
|
||||||
|
String sql = "SELECT LEFT (a.fromdate, 4 ) AS YEAR, a.RESOURCEID, b.lastname, b.workcode FROM kq_flow_split_leave a inner join hrmresource b on a.resourceid = b.id GROUP BY YEAR, a.RESOURCEID";
|
||||||
|
log.error("定时任务-sql1:"+sql);
|
||||||
|
recordSeta.executeQuery(sql);
|
||||||
|
while (recordSeta.next()) {
|
||||||
|
//每一条代表一个记录
|
||||||
|
log.error(">>>>>>>>>>>>>>>>3>>>>>>>>>>>>>>>>>>>>>");
|
||||||
|
String year = recordSeta.getString("YEAR");
|
||||||
|
String RESOURCEID = recordSeta.getString("RESOURCEID");
|
||||||
|
String lastname = recordSeta.getString("lastname");
|
||||||
|
String workcode = recordSeta.getString("workcode");
|
||||||
|
Map<String,String> hoursrs = getHours(year,RESOURCEID,recordSete);
|
||||||
|
String sql3 = "select count(id) as sums from "+qjhztablename+" where xm = "+RESOURCEID+" and nf = '"+year+"'";
|
||||||
|
log.error(">>>>>>>>>>>>>>>>4>>>>>>>>>>>>>>>>>>>>>sql6:"+sql3);
|
||||||
|
recordSetb.executeQuery(sql3);
|
||||||
|
if(recordSetb.next()) {
|
||||||
|
log.error(">>>>>>>>>>>>>>>>>>>>>>>>>xxxxxx>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||||
|
int sums = recordSetb.getInt("sums");
|
||||||
|
String sql4 = "";
|
||||||
|
if(sums>0) {//更新
|
||||||
|
sql4 = "update "+qjhztablename+" set nj = ?,dx = ?,sqj = ?,bj = ?,cj = ?,pcj = ?,hj = ?,sj = ?,brj = ? where xm = "+RESOURCEID + " and nf = '"+year+"'";
|
||||||
|
log.error("定时任务-sql3:"+sql4);
|
||||||
|
recordSetc.executeUpdate(sql4,hoursrs.get(nianjia),hoursrs.get(tiaoxiu),hoursrs.get(shijia),hoursrs.get(bingjia),hoursrs.get(chanjia),hoursrs.get(peichanjia),hoursrs.get(hunjia),hoursrs.get(sangjia),hoursrs.get(burujia));
|
||||||
|
}else {//新增
|
||||||
|
sql4 = "INSERT INTO "+qjhztablename+"(gh,xm,nf,nj,dx,sqj,bj,cj,pcj,hj,sj,brj,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
log.error("定时任务-sql4:"+sql4);
|
||||||
|
recordSetc.executeUpdate(sql4,workcode,RESOURCEID,year,hoursrs.get(nianjia),hoursrs.get(tiaoxiu),hoursrs.get(shijia),hoursrs.get(bingjia),hoursrs.get(chanjia),hoursrs.get(peichanjia),
|
||||||
|
hoursrs.get(hunjia),hoursrs.get(sangjia),hoursrs.get(burujia),
|
||||||
|
jmid,"1","0", DateUtil.today(),DateUtil.formatTime(new Date())
|
||||||
|
);
|
||||||
|
|
||||||
|
String idSql = "SELECT max(id) as mid from "+qjhztablename+" order by id desc";
|
||||||
|
log.error("定时任务-sql5:"+idSql);
|
||||||
|
recordSetd.executeQuery(idSql);
|
||||||
|
String id = recordSetd.getString("mid");
|
||||||
|
// 权限重构
|
||||||
|
permissionReconstruction(Util.getIntValue(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据年份,人员id,请假类型获取时间
|
||||||
|
private Map<String,String> getHours(String year,String resourceid,RecordSet recordSete) {
|
||||||
|
log.error(">>>>>>>>>>>>>>>>2>>>>>>>>>>>>>>>>>>>>>");
|
||||||
|
String key = year+resourceid;
|
||||||
|
Map<String,String> rs = new HashMap<>();
|
||||||
|
//初始化
|
||||||
|
rs.put(nianjia,"0");
|
||||||
|
rs.put(tiaoxiu,"0");
|
||||||
|
rs.put(shijia,"0");
|
||||||
|
rs.put(bingjia,"0");
|
||||||
|
rs.put(chanjia,"0");
|
||||||
|
rs.put(peichanjia,"0");
|
||||||
|
rs.put(hunjia,"0");
|
||||||
|
rs.put(sangjia,"0");
|
||||||
|
rs.put(burujia,"0");
|
||||||
|
|
||||||
|
String insql = nianjia+","+tiaoxiu+","+","+shijia+","+","+bingjia+","+","+chanjia+","+","+peichanjia+","+","+hunjia+","+","+sangjia+","+burujia;
|
||||||
|
String sql = "SELECT c11.year, c11.RESOURCEID, c11.newleavetype, hours - IFNULL( hoursf, 0 ) AS hours FROM " +
|
||||||
|
"( SELECT * FROM ( SELECT LEFT ( fromdate, 4 ) AS YEAR, RESOURCEID, newleavetype, SUM( durationdb ) AS hours, " +
|
||||||
|
"concat( LEFT ( fromdate, 4 ), \"-\", newleavetype, \"-\", RESOURCEID ) AS cid FROM kq_flow_split_leave GROUP BY YEAR, " +
|
||||||
|
"RESOURCEID, newleavetype ) a11 LEFT JOIN ( SELECT a.detail_newLeaveType, LEFT ( a.detail_leavefromDate, 4 ) AS YEAR1, " +
|
||||||
|
"b.RESOURCEID AS RESOURCEID1, SUM( a.detail_duration ) AS hoursf, " +
|
||||||
|
"concat( LEFT ( a.detail_leavefromDate, 4 ), \"-\", a.detail_newLeaveType, \"-\", b.RESOURCEID ) AS cidf " +
|
||||||
|
"FROM "+xjshtablenamemx+" a INNER JOIN "+xjshtablename+" b ON a.mainid = b.id WHERE b.spzt = '1' GROUP BY " +
|
||||||
|
"YEAR1, RESOURCEID1, detail_newLeaveType ) b11 ON a11.cid = b11.cidf WHERE 1 = 1 and a11.year = '"+year+"' and a11.resourceid = '"+resourceid+"' ) c11 ";
|
||||||
|
log.error("定时任务-sql2:"+sql);
|
||||||
|
recordSete.executeQuery(sql);
|
||||||
|
while (recordSete.next()) {
|
||||||
|
String type = recordSete.getString("newleavetype");
|
||||||
|
Double hours = recordSete.getDouble("hours");
|
||||||
|
String hours1 = Double.toString(hours);
|
||||||
|
rs.put(type,hours1);
|
||||||
|
}
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限重构
|
||||||
|
* @param billId
|
||||||
|
*/
|
||||||
|
private void permissionReconstruction(int billId) {
|
||||||
|
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
||||||
|
ModeRightInfo.setNewRight(true);
|
||||||
|
ModeRightInfo.editModeDataShare(1, Util.getIntValue(jmid),billId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
package weaver.haikang.cronjob;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.weaver.file.Prop;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.formmode.setup.ModeRightInfo;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.integration.logging.Logger;
|
||||||
|
import weaver.integration.logging.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时合计 讲师津贴 盛世科技
|
||||||
|
*/
|
||||||
|
public class LectureAllowanceService {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(LectureAllowanceService.class);
|
||||||
|
|
||||||
|
private static final String pxjlmxname = Prop.getPropValue("jiangshixinchou","pxjlmxname");
|
||||||
|
private static final String pxjlname = Prop.getPropValue("jiangshixinchou","pxjlname");
|
||||||
|
private static final String jmid = Prop.getPropValue("jiangshixinchou","jmid");
|
||||||
|
private static final String jsdaname = Prop.getPropValue("jiangshixinchou","jsdaname");
|
||||||
|
|
||||||
|
private static final String jsjtname = Prop.getPropValue("jiangshixinchou","jsjtname");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public synchronized void execute(String currentYm) {
|
||||||
|
//培训记录uf_pxjl
|
||||||
|
//培训记录明细uf_pxjl_dt1
|
||||||
|
//讲师档案uf_jsda
|
||||||
|
log.error("howec::::::讲师津贴合计月份:"+currentYm);
|
||||||
|
RecordSet recordSeta = new RecordSet();
|
||||||
|
RecordSet recordSetb = new RecordSet();
|
||||||
|
RecordSet recordSetc = new RecordSet();
|
||||||
|
RecordSet recordSetd = new RecordSet();
|
||||||
|
String sql1 = "select d.nums * d.jtbzks as jt,d.pxjsnx,d.pxsj, d.nums, d.jtbzks from " +
|
||||||
|
"( SELECT SUM(b.ksh) as nums, b.pxjsnx, b.pxsj, b.ksh, b.zxzt, c.jtbzks FROM "+pxjlmxname+" a INNER JOIN "+pxjlname+" b " +
|
||||||
|
"ON a.mainid = b.id INNER JOIN "+jsdaname+" c ON c.xm = b.pxjsnx where " +
|
||||||
|
"b.zxzt = 2 AND LEFT(b.pxsj,7)= '"+currentYm+"' group by b.pxjsnx ) d";
|
||||||
|
log.error("howec::::::讲师津贴合计月份:sql1:"+sql1);
|
||||||
|
recordSeta.executeQuery(sql1);
|
||||||
|
while (recordSeta.next()) {
|
||||||
|
String ny = recordSeta.getString("pxsj"); //年月
|
||||||
|
String pxjsnx = recordSeta.getString("pxjsnx"); //讲师(内训)
|
||||||
|
Double nums = recordSeta.getDouble("nums");//总数量
|
||||||
|
Double jtbzks = recordSeta.getDouble("jtbzks");//标准
|
||||||
|
Double jt = recordSeta.getDouble("jt");//津贴
|
||||||
|
String sql2 = "select count(id) as nums from "+jsjtname+" where xm = '"+pxjsnx+"' and ny = '"+currentYm+"'";
|
||||||
|
log.error("howec::::::讲师津贴合计月份:sql2:"+sql2);
|
||||||
|
recordSetb.executeQuery(sql2);
|
||||||
|
recordSetb.next();
|
||||||
|
if(recordSetb.getInt("nums") == 0) {
|
||||||
|
String sql = "insert into "+jsjtname+" (ny,xm,kcschj,jtbz,jsjt,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime) values (?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
recordSetc.executeUpdate(sql,currentYm,pxjsnx,nums,jtbzks,jt,
|
||||||
|
jmid,"1","0", DateUtil.today(),DateUtil.formatTime(new Date()));
|
||||||
|
|
||||||
|
String idSql = "SELECT max(id) as mid from "+jsjtname+" order by id desc";
|
||||||
|
recordSetd.executeQuery(idSql);
|
||||||
|
String id = recordSetd.getString("mid");
|
||||||
|
// 权限重构
|
||||||
|
permissionReconstruction(Util.getIntValue(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 权限重构
|
||||||
|
* @param billId
|
||||||
|
*/
|
||||||
|
private void permissionReconstruction(int billId) {
|
||||||
|
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
||||||
|
ModeRightInfo.setNewRight(true);
|
||||||
|
ModeRightInfo.editModeDataShare(1, Util.getIntValue(jmid),billId);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package weaver.haikang.cronjob;
|
||||||
|
|
||||||
|
import weaver.integration.logging.Logger;
|
||||||
|
import weaver.integration.logging.LoggerFactory;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时合计 讲师津贴
|
||||||
|
*/
|
||||||
|
public class LecturerAllowanceCron extends BaseCronJob {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(LecturerAllowanceCron.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
log.error("讲师津贴台账定时任务开启-------");
|
||||||
|
new Thread( ()->{
|
||||||
|
String currentNy = getCurrentNy();
|
||||||
|
LectureAllowanceService lectureAllowanceService = new LectureAllowanceService();
|
||||||
|
lectureAllowanceService.execute(currentNy);
|
||||||
|
}).start();
|
||||||
|
log.error("讲师津贴台账定时任务结束-------");
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取当前时间的上一个月
|
||||||
|
private String getCurrentNy() {
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
LocalDate previousMonth = currentDate.minusMonths(1);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||||
|
String previousMonthString = previousMonth.format(formatter);
|
||||||
|
return previousMonthString;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue