|
|
|
@ -0,0 +1,106 @@
|
|
|
|
|
package weaver.interfaces.hostar.action;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.interfaces.workflow.action.Action;
|
|
|
|
|
import weaver.soa.workflow.request.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.http.Method.POST;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 安防接口同步人员信息action
|
|
|
|
|
* 安防接口同步人员信息
|
|
|
|
|
*
|
|
|
|
|
* @author xuxy
|
|
|
|
|
* @version 1.00版本
|
|
|
|
|
* @Date 2024/4/1
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class EmployeeInsertAction implements Action {
|
|
|
|
|
@Override
|
|
|
|
|
public String execute(RequestInfo requestInfo) {
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
//获取主表数据
|
|
|
|
|
Map mainInfo = getMainInfo(requestInfo);
|
|
|
|
|
log.info("-EmployeeInsertAction-主表数据是:"+ JSONObject.toJSONString(mainInfo));
|
|
|
|
|
//此处获取主表字段信息
|
|
|
|
|
String xm = Util.null2String(mainInfo.get("xm"));//姓名
|
|
|
|
|
String xb = Util.null2String(mainInfo.get("xb"));//性别
|
|
|
|
|
String bm = Util.null2String(mainInfo.get("bm"));//部门
|
|
|
|
|
String sjhm = Util.null2String(mainInfo.get("sjhm"));//手机号
|
|
|
|
|
String zjhm = Util.null2String(mainInfo.get("zjhm"));//身份证号
|
|
|
|
|
String rybh = Util.null2String(mainInfo.get("rybh"));//人员编号
|
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
|
String jsonParam;
|
|
|
|
|
String url = Util.null2String(bb.getPropValue("project_hostar", "employeeInsert"));
|
|
|
|
|
map.put("personName",xm);
|
|
|
|
|
map.put("gender","0".equals(xb)?"1":"2");
|
|
|
|
|
map.put("orgIndexCode",bm);
|
|
|
|
|
map.put("phoneNo",sjhm);
|
|
|
|
|
map.put("certificateType","111");
|
|
|
|
|
map.put("certificateNo",zjhm);
|
|
|
|
|
map.put("jobNo",rybh);
|
|
|
|
|
jsonParam = JSONObject.toJSONString(map);
|
|
|
|
|
String res = callPost(url, jsonParam);
|
|
|
|
|
log.info("-EmployeeInsertAction-接口返回结果:res{}",res);
|
|
|
|
|
Map mapTypes = new HashMap<>();
|
|
|
|
|
if(StringUtils.isNotBlank(res)){
|
|
|
|
|
mapTypes = JSON.parseObject(res);
|
|
|
|
|
log.info("-EmployeeInsertAction-mapTypes:{}",mapTypes);
|
|
|
|
|
}
|
|
|
|
|
if(mapTypes.get("code").equals(200)){
|
|
|
|
|
log.info("安防接口同步人员信息接口返回成功!");
|
|
|
|
|
requestInfo.getRequestManager().setMessagecontent("安防接口同步人员信息接口返回成功!");
|
|
|
|
|
return Action.SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
log.error("接口异常!");
|
|
|
|
|
requestInfo.getRequestManager().setMessagecontent("接口异常!");
|
|
|
|
|
return Action.FAILURE_AND_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String callPost(String url,String jsonParam){
|
|
|
|
|
return HttpRequest.post(url).method(POST).header("Content-Type","application/json").body(jsonParam).execute().body();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据requestInfo获取主表数据
|
|
|
|
|
* */
|
|
|
|
|
public static Map<String,Object> getMainInfo(RequestInfo requestInfo){
|
|
|
|
|
Map<String,Object> map = new HashMap();
|
|
|
|
|
Property[] property = requestInfo.getMainTableInfo().getProperty();
|
|
|
|
|
for (int i = 0; i < property.length; i++) {
|
|
|
|
|
map.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据requestInfo获取明细表数据
|
|
|
|
|
* */
|
|
|
|
|
public static List getDetailInfo(RequestInfo requestInfo, int num){
|
|
|
|
|
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(num);
|
|
|
|
|
//dtltable数组中的行数据集合
|
|
|
|
|
Row[] rows = detailTable.getRow();
|
|
|
|
|
List sublist = new ArrayList();
|
|
|
|
|
for (int i = 0; i < rows.length; i++) {
|
|
|
|
|
Row row = rows[i];
|
|
|
|
|
Map onerow = new HashMap();
|
|
|
|
|
sublist.add(onerow);
|
|
|
|
|
Cell[] cells = row.getCell();
|
|
|
|
|
for (int j = 0; j < cells.length; j++) {
|
|
|
|
|
Cell cell = cells[j];
|
|
|
|
|
onerow.put(cell.getName(), Util.null2String(cell.getValue()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sublist;
|
|
|
|
|
}
|
|
|
|
|
}
|