📄 tixinggernate.java
字号:
/*
* Created on 2006-11-15 21:58:07
*
* By SinoBest
* Copyright hnisi.com.cn, 2005-2006, All rights reserved.
*/
package cn.com.juneng.tixing.task;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Calendar;
import cn.com.juneng.system.common.CommonService;
import cn.com.juneng.system.common.DateFormatter;
import cn.com.juneng.system.common.SpringBeanFactory;
import cn.com.juneng.system.common.COMMON;
import cn.com.juneng.payplan.service.PayplanService;
import cn.com.juneng.tixing.vo.TixingVOImpl;
import cn.com.juneng.tixing.service.TixingService;
import cn.com.juneng.payplan.vo.PayplanVOImpl;
import cn.com.juneng.contract.service.ContractService;
import cn.com.juneng.contract.vo.ContractVOImpl;
/**
* @author xiean
*
*/
public class TixingGernate {
//提醒类型,分别与数据库的名称对应--预付合同、预收合同、结束合同、异常合同
private static String[] tixingleibie={"1","2","3","4"};
public TixingGernate() {
super();
// TODO Auto-generated constructor stub
}
/**
* 产生预付合同
* 以预计支付合同的日期为准,提前15天提醒
* */
public void payPlanSearch(){
PayplanService paysrv=(PayplanService)SpringBeanFactory.getBean("payplanService");
TixingService tixingsrv=(TixingService)SpringBeanFactory.getBean("tixingService");
CommonService commonsrv=(CommonService)SpringBeanFactory.getBean("commonService");
List list=null;
List tixingList=null;
String hql=" (plandate<getdate() or datediff(day,plandate,getdate())<=tmp4) and tmp1=1 and flag=0 ";
String querysql=" txlx='"+tixingleibie[0]+" '";
try {
list=paysrv.getList(hql,"",0,Integer.MAX_VALUE);
tixingList=tixingsrv.getList(querysql,"",0,Integer.MAX_VALUE);
} catch (Exception e) {
e.printStackTrace();
}
if(COMMON.isEmpty(list))
return ;
//将历史信息中生日记录注入Map表中
HashMap hashMap=new HashMap();
TixingVOImpl tixingvo=null;
if(!COMMON.isEmpty(tixingList)){
for(int j=0;j<tixingList.size();j++){
tixingvo=(TixingVOImpl)(tixingList.get(j));
hashMap.put(tixingvo.getRyid(),"1");//合同计划rid
}
}
//取要提醒合同。
PayplanVOImpl vo=null;
ArrayList arylist=new ArrayList();
for(int i=0;i<list.size();i++){
vo=(PayplanVOImpl)list.get(i);
//判断是否重复发送,如若不重复,则产生记录。
if(!hashMap.containsKey(vo.getRid())){
TixingVOImpl tixingvos=new TixingVOImpl();
tixingvos.setRyid(vo.getRid());//计划id
tixingvos.setGzid(vo.getContractid());//合同id
tixingvos.setXm(vo.getContractname());
tixingvos.setTmp1(vo.getContractno());//合同编号
tixingvos.setTmp6(vo.getPlandate());//支付日期
tixingvos.setTmp2(vo.getPaytype());//支付方式
tixingvos.setTmp3(vo.getPlanno());
tixingvos.setTmp4(vo.getBatchno());
tixingvos.setTmp5(vo.getPercenge());//支付比例
tixingvos.setTxlx(tixingleibie[0]);
tixingvos.setSfcl("2");
tixingvos.setCreatedatetime(COMMON.toTimestamp());
tixingvos.setCreateid("系统管理员");
tixingvos.setTmp7(vo.getPaysum());
tixingvos.setTmp9(vo.getReceiver());//接收人
tixingvos.setTmp10(vo.getSender());//发送人
arylist.add(tixingvos);
}
}
//将记录插入到数据库中。
if(COMMON.isEmpty(arylist)||arylist.size()<=0)
return;
try{
commonsrv.batchSave(arylist);
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 预计支付合同提醒
* */
public void payoutPlanSearch(){
PayplanService paysrv=(PayplanService)SpringBeanFactory.getBean("payplanService");
TixingService tixingsrv=(TixingService)SpringBeanFactory.getBean("tixingService");
CommonService commonsrv=(CommonService)SpringBeanFactory.getBean("commonService");
List list=null;
List tixingList=null;
String hql=" (plandate<getdate() or datediff(day,plandate,getdate())<=tmp4) and tmp1=2 and flag=0 ";
String querysql=" txlx='"+tixingleibie[1]+" '";
try {
list=paysrv.getList(hql,"",0,Integer.MAX_VALUE);
tixingList=tixingsrv.getList(querysql,"",0,Integer.MAX_VALUE);
} catch (Exception e) {
e.printStackTrace();
}
if(COMMON.isEmpty(list))
return ;
//将历史信息中生日记录注入Map表中
HashMap hashMap=new HashMap();
TixingVOImpl tixingvo=null;
if(!COMMON.isEmpty(tixingList)){
for(int j=0;j<tixingList.size();j++){
tixingvo=(TixingVOImpl)(tixingList.get(j));
hashMap.put(tixingvo.getRyid(),"1");//合同计划rid
}
}
//取要提醒合同。
PayplanVOImpl vo=null;
ArrayList arylist=new ArrayList();
for(int i=0;i<list.size();i++){
vo=(PayplanVOImpl)list.get(i);
//判断是否重复发送,如若不重复,则产生记录。
if(!hashMap.containsKey(vo.getRid())){
TixingVOImpl tixingvos=new TixingVOImpl();
tixingvos.setRyid(vo.getRid());//计划id
tixingvos.setGzid(vo.getContractid());//合同id
tixingvos.setXm(vo.getContractname());
tixingvos.setTmp1(vo.getContractno());//合同编号
tixingvos.setTmp6(vo.getPlandate());//支付日期
tixingvos.setTmp2(vo.getPaytype());//支付方式
tixingvos.setTmp3(vo.getPlanno());
tixingvos.setTmp4(vo.getBatchno());
tixingvos.setTmp5(vo.getPercenge());//支付比例
tixingvos.setTxlx(tixingleibie[1]);
tixingvos.setSfcl("2");
tixingvos.setCreatedatetime(COMMON.toTimestamp());
tixingvos.setCreateid("系统管理员");
tixingvos.setTmp7(vo.getPaysum());
tixingvos.setTmp9(vo.getReceiver());//接收人
tixingvos.setTmp10(vo.getSender());//发送人
arylist.add(tixingvos);
}
}
//将记录插入到数据库中。
if(COMMON.isEmpty(arylist)||arylist.size()<=0)
return;
try{
commonsrv.batchSave(arylist);
}catch (Exception e) {
e.printStackTrace();
}
}
/**
*合同到期提醒,提醒30天
* */
public void hetongSearch(){
ContractService contractsrv=(ContractService)SpringBeanFactory.getBean("contractService");
TixingService tixingsrv=(TixingService)SpringBeanFactory.getBean("tixingService");
CommonService commonsrv=(CommonService)SpringBeanFactory.getBean("commonService");
List list=null;
List tixingList=null;
String hql=" (enddate<getdate() or datediff(day,enddate,getdate())<=30) and state in('1','2') ";//还需加上未结束合同
String querysql=" txlx='"+tixingleibie[2]+" '";
try {
list=contractsrv.getList(hql,"",0,Integer.MAX_VALUE);
tixingList=tixingsrv.getList(querysql,"",0,Integer.MAX_VALUE);
} catch (Exception e) {
e.printStackTrace();
}
if(COMMON.isEmpty(list))
return ;
//将历史信息中生日记录注入Map表中
HashMap hashMap=new HashMap();
TixingVOImpl tixingvo=null;
if(!COMMON.isEmpty(tixingList)){
for(int j=0;j<tixingList.size();j++){
tixingvo=(TixingVOImpl)(tixingList.get(j));
hashMap.put(tixingvo.getRyid(),"1");//合同计划rid
}
}
//取要提醒合同。
ContractVOImpl vo=null;
ArrayList arylist=new ArrayList();
for(int i=0;i<list.size();i++){
vo=(ContractVOImpl)list.get(i);
//判断是否重复发送,如若不重复,则产生记录。
if(!hashMap.containsKey(vo.getRid())){
TixingVOImpl tixingvos=new TixingVOImpl();
tixingvos.setRyid(vo.getRid());//计划id
tixingvos.setXm(vo.getName());//合同名称
tixingvos.setTmp1(vo.getCode());//合同编号
tixingvos.setTmp6(vo.getBegindate());//开始日期
tixingvos.setTmp18(vo.getEnddate());//结束日期
tixingvos.setTmp2(vo.getPaytype());//支付方式
tixingvos.setTxlx(tixingleibie[2]);
tixingvos.setSfcl("2");
tixingvos.setCreatedatetime(COMMON.toTimestamp());
tixingvos.setCreateid("系统管理员");
tixingvos.setTmp9(vo.getTmp2());//接收人
tixingvos.setTmp10(vo.getTmp3());//发送人
arylist.add(tixingvos);
}
}
//将记录插入到数据库中。
if(COMMON.isEmpty(arylist)||arylist.size()<=0)
return;
try{
commonsrv.batchSave(arylist);
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 异常合同
* */
public void hetongYichangSearch(){
ContractService contractsrv=(ContractService)SpringBeanFactory.getBean("contractService");
TixingService tixingsrv=(TixingService)SpringBeanFactory.getBean("tixingService");
CommonService commonsrv=(CommonService)SpringBeanFactory.getBean("commonService");
List list=null;
List tixingList=null;
String hql=" datediff(day,enddate,getdate())<0 and state in('1','2') ";//过期合同
String querysql=" txlx='"+tixingleibie[3]+" '";
try {
list=contractsrv.getList(hql,"",0,Integer.MAX_VALUE);
tixingList=tixingsrv.getList(querysql,"",0,Integer.MAX_VALUE);
} catch (Exception e) {
e.printStackTrace();
}
if(COMMON.isEmpty(list))
return ;
//将历史信息中生日记录注入Map表中
HashMap hashMap=new HashMap();
TixingVOImpl tixingvo=null;
if(!COMMON.isEmpty(tixingList)){
for(int j=0;j<tixingList.size();j++){
tixingvo=(TixingVOImpl)(tixingList.get(j));
hashMap.put(tixingvo.getRyid(),"1");//合同计划rid
}
}
//取要提醒合同。
ContractVOImpl vo=null;
ArrayList arylist=new ArrayList();
for(int i=0;i<list.size();i++){
vo=(ContractVOImpl)list.get(i);
//判断是否重复发送,如若不重复,则产生记录。
if(!hashMap.containsKey(vo.getRid())){
TixingVOImpl tixingvos=new TixingVOImpl();
tixingvos.setRyid(vo.getRid());//计划id
tixingvos.setXm(vo.getName());//合同名称
tixingvos.setTmp1(vo.getCode());//合同编号
tixingvos.setTmp6(vo.getBegindate());//开始日期
tixingvos.setTmp18(vo.getEnddate());//结束日期
tixingvos.setTmp2(vo.getPaytype());//支付方式
tixingvos.setTxlx(tixingleibie[3]);
tixingvos.setSfcl("2");
tixingvos.setCreatedatetime(COMMON.toTimestamp());
tixingvos.setCreateid("系统管理员");
tixingvos.setTmp9(vo.getTmp2());//接收人
tixingvos.setTmp10(vo.getTmp3());//发送人
arylist.add(tixingvos);
}
}
//将记录插入到数据库中。
if(COMMON.isEmpty(arylist)||arylist.size()<=0)
return;
try{
commonsrv.batchSave(arylist);
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* 产生员工合同满年提醒记录
* */
public void hetongFinish(){
}
/**
* 根据身份证号提取年龄大小
* @param sfzh
* 身份证号
* @return 年龄
* */
private int getAgeofsfzh(String sfzh){
int age=0;
if(COMMON.isEmpty(sfzh))
age=0;
if(!(sfzh.length()==15||sfzh.length()==18)){
age=0;
return age;
}
if(sfzh.length()==15)
sfzh=convert15to18(sfzh);
age=getCurrentYear()-Integer.parseInt(sfzh.substring(6,10));
return age;
}
/**
* 根据身份证号提取生日月份
* @param sfzh
* 身份证号
* @return 生日月份
* */
private int getMonthofsfzh(String sfzh){
int month=0;
if(COMMON.isEmpty(sfzh)){
month=0;
return month;
}
if(!(sfzh.length()==15||sfzh.length()==18)){
month=0;
return month;
}
if(sfzh.length()==15)
sfzh=convert15to18(sfzh);
month=Integer.parseInt(sfzh.substring(10,12));
return month;
}
/**
* 作用:身份证15转18位
* */
public String convert15to18(String id){
final int [] W =
{
7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1};
final String [] A =
{
"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"};
int i,j,s=0;
String newid;
newid = id;
newid =newid.substring(0,6)+"19"+newid.substring(6,id.length());
for ( i=0;i<newid.length() ;i++ )
{
j= Integer.parseInt(newid.substring(i,i+1))*W[i];
s=s+j;
}
s = s % 11;
newid=newid+A[s];
return newid;
}
/**
* 取得当前年份
* */
private int getCurrentYear(){
int year=0;
year=Calendar.getInstance().get(Calendar.YEAR);
return year;
}
/**
* 取得当前月份
* @return 当前月份
* */
private int getCurrentMonth(){
int month=0;
month=Calendar.getInstance().get(Calendar.MONTH)+1;
return month;
}
/**
* 判断当前月份同生日年月是否需产生记录
* @param currentmonth
* 当前系统月份
* @param realmonth
* 生日月份
* @return true:产生提醒记录 false:不产生提醒记录
* */
private int compareMonth(int currentmonth,int realmonth){
//如果给定月份小于当前月份,则加一年
if(realmonth<currentmonth)
realmonth=12+realmonth;
return realmonth-currentmonth;
}
/**
* 给定年月,计算工龄假期的年数
* @param workdate
* 参加工作日期
* @param yearMonth(yyyymm)
* 给定年月
* @return 工龄年数
* */
private int getGongnian(Date workdate,String yearMonth){
int year=0;
String tmpYearMth=DateFormatter.formatDateTime4(workdate);
if(COMMON.isEmpty(tmpYearMth)||COMMON.isEmpty(yearMonth))
return 0;
int workyear=Integer.parseInt(tmpYearMth.substring(0,4));
int workMonth=Integer.parseInt(tmpYearMth.substring(4,6));
//给定年、月
int curyear=Integer.parseInt(yearMonth.substring(0,4));
int curMonth=13;
year=((curyear-workyear-1)*12+curMonth-workMonth)/12;
return year;
}
/**
* 根据工龄的年数计算工龄的天数
* @param year
* 工作的年限
* @return days
* 工龄假的天数
* */
private int getDaysofGongjia(int year){
int days=0;
if(year<1)
days=0;
else if(year>=1&&year<5)
days=5;
else if(year>=5&&year<10)
days=7;
else if (year>=10&&year<20)
days=10;
else if (year>=20)
days=14;
return days;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -