Prechádzať zdrojové kódy

Merge branch 'master' of http://47.100.37.243:10080/ZHOU/yunsu

# Conflicts:
#	cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldFileServiceImpl.java
5 rokov pred
rodič
commit
23653cc5cb

+ 4 - 3
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldFileController.java

@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
@@ -36,7 +37,7 @@ import java.util.zip.ZipOutputStream;
  * @author 吴涛涛
  * @author 吴涛涛
  * @since 2019-08-07
  * @since 2019-08-07
  */
  */
-@RestController
+@Controller
 @RequestMapping("/mouldfile")
 @RequestMapping("/mouldfile")
 public class MouldFileController {
 public class MouldFileController {
 
 
@@ -215,12 +216,12 @@ public class MouldFileController {
      * @return
      * @return
      */
      */
     @ApiOperation("文档下载日志的excel导出")
     @ApiOperation("文档下载日志的excel导出")
-    @RequestMapping(value = "/downloadFileListExcel", method = RequestMethod.POST)
+    @RequestMapping(value = "/downloadFileListExcel")
     @ResponseBody
     @ResponseBody
     public HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response) {
     public HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response) {
         HttpRespMsg msg = new HttpRespMsg();
         HttpRespMsg msg = new HttpRespMsg();
         try {
         try {
-            msg = mouldFileService.downloadFileListExcel(userVO, response);
+            msg = mouldFileService.downloadFileListExcel(userVO, response,downloadPath);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/MouldOperationDynamicsMapper.java

@@ -18,5 +18,5 @@ import java.util.List;
  */
  */
 public interface MouldOperationDynamicsMapper extends BaseMapper<MouldOperationDynamics> {
 public interface MouldOperationDynamicsMapper extends BaseMapper<MouldOperationDynamics> {
 
 
-    List<MouldOperationDynamics> selectOperationDynamicsList(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("userVO") UserVO userVO);
+    List<MouldOperationDynamics> selectOperationDynamicsList(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("userVO") UserVO userVO);
 }
 }

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/MouldFileService.java

@@ -31,7 +31,7 @@ public interface MouldFileService extends IService<MouldFile> {
     HttpRespMsg getListByUserAndProjectId(UserVO userVO, PageUtil page);
     HttpRespMsg getListByUserAndProjectId(UserVO userVO, PageUtil page);
     HttpRespMsg dowloadFileList(UserVO userVO, HttpServletRequest request, HttpServletResponse response,String downloadPath,String path) throws IOException;
     HttpRespMsg dowloadFileList(UserVO userVO, HttpServletRequest request, HttpServletResponse response,String downloadPath,String path) throws IOException;
     HttpRespMsg addPartFile(UserVO userVO, String path, MultipartFile[] files);
     HttpRespMsg addPartFile(UserVO userVO, String path, MultipartFile[] files);
-    HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response) throws ParseException;
+    HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response,String downloadPath) throws ParseException;
 
 
     HttpRespMsg mouldUpdateCheck(UserVO userVO);
     HttpRespMsg mouldUpdateCheck(UserVO userVO);
 }
 }

+ 26 - 13
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldFileServiceImpl.java

@@ -599,7 +599,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
     }
     }
 
 
     @Override
     @Override
-    public HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response) throws ParseException {
+    public HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response,String downloadPath) throws ParseException {
         HttpRespMsg msg = new HttpRespMsg();
         HttpRespMsg msg = new HttpRespMsg();
         List<List<String>> list = new ArrayList<List<String>>();
         List<List<String>> list = new ArrayList<List<String>>();
         //标题
         //标题
@@ -612,21 +612,31 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
         QueryWrapper<MouldOperationDynamics> qw = new QueryWrapper<MouldOperationDynamics>();
         QueryWrapper<MouldOperationDynamics> qw = new QueryWrapper<MouldOperationDynamics>();
         qw.eq("content", Constant.DOWNLOAD);
         qw.eq("content", Constant.DOWNLOAD);
         String start = userVO.getStartTime().replace("Z", " UTC");//是空格+UTC
         String start = userVO.getStartTime().replace("Z", " UTC");//是空格+UTC
-        String end = userVO.getStartTime().replace("Z", " UTC");//是空格+UTC
-        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
+        String end = userVO.getEndTime().replace("Z", " UTC");//是空格+UTC
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
         Date date1 = df.parse(start);
         Date date1 = df.parse(start);
+        System.out.println(date1);
         Date date2 = df.parse(end);
         Date date2 = df.parse(end);
-        SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
-        Date startDate = df1.parse(date1.toString());
-        Date endDate = df1.parse(date2.toString());
-        SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        System.out.println(date2);
+//        SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.CHINA);
+        Calendar calendar=new GregorianCalendar();
+        calendar.setTime(date1);
+        calendar.add(calendar.DATE,-1);//把日期往后增加一天.整数往后推,负数往前移动        date=calendar.getTime();
+        Date startDate1 = calendar.getTime();
+        calendar.setTime(date2);
+        calendar.add(calendar.DATE,-1);
+//        Date startDate = df1.parse(date1.toString());
+        Date endDate2 = calendar.getTime();
+//        Date endDate = df1.parse(date2.toString());
+        SimpleDateFormat dateSdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat dateSdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
+        String startDate = dateSdf.format(startDate1);
+        String endDate = dateSdf.format(endDate2);
         List<MouldOperationDynamics> mouldOperationDynamics  = new ArrayList<>();
         List<MouldOperationDynamics> mouldOperationDynamics  = new ArrayList<>();
         if (userVO.getStartTime() != null && userVO.getEndTime() != null) {
         if (userVO.getStartTime() != null && userVO.getEndTime() != null) {
-            qw.le("indate",startDate);
-            qw.ge("indate", endDate);
             mouldOperationDynamics = mouldOperationDynamicsMapper.selectOperationDynamicsList(startDate,endDate,userVO);
             mouldOperationDynamics = mouldOperationDynamicsMapper.selectOperationDynamicsList(startDate,endDate,userVO);
         }
         }
-
         for (MouldOperationDynamics dynamic : mouldOperationDynamics) {
         for (MouldOperationDynamics dynamic : mouldOperationDynamics) {
             List<String> rowList = new ArrayList<String>();
             List<String> rowList = new ArrayList<String>();
             //文件名
             //文件名
@@ -648,11 +658,14 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                 rowList.add("模具报废");
                 rowList.add("模具报废");
             }
             }
             //下载时间
             //下载时间
-            rowList.add(dateSdf.format(dynamic.getIndate()));
+
+
+            rowList.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(dynamic.getIndate())
+                    );
+            list.add(rowList);
         }
         }
         Mould mould = mouldMapper.selectById(userVO.getMouldId());
         Mould mould = mouldMapper.selectById(userVO.getMouldId());
-        ExcelUtil.exportGeneralExcelByTitleAndList(response, mould.getModelNo() + mould.getModelName() + "-" + dateSdf.format(new Date()), list);
-        msg.data = mould;
+        msg.data = ExcelUtil.exportGeneralExcelByTitleAndList(response, mould.getModelNo() + mould.getModelName()+dateSdf2.format(new Date()), list,downloadPath);
         return msg;
         return msg;
     }
     }
 
 

+ 13 - 5
cloud-model/src/main/java/com/hssx/cloudmodel/util/ExcelUtil.java

@@ -7,6 +7,9 @@ import org.apache.poi.ss.usermodel.FillPatternType;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 
 
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.OutputStream;
 import java.io.OutputStream;
 import java.net.URLEncoder;
 import java.net.URLEncoder;
 import java.util.List;
 import java.util.List;
@@ -19,7 +22,7 @@ public class ExcelUtil {
      * @param list      数据
      * @param list      数据
      * @return
      * @return
      */
      */
-    public static String exportGeneralExcelByTitleAndList(HttpServletResponse response, String title, List<List<String>> list) {
+    public static String exportGeneralExcelByTitleAndList(HttpServletResponse response, String title, List<List<String>> list,String downloadPath) {
         String result="系统提示:Excel文件导出成功!";
         String result="系统提示:Excel文件导出成功!";
         String fileName= title+".xls";
         String fileName= title+".xls";
         try {
         try {
@@ -128,7 +131,14 @@ public class ExcelUtil {
                     start++;
                     start++;
                 }
                 }
             }
             }
-            OutputStream os = response.getOutputStream();
+//            OutputStream os = response.getOutputStream();//在线下载
+            File dir = null;
+            dir = new File(downloadPath);
+            // D://cloud/upload 文件上传后所存储的位置,部署到服务器上时配置服务器地址即可
+            if (!dir.exists()) {
+                dir.mkdirs();
+            }
+            FileOutputStream os = new FileOutputStream(downloadPath+fileName);//保存到本地
             workBook.write(os);
             workBook.write(os);
             os.flush();
             os.flush();
             os.close();
             os.close();
@@ -136,8 +146,6 @@ public class ExcelUtil {
             System.out.println(result);
             System.out.println(result);
             e.printStackTrace();
             e.printStackTrace();
         }
         }
-        return result;
+        return downloadPath+fileName;
     }
     }
-
-
 }
 }

+ 1 - 1
cloud-model/src/main/resources/mapper/MouldOperationDynamicsMapper.xml

@@ -31,7 +31,7 @@
             mould_id = #{userVO.mouldId}
             mould_id = #{userVO.mouldId}
             and content = '下载'
             and content = '下载'
             <if test="startDate != null and endDate != null">
             <if test="startDate != null and endDate != null">
-                and indate between #{startDate} and #{endDate}
+                and indate between DATE_FORMAT(#{startDate},'%Y-%m-%d') and DATE_FORMAT(#{endDate},'%Y-%m-%d')
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>