考勤排班审批功能开发

This commit is contained in:
dxfeng 2025-06-11 13:29:35 +08:00
parent 58abac45df
commit 329e7b0e11
15 changed files with 906 additions and 3 deletions

3
.gitignore vendored
View File

@ -15,4 +15,5 @@ target/
/src/META-INF
### IntelliJ IDEA ###
/log
/log
/build/

View File

@ -1,3 +1,3 @@
# secondev_zjzlt
# secondev-wugang-dxfeng
浙江浙旅投数字科技有限公司
华润武钢

View File

@ -0,0 +1,5 @@
description = "子模块demo项目"
dependencies {
//
}

View File

@ -0,0 +1,100 @@
package com.weaver.seconddev.attend.action;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.seconddev.attend.entity.po.PreSchedulingDetailPo;
import com.weaver.seconddev.attend.entity.po.SchedulingStatusPo;
import com.weaver.seconddev.attend.mapper.AttendanceSchedulingMapper;
import com.weaver.seconddev.attend.mapper.SchedulingStatusMapper;
import com.weaver.workflow.common.entity.org.WeaUser;
import com.weaver.workflow.common.util.OrgUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2025/06/09
* @version: 1.0
*/
@Slf4j
@Service("attendanceSchedulingArchiveAction")
public class AttendanceSchedulingArchiveAction implements EsbServerlessRpcRemoteInterface {
@Autowired
AttendanceSchedulingMapper schedulingMapper;
@Autowired
SchedulingStatusMapper schedulingStatusMapper;
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
try {
log.error("params=>20250610:{}", params);
Long formDataId = Convert.toLong(params.get("requestId"));
Long employeeId = Convert.toLong(params.get("employeeId"));
log.error("employeeId:{}", employeeId);
WeaUser user = OrgUtil.getUser(employeeId);
String tenantKey = user.getTenantKey();
log.error("tenantKey:{}", tenantKey);
List<PreSchedulingDetailPo> detailList = schedulingMapper.getDetailList(formDataId, tenantKey);
for (PreSchedulingDetailPo preSchedulingDetailPo : detailList) {
log.error("preSchedulingDetailPo===333>{}", preSchedulingDetailPo);
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(tenantKey, Long.valueOf(preSchedulingDetailPo.getEmployeeId()), preSchedulingDetailPo.getMonth());
log.error("schedulingStatus===>{}", schedulingStatus);
if (null != schedulingStatus) {
log.error("===数据更新===");
// 更新状态
SchedulingStatusPo.buildBaseFields(schedulingStatus, true, user);
// 审批中
schedulingStatus.setStatus("2");
schedulingStatusMapper.updateStatusById(schedulingStatus.getId(), "2");
log.error("===数据更新完成===>{}", JSON.toJSONString(schedulingStatus));
} else {
log.error("===数据插入===");
// 插入数据
schedulingStatus = new SchedulingStatusPo();
// 审批中
schedulingStatus.setStatus("2");
schedulingStatus.setMonth(preSchedulingDetailPo.getMonth());
schedulingStatus.setEmployeeId(preSchedulingDetailPo.getEmployeeId());
SchedulingStatusPo.buildBaseFields(schedulingStatus, false, user);
schedulingStatusMapper.addSchedulingStatus(schedulingStatus);
log.error("===数据插入完成===>{}", JSON.toJSONString(schedulingStatus));
}
}
//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());
}
}
}

View File

@ -0,0 +1,109 @@
package com.weaver.seconddev.attend.action;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.seconddev.attend.entity.po.PreSchedulingDetailPo;
import com.weaver.seconddev.attend.entity.po.SchedulingStatusPo;
import com.weaver.seconddev.attend.mapper.AttendanceSchedulingMapper;
import com.weaver.seconddev.attend.mapper.SchedulingStatusMapper;
import com.weaver.workflow.common.entity.org.WeaUser;
import com.weaver.workflow.common.util.OrgUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2025/06/09
* @version: 1.0
*/
@Slf4j
@Service("attendanceSchedulingSubmitAction")
public class AttendanceSchedulingSubmitAction implements EsbServerlessRpcRemoteInterface {
@Autowired
AttendanceSchedulingMapper schedulingMapper;
@Autowired
SchedulingStatusMapper schedulingStatusMapper;
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
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"));
log.error("employeeId:{}", employeeId);
WeaUser user = OrgUtil.getUser(employeeId);
String tenantKey1 = user.getTenantKey();
//String tenantKey = "tva1v1at2z";
String tenantKey = user.getTenantKey();
log.error("tenantKey:{}", tenantKey);
log.error("tenantKey1:{}", tenantKey1);
List<PreSchedulingDetailPo> detailList = schedulingMapper.getDetailList(formDataId, tenantKey);
for (PreSchedulingDetailPo preSchedulingDetailPo : detailList) {
log.error("preSchedulingDetailPo===333>{}", preSchedulingDetailPo);
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(tenantKey, Long.valueOf(preSchedulingDetailPo.getEmployeeId()), preSchedulingDetailPo.getMonth());
log.error("schedulingStatus===>{}", schedulingStatus);
if (null != schedulingStatus) {
log.error("===数据更新===");
// 更新状态
SchedulingStatusPo.buildBaseFields(schedulingStatus, true, user);
// 审批中
schedulingStatus.setStatus("1");
schedulingStatusMapper.updateStatusById(schedulingStatus.getId(), "1");
log.error("===数据更新完成===>{}", JSON.toJSONString(schedulingStatus));
} else {
log.error("===数据插入===");
// 插入数据
schedulingStatus = new SchedulingStatusPo();
// 审批中
schedulingStatus.setStatus("1");
schedulingStatus.setMonth(preSchedulingDetailPo.getMonth());
schedulingStatus.setEmployeeId(preSchedulingDetailPo.getEmployeeId());
SchedulingStatusPo.buildBaseFields(schedulingStatus, false, user);
schedulingStatusMapper.addSchedulingStatus(schedulingStatus);
log.error("===数据插入完成===>{}", JSON.toJSONString(schedulingStatus));
}
}
//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());
}
}
}

View File

@ -0,0 +1,113 @@
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;
import com.weaver.seconddev.attend.service.AttendanceSchedulingService;
import com.weaver.workflow.core.api.rest.flow.entity.operate.WfcRequestOperationResultDto;
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;
/**
* @author:dxfeng
* @createTime: 2025/06/05
* @version: 1.0
*/
@Slf4j
@RestController
@RequestMapping("/api/secondev/attendanceScheduling")
@WeaPermission(publicPermission = true)
public class AttendanceSchedulingController {
@Autowired
AttendanceSchedulingService attendanceSchedulingService;
@PostMapping("/dealSaveParams")
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 = "";
//1before 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);
//3after 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);
}
@PostMapping("/createWorkFlow")
private WeaResult<WfcRequestOperationResultDto> createWorkFlow(@RequestBody Map<String, String> params) throws UnsupportedEncodingException {
return attendanceSchedulingService.createFlowV2(params);
}
@PostMapping("/updateAttendStatus")
private WeaResult<Map<String, Object>> updateAttendStatus(@RequestBody Map<String, String> params) throws UnsupportedEncodingException {
return attendanceSchedulingService.updateAttendStatus(params);
}
//@PostMapping("/batchGetAttendStatus")
//private WeaResult<Map<String, String>> batchGetAttendStatus(@RequestBody Map<String, String> params) {
// return attendanceSchedulingService.batchGetAttendStatus(params);
//}
@GetMapping("/getAttendStatus")
private WeaResult<SchedulingStatusPo> getAttendStatus(@RequestParam("empId") String empId, @RequestParam("month") String month) {
return attendanceSchedulingService.getAttendStatus(empId, month);
}
}

View File

@ -0,0 +1,23 @@
package com.weaver.seconddev.attend.entity.po;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author:dxfeng
* @createTime: 2025/06/09
* @version: 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PreSchedulingDetailPo {
private String id;
private String formDataId;
private String flowId;
private String employeeId;
private String month;
}

View File

@ -0,0 +1,70 @@
package com.weaver.seconddev.attend.entity.po;
import com.weaver.common.distribution.genid.IdGenerator;
import com.weaver.teams.security.user.User;
import com.weaver.workflow.common.entity.org.WeaUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @author:dxfeng
* @createTime: 2025/06/10
* @version: 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SchedulingStatusPo extends UfBaseField {
private String month;
private String employeeId;
private String status;
/**
* 构建基础字段
*
* @param schedulingStatus
* @param isUpdate
* @param user
*/
public static void buildBaseFields(SchedulingStatusPo schedulingStatus, boolean isUpdate, WeaUser user) {
if (isUpdate) {
schedulingStatus.setUpdater(user.getUserId());
schedulingStatus.setUpdate_time(new Date());
} else {
schedulingStatus.setId(IdGenerator.generate());
schedulingStatus.setIs_flow("0");
schedulingStatus.setFlow_id("");
schedulingStatus.setData_status("1");
schedulingStatus.setData_index("0");
schedulingStatus.setData_index("0");
schedulingStatus.setCreator(user.getUserId());
schedulingStatus.setCreate_time(new Date());
schedulingStatus.setDelete_type("0");
schedulingStatus.setFt_status("0");
schedulingStatus.setForm_data_id(schedulingStatus.getId());
schedulingStatus.setTenant_key(user.getTenantKey());
}
}
public static void buildBaseFields(SchedulingStatusPo schedulingStatus, boolean isUpdate, User user) {
if (isUpdate) {
schedulingStatus.setUpdater(user.getUserId());
schedulingStatus.setUpdate_time(new Date());
} else {
schedulingStatus.setId(IdGenerator.generate());
schedulingStatus.setIs_flow("0");
schedulingStatus.setFlow_id("");
schedulingStatus.setData_status("1");
schedulingStatus.setData_index("0");
schedulingStatus.setData_index("0");
schedulingStatus.setCreator(user.getUserId());
schedulingStatus.setCreate_time(new Date());
schedulingStatus.setDelete_type("0");
schedulingStatus.setFt_status("0");
schedulingStatus.setForm_data_id(schedulingStatus.getId());
schedulingStatus.setTenant_key(user.getTenantKey());
}
}
}

View File

@ -0,0 +1,27 @@
package com.weaver.seconddev.attend.entity.po;
import lombok.Data;
import java.util.Date;
/**
* @author:dxfeng
* @createTime: 2025/06/10
* @version: 1.0
*/
@Data
public class UfBaseField {
private Long id;
private String is_flow;
private String flow_id;
private String data_status;
private String data_index;
private Long creator;
private Date create_time;
private Long updater;
private Date update_time;
private String delete_type;
private String ft_status;
private Long form_data_id;
private String tenant_key;
}

View File

@ -0,0 +1,18 @@
package com.weaver.seconddev.attend.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.weaver.seconddev.attend.entity.po.PreSchedulingDetailPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author:dxfeng
* @createTime: 2025/06/09
* @version: 1.0
*/
@Mapper
public interface AttendanceSchedulingMapper extends BaseMapper<PreSchedulingDetailPo> {
List<PreSchedulingDetailPo> getDetailList(@Param("formDataId") Long formDataId, @Param("tenantKey") String tenantKey);
}

View File

@ -0,0 +1,21 @@
package com.weaver.seconddev.attend.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.weaver.seconddev.attend.entity.po.SchedulingStatusPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @author:dxfeng
* @createTime: 2025/06/10
* @version: 1.0
*/
@Mapper
public interface SchedulingStatusMapper extends BaseMapper<SchedulingStatusPo> {
SchedulingStatusPo getByCondition(@Param("tenantKey") String tenantKey,@Param("employeeId") Long employeeId,@Param("month") String month);
void updateStatusById(@Param("id") Long id,@Param("status") String status);
void addSchedulingStatus(SchedulingStatusPo schedulingStatusPo);
}

View File

@ -0,0 +1,27 @@
package com.weaver.seconddev.attend.service;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.seconddev.attend.entity.po.SchedulingStatusPo;
import com.weaver.workflow.core.api.rest.flow.entity.operate.WfcRequestOperationResultDto;
import java.io.UnsupportedEncodingException;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2025/06/06
* @version: 1.0
*/
public interface AttendanceSchedulingService {
WeaResult<WfcRequestOperationResultDto> createFlowV2(Map<String, String> params) throws UnsupportedEncodingException;
WeaResult<Map<String,Object>> updateAttendStatus(Map<String, String> params);
WeaResult<SchedulingStatusPo> getAttendStatus(String empId, String month);
WeaResult<Map<String,String>> batchGetAttendStatus(Map<String, String> params);
WeaResult<String> dealSaveParams(Map<String, String> params);
}

View File

@ -0,0 +1,324 @@
package com.weaver.seconddev.attend.service.impl;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.common.form.dto.data.FormDataDetailDto;
import com.weaver.common.form.dto.data.FormDataDto;
import com.weaver.common.form.dto.data.FormDataOptionDto;
import com.weaver.common.form.metadata.ModuleSource;
import com.weaver.framework.rpc.annotation.RpcReference;
import com.weaver.seconddev.attend.entity.po.SchedulingStatusPo;
import com.weaver.seconddev.attend.mapper.AttendanceSchedulingMapper;
import com.weaver.seconddev.attend.mapper.SchedulingStatusMapper;
import com.weaver.seconddev.attend.service.AttendanceSchedulingService;
import com.weaver.teams.security.context.UserContext;
import com.weaver.teams.security.user.User;
import com.weaver.workflow.core.api.rest.flow.entity.operate.WfcRequestOperateParamDataEntity;
import com.weaver.workflow.core.api.rest.flow.entity.operate.WfcRequestOperationResultDto;
import com.weaver.workflow.core.api.rest.publicapi.WfcRequestOperateRest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;
/**
* @author:dxfeng
* @createTime: 2025/06/06
* @version: 1.0
*/
@Slf4j
@Service
public class AttendanceSchedulingServiceImpl implements AttendanceSchedulingService {
@RpcReference
private WfcRequestOperateRest wfcRequestOperateRest;
@Autowired
AttendanceSchedulingMapper schedulingMapper;
@Autowired
SchedulingStatusMapper schedulingStatusMapper;
@Override
public WeaResult<WfcRequestOperationResultDto> createFlowV2(Map<String, String> params) throws UnsupportedEncodingException {
String workflowId = params.get("workflowId");
String formId = params.get("formId");
String detailData = params.get("detailData");
String month = params.get("month");
WfcRequestOperateParamDataEntity wfcRequestOperateParamDataEntity = new WfcRequestOperateParamDataEntity();
wfcRequestOperateParamDataEntity.setWorkflowId(Long.parseLong(workflowId));
//String formId = "1134268904057012233";
Map<String, String> mainFieldsMap = new HashMap<>();
mainFieldsMap.put("ssks", "1142076308540252161");
mainFieldsMap.put("ssgs", "1142076308540252162");
mainFieldsMap.put("tjrq", "1142076308540252163");
mainFieldsMap.put("tjr", "1142076308540252164");
Map<String, String> detailFieldsMap = new HashMap<>();
detailFieldsMap.put("ygid", "1142426185342279681");
detailFieldsMap.put("ssyf", "1142426185342279682");
detailFieldsMap.put("ygxm", "1142076746702413826");
detailFieldsMap.put("gw", "1142076746702413827");
// 排班
detailFieldsMap.put("1", "1142076746702413828");
detailFieldsMap.put("2", "1142076746702413829");
detailFieldsMap.put("3", "1142076772472217609");
detailFieldsMap.put("4", "1142076772472217610");
detailFieldsMap.put("5", "1142076772472217611");
detailFieldsMap.put("6", "1142076772472217612");
detailFieldsMap.put("7", "1142076772472217613");
detailFieldsMap.put("8", "1142076978731311105");
detailFieldsMap.put("9", "1142076978731311106");
detailFieldsMap.put("10", "1142076978731311107");
detailFieldsMap.put("11", "1142076978731311108");
detailFieldsMap.put("12", "1142076978731311109");
detailFieldsMap.put("13", "1142077030052814857");
detailFieldsMap.put("14", "1142077030052814858");
detailFieldsMap.put("15", "1142077030052814859");
detailFieldsMap.put("16", "1142077030052814860");
detailFieldsMap.put("17", "1142077030052814861");
detailFieldsMap.put("18", "1142077030052814862");
detailFieldsMap.put("19", "1142077030052814863");
detailFieldsMap.put("20", "1142077030052814864");
detailFieldsMap.put("21", "1142077030052814865");
detailFieldsMap.put("22", "1142077030052814866");
detailFieldsMap.put("23", "1142077094527655943");
detailFieldsMap.put("24", "1142077094527655944");
detailFieldsMap.put("25", "1142077094527655945");
detailFieldsMap.put("26", "1142077094527655946");
detailFieldsMap.put("27", "1142077094527655947");
detailFieldsMap.put("28", "1142077098847789057");
detailFieldsMap.put("29", "1142077098847789058");
detailFieldsMap.put("30", "1142077098847789059");
detailFieldsMap.put("31", "1142077098847789060");
//表单字段集合
List<FormDataDetailDto> formDataDetailDtos = new ArrayList<>();
// 构建明细表数据
String decode = URLDecoder.decode(detailData, "UTF-8");
User currentUser = UserContext.getCurrentUser();
JSONArray detailDataArray = JSON.parseArray(decode);
for (int rorIndex = 0; rorIndex < detailDataArray.size(); rorIndex++) {
int rowNum = rorIndex + 1;
JSONObject detailRow = detailDataArray.getJSONObject(rorIndex);
String empId = detailRow.getString("empId");
String employee = detailRow.getString("employee");
String jobNo = detailRow.getString("jobNo");
String position = detailRow.getString("position");
// TODO 判断数据是否可以提交
SchedulingStatusPo byCondition = schedulingStatusMapper.getByCondition(currentUser.getTenantKey(), Long.valueOf(empId), month);
if (byCondition != null && ("1".equals(byCondition.getStatus()) || "2".equals(byCondition.getStatus()))) {
log.error("SchedulingStatusPo===跳过该条数据>{}", byCondition);
continue;
}
FormDataDetailDto empIdDetailDto = new FormDataDetailDto();
empIdDetailDto.setFieldId(Long.valueOf(detailFieldsMap.get("ygid")));
empIdDetailDto.setDataIndex((long) rowNum);
empIdDetailDto.setContent(empId);
formDataDetailDtos.add(empIdDetailDto);
FormDataDetailDto employeeDetailDto = new FormDataDetailDto();
employeeDetailDto.setFieldId(Long.valueOf(detailFieldsMap.get("ygxm")));
employeeDetailDto.setDataIndex((long) rowNum);
employeeDetailDto.setContent(employee);
formDataDetailDtos.add(employeeDetailDto);
// 岗位
FormDataDetailDto jobNoDetailDto = new FormDataDetailDto();
jobNoDetailDto.setFieldId(Long.valueOf(detailFieldsMap.get("gw")));
jobNoDetailDto.setDataIndex((long) rowNum);
jobNoDetailDto.setContent(position);
formDataDetailDtos.add(jobNoDetailDto);
// 所属月份
FormDataDetailDto monthDetailDto = new FormDataDetailDto();
monthDetailDto.setFieldId(Long.valueOf(detailFieldsMap.get("ssyf")));
monthDetailDto.setDataIndex((long) rowNum);
monthDetailDto.setContent(month);
formDataDetailDtos.add(monthDetailDto);
// 处理班次字段
JSONObject shifts = detailRow.getJSONObject("shifts");
for (int i = 1; i <= 31; i++) {
FormDataDetailDto shiftDetailDto = new FormDataDetailDto();
// 对应字段标识
shiftDetailDto.setFieldId(Long.valueOf(detailFieldsMap.get(String.valueOf(i))));
shiftDetailDto.setDataIndex((long) rowNum);
JSONArray shift = shifts.getJSONArray(String.valueOf(i));
List<String> shiftValueList = new ArrayList<>();
List<FormDataOptionDto> dataOptions = new ArrayList<>();
for (Object shiftObj : shift) {
JSONObject shiftObjJson = (JSONObject) shiftObj;
log.error("shiftObjJson==" + JSON.toJSONString(shiftObjJson));
FormDataOptionDto formDataOptionDto = new FormDataOptionDto();
formDataOptionDto.setOptionId(shiftObjJson.getString("id"));
formDataOptionDto.setContent(shiftObjJson.getString("name"));
//formDataOptionDto.setContent(shiftObjJson.getString("id"));
formDataOptionDto.setType(ModuleSource.attendShift);
String shiftValue = shiftObjJson.getString("id");
shiftValueList.add(shiftValue);
dataOptions.add(formDataOptionDto);
}
shiftDetailDto.setContent(StringUtils.join(shiftValueList, ","));
//shiftDetailDto.setDataOptions(dataOptions);
log.error("[" + i + "]shiftDetailDto==" + JSON.toJSONString(shiftDetailDto));
formDataDetailDtos.add(shiftDetailDto);
}
log.error("formDataDetailDtos==" + JSON.toJSONString(formDataDetailDtos));
// 插入数据到考勤排班状态表
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(currentUser.getTenantKey(), Long.valueOf(empId), month);
log.error("schedulingStatus===>{}", schedulingStatus);
if (null != schedulingStatus) {
log.error("===数据更新===");
// 更新状态
SchedulingStatusPo.buildBaseFields(schedulingStatus, true, currentUser);
// 审批中
schedulingStatus.setStatus("0");
schedulingStatusMapper.updateStatusById(schedulingStatus.getId(), "0");
log.error("===数据更新完成===>{}", JSON.toJSONString(schedulingStatus));
} else {
log.error("===数据插入===");
// 插入数据
schedulingStatus = new SchedulingStatusPo();
// 审批中
schedulingStatus.setStatus("0");
schedulingStatus.setMonth(month);
schedulingStatus.setEmployeeId(empId);
SchedulingStatusPo.buildBaseFields(schedulingStatus, false, currentUser);
schedulingStatusMapper.addSchedulingStatus(schedulingStatus);
log.error("===数据插入完成===>{}", JSON.toJSONString(schedulingStatus));
}
}
if (CollectionUtils.isEmpty(formDataDetailDtos)) {
return WeaResult.fail("审批中、已审核的无法提交审核");
}
//表单数据
FormDataDto formDataDto = new FormDataDto();
formDataDto.setFormId(Long.valueOf(formId));
formDataDto.setDataDetails(formDataDetailDtos);
//FormDataDtoParam formDataDtoParam = new FormDataDtoParam();
//formDataDtoParam.setFormDataDtos(Arrays.asList(formDataDto));
//formDataDtoParam.setFormId(Long.valueOf(formId));
//
//WeaResult<WfcRequestOperationResultDto> flow =
// wfcRequestOperateRest.createFlowV2(wfcRequestOperateParamDataEntity, UserContext.getCurrentUser(), formDataDtoParam);
WeaResult<WfcRequestOperationResultDto> flow =
wfcRequestOperateRest.createFlow(wfcRequestOperateParamDataEntity, UserContext.getCurrentUser(), formDataDto);
return flow;
}
@Override
public WeaResult<Map<String, Object>> updateAttendStatus(Map<String, String> params) {
try {
String detailData = params.get("detailData");
String month = params.get("month");
String decode = URLDecoder.decode(detailData, "UTF-8");
User currentUser = UserContext.getCurrentUser();
JSONArray detailDataArray = JSON.parseArray(decode);
for (int rorIndex = 0; rorIndex < detailDataArray.size(); rorIndex++) {
JSONObject detailRow = detailDataArray.getJSONObject(rorIndex);
String empId = detailRow.getString("empId");
// 插入数据到考勤排班状态表
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(currentUser.getTenantKey(), Long.valueOf(empId), month);
log.error("schedulingStatus===>{}", schedulingStatus);
if (null != schedulingStatus) {
log.error("===数据更新===");
// 更新状态
SchedulingStatusPo.buildBaseFields(schedulingStatus, true, currentUser);
// 审批中
schedulingStatus.setStatus("0");
schedulingStatusMapper.updateStatusById(schedulingStatus.getId(), "3");
log.error("===数据更新完成===>{}", JSON.toJSONString(schedulingStatus));
} else {
log.error("===数据插入===");
// 插入数据
schedulingStatus = new SchedulingStatusPo();
// 审批中
schedulingStatus.setStatus("3");
schedulingStatus.setMonth(month);
schedulingStatus.setEmployeeId(empId);
SchedulingStatusPo.buildBaseFields(schedulingStatus, false, currentUser);
schedulingStatusMapper.addSchedulingStatus(schedulingStatus);
log.error("===数据插入完成===>{}", JSON.toJSONString(schedulingStatus));
}
}
return null;
} catch (Exception e) {
e.printStackTrace();
return WeaResult.fail(e.getMessage());
}
}
@Override
public WeaResult<SchedulingStatusPo> getAttendStatus(String empId, String month) {
User currentUser = UserContext.getCurrentUser();
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(currentUser.getTenantKey(), Long.valueOf(empId), month);
return WeaResult.success(schedulingStatus);
}
@Override
public WeaResult<Map<String, String>> batchGetAttendStatus(Map<String, String> params) {
String empIds = Convert.toStr(params.get("empIds"));
String month = Convert.toStr(params.get("month"));
Map<String, String> returnMap = new HashMap<>();
String[] split = empIds.split(",");
for (String empId : split) {
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(UserContext.getCurrentUser().getTenantKey(), Long.valueOf(empId), month);
returnMap.put(empId, schedulingStatus.getStatus());
}
return WeaResult.success(returnMap);
}
@Override
public WeaResult<String> dealSaveParams(Map<String, String> params) {
String selectedObjMap = Convert.toStr(params.get("selectedObjMap"));
String month = Convert.toStr(params.get("month"));
if (StringUtils.isBlank(selectedObjMap)) {
return WeaResult.success("{}");
}
// String转Map
Map<String, Object> selectedObjMapMap = JSON.parseObject(selectedObjMap, Map.class);
log.error("selectedObjMapMap===>{}", selectedObjMapMap);
Set<String> keySet = selectedObjMapMap.keySet();
Iterator<String> iterator = keySet.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
SchedulingStatusPo schedulingStatus = schedulingStatusMapper.getByCondition(UserContext.getCurrentUser().getTenantKey(), Long.valueOf(key), month);
if (schedulingStatus != null && ("1".equals(schedulingStatus.getStatus()) || "2".equals(schedulingStatus.getStatus()))) {
log.error("schedulingStatus===保存时不处理该条数据===>{}", schedulingStatus);
iterator.remove();
}
}
return WeaResult.success(JSON.toJSONString(selectedObjMapMap));
}
}

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weaver.seconddev.attend.mapper.AttendanceSchedulingMapper">
<resultMap id="baseMap" type="com.weaver.seconddev.attend.entity.po.PreSchedulingDetailPo">
<id column="id" property="id"/>
<id column="form_data_id" property="formDataId"/>
<id column="flow_id" property="flowId"/>
<id column="ygid" property="employeeId"/>
<id column="ssyf" property="month"/>
</resultMap>
<sql id="BaseColumn">
t.id,form_data_id,ygid,ssyf
</sql>
<select id="getDetailList" resultMap="baseMap">
SELECT
<include refid="BaseColumn"/>
FROM
ft_ypbsp_mxb1 t
WHERE t.delete_type = 0
and t.tenant_key = #{tenantKey}
and t.form_data_id=#{formDataId}
</select>
</mapper>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weaver.seconddev.attend.mapper.SchedulingStatusMapper">
<resultMap id="baseMap" type="com.weaver.seconddev.attend.entity.po.SchedulingStatusPo">
<id column="id" property="id"/>
<id column="ry" property="employeeId"/>
<id column="yf" property="month"/>
<id column="zt" property="status"/>
</resultMap>
<sql id="BaseColumn">
t.id,ry,yf,zt
</sql>
<insert id="addSchedulingStatus">
insert into uf_kqpbztb
(id,is_flow,data_status,data_index,creator,create_time,delete_type,ft_status,form_data_id,tenant_key,ry,yf,zt)
values
(#{id},0,1,0,#{creator},#{create_time},0,0,#{form_data_id},#{tenant_key},#{employeeId},#{month},#{status})
</insert>
<update id="updateStatusById">
update uf_kqpbztb t set zt = #{status} where id = #{id}
</update>
<select id="getByCondition" resultMap="baseMap">
SELECT
<include refid="BaseColumn"/>
FROM
uf_kqpbztb t
WHERE t.delete_type = 0
<!-- and t.tenant_key = #{tenantKey}-->
and TO_CHAR(t.ry) = #{employeeId, jdbcType=VARCHAR}
and t.yf=#{month}
</select>
</mapper>