123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- package com.kingdee.eas.custom.facade.plurality;
- import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
- import com.kingdee.eas.framework.CoreBaseCollection;
- import com.kingdee.eas.framework.CoreBaseInfo;
- import com.kingdee.eas.hr.affair.*;
- import com.kingdee.eas.hr.base.AffairActionReasonFactory;
- import com.kingdee.eas.hr.base.AffairActionReasonInfo;
- import com.kingdee.eas.hr.base.ApproveTypeEnum;
- import com.kingdee.eas.hr.base.HRBillStateEnum;
- import com.kingdee.eas.hr.base.HRBizDefineFactory;
- import com.kingdee.eas.hr.base.HRBizDefineInfo;
- import com.kingdee.eas.util.app.ContextUtil;
- import com.kingdee.eas.util.app.DbUtil;
- import com.kingdee.jdbc.rowset.IRowSet;
- import com.kingdee.util.DateTimeUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.log4j.Logger;
- import java.sql.SQLException;
- import java.text.ParseException;
- import java.util.Date;
- import java.util.HashMap;
- import com.kingdee.bos.*;
- import com.kingdee.eas.common.EASBizException;
- import com.kingdee.eas.custom.hr.utils.DateUtil;
- import java.lang.String;
- public class PluralitySubFacadeControllerBean extends AbstractPluralitySubFacadeControllerBean
- {
- private static Logger logger =
- Logger.getLogger("com.kingdee.eas.custom.facade.plurality.PluralitySubFacadeControllerBean");
-
- @Override
- protected void _autoPluralitEnd(Context ctx, String personId, String curdate, int offset) throws BOSException, EASBizException {
- super._autoPluralitEnd(ctx, personId,curdate, offset);
- //变动类型
- AffairActionReasonInfo reasonInfo = AffairActionReasonFactory.getLocalInstance(ctx).getAffairActionReasonInfo(" where number = '0211' ");
- HRBizDefineInfo defineInfo = HRBizDefineFactory.getLocalInstance(ctx).getHRBizDefineInfo( " where number = 'SHR19' " );
- HashMap<String, Object> params = new HashMap ();
- params.put("reasonInfo", reasonInfo);
- params.put("defineInfo", defineInfo);
- Date bizDate = new Date();
- //查询所有当天日期的离职单
- if (StringUtils.isNotBlank(curdate)) {
- bizDate = DateUtil.stringToDate(curdate, "yyyy-MM-dd");
- }
- Date startDate = DateUtil.getDateStartTime(bizDate);
- Date endDate = DateUtil.getDateEndTime(bizDate);
- if( offset > 0 ){
- endDate = DateUtil.add(endDate, offset) ;
- }else if( offset < 0 ) {
- startDate = DateUtil.add(startDate, offset) ;
- }
- //查询兼职单
- StringBuilder sbu = new StringBuilder();
- sbu.append(" select bill.fid billId from T_HR_PluralityAddBizBill bill ");
- sbu.append(" left join T_HR_PluralityAddBizBillEntry entry on bill.FEntryId = entry.fbillid ");
- sbu.append(" where bill.fbillstate = '3' " );
- sbu.append(" and entry.fenddate >= '" + startDate+"' " );
- sbu.append(" and entry.fenddate <= '" + endDate+"' " );
- if( StringUtils.isNotBlank(personId)){
- sbu.append(" and entry.fpersonid = " + personId );
- }
- IRowSet rowSet = DbUtil.executeQuery(ctx, sbu.toString());
-
- try {
- while(rowSet.next()) {
- String billId = rowSet.getString("billId");
- newDelBill( ctx, billId , params);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- }
- private void newDelBill(Context ctx, String billId,HashMap<String, Object> params) throws BOSException, EASBizException {
- IPluralityAddBizBill addIns = PluralityAddBizBillFactory.getLocalInstance(ctx);
- PluralityAddBizBillInfo addInfo = addIns.getPluralityAddBizBillInfo(new ObjectUuidPK(billId));
- //创建新集合
- CoreBaseCollection delCol = new CoreBaseCollection();
- PluralityDelBizBillInfo delInfo = new PluralityDelBizBillInfo();
- // delInfo.setAdminOrg(addInfo.getAdminOrg());
- delInfo.setHrOrgUnit(addInfo.getHrOrgUnit());
- delInfo.setBizDate(new Date());
- delInfo.setCU(addInfo.getCU());
- delInfo.setApplier(addInfo.getApplier());
- //分录数据
- PluralityAddBizBillEntryCollection addEntrys = addInfo.getEntrys();
- //分录赋值
- PluralityDelBizBillEntryCollection addEntryData = addEntryData(addEntrys, params);
- delInfo.put("entrys", addEntryData);
- delInfo.setApplyDate(new Date());
- delInfo.setBizDate(new Date());
- delInfo.setCreator(ContextUtil.getCurrentUserInfo(ctx));
- delInfo.setHrOrgUnit(addInfo.getHrOrgUnit());
- delInfo.setIsMulti(addInfo.isIsMulti() );
- delInfo.setUseDefault(addInfo.isUseDefault());
- delInfo.setIsMultiEntry(addInfo.isIsMultiEntry());
- delInfo.setBillState(HRBillStateEnum.SAVED);
- delInfo.setApproveType(ApproveTypeEnum.DIRECT);
-
- // delCol.add(delInfo);
- //保存数据库
- IPluralityDelBizBill delIns = PluralityDelBizBillFactory.getLocalInstance(ctx);
- delIns.addnew(delInfo);
- delInfo.setBillState(HRBillStateEnum.AUDITED);
- delIns.submitEffect((CoreBaseInfo)delInfo);
- logger.error("兼职单审核完");
- }
- /**
- * 分录赋值
- * @param addEntrys
- * @return
- */
- private PluralityDelBizBillEntryCollection addEntryData(PluralityAddBizBillEntryCollection addEntrys,HashMap<String, Object> params){
- PluralityDelBizBillEntryCollection delEntryCol = new PluralityDelBizBillEntryCollection();
- for(int i =0 ;i< addEntrys.size();i++){
- PluralityAddBizBillEntryInfo addEntryInfo = addEntrys.get(i);
- PluralityDelBizBillEntryInfo delEntryInfo = new PluralityDelBizBillEntryInfo();
- delEntryInfo.setPerson(addEntryInfo.getPerson());
- delEntryInfo.setDescription("自动终止");
- delEntryInfo.setAffairActionReason((AffairActionReasonInfo)params.get("reasonInfo"));
- delEntryInfo.setHrBizDefine((HRBizDefineInfo)params.get("defineInfo"));
- delEntryInfo.setDefaultLocale(addEntryInfo.getDefaultLocale());
- delEntryInfo.setHrOrgUnit(addEntryInfo.getHrOrgUnit());
- //兼职组织-
- delEntryInfo.setOldEmpType(addEntryInfo.getEmpType());
- delEntryInfo.setOldAdminOrg(addEntryInfo.getAdminOrg());
- delEntryInfo.setOldPosition(addEntryInfo.getPosition());
- delEntryInfo.setOldCompany(addEntryInfo.getCompany());
- //任职职位-现任职位
- delEntryInfo.setEmpType(addEntryInfo.getOldEmpType());
- delEntryInfo.setMainPosition(addEntryInfo.getOldPosition());
- delEntryInfo.setMainAdminOrg(addEntryInfo.getOldAdminOrg());
- //任职部门-现任部门
- delEntryInfo.setMainDepartment(addEntryInfo.getOldAdminOrg());
- delEntryInfo.setMainCompany(addEntryInfo.getOldCompany());
- //不需要
- // delEntryInfo.setPosition(addEntryInfo.getOldPosition());
- // delEntryInfo.setAdminOrg(addEntryInfo.getOldAdminOrg());
- delEntryInfo.setBeginDate(addEntryInfo.getBizDate());
- delEntryInfo.setEmployerUnit(addEntryInfo.getEmployerUnit());
- delEntryInfo.put("pthwage", addEntryInfo.get("pthwage"));
- delEntryInfo.put("ptlmanager", addEntryInfo.get("ptlmanager"));
- // if(params.containsKey("isResign") && Boolean.getBoolean(params.get("isResign").toString()) ) {
- //
- // }
- //结束日期
- if(params.containsKey("endDate") ) {
- try {
- Date endDate = DateTimeUtils.parseDate( params.get("endDate").toString(), "yyyy-MM-dd");
- delEntryInfo.setBizDate(endDate);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }else {
- delEntryInfo.setBizDate(addEntryInfo.getEndDate());
- }
- delEntryCol.add(delEntryInfo);
- }
- return delEntryCol;
- }
-
-
-
-
- @Override
- protected void _resignCreateEnd(Context ctx, String personId, String endDate) throws BOSException, EASBizException {
- super._resignCreateEnd(ctx, personId, endDate);
- if(StringUtils.isBlank(endDate)) {
- endDate = DateUtil.dateToString(new Date(), "yyyy-MM-dd");
- }
-
- //变动类型
- AffairActionReasonInfo reasonInfo = AffairActionReasonFactory.getLocalInstance(ctx).getAffairActionReasonInfo(" where number = '0211' ");
- HRBizDefineInfo defineInfo = HRBizDefineFactory.getLocalInstance(ctx).getHRBizDefineInfo( " where number = 'SHR19' " );
- HashMap<String, Object> params = new HashMap<String,Object> ();
- params.put("reasonInfo", reasonInfo);
- params.put("defineInfo", defineInfo);
- params.put("isResign", true);
- params.put("endDate", endDate);
- //查询兼职单
- StringBuilder sbu = new StringBuilder();
- sbu.append(" select bill.fid billId , delen.fid delId from T_HR_PluralityAddBizBill bill ");
- sbu.append(" left join T_HR_PluralityAddBizBillEntry entry on bill.FId = entry.fbillid ");
- sbu.append(" left join T_HR_PluralityDelBizBillEntry delen ");
- sbu.append(" on entry.fpersonid = delen.fpersonid ");
- sbu.append(" and entry.foldpositionid = delen.FMainPositionID ");
- sbu.append(" and ( ");
- sbu.append(" entry.cfpthwage = delen.cfpthwage ");
- sbu.append(" OR ( entry.cfpthwage IS NULL AND delen.cfpthwage IS NULL ) ");
- sbu.append(" ) ");
- sbu.append(" where bill.fbillstate = '3' ");
- sbu.append(" and entry.fpersonid = '" + personId+"'" );
- sbu.append(" and ( entry.fenddate >= {" + endDate+"} or entry.fenddate is null ) ");
-
-
- IRowSet rowSet = DbUtil.executeQuery(ctx, sbu.toString());
-
- try {
- while(rowSet.next()) {
- String billId = rowSet.getString("billId");
- String delId = rowSet.getString("delId");
- if(StringUtils.isBlank(delId)) {
- newDelBill( ctx, billId ,params);
- }
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
-
-
-
-
- }
-
-
- }
|