v3.0.3
1.application.yml 增加minio物理路径path 2.历史记录图片转存,增加接口 http://39.96.9.232:1003/cell/ten/record/removeImages yearMonth 2021-05
This commit is contained in:
parent
d3204b7577
commit
40c2da9d96
|
@ -79,6 +79,9 @@ public class GlobalValue {
|
||||||
@Value("${global.minio.bucketName}")
|
@Value("${global.minio.bucketName}")
|
||||||
private String minioBucketName;
|
private String minioBucketName;
|
||||||
|
|
||||||
|
@Value("${global.minio.path}")
|
||||||
|
private String minioPath;
|
||||||
|
|
||||||
|
|
||||||
@Value("${global.device.appId}")
|
@Value("${global.device.appId}")
|
||||||
private String devAppId;
|
private String devAppId;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.shapelight.modules.ten.controller;
|
package net.shapelight.modules.ten.controller;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -9,7 +10,9 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import net.shapelight.common.config.GlobalValue;
|
||||||
import net.shapelight.common.utils.Constant;
|
import net.shapelight.common.utils.Constant;
|
||||||
|
import net.shapelight.common.utils.DateUtils;
|
||||||
import net.shapelight.modules.sys.controller.AbstractController;
|
import net.shapelight.modules.sys.controller.AbstractController;
|
||||||
import net.shapelight.modules.sys.entity.SysUserEntity;
|
import net.shapelight.modules.sys.entity.SysUserEntity;
|
||||||
import net.shapelight.modules.sys.service.SysUserRoleService;
|
import net.shapelight.modules.sys.service.SysUserRoleService;
|
||||||
|
@ -17,15 +20,17 @@ import net.shapelight.modules.ten.entity.TenDeviceEntity;
|
||||||
import net.shapelight.modules.ten.entity.TenUserScopeEntity;
|
import net.shapelight.modules.ten.entity.TenUserScopeEntity;
|
||||||
import net.shapelight.modules.ten.service.TenCellService;
|
import net.shapelight.modules.ten.service.TenCellService;
|
||||||
import net.shapelight.modules.ten.service.TenUserScopeService;
|
import net.shapelight.modules.ten.service.TenUserScopeService;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.unit.DataUnit;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import net.shapelight.modules.ten.entity.TenRecordEntity;
|
import net.shapelight.modules.ten.entity.TenRecordEntity;
|
||||||
import net.shapelight.modules.ten.service.TenRecordService;
|
import net.shapelight.modules.ten.service.TenRecordService;
|
||||||
import net.shapelight.common.utils.PageUtils;
|
import net.shapelight.common.utils.PageUtils;
|
||||||
import net.shapelight.common.utils.R;
|
import net.shapelight.common.utils.R;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +49,8 @@ public class TenRecordController extends AbstractController {
|
||||||
private TenCellService tenCellService;
|
private TenCellService tenCellService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenUserScopeService tenUserScopeService;
|
private TenUserScopeService tenUserScopeService;
|
||||||
|
@Autowired
|
||||||
|
private GlobalValue globalValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
|
@ -148,4 +155,48 @@ public class TenRecordController extends AbstractController {
|
||||||
// return R.ok();
|
// return R.ok();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理历史图片转存
|
||||||
|
* 输入年月,年月格式 2021-10
|
||||||
|
*/
|
||||||
|
@PostMapping("/removeImages")
|
||||||
|
public R removeImages(@RequestParam("yearMonth") String yearMonth){
|
||||||
|
String tenantId = getUser().getTenantId()+"";
|
||||||
|
int count = 0;
|
||||||
|
String[] yearMonthArray = yearMonth.split("-");
|
||||||
|
int year = Integer.parseInt(yearMonthArray[0]);
|
||||||
|
int month = Integer.parseInt(yearMonthArray[1]);
|
||||||
|
//yyyy-MM-dd
|
||||||
|
String yearMonthLastDay = DateUtils.getLastDayOfMonth(year,month);
|
||||||
|
String start = yearMonth+"-01 00:00:0l";
|
||||||
|
String end = yearMonthLastDay+" 23:59:59";
|
||||||
|
|
||||||
|
List<TenRecordEntity> monthRecords = tenRecordService.getMonthRecords(start,end,tenantId);
|
||||||
|
|
||||||
|
for(TenRecordEntity recordEntity: monthRecords){
|
||||||
|
if (recordEntity.getRecordFace()!=null && recordEntity.getRecordFace().length()>0) {
|
||||||
|
String srcFileStr = globalValue.getMinioPath()+"/"+recordEntity.getRecordFace();
|
||||||
|
try {
|
||||||
|
File srcFile = new File(srcFileStr);
|
||||||
|
if(srcFile.exists()){
|
||||||
|
// images/836267246392180742/836268331420876805/b8c6fa0e9cf54f56ae9189024f0e9058.jpg
|
||||||
|
String userDir = recordEntity.getRecordFace().split("/")[2];
|
||||||
|
String disPath = "imagebak/"+yearMonth+"/"+userDir;
|
||||||
|
File disPathFile = new File(disPath);
|
||||||
|
FileUtils.forceMkdir(disPathFile);
|
||||||
|
|
||||||
|
FileUtils.copyFileToDirectory(srcFile,disPathFile);
|
||||||
|
FileUtils.deleteQuietly(srcFile);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.ok().put("data",count);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,4 +39,6 @@ public interface TenRecordDao {
|
||||||
|
|
||||||
List<TenRecordEntity> getNotSyncImage(@Param("cellId") Long paramLong1, @Param("tenantId") Long paramLong2);
|
List<TenRecordEntity> getNotSyncImage(@Param("cellId") Long paramLong1, @Param("tenantId") Long paramLong2);
|
||||||
|
|
||||||
|
List<TenRecordEntity> getMonthRecords(@Param("start") String start, @Param("end") String end, @Param("tenantId") String tenantId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,5 +38,7 @@ public interface TenRecordService {
|
||||||
|
|
||||||
List<TenRecordEntity> getNotSyncImage(Long cellId, Long tenantId);
|
List<TenRecordEntity> getNotSyncImage(Long cellId, Long tenantId);
|
||||||
|
|
||||||
|
List<TenRecordEntity> getMonthRecords(String start, String end, String tenantId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,4 +379,9 @@ public class TenRecordServiceImpl implements TenRecordService {
|
||||||
public List<TenRecordEntity> getNotSyncImage(Long cellId, Long tenantId) {
|
public List<TenRecordEntity> getNotSyncImage(Long cellId, Long tenantId) {
|
||||||
return this.tenRecordDao.getNotSyncImage(cellId, tenantId);
|
return this.tenRecordDao.getNotSyncImage(cellId, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TenRecordEntity> getMonthRecords(String start, String end, String tenantId) {
|
||||||
|
return this.tenRecordDao.getMonthRecords(start, end, tenantId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ global:
|
||||||
accessKey: admin
|
accessKey: admin
|
||||||
secretKey: admin@C501
|
secretKey: admin@C501
|
||||||
bucketName: cell
|
bucketName: cell
|
||||||
|
path: /root/minio/data/cell
|
||||||
# minio:
|
# minio:
|
||||||
# endpoint: https://c.xitu3d.com:19000
|
# endpoint: https://c.xitu3d.com:19000
|
||||||
# port: 19000
|
# port: 19000
|
||||||
|
|
|
@ -432,5 +432,14 @@
|
||||||
and TO_DAYS(record_time) = TO_DAYS(NOW())
|
and TO_DAYS(record_time) = TO_DAYS(NOW())
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getMonthRecords" resultType="net.shapelight.modules.ten.entity.TenRecordEntity">
|
||||||
|
select * from ten_record_${tenantId}
|
||||||
|
where
|
||||||
|
record_time >= #{start}
|
||||||
|
and record_time <= #{end}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +24,7 @@ public class DateUtils {
|
||||||
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||||
public final static String DATE_TIME_DB= "yyyyMMddHHmmss";
|
public final static String DATE_TIME_DB= "yyyyMMddHHmmss";
|
||||||
public final static String DATE_YEAR_MONTH= "yyyyMMdd";
|
public final static String DATE_YEAR_MONTH= "yyyyMMdd";
|
||||||
|
public final static String DATE_MONTH= "yyyy-MM";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||||
|
@ -159,4 +161,26 @@ public class DateUtils {
|
||||||
DateTime dateTime = new DateTime(date);
|
DateTime dateTime = new DateTime(date);
|
||||||
return dateTime.plusYears(years).toDate();
|
return dateTime.plusYears(years).toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某月的最后一天
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static String getLastDayOfMonth(int year,int month)
|
||||||
|
{
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
//设置年份
|
||||||
|
cal.set(Calendar.YEAR,year);
|
||||||
|
//设置月份
|
||||||
|
cal.set(Calendar.MONTH, month-1);
|
||||||
|
//获取某月最大天数
|
||||||
|
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||||
|
//设置日历中月份的最大天数
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, lastDay);
|
||||||
|
//格式化日期
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String lastDayOfMonth = sdf.format(cal.getTime());
|
||||||
|
|
||||||
|
return lastDayOfMonth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue