|
|
|
@ -86,23 +86,34 @@ public class ERPPortServiceImpl implements IERPPortService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BaseStaffInfo> getERPEmployeeWageData(ERPParamDto paramDto) {
|
|
|
|
|
// 定义一个返回的员工信息列表
|
|
|
|
|
List<BaseStaffInfo> resultList = new ArrayList<>();
|
|
|
|
|
// 定义一个请求参数
|
|
|
|
|
String requestParam = null;
|
|
|
|
|
// 定义一个接口返回结果
|
|
|
|
|
String result = null;
|
|
|
|
|
try {
|
|
|
|
|
// 创建ObjectMapper实例 对象转JSON字符串
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
// 设置对象转换为JSON字符串的命名策略
|
|
|
|
|
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
|
|
|
|
|
// 将ERPParamDto对象转换为JSON字符串
|
|
|
|
|
requestParam = objectMapper.writeValueAsString(paramDto);
|
|
|
|
|
// 调用接口获取返回结果
|
|
|
|
|
result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
|
|
|
|
|
// 处理接口返回消息
|
|
|
|
|
ObjectMapper resultMapper = new ObjectMapper();
|
|
|
|
|
// 将 JSON 字符串转换为 Java 对象
|
|
|
|
|
HashMap hashMap = resultMapper.readValue(result, HashMap.class);
|
|
|
|
|
// 获取返回数据
|
|
|
|
|
HashMap returnData = (HashMap)hashMap.get("ReturnData");
|
|
|
|
|
// 获取数据列表
|
|
|
|
|
List<HashMap<String, String>> dataList = (List<HashMap<String, String>>)returnData.get("data");
|
|
|
|
|
// 遍历数据列表
|
|
|
|
|
for (HashMap<String, String> data : dataList) {
|
|
|
|
|
// 将数据插入员工信息表
|
|
|
|
|
BaseStaffInfo baseStaffInfo = staffInfoService.insertStaffByERP(data);
|
|
|
|
|
// 将员工信息添加到返回列表中
|
|
|
|
|
resultList.add(baseStaffInfo);
|
|
|
|
|
}
|
|
|
|
|
logger.warn("获取员工工资系数成功:" + requestParam + "|" + result);
|
|
|
|
@ -152,58 +163,74 @@ public class ERPPortServiceImpl implements IERPPortService {
|
|
|
|
|
return latestSalary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增【薪资明细】
|
|
|
|
|
* @param recordStaffSalary
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String addSalaryBreakdown(RecordStaffSalary recordStaffSalary) {
|
|
|
|
|
String objectId = null;//ERP返回数据的ObjectId
|
|
|
|
|
String requestParam = null;
|
|
|
|
|
String result = null;
|
|
|
|
|
ERPStaffSalary erpStaffSalary = new ERPStaffSalary();
|
|
|
|
|
erpStaffSalary.setAppCode(ERPConstants.addSalaryAppCode);
|
|
|
|
|
erpStaffSalary.setController(ERPConstants.addSalaryController);
|
|
|
|
|
erpStaffSalary.setActionName(ERPConstants.addSalaryActionName);
|
|
|
|
|
erpStaffSalary.setIdCard(recordStaffSalary.getIdCard());
|
|
|
|
|
erpStaffSalary.setGroupId(recordStaffSalary.getGroupId());
|
|
|
|
|
erpStaffSalary.setEventDate(recordStaffSalary.getEventDate());
|
|
|
|
|
erpStaffSalary.setSalaryCategory(recordStaffSalary.getSalaryCategory());
|
|
|
|
|
erpStaffSalary.setRevenueClass(recordStaffSalary.getRevenueClass());
|
|
|
|
|
erpStaffSalary.setRevenueAmount(recordStaffSalary.getRevenueAmount());
|
|
|
|
|
erpStaffSalary.setRevenueReason(recordStaffSalary.getRevenueReason());
|
|
|
|
|
try {
|
|
|
|
|
// 创建ObjectMapper实例 对象转JSON字符串
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
|
|
|
|
|
requestParam = objectMapper.writeValueAsString(erpStaffSalary);
|
|
|
|
|
// result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
|
|
|
|
|
result = "{\n" +
|
|
|
|
|
"\t\"Successful\": true,\n" +
|
|
|
|
|
"\t\"ErrorMessage\": null,\n" +
|
|
|
|
|
"\t\"Logined\": false,\n" +
|
|
|
|
|
"\t\"ReturnData\": {\n" +
|
|
|
|
|
"\t\t\"data\": {\n" +
|
|
|
|
|
"\t\t\t\"ObjectId\": \"25ff81b4-fb0b-4f1c-b9b1-6a2afab1cd0f\"\n" +
|
|
|
|
|
"\t\t},\n" +
|
|
|
|
|
"\t\t\"result\": \"success\",\n" +
|
|
|
|
|
"\t\t\"message\": \"创建成功!\"\n" +
|
|
|
|
|
"\t},\n" +
|
|
|
|
|
"\t\"DataType\": 0\n" +
|
|
|
|
|
"}";
|
|
|
|
|
// 处理接口返回消息
|
|
|
|
|
ObjectMapper resultMapper = new ObjectMapper();
|
|
|
|
|
// 将 JSON 字符串转换为 Java 对象
|
|
|
|
|
HashMap hashMap = resultMapper.readValue(result, HashMap.class);
|
|
|
|
|
HashMap returnData = (HashMap)hashMap.get("ReturnData");
|
|
|
|
|
HashMap<String, Object> data = (HashMap<String, Object>)returnData.get("data");
|
|
|
|
|
objectId = String.valueOf(data.get("ObjectId"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.warn("新增【薪资明细】异常:" + requestParam + "|" + result + "|" + e);
|
|
|
|
|
}
|
|
|
|
|
return objectId;
|
|
|
|
|
/**
|
|
|
|
|
* 新增【薪资明细】
|
|
|
|
|
* 该方法用于将员工的薪资明细添加到系统中,通过调用ERP系统的接口来完成
|
|
|
|
|
* @param recordStaffSalary 包含员工薪资明细的RecordStaffSalary对象
|
|
|
|
|
* @return 返回ERP系统生成的ObjectId,用于唯一标识新增的薪资记录
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String addSalaryBreakdown(RecordStaffSalary recordStaffSalary) {
|
|
|
|
|
// ERP返回数据的ObjectId,用于唯一标识新增的记录
|
|
|
|
|
String objectId = null;
|
|
|
|
|
// 用于存储发送给ERP系统的请求参数的字符串
|
|
|
|
|
String requestParam = null;
|
|
|
|
|
// ERP系统返回的结果
|
|
|
|
|
String result = null;
|
|
|
|
|
// 创建一个ERPStaffSalary对象,用于准备发送给ERP系统的请求数据
|
|
|
|
|
ERPStaffSalary erpStaffSalary = new ERPStaffSalary();
|
|
|
|
|
|
|
|
|
|
// 设置ERP系统请求的参数
|
|
|
|
|
erpStaffSalary.setAppCode(ERPConstants.addSalaryAppCode);
|
|
|
|
|
erpStaffSalary.setController(ERPConstants.addSalaryController);
|
|
|
|
|
erpStaffSalary.setActionName(ERPConstants.addSalaryActionName);
|
|
|
|
|
erpStaffSalary.setIdCard(recordStaffSalary.getIdCard());
|
|
|
|
|
erpStaffSalary.setGroupId(recordStaffSalary.getGroupId());
|
|
|
|
|
erpStaffSalary.setEventDate(recordStaffSalary.getEventDate());
|
|
|
|
|
erpStaffSalary.setSalaryCategory(recordStaffSalary.getSalaryCategory());
|
|
|
|
|
erpStaffSalary.setRevenueClass(recordStaffSalary.getRevenueClass());
|
|
|
|
|
erpStaffSalary.setRevenueAmount(recordStaffSalary.getRevenueAmount());
|
|
|
|
|
erpStaffSalary.setRevenueReason(recordStaffSalary.getRevenueReason());
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 创建ObjectMapper实例 对象转JSON字符串
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
|
|
|
|
|
// 将erpStaffSalary对象转换为JSON字符串,以便发送给ERP系统
|
|
|
|
|
requestParam = objectMapper.writeValueAsString(erpStaffSalary);
|
|
|
|
|
// 使用API工具类发送HTTP POST请求到ERP系统,这里代码已省略
|
|
|
|
|
// result = ApiUtils.sendERPHttpPost(ERPConstants.ERP_URL, requestParam);
|
|
|
|
|
|
|
|
|
|
// 模拟ERP系统返回的结果
|
|
|
|
|
result = "{\n" +
|
|
|
|
|
"\t\"Successful\": true,\n" +
|
|
|
|
|
"\t\"ErrorMessage\": null,\n" +
|
|
|
|
|
"\t\"Logined\": false,\n" +
|
|
|
|
|
"\t\"ReturnData\": {\n" +
|
|
|
|
|
"\t\t\"data\": {\n" +
|
|
|
|
|
"\t\t\t\"ObjectId\": \"25ff81b4-fb0b-4f1c-b9b1-6a2afab1cd0f\"\n" +
|
|
|
|
|
"\t\t},\n" +
|
|
|
|
|
"\t\t\"result\": \"success\",\n" +
|
|
|
|
|
"\t\t\"message\": \"创建成功!\"\n" +
|
|
|
|
|
"\t},\n" +
|
|
|
|
|
"\t\"DataType\": 0\n" +
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
// 处理接口返回消息
|
|
|
|
|
ObjectMapper resultMapper = new ObjectMapper();
|
|
|
|
|
// 将 JSON 字符串转换为 Java 对象
|
|
|
|
|
HashMap hashMap = resultMapper.readValue(result, HashMap.class);
|
|
|
|
|
HashMap returnData = (HashMap)hashMap.get("ReturnData");
|
|
|
|
|
HashMap<String, Object> data = (HashMap<String, Object>)returnData.get("data");
|
|
|
|
|
// 提取并返回ObjectId
|
|
|
|
|
objectId = String.valueOf(data.get("ObjectId"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 记录异常信息,包括请求参数、结果和异常详情
|
|
|
|
|
logger.warn("新增【薪资明细】异常:" + requestParam + "|" + result + "|" + e);
|
|
|
|
|
}
|
|
|
|
|
// 返回ERP系统生成的ObjectId
|
|
|
|
|
return objectId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|