|
|
package com.weaver.seconddev.sxjg.esb;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.weaver.common.base.entity.result.WeaResult;
|
|
|
import com.weaver.ebuilder.common.exception.BusinessException;
|
|
|
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
|
|
import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfig;
|
|
|
import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfigResp;
|
|
|
import com.weaver.seconddev.sxjg.util.NccApiUtil;
|
|
|
import com.weaver.seconddev.sxjg.util.NccResultUtil;
|
|
|
import org.apache.commons.configuration.ConfigurationException;
|
|
|
import org.apache.commons.configuration.PropertiesConfiguration;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 子职工报到联系单-总部ncc
|
|
|
*
|
|
|
* 职工报到联系单-总部流程同步ncc
|
|
|
* 6
|
|
|
*/
|
|
|
@Service("esb_zhigongbd_howe")
|
|
|
public class ZhiGongBdToNcc implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
|
public ZhiGongBdToNcc() {
|
|
|
PropertiesConfiguration p = null;
|
|
|
try {
|
|
|
p = new PropertiesConfiguration();
|
|
|
p.setEncoding("utf-8");
|
|
|
p.setFileName("config/nccconfig.properties");
|
|
|
p.load();
|
|
|
this.b13 = p.getString("sxjgncc.b13");
|
|
|
}catch (ConfigurationException e) {
|
|
|
throw new BusinessException("获取sxjg.properties配置文件失败,", e);
|
|
|
}
|
|
|
}
|
|
|
private String b13;
|
|
|
private static final Logger log = LoggerFactory.getLogger(ZhiGongBdToNcc.class);
|
|
|
private JdbcTemplate jdbcTemplateresp = new JdbcTemplate(EbDbDataSourceConfigResp.dbDataSource());
|
|
|
|
|
|
private JdbcTemplate jdbcTemplate = new JdbcTemplate(EbDbDataSourceConfig.dbDataSource());
|
|
|
@Override
|
|
|
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
|
|
Map<String, Object> finresult = new HashMap<>();
|
|
|
finresult.put("code",200);
|
|
|
String pk_dept = (String) params.get("pk_dept");
|
|
|
String pk_jobgrade = (String) params.get("pk_jobgrade");
|
|
|
String jobglbdef1 = (String) params.get("jobglbdef1");
|
|
|
String joinworkdate = (String) params.get("joinworkdate");
|
|
|
String pk_org = (String) params.get("pk_org");
|
|
|
String bsid = (String)params.get("bsid");
|
|
|
String username = (String)params.get("username");
|
|
|
String usercode = (String)params.get("usercode");
|
|
|
String applyer = (String) params.get("applyer");
|
|
|
String usedate = (String) params.get("usedate");
|
|
|
String zryda = (String) params.get("zryda");
|
|
|
try {
|
|
|
|
|
|
//同步明细
|
|
|
JSONObject r1 = new JSONObject();
|
|
|
String state = "1";
|
|
|
JSONArray array = getDataArray(bsid,username,usercode,usedate);
|
|
|
if(array == null || array.size() == 0) {
|
|
|
state = "0";
|
|
|
}
|
|
|
if(zryda.equals("是")) {
|
|
|
if(array == null || array.size() == 0) {
|
|
|
return WeaResult.success(finresult);
|
|
|
}
|
|
|
state = "2";
|
|
|
}
|
|
|
r1.put("pk_psndoc",applyer);
|
|
|
r1.put("state",state);
|
|
|
r1.put("pk_dept",pk_dept);
|
|
|
r1.put("pk_jobgrade",pk_jobgrade);
|
|
|
r1.put("jobglbdef1",jobglbdef1);
|
|
|
r1.put("joinworkdate",joinworkdate);
|
|
|
r1.put("pk_org",pk_org);
|
|
|
r1.put("data",array);
|
|
|
NccApiUtil nccApiUtil = new NccApiUtil();
|
|
|
nccApiUtil.init();
|
|
|
String token = nccApiUtil.getToken();
|
|
|
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrwa/customermanage/adjust/import";
|
|
|
String rs11 = nccApiUtil.doJsonPost(url,token,r1.toJSONString());
|
|
|
NccResultUtil rs = new NccResultUtil(rs11);
|
|
|
if(rs.getResult()) {
|
|
|
return WeaResult.success(finresult);
|
|
|
}else {
|
|
|
finresult.put("code",500);
|
|
|
finresult.put("msg",rs.getDescription());
|
|
|
return WeaResult.success(finresult);
|
|
|
}
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
finresult.put("code",500);
|
|
|
finresult.put("msg",e.getMessage());
|
|
|
log.error("howec:::::::::1:"+e.getMessage());
|
|
|
return WeaResult.success(finresult);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private JSONArray getDataArray(String bsid,String username,String usercode,String usedate) {
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
String sql = "select dataid from wfc_form_data wfd where requestid = "+bsid;
|
|
|
Map<String, Object> rs = jdbcTemplateresp.queryForMap(sql);
|
|
|
long dataid = (long)rs.get("dataid");
|
|
|
sql = "select waitem,xzxmmc,pk_wa_crt,negotiation,wa_seclv,money,memo from "+b13+" where FORM_DATA_ID = "+dataid+" and tbddzwh = '1'";
|
|
|
log.error("howec::::::::3"+sql);
|
|
|
List<Map<String, Object>> rs1 = jdbcTemplateresp.queryForList(sql);
|
|
|
if(CollectionUtil.isNotEmpty(rs1)) {
|
|
|
for(Map<String,Object> r : rs1) {
|
|
|
String xzxmmc = (String)r.get("xzxmmc");//薪资项目名称
|
|
|
long negotiation = (long)r.get("negotiation");//谈判工资
|
|
|
String xbdb = "";
|
|
|
if(r.get("wa_seclv")!=null) {
|
|
|
String id1 = (String)r.get("wa_seclv");
|
|
|
if(id1.length()>0) {
|
|
|
sql = "select levelname from uf_wa_prmlv where id = "+id1;
|
|
|
Map<String,Object> rso= jdbcTemplate.queryForMap(sql);
|
|
|
xbdb = (String)rso.get("levelname");
|
|
|
}
|
|
|
}
|
|
|
String nmoney = "";
|
|
|
if(r.get("money")!=null) {
|
|
|
nmoney = String.valueOf(r.get("money"));//金额
|
|
|
}
|
|
|
String memo=(String)r.get("memo");//备注
|
|
|
//通过薪资标准表id获取薪资标准名称
|
|
|
String pk_wa_crt_name = "";
|
|
|
if(r.get("pk_wa_crt") != null) {
|
|
|
String pk_wa_crt = String.valueOf(r.get("pk_wa_crt"));//薪资标准表
|
|
|
sql = "select name from uf_wa_grade where id = "+pk_wa_crt;
|
|
|
Map<String,Object> rso= jdbcTemplate.queryForMap(sql);
|
|
|
pk_wa_crt_name = (String)rso.get("name");
|
|
|
}
|
|
|
String negotiation_wage = negotiation == 0l ? "N" : "Y";
|
|
|
JSONObject dataobj = new JSONObject();
|
|
|
dataobj.put("negotiation_wage",negotiation_wage);
|
|
|
dataobj.put("begindate",usedate);
|
|
|
dataobj.put("wa_prmlv",xbdb);//薪资级别
|
|
|
// dataobj.put("wa_seclv","");//薪档级别
|
|
|
dataobj.put("nmoney",nmoney);
|
|
|
dataobj.put("waflag","Y");
|
|
|
dataobj.put("pk_wa_item_showname",xzxmmc);
|
|
|
dataobj.put("pk_wa_grd_showname",pk_wa_crt_name);
|
|
|
dataobj.put("psnCode",usercode);
|
|
|
dataobj.put("psnName",username);
|
|
|
dataobj.put("vnote",memo);
|
|
|
jsonArray.add(dataobj);
|
|
|
}
|
|
|
}
|
|
|
return jsonArray;
|
|
|
}
|
|
|
}
|