|
@@ -12,6 +12,7 @@ import com.ruoyi.common.core.domain.PageQuery;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.ruoyi.framework.obs.ObsService;
|
|
|
import com.ruoyi.zdsz.domain.ZEngiineeringPhoto;
|
|
|
import com.ruoyi.zdsz.domain.ZEngineeringInfo;
|
|
|
import com.ruoyi.zdsz.domain.ZEngineeringNode;
|
|
@@ -23,6 +24,8 @@ import com.ruoyi.zdsz.service.IZEngiineeringPhotoService;
|
|
|
import com.ruoyi.zdsz.service.IZEngineeringNodeService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.zdsz.domain.vo.ZEngineeringDangerousVo;
|
|
|
import com.ruoyi.zdsz.domain.ZEngineeringDangerous;
|
|
@@ -31,6 +34,10 @@ import com.ruoyi.zdsz.service.IZEngineeringDangerousService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -51,7 +58,72 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
|
|
|
@Autowired
|
|
|
private IZEngiineeringPhotoService photoService;
|
|
|
+ @Value("${filePath}")
|
|
|
+ private String filePath;
|
|
|
+ @Resource
|
|
|
+ private ObsService obsService;
|
|
|
+ @Override
|
|
|
+ public boolean review(ZEngineeringDangerousBo zEngineeringDangerousBo) {
|
|
|
+ System.out.println(zEngineeringDangerousBo);
|
|
|
+ ZEngineeringDangerous add = BeanUtil.toBean(zEngineeringDangerousBo, ZEngineeringDangerous.class);
|
|
|
+ int i = baseMapper.updateById(add);
|
|
|
+ if ("1".equals(zEngineeringDangerousBo.getReviewStatus())){
|
|
|
+ ZEngiineeringPhotoBo bo = new ZEngiineeringPhotoBo();
|
|
|
+ bo.setParentId(add.getId());
|
|
|
+ bo.setCreateTime(zEngineeringDangerousBo.getCreateTime());
|
|
|
+ write(photoService.queryList(bo), add.getEnginName());
|
|
|
+ }
|
|
|
+ return i>0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ public void write(List<ZEngiineeringPhotoVo> zEngiineeringPhotoVos,String enginName) {
|
|
|
+ zEngiineeringPhotoVos.forEach( item ->{
|
|
|
+ String photo = item.getPicUrl();
|
|
|
+ if (StringUtils.isNotBlank(photo)) {
|
|
|
+ try {
|
|
|
+ // 创建最外层文件夹
|
|
|
+ byte[] fileNameBytes = filePath.getBytes("UTF-8");
|
|
|
+ // 使用UTF-8编码创建文件
|
|
|
+ File file = new File(new String(fileNameBytes, "UTF-8"));
|
|
|
+ if (!file.exists()) {
|
|
|
+ file.mkdirs();
|
|
|
+ }
|
|
|
+ byte[] typeFileNameByte = (file.getPath() + "/危险工程").getBytes("UTF-8");
|
|
|
+ // 使用UTF-8编码创建文件
|
|
|
+ File typeFiles = new File(new String(typeFileNameByte, "UTF-8"));
|
|
|
+ if (!typeFiles.exists()) {
|
|
|
+ typeFiles.mkdirs();
|
|
|
+ }
|
|
|
+ byte[] typeFileNameBytes = (typeFiles.getPath() + "/" + enginName).getBytes("UTF-8");
|
|
|
+ // 使用UTF-8编码创建文件
|
|
|
+ File typeFile = new File(new String(typeFileNameBytes, "UTF-8"));
|
|
|
+ if (!typeFile.exists()) {
|
|
|
+ typeFile.mkdirs();
|
|
|
+ }
|
|
|
+ byte[] enginNameFileNameBytes = (typeFile.getPath() + "/" + baseMapper.getName(item.getCreateBy())).getBytes("UTF-8");
|
|
|
+ // 使用UTF-8编码创建文件
|
|
|
+ File enginNameFile = new File(new String(enginNameFileNameBytes, "UTF-8"));
|
|
|
+ if (!enginNameFile.exists()) {
|
|
|
+ enginNameFile.mkdirs();
|
|
|
+ }
|
|
|
+ byte[] CreateTimeFileNameBytes = (enginNameFile.getPath() + "/" + new SimpleDateFormat("yyyy-MM-dd").format(item.getUpdateTime())).getBytes("UTF-8");
|
|
|
+ // 时间
|
|
|
+ // 使用UTF-8编码创建文件
|
|
|
+ File CreateTimeFile = new File(new String(CreateTimeFileNameBytes, "UTF-8"));
|
|
|
+ if (!CreateTimeFile.exists()) {
|
|
|
+ CreateTimeFile.mkdirs();
|
|
|
+ }
|
|
|
+ obsService.download(CreateTimeFile.getPath(), photo.substring(photo.lastIndexOf("/")+1));
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
/**
|
|
|
* 查询危险工程列表
|
|
|
*/
|
|
@@ -348,7 +420,9 @@ public class ZEngineeringDangerousServiceImpl implements IZEngineeringDangerousS
|
|
|
ZEngiineeringPhotoBo bo = new ZEngiineeringPhotoBo();
|
|
|
bo.setParentId(vo.getId());
|
|
|
bo.setCreateTime(vo.getCreateTime());
|
|
|
- vo.setPics(photoService.queryList(bo));
|
|
|
+ List<ZEngiineeringPhotoVo> zEngiineeringPhotoVos = photoService.queryList(bo);
|
|
|
+ zEngiineeringPhotoVos.forEach(item -> item.setCreateByName(baseMapper.getName(item.getCreateBy())));
|
|
|
+ vo.setPics(zEngiineeringPhotoVos);
|
|
|
return vo;
|
|
|
}
|
|
|
@Override
|