Browse Source

薪资发放添加发送通知员工功能

chenzhfa 3 years ago
parent
commit
be821857b7

+ 11 - 0
hrwa/META-INF/salaryadjmgtex.upm

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module name="nc.itf.hr.wa.HRWAEJB"> 
+  <public>
+    <component priority="0" singleton="true" remote="true" tx="CMT" supportAlias="true">
+      <interface>nc.itf.hr.wa.IWaAdjustManageExService</interface>
+      <implementation>nc.impl.wa.adjust.WaAdjustManageExServiceImpl</implementation>
+    </component>
+    
+  </public>
+</module>
+

+ 72 - 0
hrwa/nccloud/src/client/nccloud/web/hrwa/paydata/action/SendMsgAction.java

@@ -0,0 +1,72 @@
+package nccloud.web.hrwa.paydata.action;
+
+import com.alibaba.fastjson.JSONObject;
+
+import nc.itf.hr.wa.IPaydataExService;
+import nc.itf.hr.wa.IPaydataManageService;
+import nc.vo.pub.BusinessException;
+import nc.vo.pub.lang.UFBoolean;
+import nc.vo.wa.paydata.DataVO;
+import nc.vo.wa.pub.WaLoginContext;
+import nccloud.framework.service.ServiceLocator;
+import nccloud.framework.web.container.IRequest;
+import nccloud.web.hr.pub.HRCommonAction;
+import nccloud.web.hr.pub.HRNccTemplateUtils;
+import nccloud.web.hrwa.helper.WaLoginContextUtils;
+import nccloud.web.hrwa.pub.WaClassState;
+import nccloud.web.uapbd.commons.web.ParamUtils;
+
+/**
+ * 审核数据
+ * <p>
+ * {@link nc.ui.wa.paydata.action.CheckAction}
+ * </p>
+ * 
+ * @author liuyuan
+ * @date 2018-5-22
+ */
+public class SendMsgAction extends HRCommonAction {
+
+	/**
+	 * 审核数据
+	 * 
+	 * @param arg0
+	 *            请求参数,包含参数,year,period,pk_org,node_type
+	 * @param isRangeAll
+	 *            是否时全部计算,true为全部计算,false为部分计算
+	 * @return
+	 * @throws BusinessException
+	 */
+	@Override
+	public <T> Object execute(IRequest request, T para) throws Exception {
+
+		JSONObject result = new JSONObject();
+		result.put("status", 200);
+		ParamUtils param = new ParamUtils(request);
+		boolean isRangeAll = UFBoolean.valueOf(param.getString("isRangeAll", "true")).booleanValue();
+		boolean sure = param.getBoolean("sure", false);
+		IPaydataManageService service = ServiceLocator.find(IPaydataManageService.class);
+
+		WaLoginContext loginContext = WaLoginContextUtils.getWaLoginContext(param);
+		// 判断薪资档案数据状态是否发生了改变20200410
+//		new WaClassState().validateWaClassStatus(loginContext, "check");
+		// 当前页数据,用于时间戳校验
+		JSONObject jo = JSONObject.parseObject(request.read());
+		DataVO[] dataVos = HRNccTemplateUtils.getVOFromGrid(DataVO.class, jo.getString("modelInfo"));
+		String whereCondition = isRangeAll ? null : WaPaydataQueryHelper.getWhereCondition(param);
+
+		IPaydataExService serviceEx = ServiceLocator.find(IPaydataExService.class);
+		//判断已经发放
+		Boolean checkFlag = serviceEx.checkPeriodstate(loginContext.getWaLoginVO());
+//		checkFlag = Boolean.TRUE;
+		if (checkFlag) {
+			//发送员工通知
+			serviceEx.onSendMsg(loginContext.getWaLoginVO(), whereCondition);
+			result.put("msg", "发送成功");
+			return result;
+
+		}
+		throw new BusinessException("薪资未发放,不允许发送消息");
+	}
+
+}

+ 9 - 0
hrwa/src/client/yyconfig/modules/hrwa/paydata/config/action/msg_hrwa.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<actions>
+  <action>
+		<name>hrwa.paydata.SendMsgAction</name>
+		<label>通知员工</label>
+		<clazz>nccloud.web.hrwa.paydata.action.SendMsgAction</clazz>
+	</action>
+
+</actions>

+ 12 - 0
hrwa/src/client/yyconfig/modules/hrwa/paydata/config/authorize/msg_hrwa_authorize.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+
+<authorizes>
+	<authorize>
+		<appcode>*</appcode>
+		<actions>
+			<action>hrwa.paydata.SendMsgAction</action>
+		</actions>
+		
+	</authorize>
+
+</authorizes>

+ 215 - 0
hrwa/src/private/nc/impl/wa/paydata/PaydataExServiceImpl.java

@@ -0,0 +1,215 @@
+package nc.impl.wa.paydata;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import nc.bs.dao.BaseDAO;
+import nc.bs.dao.DAOException;
+import nc.bs.framework.common.NCLocator;
+import nc.hr.utils.SQLHelper;
+import nc.itf.hr.wa.IPaydataExService;
+import nc.itf.hr.wa.IPaydataQueryService;
+import nc.jdbc.framework.processor.BeanListProcessor;
+import nc.jdbc.framework.processor.BeanProcessor;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.jdbc.framework.processor.MapProcessor;
+import nc.vo.pub.BusinessException;
+import nc.vo.pub.lang.UFBoolean;
+import nc.vo.pub.lang.UFDateTime;
+import nc.vo.pubapp.AppContext;
+import nc.vo.wa.classitempower.ItemPowerUtil;
+import nc.vo.wa.func.WherePartUtil;
+import nc.vo.wa.paydata.DataSVO;
+import nc.vo.wa.paydata.DataVO;
+import nc.vo.wa.periodsate.WaPeriodstateVO;
+import nc.vo.wa.pub.WaLoginContext;
+import nc.vo.wa.pub.WaLoginVO;
+import nccloud.message.vo.NCCMessage;
+import nccloud.message.vo.NCCNoticeMessageVO;
+
+public class PaydataExServiceImpl implements IPaydataExService {
+	
+	private BaseDAO baseDAO;
+	
+	public BaseDAO getBaseDAO() {
+		if(baseDAO == null) {
+			baseDAO = new BaseDAO();
+		}
+		return baseDAO;
+	}
+
+	@Override
+	public void onSendMsg(WaLoginVO waLoginVO, String whereCondition) throws BusinessException {
+		IPaydataQueryService service = NCLocator.getInstance().lookup(IPaydataQueryService.class);
+		//查询所有人员工资信息
+		DataVO[] dataVOs = service.queryDataVOsByCond(waLoginVO.toWaLoginContext(), whereCondition, null);
+		
+		List<NCCMessage> nccMessages = new ArrayList();
+		if(dataVOs != null && dataVOs.length > 0) {
+			for(DataVO dataVO : dataVOs) {
+				NCCMessage nccMessage = getNCCMessage(dataVO);
+				if(nccMessage != null) {
+					nccMessages.add(nccMessage);
+				}
+			}
+		}
+		
+		if(nccMessages.size()>0) {
+			try {
+				String[] pk_message = nccloud.message.util.MessageCenter.sendMessage(nccMessages.toArray(new NCCMessage[nccMessages.size()]));
+				System.out.println("====");
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	
+	private NCCMessage getNCCMessage(DataVO dataVO) {
+		NCCNoticeMessageVO nccNoticeMessageVO = new NCCNoticeMessageVO();
+		
+		String subject = dataVO.getCyear()+"年度"+dataVO.getCperiod()+"月度工资已发放,请注意查收";
+		
+		nccNoticeMessageVO.setSubject(subject);
+		nccNoticeMessageVO.setContent(subject);
+		nccNoticeMessageVO.setPk_group(AppContext.getInstance().getPkGroup());
+		
+		String sql = "select cuserid from sm_user where pk_psndoc = '"+dataVO.getPk_psndoc()+"'";
+		String receiver = "";
+		try {
+			receiver = (String) getBaseDAO().executeQuery(sql, new ColumnProcessor());
+		} catch (DAOException e) {
+			e.printStackTrace();
+		}
+		if(receiver == null || "".equals(receiver)) {
+			return null;
+		}
+		nccNoticeMessageVO.setReceiver(receiver);
+		
+		nccNoticeMessageVO.setSender("NC_USER0000000000000");
+		nccNoticeMessageVO.setContenttype("BIZ");
+		nccNoticeMessageVO.setMsgsourcetype("notice");
+		nccNoticeMessageVO.setMsgtype("nc");
+		nccNoticeMessageVO.setPriority(0);
+		nccNoticeMessageVO.setReceipt(UFBoolean.FALSE);
+		nccNoticeMessageVO.setResendtimes(0);
+		nccNoticeMessageVO.setSendstate(UFBoolean.TRUE);
+		nccNoticeMessageVO.setCanBatch(UFBoolean.FALSE);
+		nccNoticeMessageVO.setSendtime(new UFDateTime());
+		nccNoticeMessageVO.setWorkflowtype(null);
+		nccNoticeMessageVO.setActions(null);
+		nccNoticeMessageVO.setBillid(null);
+		nccNoticeMessageVO.setBillno(null);
+		nccNoticeMessageVO.setBilltype(null);
+		nccNoticeMessageVO.setDetail(null);
+		nccNoticeMessageVO.setDomainflag(null);
+		nccNoticeMessageVO.setFunccode(null);
+		nccNoticeMessageVO.setFuncid(null);
+		nccNoticeMessageVO.setPk_message(null);
+		nccNoticeMessageVO.setPk_org(null);
+		nccNoticeMessageVO.setParams(null);
+		nccNoticeMessageVO.setPk_detail(null);
+		
+		NCCMessage nccMessage = new NCCMessage();
+		nccMessage.setMessage(nccNoticeMessageVO);
+		nccMessage.setMessageType("notice");
+		
+		return nccMessage;
+	}
+
+	
+	
+	private String getPeriodstateCond(String pk_wa_class, String cyear, String cperiod) { return " pk_wa_class = '" + pk_wa_class + "' and exists (select wa_period.pk_wa_period  from wa_period  where wa_period.pk_wa_period = wa_periodstate.pk_wa_period and wa_period.cyear =  '" + cyear + "' and wa_period.cperiod =  '" + cperiod + "' and  wa_periodstate.pk_wa_class =  '" + pk_wa_class + "')"; }
+
+	@Override
+	public Boolean checkPeriodstate(WaLoginVO waLoginVO) throws BusinessException {
+		Boolean resultFlag = Boolean.FALSE;
+		String cond = getPeriodstateCond(waLoginVO.getPk_prnt_class(), waLoginVO.getCyear(), waLoginVO.getCperiod());
+		String sql = "select * from wa_periodstate where "+ cond;
+		WaPeriodstateVO waPeriodstateVO = (WaPeriodstateVO) getBaseDAO().executeQuery(sql, new BeanProcessor(WaPeriodstateVO.class));	
+		if(waPeriodstateVO != null && waPeriodstateVO.getPayoffflag().booleanValue()) {
+			resultFlag = Boolean.TRUE;
+		}
+		return resultFlag;
+	}
+
+	@Override
+	public DataVO queryWaData(String pk_wa_data) throws BusinessException {
+		return (DataVO) getBaseDAO().retrieveByPK(DataVO.class, pk_wa_data);
+	}
+
+	@Override
+	public Map<String, Object> querySql(String sql) throws BusinessException {
+		return (Map<String, Object>) getBaseDAO().executeQuery(sql, new MapProcessor());
+	}
+	
+	@Override
+	public DataSVO[] getDataSVOs(WaLoginContext loginContext) throws BusinessException {
+		// TODO 增加人员权限
+		StringBuffer sqlBuffer = new StringBuffer();
+		sqlBuffer.append("select wa_datas.pk_wa_data, "); // 1
+		sqlBuffer.append("       wa_datas.pk_wa_datas, "); // 2
+		sqlBuffer.append("       wa_datas.pk_wa_classitem, "); // 3
+		sqlBuffer.append("       wa_datas.ts, "); // 4
+		sqlBuffer.append("       wa_datas.value, "); // 5
+		sqlBuffer.append("       wa_datas.to_next, "); // 5
+		sqlBuffer.append("       wa_datas.modifier, "); // 5
+		sqlBuffer.append("       wa_datas.caculatevalue, "); // 6
+		sqlBuffer.append("       wa_datas.notes, "); // 7
+		sqlBuffer.append("       wa_item.itemkey itemkey, "); // 8
+		sqlBuffer.append("        " + SQLHelper.getMultiLangNameColumn("wa_classitem.name") + "  itemname, "); // 8
+		sqlBuffer.append("        " + SQLHelper.getMultiLangNameColumn("bd_psndoc.name") + "  " + "psnname" + ", "); // 9
+		sqlBuffer.append("       wa_classitem.iflddecimal, "); // 10
+		sqlBuffer.append("       bd_psndoc.code " + "psncode" + ", "); // 11
+		sqlBuffer.append("       hi_psnjob.clerkcode, "); // 3
+		sqlBuffer.append("       wa_data.checkflag "); // 12
+		sqlBuffer.append("  from wa_datas ");
+		sqlBuffer.append(" inner join wa_data on wa_datas.pk_wa_data = wa_data.pk_wa_data ");
+		sqlBuffer.append(" inner join hi_psnjob on wa_data.pk_psnjob = hi_psnjob.pk_psnjob ");
+		sqlBuffer.append(" inner join bd_psndoc on wa_data.pk_psndoc = bd_psndoc.pk_psndoc ");
+		sqlBuffer.append(" inner join wa_classitem on wa_datas.pk_wa_classitem = wa_classitem.pk_wa_classitem ");
+		sqlBuffer.append(" inner join wa_item on wa_classitem.pk_wa_item = wa_item.pk_wa_item ");
+
+		sqlBuffer.append(
+				WherePartUtil.addWhereKeyWord2Condition(getCommonWhereCondtion4Data(loginContext.getWaLoginVO())));
+//		String powerSql = WaPowerSqlHelper.getWaPowerSql(loginContext.getPk_group(), IHRWADataResCode.WADATA,
+//				IHRWAActionCode.SpecialPsnAction, "hi_psnjob");
+//		if (!StringUtils.isBlank(powerSql)) {
+//			sqlBuffer.append(" and " + powerSql);
+//		}
+//		powerSql = WaPowerSqlHelper.getWaPowerSql(loginContext.getPk_group(), HICommonValue.RESOUCECODE_6007PSNJOB,
+//				IHRWADataResCode.WADEFAULT, "wa_data");
+//		if (!StringUtil.isEmptyWithTrim(powerSql)) {
+//			sqlBuffer.append(" and " + powerSql);
+//		}
+		sqlBuffer.append("  and  wa_item.pk_wa_item in (" + ItemPowerUtil.getItemPower(loginContext) + ")");
+		sqlBuffer.append(" order by wa_datas.pk_wa_data, wa_datas.pk_wa_classitem");
+		List<DataSVO> list = (List<DataSVO>) getBaseDAO().executeQuery(sqlBuffer.toString(), new BeanListProcessor(DataSVO.class));
+		return list.toArray(new DataSVO[0]);
+	}
+	
+	public static String getCommonWhereCondtion4Data(WaLoginVO waLoginVO) {
+	     StringBuffer sqlBuffer = new StringBuffer();
+	     if (waLoginVO.getBatch() != null && waLoginVO.getBatch().intValue() > 100) {
+	       sqlBuffer.append("  wa_data.pk_wa_class in (select pk_childclass from wa_inludeclass where pk_parentclass = '" + waLoginVO.getPk_prnt_class() + "' and batch > 100) ");
+	     } else {
+	       sqlBuffer.append("  wa_data.pk_wa_class = '" + waLoginVO.getPk_wa_class() + "' ");
+	     } 
+	     sqlBuffer.append("   and wa_data.cyear = '" + waLoginVO.getPeriodVO().getCyear() + "' ");
+	     sqlBuffer.append("   and wa_data.cperiod = '" + waLoginVO.getPeriodVO().getCperiod() + "' ");
+	     sqlBuffer.append("   and wa_data.stopflag = 'N'");
+	     
+//	     String powerSql = WaPowerSqlHelper.getWaPowerSql(waLoginVO.getPk_group(), "6007psnjob", "wadefault", "wa_data");
+//	     
+//	     if (!StringUtil.isEmptyWithTrim(powerSql)) {
+//	       sqlBuffer.append(" and " + powerSql);
+//	     }
+//	     powerSql = WaPowerSqlHelper.getWaPowerSql(waLoginVO.getPk_group(), "wa_data", "SpecialPsnAction", "hi_psnjob");
+//	     if (!StringUtils.isBlank(powerSql)) {
+//	       sqlBuffer.append(" and " + powerSql);
+//	     }
+	     
+	     return sqlBuffer.toString();
+	   }
+}

+ 54 - 0
hrwa/src/public/nc/itf/hr/wa/IPaydataExService.java

@@ -0,0 +1,54 @@
+package nc.itf.hr.wa;
+
+import java.util.Map;
+
+import nc.vo.pub.BusinessException;
+import nc.vo.uif2.LoginContext;
+import nc.vo.wa.paydata.DataSVO;
+import nc.vo.wa.paydata.DataVO;
+import nc.vo.wa.payslip.MyPayslipVO;
+import nc.vo.wa.pub.WaLoginContext;
+import nc.vo.wa.pub.WaLoginVO;
+
+public interface IPaydataExService {
+	
+	/**
+	 * 发送员工通知
+	 * @param waLoginVO
+	 * @param whereCondition
+	 * @throws nc.vo.pub.BusinessException
+	 */
+	public void onSendMsg(WaLoginVO waLoginVO, String whereCondition) throws nc.vo.pub.BusinessException;
+	
+	/**
+	 * 判断方案是否已发放
+	 * @param waLoginVO
+	 * @return
+	 * @throws nc.vo.pub.BusinessException
+	 */
+	public Boolean checkPeriodstate(WaLoginVO waLoginVO) throws nc.vo.pub.BusinessException;
+	
+	/**
+	 * 查询薪资数据
+	 * @param pk_wa_data
+	 * @return
+	 * @throws nc.vo.pub.BusinessException
+	 */
+	public DataVO queryWaData(String pk_wa_data) throws nc.vo.pub.BusinessException;
+	
+	/**
+	 * 查询sql语句值
+	 * @param sql
+	 * @return
+	 * @throws nc.vo.pub.BusinessException
+	 */
+	public Map<String,Object> querySql(String sql) throws nc.vo.pub.BusinessException;
+	
+	/**
+	 * 个人调整查询
+	 * @param loginContext
+	 * @return
+	 * @throws BusinessException
+	 */
+	public DataSVO[] getDataSVOs(WaLoginContext loginContext) throws BusinessException;
+}