EmpEnrollBizBillHrManEditExtendHandler.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. package com.kingdee.eas.custom.wamke.web;
  2. import java.util.Date;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import org.apache.log4j.Logger;
  8. import org.apache.log4j.Priority;
  9. import org.springframework.ui.ModelMap;
  10. import com.kingdee.bos.BOSException;
  11. import com.kingdee.bos.Context;
  12. import com.kingdee.bos.dao.IObjectPK;
  13. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  14. import com.kingdee.eas.framework.CoreBaseInfo;
  15. import com.kingdee.eas.hr.affair.EmpEnrollBizBillFactory;
  16. import com.kingdee.eas.hr.affair.EmpEnrollBizBillInfo;
  17. import com.kingdee.eas.util.app.DbUtil;
  18. import com.kingdee.jdbc.rowset.IRowSet;
  19. import com.kingdee.shr.affair.web.handler.hrman.EmpEnrollBizBillHrManEditHandler;
  20. import com.kingdee.shr.base.syssetting.context.SHRContext;
  21. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  22. import com.kingdee.eas.common.EASBizException;
  23. import com.kingdee.util.StringUtils;
  24. public class EmpEnrollBizBillHrManEditExtendHandler extends
  25. EmpEnrollBizBillHrManEditHandler {
  26. private static Logger logger = Logger.getLogger(EmpEnrollBizBillHrManEditExtendHandler.class);
  27. private void logInfo(String msg) {
  28. System.out.println(msg);
  29. logger.log(Priority.INFO, msg);
  30. }
  31. @Override
  32. protected IObjectPK runSaveData(HttpServletRequest request,
  33. HttpServletResponse response, CoreBaseInfo model) throws Exception {
  34. throw new SHRWebException("是否执行了错误 ");
  35. // IObjectPK pk = super.runSaveData(request, response, model);
  36. //
  37. // try{
  38. // if(pk!=null){
  39. // adjustWorkType(pk.toString());
  40. // }
  41. // }
  42. // catch(Exception e){
  43. // logInfo("执行更新工种时发生了异常");
  44. // e.printStackTrace();
  45. // }
  46. // return pk;
  47. }
  48. protected IObjectPK runSubmit(HttpServletRequest request,
  49. HttpServletResponse response, CoreBaseInfo model) throws Exception {
  50. throw new SHRWebException("是否执行了错误 ");
  51. // IObjectPK pk = super.runSubmit(request, response, model);
  52. // try{
  53. // if(pk!=null){
  54. // adjustWorkType(pk.toString());
  55. // }
  56. // }
  57. // catch(Exception e){
  58. // logInfo("执行更新工种时发生了异常");
  59. // e.printStackTrace();
  60. // }
  61. // return pk;
  62. }
  63. public String editAction(HttpServletRequest request,
  64. HttpServletResponse response, ModelMap modelMap)
  65. throws SHRWebException {
  66. throw new SHRWebException("是否执行了错误 ");
  67. // String result = super.editAction(request, response, modelMap);
  68. // EmpEnrollBizBillInfo billInfo = null;
  69. // try {
  70. // if ((!(StringUtils.isEmpty(getBillId(request))))
  71. // && (getBillId(request).length() > 5))
  72. // billInfo = EmpEnrollBizBillFactory.getRemoteInstance()
  73. // .getEmpEnrollBizBillInfo(
  74. // new ObjectUuidPK(getBillId(request)));
  75. // } catch (EASBizException e) {
  76. // e.printStackTrace();
  77. // throw new SHRWebException(e);
  78. // } catch (BOSException e) {
  79. // e.printStackTrace();
  80. // throw new SHRWebException(e);
  81. // }
  82. //
  83. // if(billInfo!=null){
  84. // try{
  85. // adjustWorkType(billInfo.getId().toString());
  86. // }
  87. // catch(Exception e){
  88. // logInfo("执行更新工种时发生了异常");
  89. // e.printStackTrace();
  90. // }
  91. // }
  92. //
  93. // return result;
  94. }
  95. /**
  96. * 根据跨公司调动单ID进行员工新工种信息
  97. * @param id
  98. * @throws Exception
  99. */
  100. private void adjustWorkType(String id) throws Exception{
  101. Map<String,String> info = isWjCompany(id);
  102. if(info.get("pass").equals("true")){
  103. String posId = info.get("posId");
  104. String workId = getWorkCategoryIdByPosId(posId);
  105. if(null==workId){
  106. return;
  107. }
  108. //更新当前记录的工种
  109. String sql = "UPDATE T_HR_EmpEnrollBizBillEntry SET CFWORKCATEGORYID = '"+workId+"' WHERE FBillID = '"+id+"'";
  110. Context ctx = SHRContext.getInstance().getContext();
  111. DbUtil.execute(ctx, sql);
  112. }
  113. }
  114. /**
  115. * 根据岗位ID获取对应匹配的工种ID
  116. * @param posId
  117. * @return
  118. */
  119. private String getWorkCategoryIdByPosId(String posId){
  120. try{
  121. String sql = " SELECT work_category_id fROM T_ORG_Position a "
  122. + " INNER JOIN CT_WK_work_category_setting b ON(a.FName_l2 COLLATE Chinese_PRC_CI_AS = b.position_name) "
  123. + " WHERE a.FID= '"+posId+"' ";
  124. logInfo("根据岗位ID获取对应匹配的工种IDsql:"+sql);
  125. Context ctx = SHRContext.getInstance().getContext();
  126. IRowSet rowSet = DbUtil.executeQuery(ctx, sql);
  127. while(rowSet.next()){
  128. return rowSet.getString("work_category_id");
  129. }
  130. }
  131. catch(Exception e){
  132. logInfo("根据岗位ID获取对应匹配的工种ID时发生异常:"+e.getMessage());
  133. e.printStackTrace();
  134. return null;
  135. }
  136. return null;
  137. }
  138. /**
  139. * 判断是否为万净公司下的人员
  140. * @param id
  141. * @param isSubmitEffect 是否提交生效
  142. * @return
  143. */
  144. private Map<String,String> isWjCompany(String id ) {
  145. Map<String,String> result = new HashMap<String,String>();
  146. result.put("pass","false");
  147. try{
  148. String sql = "SELECT TOP 1 FADMINORGID, FPositionId FROM T_HR_EmpEnrollBizBillEntry WHERE FBILLID = '"+id+"' ";
  149. logInfo("执行公司内调入单据数据sql:"+sql);
  150. Context ctx = SHRContext.getInstance().getContext();
  151. IRowSet rowSet = DbUtil.executeQuery(ctx, sql);
  152. String adminId = null, posId = null, personId = null;
  153. Date bizDate = null;
  154. while (rowSet.next()) {
  155. adminId = rowSet.getString("FADMINORGID");
  156. posId = rowSet.getString("FPositionId");
  157. result.put("adminId",adminId);
  158. result.put("posId",posId);
  159. break;
  160. }
  161. if(adminId==null || adminId == ""){
  162. result.put("pass","false");
  163. return result;
  164. }
  165. sql = "SELECT TOP 1 FID FROM T_ORG_ADmin WHERE FId = '"+adminId+"' AND FLONGNUMBER LIKE '01!WKWY!50952375!%";
  166. logInfo("执行查询是否为万净公司sql:"+sql);
  167. IRowSet rowSetWj = DbUtil.executeQuery(ctx, sql);
  168. while(rowSetWj.next()){
  169. if(rowSetWj.getString("FID") != null && rowSetWj.getString("FID") != ""){
  170. result.put("pass","true");
  171. }
  172. else{
  173. result.put("pass","false");
  174. }
  175. break;
  176. }
  177. return result;
  178. }
  179. catch(Exception e ){
  180. logInfo("判 断是否为万净公司数据时发生了异常:"+e.getMessage());
  181. e.printStackTrace();
  182. return result;
  183. }
  184. }
  185. }