740 lines
34 KiB
Java
740 lines
34 KiB
Java
package com.evo.common.controller;
|
||
|
||
import cn.hutool.core.date.DateUtil;
|
||
import com.alibaba.fastjson2.JSON;
|
||
import com.alibaba.fastjson2.JSONObject;
|
||
import com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponseBody;
|
||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
import com.evo.attendance.service.IRzAttendanceService;
|
||
import com.evo.attendance.service.IRzAttendanceStatisticalService;
|
||
import com.evo.attendance.service.RzAttendanceDetailService;
|
||
import com.evo.common.config.Global;
|
||
import com.evo.common.constant.Constants;
|
||
import com.evo.common.core.domain.AjaxResult;
|
||
import com.evo.common.utils.Collections;
|
||
import com.evo.common.utils.http.HttpUtils;
|
||
import com.evo.common.utils.spring.SpringUtils;
|
||
import com.evo.ding.DingUtils;
|
||
import com.evo.ding.processor.callback.DingCallBackExchangeProcessor;
|
||
import com.evo.ding.processor.callback.impl.DingCallBackCheckRecordExchangeProcessor;
|
||
import com.evo.ding.processor.callback.impl.DingCallBackUserAddOrgExchangeProcessor;
|
||
import com.evo.personnelMatters.mapper.RzOverTimeDetailMapper;
|
||
import com.evo.personnelMatters.mapper.RzOverTimeMapper;
|
||
import com.evo.restaurant.service.IRzRestaurantStatisticsService;
|
||
import com.evo.system.domain.SysStaff;
|
||
import com.evo.system.service.ISysStaffService;
|
||
import com.evo.wechat.TemplateMessageUtil;
|
||
import com.evo.wechat.dto.AbnormalAttendanceTemplate;
|
||
import com.evo.wechat.dto.MessageTemplate;
|
||
import com.evo.wechat.service.GZHAccessTokenService;
|
||
import org.apache.ibatis.annotations.Param;
|
||
import org.jasypt.encryption.StringEncryptor;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.ui.Model;
|
||
import org.springframework.util.LinkedMultiValueMap;
|
||
import org.springframework.util.MultiValueMap;
|
||
import org.springframework.web.bind.annotation.*;
|
||
import org.springframework.web.client.RestTemplate;
|
||
import org.springframework.web.multipart.MultipartFile;
|
||
|
||
import javax.annotation.Resource;
|
||
import java.io.*;
|
||
import java.net.HttpURLConnection;
|
||
import java.net.URL;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.Date;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.concurrent.atomic.AtomicReference;
|
||
import java.util.stream.Collectors;
|
||
|
||
/**
|
||
* 类
|
||
*
|
||
* @ClassName:TestController
|
||
* @date: 2025年06月04日 11:12
|
||
* @author: andy.shi
|
||
* @contact: 17330188597
|
||
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||
*/
|
||
@RestController
|
||
@RequestMapping("/test")
|
||
public class TestController {
|
||
@Resource
|
||
private RzOverTimeMapper rzOverTimeMapper;
|
||
@Resource
|
||
private RzOverTimeDetailMapper rzOverTimeDetailMapper;
|
||
@Resource
|
||
private ISysStaffService sysStaffService;
|
||
@Resource
|
||
IRzAttendanceStatisticalService rzAttendanceStatisticalService;
|
||
@Resource
|
||
IRzRestaurantStatisticsService rzRestaurantStatisticsService;
|
||
|
||
@Resource
|
||
private IRzAttendanceService rzAttendanceService;
|
||
@Resource
|
||
private RzAttendanceDetailService rzAttendanceDetailService;
|
||
@Resource
|
||
private GZHAccessTokenService gzhAccessTokenService;
|
||
@Resource
|
||
private StringEncryptor stringEncryptor;
|
||
@Autowired
|
||
List<DingCallBackExchangeProcessor> dingCallBackExchangeProcessorList;
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/dk")
|
||
public AjaxResult dk(@RequestBody JSONObject jsonObject) throws ParseException {
|
||
SpringUtils.getBean(DingCallBackCheckRecordExchangeProcessor.class).exchange(jsonObject);
|
||
return AjaxResult.success("");
|
||
}
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/ding/addUser")
|
||
public AjaxResult dingAdduser() throws ParseException {
|
||
String userStr = "{\"eventId\":\"8885d16e2e94467586272bac110c0083\",\"CorpId\":\"dinga5c6eeb2f797ecdbf5bf40eda33b7ba0\",\"EventType\":\"user_add_org\",\"UserId\":[\"04022527541521544736\"],\"OptStaffId\":\"190059053229069198\",\"TimeStamp\":\"1783990123767\"}";
|
||
SpringUtils.getBean(DingCallBackUserAddOrgExchangeProcessor.class).exchange(JSONObject.parseObject(userStr));
|
||
return AjaxResult.success("");
|
||
}
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/dept")
|
||
public AjaxResult dept(Long deptId) throws ParseException {
|
||
return AjaxResult.success("");
|
||
}
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/user")
|
||
public AjaxResult user(String phone) throws ParseException {
|
||
return AjaxResult.success(DingUtils.getUserIdByPhoto(phone));
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/aes")
|
||
public void aes() throws ParseException {
|
||
// 1. 解密用户名(去掉ENC())
|
||
String usernameCipher = "QpRNGkSzaeihXTOqXCqXCdAgTTBTOD8M";
|
||
String usernamePlain = stringEncryptor.decrypt(usernameCipher);
|
||
System.out.println("解密后的用户名:" + usernamePlain);
|
||
|
||
// 2. 解密密码(去掉ENC())
|
||
String passwordCipher = "c5Sf+6DNzIgtVm2BoHLFmJqnsTJhqRQd721fQ5HXFEY=";
|
||
String passwordPlain = stringEncryptor.decrypt(passwordCipher);
|
||
System.out.println("解密后的密码:" + passwordPlain);
|
||
}
|
||
|
||
|
||
@GetMapping("/buildUser")
|
||
public AjaxResult buildUser() throws ParseException {
|
||
List<SysStaff> staffList = sysStaffService.list(new LambdaQueryWrapper<SysStaff>().ne(SysStaff::getStatus, -1).isNull(SysStaff::getDingUserId));
|
||
List<String> notDingDing = Collections.emptyList();
|
||
if(Collections.isNotEmpty(staffList)){
|
||
staffList.stream().forEach(data ->{
|
||
String result = DingUtils.getUserIdByPhoto(data.getPhone());
|
||
JSONObject resObject = JSON.parseObject(result);
|
||
if(Integer.valueOf(0).equals(resObject.getInteger("errcode"))){
|
||
JSONObject dingRes = resObject.getJSONObject("result");
|
||
String userId = dingRes.getString("userid");
|
||
data.setDingUserId(userId);
|
||
}else{
|
||
notDingDing.add(data.getName());
|
||
}
|
||
});
|
||
}
|
||
sysStaffService.updateBatchById(staffList);
|
||
if(Collections.isNotEmpty(notDingDing)){
|
||
return AjaxResult.success("部分更新失败, 未找到钉钉数据, 人员名单如下: "+ String.join(",", notDingDing));
|
||
}
|
||
return AjaxResult.success("更新完成");
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 上传
|
||
*/
|
||
@GetMapping("/update")
|
||
public void testUpload(@Param("file") MultipartFile filePath) throws Exception {
|
||
GetFileUploadInfoResponseBody responseBody = DingUtils.resourceUrls();
|
||
// 从接口返回信息中拿到url
|
||
String resourceUrl = responseBody.getHeaderSignatureInfo().getResourceUrls().get(0);
|
||
// 从接口返回信息中拿到headers
|
||
Map<String, String> headers = responseBody.getHeaderSignatureInfo().getHeaders();
|
||
URL url = new URL(resourceUrl);
|
||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||
if (headers != null) {
|
||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||
connection.setRequestProperty(entry.getKey(), entry.getValue());
|
||
}
|
||
}
|
||
connection.setDoOutput(true);
|
||
connection.setRequestMethod("PUT");
|
||
connection.setUseCaches(false);
|
||
connection.setReadTimeout(10000);
|
||
connection.setConnectTimeout(10000);
|
||
connection.connect();
|
||
OutputStream out = connection.getOutputStream();
|
||
InputStream is = filePath.getInputStream();
|
||
byte[] b =new byte[1024];
|
||
int temp;
|
||
while ((temp=is.read(b))!=-1){
|
||
out.write(b,0,temp);
|
||
}
|
||
out.flush();
|
||
out.close();
|
||
int responseCode = connection.getResponseCode();
|
||
connection.disconnect();
|
||
if (responseCode == 200) {
|
||
System.out.println("上传成功");
|
||
} else {
|
||
System.out.println("上传失败");
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/testAdapterSend")
|
||
public AjaxResult testSend() throws ParseException {
|
||
RestTemplate restTemplate = new RestTemplate();
|
||
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
||
// // 文件
|
||
// File file = new File("D:\\andy\\车辆管理.png");
|
||
//// File file1 = new File("D:\\andy\\index.ts");
|
||
// FileSystemResource resource = new FileSystemResource(file);
|
||
//// FileSystemResource resource1 = new FileSystemResource(file1);
|
||
// params.add("files", resource);
|
||
//// params.add("files", resource1);
|
||
// StringBuilder markdownMsg = new StringBuilder();
|
||
// markdownMsg.append("### 🚀 安全库存提醒")
|
||
// .append("今日暂无安全库存预警数据。");
|
||
// // 只显示前三个安全库存数据
|
||
// markdownMsg.append("**物料编号: ").append("123321").append("**")
|
||
// .append("- 物料名称: ").append("测试测试567").append("")
|
||
// .append("- 预计可用量: ").append("200").append("")
|
||
// .append("- 即时库存: ").append("100").append("")
|
||
// .append("- 最大库存: ").append("50").append("")
|
||
// .append("- 创建时间: ").append(DateUtil.formatDateTime(new Date())).append("")
|
||
// .append("---"); // 添加分隔线
|
||
// // 添加总数汇总
|
||
// markdownMsg.append("**总数汇总**")
|
||
// .append("- 今日安全库存预警数据总数: **").append(50).append("**");
|
||
//
|
||
//
|
||
//
|
||
//
|
||
// {"month":"sendMarkdownAndFileToUser","robotCode":"dinge794oclijuyxsyub","clientId":"dinge794oclijuyxsyub","clientSecret":"4ryzLl48I8ghhKqEMPCwablFqbs6PCmadqfDAPFWBNuIEBMJvPFQg-XHAe2oH2Fe","recipientType":"code","users":["00312","00150"],"title":"消息通知测试","content":"消息正文内容。。。。。。。。"}
|
||
|
||
Map<String,String> dataMap = Collections.emptyMap();
|
||
dataMap.put("month", "sendMarkdownAndFileToUser");
|
||
dataMap.put("robotCode","dinge794oclijuyxsyub");
|
||
dataMap.put("clientId", "dinge794oclijuyxsyub");
|
||
dataMap.put("clientSecret", "4ryzLl48I8ghhKqEMPCwablFqbs6PCmadqfDAPFWBNuIEBMJvPFQg-XHAe2oH2Fe");
|
||
dataMap.put("recipientType", "code");//00146
|
||
dataMap.put("users", JSON.toJSONString(Collections.asList("00312","00150")));
|
||
dataMap.put("title", "消息通知测试");
|
||
dataMap.put("content", "消息正文内容。。。。。。。。");
|
||
//
|
||
//// dataMap.put("parameterTypes", JSON.toJSONString(Collections.asList("java.lang.String","java.lang.String")));
|
||
//// dataMap.put("parameters", JSON.toJSONString(Collections.asList("test测试",markdownMsg.toString())));
|
||
// //推送数据类型
|
||
params.add("data", JSON.toJSONString(dataMap));
|
||
//
|
||
String url = "http://localhost:8089/ding/send";
|
||
return AjaxResult.success(restTemplate.postForObject(url, params, String.class));
|
||
//
|
||
|
||
//String data = "{\"FormId\":\"BD_Empinfo\",\"FieldKeys\":\"FID\",\"FilterString\":[{\"Left\":\"\",\"FieldName\":\"FStaffNumber\",\"Compare\":\"17\",\"Value\":\"00046\",\"Right\":\"\",\"Logic\":0}],\"OrderString\":\"\",\"TopRowCount\":0,\"StartRow\":0,\"Limit\":2000,\"SubSystemId\":\"\"}";
|
||
//
|
||
// String data = "{" +
|
||
// " \"FormId\" : \"PRD_MO\"," +
|
||
// " \"FieldKeys\" : \"F_HBYT_SCLH,FBillNo,FWorkShopID.FName,FMaterialId.FNumber,FMaterialName,FPlanStartDate,FPlanFinishDate,FPickMtrlStatus\"," +
|
||
// " \"FilterString\" : [ {" +
|
||
// " \"FieldName\" : \"FStatus\"," +
|
||
// " \"Compare\" : \"105\"," +
|
||
// " \"Value\" : \"4\"," +
|
||
// " \"Left\" : \"\"," +
|
||
// " \"Right\" : \"\"," +
|
||
// " \"Logic\" : 0" +
|
||
// " }, {" +
|
||
// " \"FieldName\" : \"FPickMtrlStatus\"," +
|
||
// " \"Compare\" : \"29\"," +
|
||
// " \"Value\" : \"1\"," +
|
||
// " \"Left\" : \"\"," +
|
||
// " \"Right\" : \"\"," +
|
||
// " \"Logic\" : 0" +
|
||
// " }, {" +
|
||
// " \"FieldName\" : \"F_HBYT_SCLH\"," +
|
||
// " \"Compare\" : \"67\"," +
|
||
// " \"Value\" : \"QB-26-163-XCL\"," +
|
||
// " \"Left\" : \"\"," +
|
||
// " \"Right\" : \"\"," +
|
||
// " \"Logic\" : 0" +
|
||
// " } ]," +
|
||
// " \"OrderString\" : \"\"," +
|
||
// " \"TopRowCount\" : 0," +
|
||
// " \"StartRow\" : 0," +
|
||
// " \"Limit\" : 10000," +
|
||
// " \"SubSystemId\" : \"\"" +
|
||
// "}";
|
||
//
|
||
// return AjaxResult.success(HttpUtils.sendPost("http://localhost:8089/distribution/kingdee/send", JSONObject.toJSONString(
|
||
// Collections.asMap("fromId","PRD_MO", "month","billQuery", "parameterTypes",Collections.asList(String.class),"data",Collections.asMap("123",data)))));
|
||
}
|
||
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/testSend")
|
||
public AjaxResult sendAttendanceDetail() throws ParseException {
|
||
rzAttendanceDetailService.sendAttendanceDetail();
|
||
return AjaxResult.success();
|
||
}
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@GetMapping("/overTime")
|
||
public AjaxResult overTime(Date date) {
|
||
|
||
// rzOverTimeMapper.sele
|
||
// RzOverTimeDetail rzOverTimeDetail = rzOverTimeDetailMapper.queryRzOverTimeDetailByDateAndOverId(rzOverTime.getId(),date);
|
||
// rzOverTimeDetail.setOverTimeEnd(date);
|
||
// //计算加班时长 小时
|
||
// double minutes = (rzOverTimeDetail.getOverTimeEnd().getTime() - rzOverTimeDetail.getOverTimeStart().getTime())/1000/60;
|
||
// //计算小时, 保留2位小数
|
||
// double hours = new BigDecimal(minutes).divide(new BigDecimal(60),2,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||
// //获取规则
|
||
// JSONObject deviceRules = ParamUtils.getDeviceOverTimeRules(sn);
|
||
// //获取最大加班时长
|
||
// Integer maxOverTimeHour = deviceRules.getInteger("maxHour");
|
||
// //记录加班时长
|
||
// rzOverTimeDetail.setOverTimeHours(BigDecimal.valueOf(((hours > maxOverTimeHour) ? maxOverTimeHour : hours)));
|
||
|
||
// if(rzOverTimeDetailMapper.updateRzOverTimeDetail(rzOverTimeDetail) < 1){
|
||
return AjaxResult.success(Global.newInstance().getActive());
|
||
}
|
||
|
||
|
||
|
||
@GetMapping("/message")
|
||
public String message(String openid) {
|
||
|
||
AbnormalAttendanceTemplate templateData = new AbnormalAttendanceTemplate();
|
||
|
||
templateData.setThing1((JSONObject) JSON.toJSON(Collections.asMap("value", "研发部")));
|
||
templateData.setThing2((JSONObject)JSON.toJSON(Collections.asMap("value", "张三")));//动态跟换车牌号
|
||
templateData.setConst4((JSONObject)JSON.toJSON(Collections.asMap("value", "昨天下班未打卡")));//动态跟换车牌号
|
||
templateData.setTime6((JSONObject)JSON.toJSON(Collections.asMap("value", DateUtil.format(new Date(), "yyyy年MM月dd日"))));//动态跟换车牌号
|
||
|
||
MessageTemplate sendData = new MessageTemplate();
|
||
sendData.setTouser(openid);
|
||
sendData.setTemplate_id("z9sy-38K-iC5MAWHbxcxwg1c-9oNTFWeCOoy6B6zdKY");
|
||
sendData.setData((JSONObject)JSON.toJSON(templateData));
|
||
return TemplateMessageUtil.templateMessageSend(gzhAccessTokenService.gzhAccessToken(), sendData);
|
||
}
|
||
|
||
|
||
@GetMapping("/error")
|
||
public String error(Model model) {
|
||
SysStaff user = new SysStaff();
|
||
user.setName("张三");
|
||
user.setIdCard("130132197019183237");
|
||
user.setOpenid("123456");
|
||
model.addAttribute("user", user);
|
||
model.addAttribute("message", "信息提交失败, 请检查你的个人信息录入是否正确");
|
||
|
||
return "error.html";
|
||
}
|
||
|
||
|
||
@GetMapping("/success")
|
||
public String success(Model model) {
|
||
model.addAttribute("message", "信息提交成功");
|
||
|
||
return "success.html";
|
||
}
|
||
|
||
/**
|
||
* 清洗加班
|
||
*/
|
||
@PostMapping("/attendanceStatistical")
|
||
public AjaxResult attendanceStatistical(String userIds, String date) throws ParseException {
|
||
Date d = new SimpleDateFormat("yyyy-MM-dd").parse(date);
|
||
for (SysStaff sysStaff : sysStaffService.list(new LambdaQueryWrapper<SysStaff>().in(SysStaff::getUserId, Collections.asList(userIds.split(","))))){
|
||
rzAttendanceStatisticalService.createRzAttendance(sysStaff, null, d);
|
||
rzRestaurantStatisticsService.createRestaurantStatistics(sysStaff, d);
|
||
}
|
||
|
||
return AjaxResult.success();
|
||
}
|
||
|
||
|
||
@PostMapping("/qxdk")
|
||
public AjaxResult qxdk() throws ParseException {
|
||
// Map<Long, String> snMap = sysStaffService.list(new LambdaQueryWrapper<SysStaff>().eq(SysStaff::getDelFlag, Constants.DELETE_FLAG_0)).stream().filter(data->{ return (data.getUserId() != null && StringUtils.isNotEmpty(data.getTimeClock()));
|
||
// }).collect(Collectors.toMap(SysStaff::getUserId, SysStaff::getTimeClock));
|
||
//
|
||
//
|
||
// Date d = new SimpleDateFormat("yyyy-MM-dd").parse("2025-07-08");
|
||
// Map<String, Integer> timeMap = Collections.asMap("上班卡(倒班12时制)",12,"上班卡(单班制)",9,"上班卡(倒班8时制)",9);
|
||
// List<RzAttendance> list = rzAttendanceService.list(new LambdaQueryWrapper<RzAttendance>()
|
||
// .eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0)
|
||
// .apply(" date_format(`attendance_date`,'%Y%m%d')=date_format({0},'%Y%m%d') ",d)
|
||
// .apply(" work_start_time is not null ")
|
||
// ).stream().map(data ->{
|
||
// data.setWorkEndTime(DateUtils.addHours(data.getWorkStartTime(), timeMap.get(data.getRules())));
|
||
// return data;
|
||
// }).collect(Collectors.toList());
|
||
//
|
||
// if(Collections.isNotEmpty(list)){
|
||
// //更新所有的卡时间
|
||
// rzAttendanceService.updateBatchById(list);
|
||
// for (RzAttendance rzAttendance : list){
|
||
// List<RzAttendanceDetail> sbList = rzAttendanceDetailService.list(new LambdaQueryWrapper<RzAttendanceDetail>().eq(RzAttendanceDetail::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendanceDetail::getAttendanceId, rzAttendance.getId()).like(RzAttendanceDetail::getButtonType,"%上班%"));
|
||
// if(Collections.isEmpty(sbList)){
|
||
// rzAttendanceDetailService.addOrUpdateDetail(rzAttendance, rzAttendance.getRules(), snMap.get(rzAttendance.getStaffId()), rzAttendance.getWorkStartTime(), "系统清洗");
|
||
// }else if(sbList.size() > 1){
|
||
// sbList.remove(0);
|
||
// rzAttendanceDetailService.removeByIds(sbList);
|
||
// }
|
||
// List<RzAttendanceDetail> xbList = rzAttendanceDetailService.list(new LambdaQueryWrapper<RzAttendanceDetail>().eq(RzAttendanceDetail::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendanceDetail::getAttendanceId, rzAttendance.getId()).like(RzAttendanceDetail::getButtonType,"%下班%"));
|
||
// if(ObjectUtils.isEmpty(xbList)){
|
||
// rzAttendanceDetailService.addOrUpdateDetail(rzAttendance, "下班卡", snMap.get(rzAttendance.getStaffId()), rzAttendance.getWorkEndTime(), "系统清洗");
|
||
// }else if(xbList.size() > 1){
|
||
// xbList.remove(0);
|
||
// rzAttendanceDetailService.removeByIds(xbList);
|
||
// }
|
||
// }
|
||
// }
|
||
//
|
||
//
|
||
//
|
||
// list = rzAttendanceService.list(new LambdaQueryWrapper<RzAttendance>()
|
||
// .eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0)
|
||
// .apply(" date_format(`attendance_date`,'%Y%m%d')=date_format({0},'%Y%m%d') ",new SimpleDateFormat("yyyy-MM-dd").parse("2025-07-09"))
|
||
// .apply(" work_start_time is not null ")
|
||
// );
|
||
//
|
||
// if(Collections.isNotEmpty(list)){
|
||
// //更新所有的卡时间
|
||
// for (RzAttendance rzAttendance : list){
|
||
// List<RzAttendanceDetail> sbList = rzAttendanceDetailService.list(new LambdaQueryWrapper<RzAttendanceDetail>().eq(RzAttendanceDetail::getDelFlag, Constants.DELETE_FLAG_0).eq(RzAttendanceDetail::getAttendanceId, rzAttendance.getId()).like(RzAttendanceDetail::getButtonType,"%上班%"));
|
||
// if(Collections.isEmpty(sbList)){
|
||
// rzAttendanceDetailService.addOrUpdateDetail(rzAttendance, rzAttendance.getRules(), snMap.get(rzAttendance.getStaffId()), rzAttendance.getWorkStartTime(), "系统清洗");
|
||
// }else if(sbList.size() > 1){
|
||
// sbList.remove(0);
|
||
// rzAttendanceDetailService.removeByIds(sbList);
|
||
// }
|
||
// }
|
||
// }
|
||
return AjaxResult.success();
|
||
}
|
||
|
||
private String buildCode(Integer code){
|
||
if(code < 10){
|
||
return Constants.SEIZE_A_SEAT_3 + code;
|
||
}else if(code < 100){
|
||
return Constants.SEIZE_A_SEAT_2 + code;
|
||
}else if(code < 1000){
|
||
return Constants.SEIZE_A_SEAT_1 + code;
|
||
}else if(code < 10000){
|
||
return Constants.SEIZE_A_SEAT_0 + code;
|
||
}else{
|
||
return String.valueOf(code);
|
||
}
|
||
}
|
||
|
||
@PostMapping("/qxCode")
|
||
public AjaxResult qxCode() throws ParseException {
|
||
AtomicReference<Integer> code = new AtomicReference<>(6);
|
||
List<SysStaff> list = sysStaffService.list(new LambdaQueryWrapper<SysStaff>().notIn(SysStaff::getName, Collections.asList("胡景昌","张敏","胡毅鹏","李雾","尹国峰")).orderByAsc(SysStaff::getEmploymentDate)).stream().map(data ->{
|
||
data.setCode(buildCode(code.get()));
|
||
code.set(code.get() +1);
|
||
return data;
|
||
}).collect(Collectors.toList());
|
||
|
||
sysStaffService.updateBatchById(list,list.size());
|
||
|
||
return AjaxResult.success();
|
||
}
|
||
|
||
|
||
|
||
|
||
@PostMapping("/jb")
|
||
public AjaxResult jb() throws Exception{
|
||
|
||
// BufferedReader reader = new BufferedReader(new FileReader(new File("D:\\andy\\文档\\考勤\\7月8号加班数据清洗.txt")));
|
||
// String line = reader.readLine();
|
||
// while (line != null) {
|
||
// String[] info = line.split("-");
|
||
// RzAttendanceDetail detail = rzAttendanceDetailService.getOne(new LambdaQueryWrapper<RzAttendanceDetail>()
|
||
// .eq(RzAttendanceDetail::getDelFlag, Constants.DELETE_FLAG_0)
|
||
// .eq(RzAttendanceDetail::getName, info[0])
|
||
// .eq(RzAttendanceDetail::getButtonType,"下班卡")
|
||
// .apply(" DATE_FORMAT(date_time,'%Y%m%d') = DATE_FORMAT({0},'%Y%m%d') ", "2025-07-08"));
|
||
//
|
||
// RzAttendance attendance= rzAttendanceService.getOne(new LambdaQueryWrapper<RzAttendance>()
|
||
// .eq(RzAttendance::getDelFlag, Constants.DELETE_FLAG_0)
|
||
// .eq(RzAttendance::getName, info[0])
|
||
// .eq(RzAttendance::getAttendanceDate, "2025-07-08")
|
||
// );
|
||
// System.out.println(info[0]);
|
||
// SysStaff sysStaff = sysStaffService.getById(detail.getStaffId());
|
||
// RzOverTime rzOverTime = rzOverTimeMapper.selectRzOverTimeByNameAndMonth(sysStaff.getUserId(),detail.getDateTime());
|
||
// if(rzOverTime == null){
|
||
// rzOverTime = new RzOverTime();
|
||
// rzOverTime.setUserId(sysStaff.getUserId());
|
||
// rzOverTime.setOverHours(new BigDecimal("0.0"));
|
||
// rzOverTime.setDeptId(sysStaff.getDeptId());
|
||
// rzOverTime.setName(sysStaff.getName());
|
||
// rzOverTime.setOverTimeMonth(detail.getDateTime());
|
||
// rzOverTimeMapper.insert(rzOverTime);
|
||
// }
|
||
//
|
||
// detail = rzAttendanceDetailService.addOrUpdateDetail(attendance, "加班卡", detail.getEquipmentCode(), com.evo.common.utils.DateUtils.addSeconds(detail.getDateTime(), 10), "数据清洗");
|
||
// RzOverTimeDetail rzOverTimeDetail = new RzOverTimeDetail();
|
||
// rzOverTimeDetail.setOverTimeId(rzOverTime.getId());
|
||
// rzOverTimeDetail.setOverTimeStart(detail.getDateTime());
|
||
// rzOverTimeDetail.setName(sysStaff.getName());
|
||
// rzOverTimeDetail.setDelFlag(Constants.DELETE_FLAG_0);
|
||
// rzOverTimeDetail.setCreateBy("admin");
|
||
// rzOverTimeDetail.setCreateTime(com.evo.common.utils.DateUtils.getNowDate());
|
||
//
|
||
// detail = rzAttendanceDetailService.addOrUpdateDetail(attendance, "下班卡", detail.getEquipmentCode(), com.evo.common.utils.DateUtils.addMinutes(detail.getDateTime(), new BigDecimal(info[1]).multiply(new BigDecimal(60)).add(new BigDecimal(30)).intValue()), "数据清洗");
|
||
// rzOverTimeDetail.setOverTimeEnd(detail.getDateTime());
|
||
// rzOverTimeDetailMapper.insert(rzOverTimeDetail);
|
||
// KqUtils.calculateOverTimeHours(rzOverTimeDetail, sysStaff.getUserId(), sysStaff.getTimeClock());
|
||
// rzOverTimeDetailMapper.updateRzOverTimeDetail(rzOverTimeDetail);
|
||
// //加班修改统计
|
||
// rzOverTime.setOverHours(rzOverTime.getOverHours().add(rzOverTimeDetail.getOverTimeHours()));
|
||
// rzOverTimeMapper.updateRzOverTime(rzOverTime);
|
||
// line = reader.readLine();
|
||
// }
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
return AjaxResult.success();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
public static void main(String[] args) throws Exception {
|
||
|
||
String str = "132331198104302969,5" +
|
||
";13013219980404003X,5" +
|
||
";13013219980911005X,5" +
|
||
";130132198208112864,5" +
|
||
";130123200301063335,10" +
|
||
";130124198901012722,5" +
|
||
";130132200506291936,5" +
|
||
";130823200510275017,10" +
|
||
";130124200409112713,5" +
|
||
";132332197909035249,5" +
|
||
";132330197211121556,10" +
|
||
";132331197809282537,5" +
|
||
";132223196903210011,10" +
|
||
";130425200503282017,10" +
|
||
";130132198312085341,5" +
|
||
";132331197907081018,5" +
|
||
";130132198808171948,5" +
|
||
";130132198510223266,5" +
|
||
";130132199112222860,5" +
|
||
";130132199402281930,5" +
|
||
";132331197405072250,5" +
|
||
";130427200507260010,10" +
|
||
";130633200510046072,10" +
|
||
";132331196902122373,5" +
|
||
";13233119650311435X,5" +
|
||
";130627200502080011,10" +
|
||
";132331197009041014,5" +
|
||
";132331196705281797,5" +
|
||
";130132198206102865,5" +
|
||
";130129200303021014,10" +
|
||
";130124199010212418,5" +
|
||
";130124198705142415,5" +
|
||
";13013219940118379X,5" +
|
||
";130132200210022913,5" +
|
||
";130132198512242866,5" +
|
||
";130132199712312878,5" +
|
||
";130185200104092515,10" +
|
||
";132331198106272847,5" +
|
||
";130124199111162464,5" +
|
||
";130127198304171820,5" +
|
||
";130132198712262861,5" +
|
||
";130981200705293871,10" +
|
||
";13233119800512284X,5" +
|
||
";130132198608021945,5" +
|
||
";130521200510130011,10" +
|
||
";130132198208172840,5" +
|
||
";140622198704165224,5" +
|
||
";130132198808183201,5" +
|
||
";130132198405163177,5" +
|
||
";132331197906192867,5" +
|
||
";130132198212181942,5" +
|
||
";13012419821023246X,5" +
|
||
";130124198811222427,5" +
|
||
";130132198510203193,5" +
|
||
";452226198606061307,5" +
|
||
";132331197511112527,5" +
|
||
";132331197609181563,5" +
|
||
";130124197108282423,5" +
|
||
";132331196810232882,5" +
|
||
";130124200110161211,5" +
|
||
";130132199105122861,5" +
|
||
";13013219820321284X,5" +
|
||
";130132199908050013,5" +
|
||
";13233119810823254X,5" +
|
||
";130124198805202411,5" +
|
||
";130132199905060056,5" +
|
||
";130132199510162875,5" +
|
||
";13013219951103287X,5" +
|
||
";131124200504142313,10" +
|
||
";130132199010252946,5" +
|
||
";130532198612091526,5" +
|
||
";130132200009262878,5" +
|
||
";130132198612102887,5" +
|
||
";130132198709151968,5" +
|
||
";130132198806101970,5" +
|
||
";130981200505054817,10" +
|
||
";130130200501311536,10" +
|
||
";130185199906282518,10" +
|
||
";130525198809185717,5" +
|
||
";131122200312200010,10" +
|
||
";13013219890818288X,5" +
|
||
";130124198511212438,5" +
|
||
";130823200405243013,10" +
|
||
";130726200303022213,10" +
|
||
";130582200301013612,10" +
|
||
";130429200008068019,10" +
|
||
";131122200312282431,10" +
|
||
";131122200405010216,10" +
|
||
";130132200112192871,5" +
|
||
";131122200310071219,10" +
|
||
";13013319910307097X,5" +
|
||
";130726200203256135,10" +
|
||
";130928200104025810,10" +
|
||
";130132198811222865,5" +
|
||
";130133197912031517,5" +
|
||
";130125198908120079,10" +
|
||
";130105196807301212,5" +
|
||
";130121198909172019,10" +
|
||
";130132199001114410,10" +
|
||
";130132198903171946,5" +
|
||
";130127199209191836,5" +
|
||
";130127200308081814,10" +
|
||
";372925198703276715,5" +
|
||
";130133200012160019,10" +
|
||
";130132199004162880,5" +
|
||
";130221200411236818,10" +
|
||
";130121199811122819,10" +
|
||
";130132198407011943,5" +
|
||
";13053219860424502x,5" +
|
||
";130132199203183190,5" +
|
||
";130124197508072417,5" +
|
||
";130108197903081217,5" +
|
||
";13013219990920001X,5" +
|
||
";130132200110210052,5" +
|
||
";13012419991024241X,5" +
|
||
";130132200107220057,5" +
|
||
";130131199202104239,5" +
|
||
";130132198506023173,5" +
|
||
";130132199007270035,5" +
|
||
";130124198904062506,5" +
|
||
";130123197905264213,10" +
|
||
";130124198407082434,5" +
|
||
";130132199505170010,5" +
|
||
";130132199512053218,5" +
|
||
";130132200309122893,5" +
|
||
";130124198603142465,5" +
|
||
";130133199002271510,10" +
|
||
";130402200201102426,5" +
|
||
";130132198701021966,5" +
|
||
";130132200312111634,5" +
|
||
";130132198908221949,5" +
|
||
";431124198612294526,5" +
|
||
";130102197209081550,5" +
|
||
";130132198610153189,5" +
|
||
";130185199207201360,5" +
|
||
";130528199209261812,5" +
|
||
";130124198512260079,5" +
|
||
";130132200008303199,5" +
|
||
";130124198910152516,5" +
|
||
";132331197312081393,5" +
|
||
";130124198612102414,5" +
|
||
";130132199210280052,5" +
|
||
";130132198304112987,5" +
|
||
";130132198404092864,5" +
|
||
";132331198108151512,5" +
|
||
";130123198207213915,5" +
|
||
";130124198808040016,5" +
|
||
";130132198301262875,5" +
|
||
";130132198603141948,5" +
|
||
";130132198701102934,5" +
|
||
";130124199504182415,5" +
|
||
";132331197903162849,5" +
|
||
";132332197812100016,5" +
|
||
";130132198812093268,5" +
|
||
";130132199106160026,5" +
|
||
";130133198208150920,5" +
|
||
";13012319720704001X,5" +
|
||
";130132198311182860,5" +
|
||
";130132199412151937,5" +
|
||
";130132198706282903,5" +
|
||
";130132199808132871,5" +
|
||
";130132199010252903,5" +
|
||
";610330197811233028,5" +
|
||
";130123196005286930,5";
|
||
String[] aa = str.split(";");
|
||
for (int i = 0; i < aa.length; i++) {
|
||
String a = aa[i].trim();
|
||
String[] ss = a.split(",");
|
||
//System.out.println("update sys_staff s set s.dept_id = (select dept_id from sys_dept where dept_name = '"+ss[2]+"') where s.name='"+ss[0]+"' and s.id_card = '"+ss[1]+"';");
|
||
//System.out.println("update rz_attendance_statistical ras left join sys_staff s on s.user_id = ras.staff_id set ras.dept_id = (select dept_id from sys_dept where dept_name = '"+ss[2]+"') where DATE_FORMAT(ras.month,'%Y-%m') = DATE_FORMAT('2026-07-01','%Y-%m') AND s.name='"+ss[0]+"' and s.id_card = '"+ss[1]+"';");
|
||
//System.out.println("update rz_restaurant_statistics ras left join sys_staff s on s.user_id = ras.staff_id set ras.dept_id = (select dept_id from sys_dept where dept_name = '"+ss[2]+"') where DATE_FORMAT(ras.month,'%Y-%m') = DATE_FORMAT('2026-07-01','%Y-%m') AND s.name='"+ss[0]+"' and s.id_card = '"+ss[1]+"';");
|
||
//System.out.println("update rz_leave l left join sys_staff s on s.user_id = l.user_id set l.dept_id = (select dept_id from sys_dept where dept_name = '"+ss[2]+"') where s.name='"+ss[0]+"' and s.id_card = '"+ss[1]+"';");
|
||
System.out.println("update sys_staff_detail ssd left join sys_staff ss on ss.user_id = ssd.staff_id set ssd.daily_wage = ssd.daily_wage-"+ss[1]+" where ss.id_card = '"+ss[0]+"';");
|
||
}
|
||
// BufferedReader reader = new BufferedReader(new FileReader(new File("D:\\andy\\文档\\考勤\\岗位任职部门信息.txt")));
|
||
// String line = reader.readLine();
|
||
// while (line != null) {
|
||
// String[] configData = line.split("_");
|
||
// System.out.println("update sys_dict_data set dict_value='"+line+"' where dict_value='"+configData[0]+"';");
|
||
// line = reader.readLine();
|
||
// }
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|