generated from dxfeng/secondev_zjzlt
考勤排班审批功能开发 保存功能调整后端过滤、拦截
This commit is contained in:
parent
329e7b0e11
commit
ddb1560606
|
|
@ -74,27 +74,12 @@ public class AttendanceSchedulingArchiveAction implements EsbServerlessRpcRemote
|
|||
|
||||
}
|
||||
|
||||
//String groupId = "weaver-ebuilder-app-service";
|
||||
//// String groupId = "";
|
||||
//String sql = "select t.id,form_data_id,ygid,ssyf from ft_ypbsp_mxb1 t where t.form_data_id='" + formDataId + "' and tenant_key = '" + tenantKey + "' and delete_type = 0";
|
||||
//log.error("sql:{}", sql);
|
||||
//Map<String, Object> recordMap = new HashMap<>();
|
||||
//String sourceType = "LOGIC";
|
||||
//
|
||||
//Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
|
||||
//List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
//
|
||||
//for (Map<String, Object> record : recordList) {
|
||||
// log.error("record===>{}", record);
|
||||
// String id = Convert.toStr(record.get("id"));
|
||||
//}
|
||||
|
||||
log.error("formDataId:{}", formDataId);
|
||||
return WeaResult.success();
|
||||
} catch (Throwable t) { // 改为捕获所有Throwable
|
||||
log.error("执行异常", t); // 打印完整堆栈
|
||||
t.printStackTrace(); // 补充控制台输出
|
||||
return WeaResult.fail("操作失败111: " + t.getMessage());
|
||||
} catch (Throwable t) {
|
||||
log.error("执行异常", t);
|
||||
t.printStackTrace();
|
||||
return WeaResult.fail("操作失败: " + t.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,12 +36,9 @@ public class AttendanceSchedulingSubmitAction implements EsbServerlessRpcRemoteI
|
|||
try {
|
||||
log.error("params=>20250610:{}", params);
|
||||
|
||||
//用户employeeId
|
||||
//Long employeeId = currentUser.getEmployeeId();
|
||||
//租户key
|
||||
//String tenantKey = currentUser.getTenantKey();
|
||||
Long formDataId = Convert.toLong(params.get("requestId"));
|
||||
Long employeeId = Convert.toLong(params.get("employeeId"));
|
||||
String status = Convert.toStr(params.get("status"));
|
||||
log.error("employeeId:{}", employeeId);
|
||||
WeaUser user = OrgUtil.getUser(employeeId);
|
||||
String tenantKey1 = user.getTenantKey();
|
||||
|
|
@ -64,15 +61,15 @@ public class AttendanceSchedulingSubmitAction implements EsbServerlessRpcRemoteI
|
|||
// 更新状态
|
||||
SchedulingStatusPo.buildBaseFields(schedulingStatus, true, user);
|
||||
// 审批中
|
||||
schedulingStatus.setStatus("1");
|
||||
schedulingStatusMapper.updateStatusById(schedulingStatus.getId(), "1");
|
||||
schedulingStatus.setStatus(status);
|
||||
schedulingStatusMapper.updateStatusById(schedulingStatus.getId(), status);
|
||||
log.error("===数据更新完成===>{}", JSON.toJSONString(schedulingStatus));
|
||||
} else {
|
||||
log.error("===数据插入===");
|
||||
// 插入数据
|
||||
schedulingStatus = new SchedulingStatusPo();
|
||||
// 审批中
|
||||
schedulingStatus.setStatus("1");
|
||||
schedulingStatus.setStatus(status);
|
||||
schedulingStatus.setMonth(preSchedulingDetailPo.getMonth());
|
||||
schedulingStatus.setEmployeeId(preSchedulingDetailPo.getEmployeeId());
|
||||
SchedulingStatusPo.buildBaseFields(schedulingStatus, false, user);
|
||||
|
|
@ -82,28 +79,12 @@ public class AttendanceSchedulingSubmitAction implements EsbServerlessRpcRemoteI
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
//String groupId = "weaver-ebuilder-app-service";
|
||||
//// String groupId = "";
|
||||
//String sql = "select t.id,form_data_id,ygid,ssyf from ft_ypbsp_mxb1 t where t.form_data_id='" + formDataId + "' and tenant_key = '" + tenantKey + "' and delete_type = 0";
|
||||
//log.error("sql:{}", sql);
|
||||
//Map<String, Object> recordMap = new HashMap<>();
|
||||
//String sourceType = "LOGIC";
|
||||
//
|
||||
//Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
|
||||
//List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
//
|
||||
//for (Map<String, Object> record : recordList) {
|
||||
// log.error("record===>{}", record);
|
||||
// String id = Convert.toStr(record.get("id"));
|
||||
//}
|
||||
|
||||
log.error("formDataId:{}", formDataId);
|
||||
return WeaResult.success();
|
||||
} catch (Throwable t) { // 改为捕获所有Throwable
|
||||
log.error("执行异常", t); // 打印完整堆栈
|
||||
t.printStackTrace(); // 补充控制台输出
|
||||
return WeaResult.fail("操作失败111: " + t.getMessage());
|
||||
} catch (Throwable t) {
|
||||
log.error("执行异常", t);
|
||||
t.printStackTrace();
|
||||
return WeaResult.fail("操作失败: " + t.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
package com.weaver.seconddev.attend.controller;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.attend.entity.po.SchedulingStatusPo;
|
||||
|
|
@ -15,7 +9,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -35,58 +28,13 @@ public class AttendanceSchedulingController {
|
|||
AttendanceSchedulingService attendanceSchedulingService;
|
||||
|
||||
@PostMapping("/dealSaveParams")
|
||||
public WeaResult<String> dealSaveParams( @RequestBody Map<String, String> params) {
|
||||
public WeaResult<String> dealSaveParams(@RequestBody Map<String, String> params) {
|
||||
return attendanceSchedulingService.dealSaveParams(params);
|
||||
}
|
||||
|
||||
@PostMapping("/saveChoseFirstShiftSec")
|
||||
public String saveChoseFirstShiftSec(@RequestHeader Map<String, String> header, @RequestBody Map<String, Object> body) {
|
||||
log.error("======saveChoseFirstShiftSec=========");
|
||||
String result = "";
|
||||
|
||||
//1、before callApi
|
||||
//在调用接口前 可以做一些前置操作
|
||||
|
||||
|
||||
//2、调用实际api
|
||||
String origin = header.get("origin");//系统地址
|
||||
String realUrl = String.valueOf(body.get("realUrl"));//数据接口
|
||||
String url = origin + realUrl;
|
||||
log.error("url===" + url);
|
||||
|
||||
String bodyStr = JSON.toJSONString(body);
|
||||
log.error("bodyStr===" + bodyStr);
|
||||
String resultStr = HttpRequest.post(url).headerMap(header, true).body(bodyStr).execute().body();
|
||||
log.error("resultStr===" + resultStr);
|
||||
//3、after callApi
|
||||
//对返回的数据做加工
|
||||
JSONObject resultObj = JSON.parseObject(resultStr);
|
||||
JSONObject data = resultObj.getJSONObject("data");
|
||||
|
||||
//for (Object o : data.getJSONArray("listDataGroup")) {
|
||||
// JSONObject group = (JSONObject) o;
|
||||
// group.put("typename", group.getString("typename") + "_二开");
|
||||
//}
|
||||
|
||||
return JSON.toJSONString(resultObj);
|
||||
|
||||
}
|
||||
|
||||
public static String removeKeyFromJson(String jsonString, String keyToRemove) throws IOException {
|
||||
// 创建 ObjectMapper 实例,用于处理 JSON 数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 将 JSON 字符串解析为 JsonNode 对象
|
||||
JsonNode rootNode = objectMapper.readTree(jsonString);
|
||||
|
||||
// 检查根节点是否为 ObjectNode
|
||||
if (rootNode instanceof ObjectNode) {
|
||||
ObjectNode objectNode = (ObjectNode) rootNode;
|
||||
// 移除指定的 key
|
||||
objectNode.remove(keyToRemove);
|
||||
}
|
||||
|
||||
// 将修改后的 JsonNode 对象转换为 JSON 字符串
|
||||
return objectMapper.writeValueAsString(rootNode);
|
||||
return attendanceSchedulingService.saveChoseFirstShiftSec(header, body);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,5 +23,7 @@ public interface AttendanceSchedulingService {
|
|||
|
||||
WeaResult<String> dealSaveParams(Map<String, String> params);
|
||||
|
||||
String saveChoseFirstShiftSec(Map<String, String> header,Map<String, Object> body);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.weaver.seconddev.attend.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
|
@ -321,4 +322,58 @@ public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingServ
|
|||
|
||||
return WeaResult.success(JSON.toJSONString(selectedObjMapMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveChoseFirstShiftSec(Map<String, String> header, Map<String, Object> body) {
|
||||
log.error("======saveChoseFirstShiftSec=========");
|
||||
String result = "";
|
||||
|
||||
//1、before callApi
|
||||
//在调用接口前 可以做一些前置操作
|
||||
|
||||
|
||||
//2、调用实际api
|
||||
String origin = header.get("origin");
|
||||
String realUrl = String.valueOf(body.get("realUrl"));
|
||||
String url = origin + realUrl;
|
||||
log.error("url===" + url);
|
||||
|
||||
// 处理body参数
|
||||
|
||||
String bodyStr = JSON.toJSONString(body);
|
||||
JSONObject jsonObject = JSONObject.parseObject(bodyStr);
|
||||
String month = jsonObject.getString("month");
|
||||
String selectedObjMap = jsonObject.getString("selectedObjMap");
|
||||
|
||||
Map<String, Object> selectedObjMapMap = JSON.parseObject(selectedObjMap, Map.class);
|
||||
Set<String> keySet = selectedObjMapMap.keySet();
|
||||
String tenantKey = UserContext.getCurrentUser().getTenantKey();
|
||||
// 使用迭代器安全删除元素
|
||||
Iterator<String> iterator = keySet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(tenantKey, Long.valueOf(key), month);
|
||||
if (schedulingStatus != null && ("1".equals(schedulingStatus.getStatus()) || "2".equals(schedulingStatus.getStatus()))) {
|
||||
log.error("schedulingStatus===保存时不处理该条数据===>{}", schedulingStatus);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedObjMapMap.size() == 0) {
|
||||
WeaResult<Object> fail = WeaResult.fail("审批中、已审核状态下无法修改");
|
||||
return JSON.toJSONString(fail);
|
||||
}
|
||||
// 更新请求参数
|
||||
jsonObject.put("selectedObjMap", selectedObjMapMap);
|
||||
|
||||
log.error("bodyStr===" + bodyStr);
|
||||
String resultStr = HttpRequest.post(url).headerMap(header, true).body(jsonObject.toJSONString()).execute().body();
|
||||
log.error("resultStr===" + resultStr);
|
||||
//3、after callApi
|
||||
|
||||
|
||||
JSONObject resultObj = JSON.parseObject(resultStr);
|
||||
log.error("resultObj===" + resultObj);
|
||||
return JSON.toJSONString(resultObj);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue