update code

dev_xds
haha 2024-04-21 15:05:04 +08:00
parent 57fb2aeca4
commit 07ed3deb3d
4 changed files with 89 additions and 6 deletions

View File

@ -104,6 +104,27 @@ public class FileUtils
return FileUploadUtils.getPathFileName(uploadDir, pathName);
}
public static String writeBytes(byte[] data, String uploadDir,String fileName) throws IOException
{
FileOutputStream fos = null;
String pathName = "";
try
{
String extension = getFileExtendName(data);
pathName = DateUtils.datePath() + "/" + fileName;
File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
if(file.exists()){
file.delete();
}
fos = new FileOutputStream(file);
fos.write(data);
}
finally
{
IOUtils.close(fos);
}
return FileUploadUtils.getPathFileName(uploadDir, pathName);
}
/**
*
*

View File

@ -44,7 +44,7 @@ public class AttendanceHuazhuTask {
long startTime=DateUtil.date(DateUtil.parse("2024-03-16")).getTime();
long endTime=startTime+3600*1000*24*1;
long endTime=startTime+3600l*1000*24*1;
Map<String, String> headerParams=new HashMap<>();
headerParams.put("appId","8024283707153666851");
headerParams.put("appSecret","2070308b49399d94b401d98adeaa5b342aa81627");
@ -130,7 +130,7 @@ public class AttendanceHuazhuTask {
*/
public void syncLast90DayAttendanceData() {
long endTime=DateUtil.current();
long startTime=endTime-3600*1000*24*90;
long startTime=endTime-3600l*1000*24*90;
syncAttendanceData(startTime);
}
@ -139,7 +139,7 @@ public class AttendanceHuazhuTask {
*/
public void syncLastWeekAttendanceData() {
long endTime=DateUtil.current();
long startTime=endTime-3600*1000*24*7;
long startTime=endTime-3600l*1000*24*7;
syncAttendanceData(startTime);
}

View File

@ -3,6 +3,7 @@ package com.yanzhu.jh.project.task;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -129,6 +131,59 @@ public class AttendanceJgwTask {
}
return builder.build();
}
public void clearAlllPhoto(){
String filePath= RuoYiConfig.getUploadPath();
String path=filePath+"/jgw";
long endTime=DateUtil.current();
for(int i=365;i>0;i--) {
Date dt = DateUtil.date(endTime - 3600l * 1000 * 24 * i);
String clearPath=path +"/" + DateUtil.format(dt, "YYYY/MM/dd");
String url="/jgw/"+DateUtil.format(dt, "YYYY/MM/dd");
clearDatePhone(clearPath,url);
}
}
public void clear3DayPhoto(){
String filePath= RuoYiConfig.getUploadPath();
String path=filePath+"/jgw";
long endTime=DateUtil.current();
for(int i=3;i>0;i--) {
Date dt = DateUtil.date(endTime - 3600l * 1000 * 24 * i);
String clearPath=path +"/" + DateUtil.format(dt, "YYYY/MM/dd");
String url="/jgw/"+DateUtil.format(dt, "YYYY/MM/dd");
clearDatePhone(clearPath,url);
}
}
private void clearDatePhone(String path,String url){
File file=new File(path);
if(file.isDirectory()){
SurProjectAttendanceData where=new SurProjectAttendanceData();
where.setScanPhoto(url);
List<SurProjectAttendanceData> list=attendanceDataService.selectSurProjectAttendanceDataList(where);
List<String> names=new ArrayList<>();
for(SurProjectAttendanceData it:list){
names.add(it.getScanPhoto());
}
for(String f : file.list()){
try{
String name= FileUtils.getName(f);
if(!findInNames(names,name)){
FileUtil.del(path+"/"+f);
}
}catch (Exception ex){
}
}
}
}
private boolean findInNames(List<String> names, String name) {
for(String it :names){
if(it.indexOf(name)>=0){
return true;
}
}
return false;
}
public static void main(String[] args){
String d="sxyzxx2024suc";
@ -149,6 +204,8 @@ public class AttendanceJgwTask {
String subcontractorId=new AttendanceJgwTask().getSubcontractor(appid,token,phone);
String leaderTeamId="b3774a8cd04c418dabf36bffbf276661";
System.out.println(subcontractorId);
//findWorkerByLeader(appid,token,leaderTeamId);
//findDirectlyUnderTeam(appid,token,prjId,subcontractorId,0);
//queryProject(appid,token,phone,0);;
@ -156,7 +213,7 @@ public class AttendanceJgwTask {
//findUpdateWorkerByProject(appid,token,prjId,0);
//findAttendanceByProject(appid,token,prjId,"0");
//findTeamByProjectId(appid,token,prjId);
findProContractorByProjectId(appid,token,prjId);
//findProContractorByProjectId(appid,token,prjId);
//getJobTypeData(appid,token,"0");
//findDirectlyUnderTeam(appid,token,prjId);
}
@ -346,6 +403,7 @@ public class AttendanceJgwTask {
params.put("timestamp",time);
params.put("tokenSign",tokenSign);
params.put("filePath",photo);
Request request = new Request.Builder()
.url(host+path)
.post(toFormBody(params))
@ -357,12 +415,16 @@ public class AttendanceJgwTask {
byte[] buffer= HttpUtil.downloadBytes(purl);
String filePath= RuoYiConfig.getUploadPath();
try {
return FileUtils.writeBytes(buffer, filePath+"/jgw");
String name=FileUtil.getName(photo);
return FileUtils.writeBytes(buffer, filePath+"/jgw",name);
}catch (Exception ex){
return "";
}
}
public static void findWorkerByLeader(String appId,String token,String leaderTeamId){
String path="/webapi/project/findWorkerByLeader";
String time = System.currentTimeMillis() + "";

View File

@ -131,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="vendorId != null "> and vendorId = #{vendorId}</if>
<if test="deviceCode != null and deviceCode != ''"> and device_code = #{deviceCode}</if>
<if test="scanPhoto != null and scanPhoto != ''"> and scanPhoto = #{scanPhoto}</if>
<if test="scanPhoto != null and scanPhoto != ''"> and scanPhoto like concat('%', #{scanPhoto}, '%')</if>
<if test="isDel != null "> and is_del = #{isDel}</if>
</where>
order by attendance_time desc