bug修复
This commit is contained in:
parent
a7442c177e
commit
7c1ce3d46e
@ -20,8 +20,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
@ -48,35 +46,14 @@ public class UploadFileServiceImpl implements UploadFileService {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> uploadImage(MultipartFile[] files) throws Exception {
|
public Map<String, Object> uploadImage(MultipartFile[] files) throws Exception {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
//String separator = File.separator;
|
|
||||||
String path = null;
|
String path = null;
|
||||||
String savePath = null;
|
String savePath = null;
|
||||||
//String imageUrl = PropertiesUtils.getValue("imageUrl");
|
|
||||||
List<Map<String, Object>> datalist = new ArrayList<>();
|
List<Map<String, Object>> datalist = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
// 文件原始扩展名
|
// 文件原始扩展名
|
||||||
/* String uuid = UUID.randomUUID().toString();
|
|
||||||
String oldname = file.getOriginalFilename();
|
|
||||||
String fileExtension = StringUtils.substringAfter(file.getOriginalFilename(), ".");
|
|
||||||
String newFileName = uuid + "." + fileExtension;
|
|
||||||
log.info("----文件名---"+oldname+",类型----"+fileExtension);
|
|
||||||
path = basePath + newFileName;
|
|
||||||
//String completeUrl = imageUrl + newFileName;
|
|
||||||
|
|
||||||
File localfile = new File(path);
|
|
||||||
// 判断文件夹是否存在,如果不存在则创建文件夹
|
|
||||||
*//*if (!localfile.exists()) {
|
|
||||||
//localfile.mkdir();
|
|
||||||
FileUtils.touch(localfile);
|
|
||||||
}*//*
|
|
||||||
|
|
||||||
file.transferTo(localfile);*/
|
|
||||||
//FileInfo fileInfo=fileService.upload(file);
|
|
||||||
FileInfo fileInfo = fileStorageService.of(file).upload();
|
FileInfo fileInfo = fileStorageService.of(file).upload();
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
/*dataMap.put("imageUrl", newFileName);
|
|
||||||
dataMap.put("filename", oldname);*/
|
|
||||||
dataMap.put("imageUrl", fileInfo.getFilename());
|
dataMap.put("imageUrl", fileInfo.getFilename());
|
||||||
dataMap.put("filename", fileInfo.getFilename());
|
dataMap.put("filename", fileInfo.getFilename());
|
||||||
dataMap.put("fileInfo", fileInfo);
|
dataMap.put("fileInfo", fileInfo);
|
||||||
@ -98,41 +75,6 @@ public class UploadFileServiceImpl implements UploadFileService {
|
|||||||
public Map<String, Object> uploadBase64Image(String base64Data) {
|
public Map<String, Object> uploadBase64Image(String base64Data) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
/*String dataPrix = "";
|
|
||||||
String data = "";
|
|
||||||
//String imageUrl = PropertiesUtils.getValue("imageUrl");
|
|
||||||
String uuid = UUID.randomUUID().toString();
|
|
||||||
if (base64Data == null || "".equals(base64Data)) {
|
|
||||||
throw new Exception(MessageUtil.get("uploadEmptyErr"));
|
|
||||||
} else {
|
|
||||||
String[] d = base64Data.split("base64,");
|
|
||||||
if (d != null && d.length == 2) {
|
|
||||||
dataPrix = d[0];
|
|
||||||
data = d[1];
|
|
||||||
} else {
|
|
||||||
throw new Exception(MessageUtil.get("uploadDataErr"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String suffix = "";
|
|
||||||
if ("data:image/jpeg;".equalsIgnoreCase(dataPrix)) {// data:image/jpeg;base64,base64编码的jpeg图片数据
|
|
||||||
suffix = ".jpg";
|
|
||||||
} else if ("data:image/x-icon;".equalsIgnoreCase(dataPrix)) {// data:image/x-icon;base64,base64编码的icon图片数据
|
|
||||||
suffix = ".ico";
|
|
||||||
} else if ("data:image/gif;".equalsIgnoreCase(dataPrix)) {// data:image/gif;base64,base64编码的gif图片数据
|
|
||||||
suffix = ".gif";
|
|
||||||
} else if ("data:image/png;".equalsIgnoreCase(dataPrix)) {// data:image/png;base64,base64编码的png图片数据
|
|
||||||
suffix = ".png";
|
|
||||||
} else if ("data:image/jpg;".equalsIgnoreCase(dataPrix)) {// data:image/png;base64,base64编码的png图片数据
|
|
||||||
suffix = ".jpg";
|
|
||||||
} else {
|
|
||||||
throw new Exception(MessageUtil.get("uploadFileFormatErr"));
|
|
||||||
}
|
|
||||||
String newFileName = uuid + suffix;
|
|
||||||
|
|
||||||
//log.info("data-------" + data);
|
|
||||||
//data = data.replaceAll(" ", "+");
|
|
||||||
generateImage(data, basePath + newFileName);*/
|
|
||||||
FileInfo fileInfo = uploadFileBase64Image(base64Data);
|
FileInfo fileInfo = uploadFileBase64Image(base64Data);
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
dataMap.put("imageUrl", fileInfo.getUrl());
|
dataMap.put("imageUrl", fileInfo.getUrl());
|
||||||
@ -155,10 +97,8 @@ public class UploadFileServiceImpl implements UploadFileService {
|
|||||||
throw new RuntimeException(MessageUtil.get("uploadEmptyErr"));
|
throw new RuntimeException(MessageUtil.get("uploadEmptyErr"));
|
||||||
} else {
|
} else {
|
||||||
String[] d = base64Data.split("base64,");
|
String[] d = base64Data.split("base64,");
|
||||||
if (d != null && d.length == 2) {
|
if (d.length == 2) {
|
||||||
dataPrix = d[0];
|
dataPrix = d[0];
|
||||||
} else {
|
|
||||||
throw new OpenAlertException(MessageUtil.get("uploadDataErr"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String suffix = "";
|
String suffix = "";
|
||||||
@ -173,13 +113,12 @@ public class UploadFileServiceImpl implements UploadFileService {
|
|||||||
} else if ("data:image/jpg;".equalsIgnoreCase(dataPrix)) {// data:image/png;base64,base64编码的png图片数据
|
} else if ("data:image/jpg;".equalsIgnoreCase(dataPrix)) {// data:image/png;base64,base64编码的png图片数据
|
||||||
suffix = ".jpg";
|
suffix = ".jpg";
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(MessageUtil.get("uploadFileFormatErr"));
|
//没有前缀的base64图片,加前缀
|
||||||
|
base64Data = "data:image/jpeg;base64," + base64Data;
|
||||||
|
suffix = ".jpeg";
|
||||||
}
|
}
|
||||||
String newFileName = uuid + suffix;
|
String newFileName = uuid + suffix;
|
||||||
//fileInfo.setOriginalFilename(newFileName);
|
|
||||||
MultipartFile file = FileUtil.base64toMultipart(base64Data, newFileName);
|
MultipartFile file = FileUtil.base64toMultipart(base64Data, newFileName);
|
||||||
|
|
||||||
|
|
||||||
fileInfo = fileStorageService.of(file).upload();
|
fileInfo = fileStorageService.of(file).upload();
|
||||||
return fileInfo;
|
return fileInfo;
|
||||||
}
|
}
|
||||||
@ -218,67 +157,6 @@ public class UploadFileServiceImpl implements UploadFileService {
|
|||||||
throw new RuntimeException("转码错误!");
|
throw new RuntimeException("转码错误!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean generateImage(String imgStr, String path) {
|
|
||||||
if (imgStr == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Base64.Decoder decoder = Base64.getMimeDecoder();
|
|
||||||
//BASE64Decoder decoder = new BASE64Decoder();
|
|
||||||
try {
|
|
||||||
//byte[] b = decoder.decodeBuffer(imgStr);
|
|
||||||
byte[] b = decoder.decode(imgStr);
|
|
||||||
for (int i = 0; i < b.length; ++i) {
|
|
||||||
if (b[i] < 0) {
|
|
||||||
b[i] += 256;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OutputStream out = new FileOutputStream(path);
|
|
||||||
out.write(b);
|
|
||||||
out.flush();
|
|
||||||
out.close();
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@Override
|
|
||||||
public Map<String, Object> companyImage(MultipartFile file, String companySn) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
String path = null;
|
|
||||||
try {
|
|
||||||
String tempBasePath=basePath+"/"+companySn;
|
|
||||||
File pathFile = new File(tempBasePath);
|
|
||||||
if (!pathFile.exists()) {
|
|
||||||
pathFile.mkdirs();
|
|
||||||
}
|
|
||||||
// 文件原始扩展名
|
|
||||||
String uuid = UUID.randomUUID().toString();
|
|
||||||
String oldname = file.getOriginalFilename();
|
|
||||||
String fileExtension = StringUtils.substringAfter(file.getOriginalFilename(), ".");
|
|
||||||
String newFileName = uuid + "." + fileExtension;
|
|
||||||
path = tempBasePath + newFileName;
|
|
||||||
File localfile = new File(path);
|
|
||||||
// 判断文件夹是否存在,如果不存在则创建文件夹
|
|
||||||
*//*if (!localfile.exists()) {
|
|
||||||
//localfile.mkdir();
|
|
||||||
FileUtils.touch(localfile);
|
|
||||||
}*//*
|
|
||||||
file.transferTo(localfile);
|
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
|
||||||
dataMap.put("imageUrl", companySn+"/"+newFileName);
|
|
||||||
dataMap.put("filename", oldname);
|
|
||||||
result.put("status", "SUCCESS");
|
|
||||||
result.put("data", dataMap);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步文件上传
|
* 异步文件上传
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -25,14 +25,14 @@ public class UfaceDevApiController {
|
|||||||
|
|
||||||
@ApiOperation(value = "下载白名单(拉取允许通行人员信息)", notes = "下载白名单(拉取允许通行人员信息)", httpMethod = "GET")
|
@ApiOperation(value = "下载白名单(拉取允许通行人员信息)", notes = "下载白名单(拉取允许通行人员信息)", httpMethod = "GET")
|
||||||
@GetMapping(value = "/service-address/workers")
|
@GetMapping(value = "/service-address/workers")
|
||||||
public Result<GetWorkerInfoByDevVo> getWorkerInfoByDev(GetWorkerInfoByDevDto dto) {
|
public GetWorkerInfoByDevVo getWorkerInfoByDev(GetWorkerInfoByDevDto dto) {
|
||||||
return Result.success(workerInfoService.getWorkerInfoByDev(dto));
|
return workerInfoService.getWorkerInfoByDev(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "考勤照片上传", notes = "考勤照片上传", httpMethod = "POST")
|
@ApiOperation(value = "考勤照片上传", notes = "考勤照片上传", httpMethod = "POST")
|
||||||
@PostMapping(value = "/service-address/photo")
|
@PostMapping(value = "/service-address/photo")
|
||||||
public Result<GetWorkerInfoByDevVo> uploadAttendanceByDev(@RequestBody UploadAttendanceByDevDto dto) {
|
public GetWorkerInfoByDevVo uploadAttendanceByDev(@RequestBody UploadAttendanceByDevDto dto) {
|
||||||
return Result.success(workerAttendanceService.uploadAttendanceByDev(dto));
|
return workerAttendanceService.uploadAttendanceByDev(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package com.zhgd.xmgl.modules.worker.entity.vo;
|
package com.zhgd.xmgl.modules.worker.entity.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -38,10 +41,8 @@ public class GetWorkerInfoByDevVo {
|
|||||||
@JsonProperty("photo")
|
@JsonProperty("photo")
|
||||||
private String photo;
|
private String photo;
|
||||||
@ApiModelProperty("项目id(项目sn)")
|
@ApiModelProperty("项目id(项目sn)")
|
||||||
@JsonProperty("photo")
|
|
||||||
private String projectId;
|
private String projectId;
|
||||||
@ApiModelProperty("0 修改过的数据 1 删除的数据")
|
@ApiModelProperty("0 修改过的数据 1 删除的数据")
|
||||||
@JsonProperty("photo")
|
|
||||||
private String del;
|
private String del;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,11 +10,6 @@ public class UploadAttendanceByDevDto {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("图片base64编码 (没有文件类型的头)")
|
@ApiModelProperty("图片base64编码 (没有文件类型的头)")
|
||||||
private String base64;
|
private String base64;
|
||||||
/**
|
|
||||||
* 项目编号
|
|
||||||
*/
|
|
||||||
@ApiModelProperty("项目编号")
|
|
||||||
private String projectId;
|
|
||||||
/**
|
/**
|
||||||
* 设备编号
|
* 设备编号
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1080,11 +1080,14 @@ status 状态码 String 1表示成功;其余表示失败
|
|||||||
WorkerAttendance attendance = new WorkerAttendance();
|
WorkerAttendance attendance = new WorkerAttendance();
|
||||||
attendance.setPersonSn(workerInfo.getPersonSn());
|
attendance.setPersonSn(workerInfo.getPersonSn());
|
||||||
attendance.setPassType(getPassType(dto.getDirection()));
|
attendance.setPassType(getPassType(dto.getDirection()));
|
||||||
attendance.setCreateTime(DateUtil.formatDateTime(new Date(dto.getTime())));
|
attendance.setCreateTime(DateUtil.formatDateTime(new Date(Long.valueOf(dto.getTime()))));
|
||||||
attendance.setProjectSn(workerInfo.getProjectSn());
|
attendance.setProjectSn(workerInfo.getProjectSn());
|
||||||
attendance.setCardType(getCardType(dto.getType()));
|
attendance.setCardType(getCardType(dto.getType()));
|
||||||
FileInfo fileInfo = uploadFileService.uploadFileBase64Image(dto.getBase64());
|
FileInfo fileInfo = null;
|
||||||
attendance.setImageUrl(fileInfo.getUrl());
|
if (StringUtils.isNotBlank(dto.getBase64())) {
|
||||||
|
fileInfo = uploadFileService.uploadFileBase64Image(dto.getBase64());
|
||||||
|
attendance.setImageUrl(fileInfo.getUrl());
|
||||||
|
}
|
||||||
attendance.setAttendanceType(1);
|
attendance.setAttendanceType(1);
|
||||||
attendance.setPassagewayName(dev.getDevName());
|
attendance.setPassagewayName(dev.getDevName());
|
||||||
attendance.setAttendanceStatus(1);
|
attendance.setAttendanceStatus(1);
|
||||||
@ -1093,14 +1096,16 @@ status 状态码 String 1表示成功;其余表示失败
|
|||||||
attendance.setIsStatistics(1);
|
attendance.setIsStatistics(1);
|
||||||
baseMapper.insert(attendance);
|
baseMapper.insert(attendance);
|
||||||
|
|
||||||
HashMap<String, String> rtMap = new HashMap<>();
|
|
||||||
rtMap.put("path", serverUrl + "/image/" + fileInfo.getUrl());
|
|
||||||
GetWorkerInfoByDevVo vo = new GetWorkerInfoByDevVo();
|
GetWorkerInfoByDevVo vo = new GetWorkerInfoByDevVo();
|
||||||
vo.setSuccess(true);
|
vo.setSuccess(true);
|
||||||
vo.setCode(0);
|
vo.setCode(0);
|
||||||
vo.setMessage("success");
|
vo.setMessage("success");
|
||||||
vo.setTime(System.currentTimeMillis() / 1000);
|
vo.setTime(System.currentTimeMillis() / 1000);
|
||||||
vo.setData(rtMap);
|
HashMap<String, String> rtMap = new HashMap<>();
|
||||||
|
if (fileInfo != null) {
|
||||||
|
rtMap.put("path", serverUrl + "/image/" + fileInfo.getUrl());
|
||||||
|
vo.setData(rtMap);
|
||||||
|
}
|
||||||
vo.setEvent("photo");
|
vo.setEvent("photo");
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -306,6 +306,12 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
|||||||
govtOpenApiService.workerInfoAddSync(workerInfo);
|
govtOpenApiService.workerInfoAddSync(workerInfo);
|
||||||
}
|
}
|
||||||
asyncJiLianDa.saveWorkerInfo(workerInfo);
|
asyncJiLianDa.saveWorkerInfo(workerInfo);
|
||||||
|
|
||||||
|
//删除人员删除表的记录
|
||||||
|
workerInfoDeleteMapper.delete(new LambdaQueryWrapper<WorkerInfoDelete>()
|
||||||
|
.eq(WorkerInfoDelete::getProjectSn, workerInfo.getProjectSn())
|
||||||
|
.eq(WorkerInfoDelete::getIdCard, workerInfo.getIdCard())
|
||||||
|
);
|
||||||
return workerInfo;
|
return workerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,6 +393,11 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
|||||||
govtOpenApiService.workerInfoDelSync(workerInfo);
|
govtOpenApiService.workerInfoDelSync(workerInfo);
|
||||||
}
|
}
|
||||||
asyncJiLianDa.removeWorkerInfo(workerInfo);
|
asyncJiLianDa.removeWorkerInfo(workerInfo);
|
||||||
|
|
||||||
|
//添加到人员删除表中
|
||||||
|
WorkerInfoDelete entity = new WorkerInfoDelete();
|
||||||
|
BeanUtil.copyProperties(workerInfo, entity);
|
||||||
|
workerInfoDeleteMapper.insert(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkExistAccount(String id) {
|
private void checkExistAccount(String id) {
|
||||||
@ -1885,7 +1896,7 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
|||||||
}
|
}
|
||||||
String update = null;
|
String update = null;
|
||||||
if (StringUtils.isNotBlank(dto.getUpdate())) {
|
if (StringUtils.isNotBlank(dto.getUpdate())) {
|
||||||
update = DateUtil.formatDateTime(new Date(Long.valueOf(dto.getUpdate())));
|
update = DateUtil.formatDateTime(new Date(Long.valueOf(dto.getUpdate()) * 1000));
|
||||||
}
|
}
|
||||||
String projectSn = dev.getProjectSn();
|
String projectSn = dev.getProjectSn();
|
||||||
List<WorkerInfo> workerInfos = workerInfoMapper.selectList(new LambdaQueryWrapper<WorkerInfo>()
|
List<WorkerInfo> workerInfos = workerInfoMapper.selectList(new LambdaQueryWrapper<WorkerInfo>()
|
||||||
@ -1916,7 +1927,7 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
|||||||
getWorkerInfoByDevVo.setSuccess(true);
|
getWorkerInfoByDevVo.setSuccess(true);
|
||||||
getWorkerInfoByDevVo.setCode(0);
|
getWorkerInfoByDevVo.setCode(0);
|
||||||
getWorkerInfoByDevVo.setMessage("success");
|
getWorkerInfoByDevVo.setMessage("success");
|
||||||
getWorkerInfoByDevVo.setTime(null);
|
getWorkerInfoByDevVo.setTime(System.currentTimeMillis() / 1000);
|
||||||
getWorkerInfoByDevVo.setData(datas);
|
getWorkerInfoByDevVo.setData(datas);
|
||||||
getWorkerInfoByDevVo.setEvent("workers");
|
getWorkerInfoByDevVo.setEvent("workers");
|
||||||
return getWorkerInfoByDevVo;
|
return getWorkerInfoByDevVo;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ video.alarm.newUrl=223.82.100.80:6040
|
|||||||
wx-appid=
|
wx-appid=
|
||||||
wx-AppSecret=
|
wx-AppSecret=
|
||||||
mqtt-scope=zjsjTopic
|
mqtt-scope=zjsjTopic
|
||||||
serverUrl=http://192.168.34.221:30002
|
serverUrl=http://192.168.34.221:19111
|
||||||
#serverUrl=http://182.90.224.237:7000
|
#serverUrl=http://182.90.224.237:7000
|
||||||
#serverUrl=http://127.0.0.1:6023
|
#serverUrl=http://127.0.0.1:6023
|
||||||
#\u89C6\u9891\u5206\u6790url
|
#\u89C6\u9891\u5206\u6790url
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user