| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- package com.kingdee.eas.custom.wamke.web;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.log4j.Logger;
- import org.apache.log4j.Priority;
- import org.springframework.ui.ModelMap;
- import com.kingdee.bos.BOSException;
- import com.kingdee.bos.Context;
- import com.kingdee.bos.dao.IObjectPK;
- import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
- import com.kingdee.eas.framework.CoreBaseInfo;
- import com.kingdee.eas.hr.affair.EmpEnrollBizBillFactory;
- import com.kingdee.eas.hr.affair.EmpEnrollBizBillInfo;
- import com.kingdee.eas.util.app.DbUtil;
- import com.kingdee.jdbc.rowset.IRowSet;
- import com.kingdee.shr.affair.web.handler.hrman.EmpEnrollBizBillHrManEditHandler;
- import com.kingdee.shr.base.syssetting.context.SHRContext;
- import com.kingdee.shr.base.syssetting.exception.SHRWebException;
- import com.kingdee.eas.common.EASBizException;
- import com.kingdee.util.StringUtils;
- public class EmpEnrollBizBillHrManEditExtendHandler extends
- EmpEnrollBizBillHrManEditHandler {
-
- private static Logger logger = Logger.getLogger(EmpEnrollBizBillHrManEditExtendHandler.class);
- private void logInfo(String msg) {
- System.out.println(msg);
- logger.log(Priority.INFO, msg);
- }
-
- @Override
- protected IObjectPK runSaveData(HttpServletRequest request,
- HttpServletResponse response, CoreBaseInfo model) throws Exception {
-
- throw new SHRWebException("是否执行了错误 ");
- // IObjectPK pk = super.runSaveData(request, response, model);
- //
- // try{
- // if(pk!=null){
- // adjustWorkType(pk.toString());
- // }
- // }
- // catch(Exception e){
- // logInfo("执行更新工种时发生了异常");
- // e.printStackTrace();
- // }
- // return pk;
- }
-
- protected IObjectPK runSubmit(HttpServletRequest request,
- HttpServletResponse response, CoreBaseInfo model) throws Exception {
- throw new SHRWebException("是否执行了错误 ");
- // IObjectPK pk = super.runSubmit(request, response, model);
- // try{
- // if(pk!=null){
- // adjustWorkType(pk.toString());
- // }
- // }
- // catch(Exception e){
- // logInfo("执行更新工种时发生了异常");
- // e.printStackTrace();
- // }
- // return pk;
- }
-
- public String editAction(HttpServletRequest request,
- HttpServletResponse response, ModelMap modelMap)
- throws SHRWebException {
- throw new SHRWebException("是否执行了错误 ");
- // String result = super.editAction(request, response, modelMap);
- // EmpEnrollBizBillInfo billInfo = null;
- // try {
- // if ((!(StringUtils.isEmpty(getBillId(request))))
- // && (getBillId(request).length() > 5))
- // billInfo = EmpEnrollBizBillFactory.getRemoteInstance()
- // .getEmpEnrollBizBillInfo(
- // new ObjectUuidPK(getBillId(request)));
- // } catch (EASBizException e) {
- // e.printStackTrace();
- // throw new SHRWebException(e);
- // } catch (BOSException e) {
- // e.printStackTrace();
- // throw new SHRWebException(e);
- // }
- //
- // if(billInfo!=null){
- // try{
- // adjustWorkType(billInfo.getId().toString());
- // }
- // catch(Exception e){
- // logInfo("执行更新工种时发生了异常");
- // e.printStackTrace();
- // }
- // }
- //
- // return result;
- }
- /**
- * 根据跨公司调动单ID进行员工新工种信息
- * @param id
- * @throws Exception
- */
- private void adjustWorkType(String id) throws Exception{
- Map<String,String> info = isWjCompany(id);
- if(info.get("pass").equals("true")){
- String posId = info.get("posId");
- String workId = getWorkCategoryIdByPosId(posId);
- if(null==workId){
- return;
- }
- //更新当前记录的工种
- String sql = "UPDATE T_HR_EmpEnrollBizBillEntry SET CFWORKCATEGORYID = '"+workId+"' WHERE FBillID = '"+id+"'";
- Context ctx = SHRContext.getInstance().getContext();
- DbUtil.execute(ctx, sql);
- }
- }
-
- /**
- * 根据岗位ID获取对应匹配的工种ID
- * @param posId
- * @return
- */
- private String getWorkCategoryIdByPosId(String posId){
- try{
- String sql = " SELECT work_category_id fROM T_ORG_Position a "
- + " INNER JOIN CT_WK_work_category_setting b ON(a.FName_l2 COLLATE Chinese_PRC_CI_AS = b.position_name) "
- + " WHERE a.FID= '"+posId+"' ";
- logInfo("根据岗位ID获取对应匹配的工种IDsql:"+sql);
- Context ctx = SHRContext.getInstance().getContext();
- IRowSet rowSet = DbUtil.executeQuery(ctx, sql);
- while(rowSet.next()){
- return rowSet.getString("work_category_id");
- }
- }
- catch(Exception e){
- logInfo("根据岗位ID获取对应匹配的工种ID时发生异常:"+e.getMessage());
- e.printStackTrace();
- return null;
- }
- return null;
- }
-
- /**
- * 判断是否为万净公司下的人员
- * @param id
- * @param isSubmitEffect 是否提交生效
- * @return
- */
- private Map<String,String> isWjCompany(String id ) {
- Map<String,String> result = new HashMap<String,String>();
- result.put("pass","false");
-
- try{
- String sql = "SELECT TOP 1 FADMINORGID, FPositionId FROM T_HR_EmpEnrollBizBillEntry WHERE FBILLID = '"+id+"' ";
- logInfo("执行公司内调入单据数据sql:"+sql);
- Context ctx = SHRContext.getInstance().getContext();
- IRowSet rowSet = DbUtil.executeQuery(ctx, sql);
- String adminId = null, posId = null, personId = null;
- Date bizDate = null;
- while (rowSet.next()) {
- adminId = rowSet.getString("FADMINORGID");
- posId = rowSet.getString("FPositionId");
- result.put("adminId",adminId);
- result.put("posId",posId);
- break;
- }
-
- if(adminId==null || adminId == ""){
- result.put("pass","false");
- return result;
- }
-
- sql = "SELECT TOP 1 FID FROM T_ORG_ADmin WHERE FId = '"+adminId+"' AND FLONGNUMBER LIKE '01!WKWY!50952375!%";
- logInfo("执行查询是否为万净公司sql:"+sql);
- IRowSet rowSetWj = DbUtil.executeQuery(ctx, sql);
- while(rowSetWj.next()){
- if(rowSetWj.getString("FID") != null && rowSetWj.getString("FID") != ""){
- result.put("pass","true");
- }
- else{
- result.put("pass","false");
- }
- break;
- }
- return result;
- }
- catch(Exception e ){
- logInfo("判 断是否为万净公司数据时发生了异常:"+e.getMessage());
- e.printStackTrace();
- return result;
- }
- }
-
- }
|