Commit 37c8f0c8 authored by lisong's avatar lisong

修改文件上传路径

parent 90065ac3
package com.yeejoin.amos.api.openapi.controller; package com.yeejoin.amos.api.openapi.controller;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.logging.SimpleFormatter;
import com.yeejoin.amos.api.openapi.enums.FileFolderPathEnum;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -39,7 +43,7 @@ public class FilesController { ...@@ -39,7 +43,7 @@ public class FilesController {
@RequestBody MultipartFile file) throws Exception @RequestBody MultipartFile file) throws Exception
{ {
logger.info(file); logger.info(file);
JSONObject jsonObj = uploadFile(file,"cylinder"); JSONObject jsonObj = uploadFile(file,FileFolderPathEnum.CYLINDER.getPath());
return ResponseHelper.buildResponse(jsonObj.toString()); return ResponseHelper.buildResponse(jsonObj.toString());
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
...@@ -49,7 +53,7 @@ public class FilesController { ...@@ -49,7 +53,7 @@ public class FilesController {
@RequestBody MultipartFile file) throws Exception @RequestBody MultipartFile file) throws Exception
{ {
logger.info(file); logger.info(file);
JSONObject jsonObj = uploadFile(file,"csei"); JSONObject jsonObj = uploadFile(file, FileFolderPathEnum.JY.getPath());
return ResponseHelper.buildResponse(jsonObj.toString()); return ResponseHelper.buildResponse(jsonObj.toString());
} }
...@@ -57,8 +61,10 @@ public class FilesController { ...@@ -57,8 +61,10 @@ public class FilesController {
if (ValidationUtil.isEmpty(file)){ if (ValidationUtil.isEmpty(file)){
throw new BadRequest("参数校验失败."); throw new BadRequest("参数校验失败.");
} }
Date today = new Date();
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFileFree(file, "tzs/"+tag); SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
String path = format.format(today);
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFileFree(file, "tzs/" + tag + "/" + path);
JSONObject jsonObj = new JSONObject(); JSONObject jsonObj = new JSONObject();
if (date != null) { if (date != null) {
Map<String, String> map = date.getResult(); Map<String, String> map = date.getResult();
...@@ -76,16 +82,17 @@ public class FilesController { ...@@ -76,16 +82,17 @@ public class FilesController {
@ApiOperation(value = "上传附件") @ApiOperation(value = "上传附件")
@PostMapping("/supma") @PostMapping("/supma")
public ResponseModel<JSONObject> upload(@RequestBody MultipartFile file){ public ResponseModel<JSONObject> upload(@RequestBody MultipartFile file){
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFile(file); JSONObject jsonObject = uploadFile(file, FileFolderPathEnum.JG.getPath());
JSONObject jsonObj = new JSONObject(); // FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFile(file);
if (date != null) { // JSONObject jsonObj = new JSONObject();
Map<String, String> map = date.getResult(); // if (date != null) {
Iterator<String> it = map.keySet().iterator(); // Map<String, String> map = date.getResult();
String urlString=it.next(); // Iterator<String> it = map.keySet().iterator();
jsonObj.put("fileUrl", urlString); // String urlString=it.next();
jsonObj.put("fileName", map.get(urlString)); // jsonObj.put("fileUrl", urlString);
} // jsonObj.put("fileName", map.get(urlString));
return ResponseHelper.buildResponse(jsonObj); // }
return ResponseHelper.buildResponse(jsonObject);
} }
} }
package com.yeejoin.amos.api.openapi.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum FileFolderPathEnum {
/**
* 小程序
*/
WE_APP("app","/app"),
/**
* 96333
*/
ELEVATOR("elevator","/elevator"),
/**
* 气瓶
*/
CYLINDER("cylinder","/cylinder"),
/**
* 一码通
*/
YMT("ymt","/ymt"),
/**
* 两个规定
*/
PATROL("patrol","/patrol"),
/**
* TCM
*/
TCM("tcm","/tcm"),
/**
* 监管
*/
JG("jg","/supma"),
/**
* 检验报告
*/
JY("jg","/csei")
;
private String module;
private String path;
}
...@@ -174,12 +174,14 @@ ...@@ -174,12 +174,14 @@
af.check_results AS checkResult af.check_results AS checkResult
FROM FROM
( SELECT * FROM tz_cylinder_filling_record WHERE is_not_es IS NULL AND filling_before_id IS NOT NULL ( SELECT * FROM tz_cylinder_filling_record WHERE is_not_es IS NULL AND filling_before_id IS NOT NULL
AND filling_check_id IS NOT NULL LIMIT 5000 ) r AND filling_check_id IS NOT NULL and LENGTH(filling_startTime) >= 10 LIMIT 5000 ) r
LEFT JOIN tz_cylinder_filling b ON b.filling_before_id = r.filling_before_id LEFT JOIN tz_cylinder_filling b ON b.filling_before_id = r.filling_before_id
AND r.filling_before_id IS NOT NULL and b.inspection_date NOT LIKE'16%' AND r.filling_before_id IS NOT NULL and b.inspection_date NOT LIKE'16%'
AND date_format ( b.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' ) and b.sequence_code is not null AND b.app_id is not null AND date_format ( b.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' ) and b.sequence_code is not null AND b.app_id is not null
LEFT JOIN tz_cylinder_filling_check af ON af.filling_check_id = r.filling_check_id LEFT JOIN tz_cylinder_filling_check af ON af.filling_check_id = r.filling_check_id
AND date_format ( af.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' ) AND date_format ( af.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' )
and LENGTH(b.inspection_date) >= 10
and LENGTH(af.inspection_date) >= 10
LEFT JOIN tz_cylinder_unit tcn ON tcn.app_id = r.app_id LEFT JOIN tz_cylinder_unit tcn ON tcn.app_id = r.app_id
</select> </select>
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
WHEN (SELECT COUNT(1) WHEN (SELECT COUNT(1)
FROM tz_cylinder_inspection ins FROM tz_cylinder_inspection ins
WHERE ins.app_id = tcu.app_id WHERE ins.app_id = tcu.app_id
and LENGTH(ins.next_inspection_date) >= 10
and TO_DAYS(ins.next_inspection_date) - TO_DAYS(NOW()) &lt;= 30) > 0 THEN and TO_DAYS(ins.next_inspection_date) - TO_DAYS(NOW()) &lt;= 30) > 0 THEN
1 1
WHEN (SELECT COUNT(1) FROM view_unit_outofdate v WHERE v.credit_code = tcu.credit_code) > 0 THEN WHEN (SELECT COUNT(1) FROM view_unit_outofdate v WHERE v.credit_code = tcu.credit_code) > 0 THEN
......
...@@ -377,6 +377,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -377,6 +377,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
} }
builder.query(boolMust); builder.query(boolMust);
builder.sort("inspectionDateMs",SortOrder.DESC);
builder.sort("sequenceNbr",SortOrder.DESC); builder.sort("sequenceNbr",SortOrder.DESC);
builder.from((pageNum - 1) * pageSize); builder.from((pageNum - 1) * pageSize);
builder.size(pageSize); builder.size(pageSize);
......
...@@ -3,7 +3,9 @@ package com.yeejoin.amos.patrol.business.controller; ...@@ -3,7 +3,9 @@ package com.yeejoin.amos.patrol.business.controller;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.DomDriver;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.patrol.business.constants.XJConstant; import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.entity.mybatis.TaskBo; import com.yeejoin.amos.patrol.business.entity.mybatis.TaskBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.TaskFeedbackBo; import com.yeejoin.amos.patrol.business.entity.mybatis.TaskFeedbackBo;
...@@ -26,6 +28,7 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService; ...@@ -26,6 +28,7 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -35,8 +38,13 @@ import org.springframework.data.domain.Page; ...@@ -35,8 +38,13 @@ import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.*; import javax.xml.transform.*;
...@@ -44,6 +52,7 @@ import javax.xml.transform.stream.StreamResult; ...@@ -44,6 +52,7 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import java.io.*; import java.io.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -890,5 +899,33 @@ public class TaskController extends AbstractBaseController{ ...@@ -890,5 +899,33 @@ public class TaskController extends AbstractBaseController{
return map; return map;
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "图片上传按月分文件夹")
@PostMapping(value = "/imageUpload")
public ResponseModel<Object> uploadTaskFiles (@RequestBody MultipartFile file) throws Exception {
JSONObject jsonObject = uploadFile(file, "/twoRegulations");
return ResponseHelper.buildResponse(jsonObject);
}
private JSONObject uploadFile(MultipartFile file, String tag) {
if (ValidationUtil.isEmpty(file)){
throw new BadRequest("参数校验失败.");
}
Date today = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
String path = format.format(today);
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFileFree(file, "tzs/" + tag + "/" + path);
JSONObject jsonObj = new JSONObject();
if (date != null) {
Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) {
String urlString=it.next();
jsonObj.put("fileUrl", urlString);
jsonObj.put("fileName", map.get(urlString));
}
}
return jsonObj;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment