|
@@ -9,6 +9,7 @@ import com.jeeplus.modules.projectcontentinfo.entity.ProjectReportData;
|
|
import com.jeeplus.modules.projectcontentinfo.service.ProjectReportDataService;
|
|
import com.jeeplus.modules.projectcontentinfo.service.ProjectReportDataService;
|
|
import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
|
|
import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
|
|
import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
|
|
import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectRecordsService;
|
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.service.RuralProjectSignatureOldMessageDisposeService;
|
|
import com.jeeplus.modules.sys.entity.User;
|
|
import com.jeeplus.modules.sys.entity.User;
|
|
import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
import com.jeeplus.modules.sys.utils.UserUtils;
|
|
@@ -33,10 +34,8 @@ import java.util.*;
|
|
* @author 徐滕
|
|
* @author 徐滕
|
|
* @version 2021-11-04
|
|
* @version 2021-11-04
|
|
*/
|
|
*/
|
|
-/*@Controller
|
|
|
|
-@RequestMapping(value = "${adminPath}/ruralProject/signatureOldMessageDispose")*/
|
|
|
|
-@Service
|
|
|
|
-@Transactional(readOnly = true)
|
|
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping(value = "${adminPath}/ruralProject/signatureOldMessageDispose")
|
|
public class RuralProjectSignatureOldMessageDisposeController extends BaseController {
|
|
public class RuralProjectSignatureOldMessageDisposeController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@@ -49,7 +48,7 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
|
|
@Autowired
|
|
@Autowired
|
|
protected HistoryService historyService;
|
|
protected HistoryService historyService;
|
|
@Autowired
|
|
@Autowired
|
|
- private WorkattachmentService workattachmentService;
|
|
|
|
|
|
+ private RuralProjectSignatureOldMessageDisposeService service;
|
|
|
|
|
|
|
|
|
|
private static final String HTTPTOP = Global.getConfig("signature_http_top");
|
|
private static final String HTTPTOP = Global.getConfig("signature_http_top");
|
|
@@ -63,11 +62,10 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
|
|
* 签章文件处理
|
|
* 签章文件处理
|
|
* @param type 1:审定单;2:报告签章;
|
|
* @param type 1:审定单;2:报告签章;
|
|
* @param count
|
|
* @param count
|
|
- * @param response
|
|
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- /*@RequestMapping(value = "/ossUploading")
|
|
|
|
- @ResponseBody*/
|
|
|
|
|
|
+ @RequestMapping(value = "/ossUploading")
|
|
|
|
+ @ResponseBody
|
|
public Map<String,Object> ossUploading(@RequestParam("type") Integer type,@RequestParam("count")Integer count){
|
|
public Map<String,Object> ossUploading(@RequestParam("type") Integer type,@RequestParam("count")Integer count){
|
|
Map<String,Object> map = new HashMap<>();
|
|
Map<String,Object> map = new HashMap<>();
|
|
List<String> projectNumber = Lists.newArrayList();
|
|
List<String> projectNumber = Lists.newArrayList();
|
|
@@ -79,8 +77,16 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
|
|
// count为处理的项目信息条数
|
|
// count为处理的项目信息条数
|
|
List<ProjectReportData> projectReportDataList = projectReportDataService.getProjectReportDataSignatureByCount(count);
|
|
List<ProjectReportData> projectReportDataList = projectReportDataService.getProjectReportDataSignatureByCount(count);
|
|
for (ProjectReportData info: projectReportDataList) {
|
|
for (ProjectReportData info: projectReportDataList) {
|
|
- downLoadApprovalAttach(info.getSignatureContractId());
|
|
|
|
- projectNumber.add(info.getNumber());
|
|
|
|
|
|
+ try {
|
|
|
|
+ service.downLoadApprovalAttach(info.getSignatureContractId());
|
|
|
|
+ projectNumber.add(info.getNumber());
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ logger.error("审定单文件处理异常:",e);
|
|
|
|
+ }finally {
|
|
|
|
+ //修改签章对应信息文件
|
|
|
|
+ info.setSignatureUrlFlag(1);
|
|
|
|
+ projectReportDataService.updateSignatureInfo(info);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if(projectNumber.size()>0){
|
|
if(projectNumber.size()>0){
|
|
String numbersStr = String.join(",", projectNumber);
|
|
String numbersStr = String.join(",", projectNumber);
|
|
@@ -100,8 +106,16 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
|
|
List<RuralProjectRecords> ruralProjectRecordsList = projectRecordsService.getProjectRecordsSignatureByCount(count);
|
|
List<RuralProjectRecords> ruralProjectRecordsList = projectRecordsService.getProjectRecordsSignatureByCount(count);
|
|
for (RuralProjectRecords info: ruralProjectRecordsList) {
|
|
for (RuralProjectRecords info: ruralProjectRecordsList) {
|
|
//进行文件处理
|
|
//进行文件处理
|
|
- downLoadReportAttach(info.getReportSignatureContractId());
|
|
|
|
- projectNumber.add(info.getProjectReportNumber());
|
|
|
|
|
|
+ try {
|
|
|
|
+ service.downLoadReportAttach(info.getReportSignatureContractId());
|
|
|
|
+ projectNumber.add(info.getProjectReportNumber());
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ logger.error("报告签章文件处理异常:",e);
|
|
|
|
+ }finally {
|
|
|
|
+ info.setReportSignatureUrlFlag(1);
|
|
|
|
+ //修改签章对应信息文件
|
|
|
|
+ projectReportDataService.updateReportSignatureInfo(info);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if(projectNumber.size()>0){
|
|
if(projectNumber.size()>0){
|
|
String numbersStr = String.join(",", projectNumber);
|
|
String numbersStr = String.join(",", projectNumber);
|
|
@@ -122,206 +136,4 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 下载审定单附件
|
|
|
|
- */
|
|
|
|
- private void downLoadApprovalAttach(String contractId) {
|
|
|
|
- //根据contractId查询对应的报告信息
|
|
|
|
- ProjectReportData projectReportData = projectReportDataService.getProjectReportDataByContractId(contractId);
|
|
|
|
- //根据contractId查询对应的报告信息
|
|
|
|
- RuralProjectRecords ruralProjectRecords = projectRecordsService.get(projectReportData.getProject().getId());
|
|
|
|
- if(null == projectReportData || StringUtils.isBlank(projectReportData.getSignatureContractId())){
|
|
|
|
- return ;
|
|
|
|
- }
|
|
|
|
- //根据contractId将文件下载下来 并上传到阿里云服务种
|
|
|
|
- //添加请求头
|
|
|
|
- Map<String,String> requestHeaderMap = new HashMap<>();
|
|
|
|
- requestHeaderMap.put("x-qys-accesstoken", apptoken);
|
|
|
|
- requestHeaderMap.put("x-qys-signature", signature);
|
|
|
|
- requestHeaderMap.put("x-qys-timestamp", "0");
|
|
|
|
- Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId="+contractId,requestHeaderMap,projectReportData.getSignatureFileName()+".zip","");
|
|
|
|
- //获取处理结果,若为true 则进行文件上传阿里云操作并写入数据库,否则不进行处理
|
|
|
|
- Boolean bool = (Boolean) map.get("success");
|
|
|
|
- if(bool){
|
|
|
|
- //将文件上传到阿里云中
|
|
|
|
- String fileName = (String) map.get("fileName");
|
|
|
|
- String filePath = (String) map.get("filePath");
|
|
|
|
- Map<String, Object> loadMap = oosLoad(filePath + fileName, "approval");
|
|
|
|
- //判定是否上传成功
|
|
|
|
- Boolean loadBool = (Boolean) loadMap.get("success");
|
|
|
|
- if(loadBool){
|
|
|
|
- //签章完成则进行数据的保存
|
|
|
|
- String loadFilePath = (String) loadMap.get("filePath");
|
|
|
|
- String fileLength = (String) loadMap.get("fileLength");
|
|
|
|
- projectReportData.setSignatureUrl(loadFilePath);
|
|
|
|
-
|
|
|
|
- //将文件存储到对应的档案信息中的“咨询报告书正文”中
|
|
|
|
- WorkClientAttachment attchment = new WorkClientAttachment();
|
|
|
|
- attchment.setProjectId(ruralProjectRecords.getId());
|
|
|
|
- attchment.setAttachmentId("058ef76b128a4d629acb039017f19161");
|
|
|
|
- attchment.setDivIdType("signature");
|
|
|
|
- //删除原有的数据信息
|
|
|
|
- workattachmentService.deleteByAttachIdAndProject(attchment);
|
|
|
|
- //查询原有文件的数据量
|
|
|
|
- Integer fileCount = workattachmentService.getAttachmentCountByAttachmentIdAndProjectId(attchment);
|
|
|
|
- if( null == fileCount){
|
|
|
|
- fileCount = 0;
|
|
|
|
- }
|
|
|
|
- fileCount = fileCount + 1;
|
|
|
|
- String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length());
|
|
|
|
- attchment.setFileSize(fileLength);
|
|
|
|
- User user = UserUtils.get(ruralProjectRecords.getCreateBy().getId());
|
|
|
|
- attchment.setCreateBy(user);
|
|
|
|
- attchment.setUpdateBy(user);
|
|
|
|
- attchment.setUrl(loadFilePath);
|
|
|
|
- attchment.setType(fileSuffix);
|
|
|
|
- attchment.setAttachmentUser(ruralProjectRecords.getCreateBy().getId());
|
|
|
|
- attchment.setAttachmentName(fileName);
|
|
|
|
- attchment.setAttachmentFlag("100");
|
|
|
|
- attchment.setSort(fileCount.toString());
|
|
|
|
- workattachmentService.insertOnWorkClientAttachment(attchment);
|
|
|
|
- //修改签章对应信息文件
|
|
|
|
- projectReportDataService.updateSignatureInfo(projectReportData);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 下载报告附件
|
|
|
|
- */
|
|
|
|
- private void downLoadReportAttach(String contractId) {
|
|
|
|
- //根据contractId查询对应的报告信息
|
|
|
|
- RuralProjectRecords ruralProjectRecords = projectRecordsService.getProjectRecordsByContractId(contractId);
|
|
|
|
- if(null == ruralProjectRecords || StringUtils.isBlank(ruralProjectRecords.getReportSignatureContractId())){
|
|
|
|
- return ;
|
|
|
|
- }
|
|
|
|
- //根据contractId将文件下载下来 并上传到阿里云服务种
|
|
|
|
- //添加请求头
|
|
|
|
- Map<String,String> requestHeaderMap = new HashMap<>();
|
|
|
|
- requestHeaderMap.put("x-qys-accesstoken", apptoken);
|
|
|
|
- requestHeaderMap.put("x-qys-signature", signature);
|
|
|
|
- requestHeaderMap.put("x-qys-timestamp", "0");
|
|
|
|
- Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId=" + contractId, requestHeaderMap, ruralProjectRecords.getReportSignatureFileName() + ".zip", "");
|
|
|
|
- //获取处理结果,若为true 则进行文件上传阿里云操作并写入数据库,否则不进行处理
|
|
|
|
- Boolean bool = (Boolean) map.get("success");
|
|
|
|
- if(bool){
|
|
|
|
- //将文件上传到阿里云中
|
|
|
|
- String fileName = (String) map.get("fileName");
|
|
|
|
- String filePath = (String) map.get("filePath");
|
|
|
|
- Map<String, Object> loadMap = oosLoad(filePath + fileName, "report");
|
|
|
|
- //判定是否上传成功
|
|
|
|
- Boolean loadBool = (Boolean) loadMap.get("success");
|
|
|
|
- if(loadBool){
|
|
|
|
- //签章完成则进行数据的保存
|
|
|
|
- String loadFilePath = (String) loadMap.get("filePath");
|
|
|
|
- String fileLength = (String) loadMap.get("fileLength");
|
|
|
|
- ruralProjectRecords.setReportSignatureUrl(loadFilePath);
|
|
|
|
-
|
|
|
|
- //将文件存储到对应的档案信息中的“咨询报告书正文”中
|
|
|
|
- WorkClientAttachment attchment = new WorkClientAttachment();
|
|
|
|
- attchment.setProjectId(ruralProjectRecords.getId());
|
|
|
|
- attchment.setAttachmentId("6c68d29ea00e4cdb8cf17fb54ee30f0f");
|
|
|
|
- attchment.setDivIdType("signature");
|
|
|
|
- //删除原有的数据信息
|
|
|
|
- workattachmentService.deleteByAttachIdAndProject(attchment);
|
|
|
|
- //查询原有文件的数据量
|
|
|
|
- Integer fileCount = workattachmentService.getAttachmentCountByAttachmentIdAndProjectId(attchment);
|
|
|
|
- if( null == fileCount){
|
|
|
|
- fileCount = 0;
|
|
|
|
- }
|
|
|
|
- fileCount = fileCount + 1;
|
|
|
|
- String fileSuffix = fileName.substring(fileName.lastIndexOf(".")+1,fileName.length());
|
|
|
|
- attchment.setFileSize(fileLength);
|
|
|
|
- User user = UserUtils.get(ruralProjectRecords.getCreateBy().getId());
|
|
|
|
- attchment.setCreateBy(user);
|
|
|
|
- attchment.setUpdateBy(user);
|
|
|
|
- attchment.setUrl(loadFilePath);
|
|
|
|
- attchment.setType(fileSuffix);
|
|
|
|
- attchment.setAttachmentUser(ruralProjectRecords.getCreateBy().getId());
|
|
|
|
- attchment.setAttachmentName(fileName);
|
|
|
|
- attchment.setAttachmentFlag("100");
|
|
|
|
- attchment.setSort(fileCount.toString());
|
|
|
|
- workattachmentService.insertOnWorkClientAttachment(attchment);
|
|
|
|
- //修改签章对应信息文件
|
|
|
|
- projectReportDataService.updateReportSignatureInfo(ruralProjectRecords);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 文件上传阿里云
|
|
|
|
- * @param filePath 文件路径
|
|
|
|
- * @param storeAs 存储文件夹名称
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private Map<String,Object> oosLoad(String filePath,String storeAs){
|
|
|
|
-
|
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
|
- map.put("success",false);
|
|
|
|
- File mfile = new File(filePath);
|
|
|
|
- SftpClientUtil sftpClientUtil = new SftpClientUtil();
|
|
|
|
- //File转MultipartFile文件
|
|
|
|
- MultipartFile file = sftpClientUtil.transformFile(mfile);
|
|
|
|
- try {
|
|
|
|
- String filepath = "";
|
|
|
|
- if (!file.isEmpty()) {
|
|
|
|
- // 文件保存路径
|
|
|
|
-
|
|
|
|
- String realPath =directory.replace("/","")+datePath()+"/signature/"+storeAs+"/";
|
|
|
|
- OSSClientUtil ossUtil = new OSSClientUtil();
|
|
|
|
- String newName = file.getName();
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- ossUtil.uploadFile2OSS(file.getInputStream(),realPath,newName);
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- logger.error("Exception e:"+e);
|
|
|
|
- }
|
|
|
|
- filepath = "/" + realPath + newName;
|
|
|
|
- map.put("filePath",filepath);
|
|
|
|
- long length = mfile.length();
|
|
|
|
- map.put("fileLength", String.valueOf(length));
|
|
|
|
- map.put("success",true);
|
|
|
|
- }
|
|
|
|
- }catch (Exception e){
|
|
|
|
-
|
|
|
|
- }finally {
|
|
|
|
- mfile.delete();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return map;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private static String datePath(){
|
|
|
|
-
|
|
|
|
- Calendar date = Calendar.getInstance();
|
|
|
|
- String year = String.valueOf(date.get(Calendar.YEAR));
|
|
|
|
- String month = String.valueOf(date.get(Calendar.MONTH)+1);
|
|
|
|
- String day = String.valueOf(date.get(Calendar.DAY_OF_MONTH));
|
|
|
|
- String path = "/"+year+"/"+month+"/"+day;
|
|
|
|
- return path;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 下载审定内附件
|
|
|
|
- */
|
|
|
|
- private void downLoadJudgementAttach(String contractId) {
|
|
|
|
- //根据contractId查询对应的报告信息
|
|
|
|
- RuralProjectRecords ruralProjectRecords = projectRecordsService.getJudgementProjectRecordsByContractId(contractId);
|
|
|
|
- if(null == ruralProjectRecords || StringUtils.isBlank(ruralProjectRecords.getQualitySignatureContractId())){
|
|
|
|
- return ;
|
|
|
|
- }
|
|
|
|
- //根据contractId将文件下载下来 并上传到阿里云服务种
|
|
|
|
- //添加请求头
|
|
|
|
- Map<String,String> requestHeaderMap = new HashMap<>();
|
|
|
|
- requestHeaderMap.put("x-qys-accesstoken", apptoken);
|
|
|
|
- requestHeaderMap.put("x-qys-signature", signature);
|
|
|
|
- requestHeaderMap.put("x-qys-timestamp", "0");
|
|
|
|
- Map<String, Object> map = SignaturePostUtil.downloadZipDesignated(HTTPTOP + "/contract/download?contractId="+contractId,requestHeaderMap,ruralProjectRecords.getQualitySignatureFileName()+".zip","");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|