|
|
@ -18,23 +18,17 @@ import com.kms.yxgh.sz.mapper.SzSuperviseWayProjectItemMapper; |
|
|
|
import com.kms.yxgh.sz.mapper.SzSuperviseWayProjectMapper; |
|
|
|
import com.kms.yxgh.util.BeanCopyUtils; |
|
|
|
import com.shuili.common.config.ShuiliConfig; |
|
|
|
import com.shuili.common.core.domain.AjaxResult; |
|
|
|
import com.shuili.common.constant.Constants; |
|
|
|
import com.shuili.common.core.service.BaseService; |
|
|
|
import com.shuili.common.utils.DateUtils; |
|
|
|
import com.shuili.common.utils.FastDfsUtil; |
|
|
|
import com.shuili.common.utils.FileUploadUtils; |
|
|
|
import com.shuili.common.utils.file.FileUtils; |
|
|
|
import com.shuili.common.utils.file.FileDownloadUtils; |
|
|
|
import com.shuili.common.utils.uuid.IdUtils; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.apache.commons.fileupload.FileItem; |
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -69,38 +63,57 @@ public class SzSuperviseWayService extends BaseService<SzSuperviseWayMapper, SzS |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Boolean copyInfo(String id) throws IOException { |
|
|
|
// 1.1 查询监督检查办法对象
|
|
|
|
SzSuperviseWay superviseWay = this.getById(id); |
|
|
|
SzSuperviseWay superviseWayNew = BeanCopyUtils.copy(superviseWay, SzSuperviseWay.class); |
|
|
|
public Boolean copyInfo(String id) { |
|
|
|
String localPath = ShuiliConfig.getProfile(); |
|
|
|
try { |
|
|
|
// 1.1 查询监督检查办法对象
|
|
|
|
SzSuperviseWay superviseWay = this.getById(id); |
|
|
|
SzSuperviseWay superviseWayNew = BeanCopyUtils.copy(superviseWay, SzSuperviseWay.class); |
|
|
|
superviseWay.setName("新建管理办法"); |
|
|
|
// 1.2 复制文件
|
|
|
|
if (StringUtils.isNotBlank(superviseWay.getSuperviseCheckWay())) { |
|
|
|
String checkWayUrl = superviseWay.getSuperviseCheckWay(); |
|
|
|
String index = checkWayUrl.substring(checkWayUrl.lastIndexOf(".")); |
|
|
|
|
|
|
|
String path = DateUtils.datePath() + "/" + IdUtils.fastUUID() + index; |
|
|
|
|
|
|
|
System.out.println("-----------test--------------" + localPath + Constants.RESOURCE_PREFIX + path); |
|
|
|
FileDownloadUtils.downloadFile(checkWayUrl, localPath, localPath + Constants.RESOURCE_PREFIX + path); |
|
|
|
|
|
|
|
String serverUrl = checkWayUrl.substring(0, checkWayUrl.lastIndexOf("/profile")); |
|
|
|
superviseWayNew.setSuperviseCheckWay(serverUrl + Constants.RESOURCE_PREFIX + "/" + path); |
|
|
|
} |
|
|
|
|
|
|
|
// todo 1.2 复制文件
|
|
|
|
// 1.3 查询水闸监督检查办法项目
|
|
|
|
List<SzSuperviseWayProjectDto> projectList = listData(superviseWay.getId()); |
|
|
|
superviseWay.setId(null); |
|
|
|
this.saveOrUpdate(superviseWay); |
|
|
|
|
|
|
|
// 1.3 查询水闸监督检查办法项目
|
|
|
|
List<SzSuperviseWayProjectDto> projectList = listData(superviseWay.getId()); |
|
|
|
if (projectList.isEmpty()){ |
|
|
|
return true; |
|
|
|
if (projectList.isEmpty()) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
List<SzSuperviseWayProject> list = BeanCopyUtils.copyList(projectList, SzSuperviseWayProject.class); |
|
|
|
list.forEach(v -> { |
|
|
|
List<SzSuperviseWayProjectItem> listItem = projectItemMapper.selectList( |
|
|
|
Wrappers.<SzSuperviseWayProjectItem>lambdaQuery().eq(SzSuperviseWayProjectItem::getProjectId, v.getId())); |
|
|
|
|
|
|
|
// 新增项目
|
|
|
|
v.setId(null); |
|
|
|
v.setWayId(superviseWayNew.getId()); |
|
|
|
wayProjectService.insert(v); |
|
|
|
|
|
|
|
// 1.4 新增水闸监督检查办法项目内容
|
|
|
|
if (!listItem.isEmpty()) { |
|
|
|
listItem.forEach(val -> { |
|
|
|
val.setId(null); |
|
|
|
val.setProjectId(v.getId()); |
|
|
|
projectItemMapper.insert(val); |
|
|
|
}); |
|
|
|
} |
|
|
|
List<SzSuperviseWayProject> list = BeanCopyUtils.copyList(projectList, SzSuperviseWayProject.class); |
|
|
|
list.forEach(v->{ |
|
|
|
List<SzSuperviseWayProjectItem> listItem = projectItemMapper.selectList( |
|
|
|
Wrappers.<SzSuperviseWayProjectItem>lambdaQuery().eq(SzSuperviseWayProjectItem::getProjectId, v.getId())); |
|
|
|
|
|
|
|
// 新增项目
|
|
|
|
v.setId(null); |
|
|
|
v.setWayId(superviseWayNew.getId()); |
|
|
|
wayProjectService.insert(v); |
|
|
|
|
|
|
|
// 1.4 新增水闸监督检查办法项目内容
|
|
|
|
if(!listItem.isEmpty()){ |
|
|
|
listItem.forEach(val->{ |
|
|
|
val.setId(null); |
|
|
|
val.setProjectId(v.getId()); |
|
|
|
projectItemMapper.insert(val); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}catch (Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|