whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
src/main/java/com/fgkj/controller/MyFileController.java
@@ -1,40 +1,28 @@
package com.fgkj.controller;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import com.fgkj.dto.*;
import com.fgkj.mapper.UinfDaoFactory;
import com.fgkj.services.User_logService;
import com.fgkj.util.*;
import com.google.gson.Gson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import com.fgkj.mapper.DAOHelper;
import com.fgkj.mapper.UinfDaoFactory;
import com.fgkj.dto.BattInf;
import com.fgkj.dto.BattMap_information;
import com.fgkj.dto.ImageSize;
import com.fgkj.dto.MyFile;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_inf;
import com.fgkj.dto.User_log;
import com.fgkj.services.User_logService;
import com.google.gson.Gson;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RequestMapping("myFile")
@RestController
@Api
@Api(tags = "myFile接口")
public class MyFileController{
   
@@ -50,6 +38,7 @@
   
   //上传文件
   @PostMapping("/uploadTestFile")
   @ApiOperation(notes = "",value="byInfo")
   public ServiceModel UploadTestFile(@RequestParam File[] file,String[] fileFileName,String battName){
      HttpServletResponse res = ActionUtil.getResponse();
      res.setHeader("Access-Control-Allow-Origin", "*");            //允许跨域访问
@@ -122,6 +111,7 @@
   }
   @PostMapping("uploadIphoneFile")
   @ApiOperation(notes = "",value="byInfo")
   public ServiceModel UploadIphoneFile(@RequestParam String filestr,String fname,String battname){
      HttpServletResponse res = ActionUtil.getResponse();
      res.setHeader("Access-Control-Allow-Origin", "*");            //允许跨域访问
@@ -196,6 +186,7 @@
   
   //上传机房视频接口
   @PostMapping("uploadStationFile")
   @ApiOperation(notes = "",value="上传机房视频接口")
   public ServiceModel uploadStationFile(@RequestBody BattInf binf,@RequestParam File[] file,String[] fileFileName){
      // BattInf binf = getGson().fromJson(json, BattInf.class);
      String fileRoot = "stationsrc";
@@ -225,7 +216,8 @@
    * 
    *    获取指定机房得资源
    */
   @GetMapping("stationSource")
   @PostMapping("stationSource")
   @ApiOperation(notes = "",value="获取指定机房得资源")
   public ServiceModel searchStationSource(@RequestBody BattInf binf){
      String fileRoot = "stationsrc";                                             //存放机房资源文件的文件夹
      // BattInf binf = getGson().fromJson(json, BattInf.class);
@@ -301,6 +293,7 @@
   
   //上传机房视频接口(手机端)
   @PostMapping("uploadStationFile4Mobile")
   @ApiOperation(notes = "",value="上传机房视频接口(手机端)")
   public ServiceModel uploadStationFile_mobile(@RequestBody BattInf binf,@RequestParam File[] file,String[] fileFileName){
      // BattInf binf = getGson().fromJson(json, BattInf.class);
      String fileRoot = "stationsrc";
@@ -383,7 +376,7 @@
            
            
            //设置时间
            g.drawString("时间:"+DAOHelper.sdf.format(new Date()),  0 , font_size*4);
            g.drawString("时间:"+ DateUtil.sdf.format(new Date()),  0 , font_size*4);
            //设置机房id
            g.drawString("机房ID:"+binfmation.getStationId(),  0 , font_size*5);
            //设置备注
@@ -469,6 +462,7 @@
     * @return
     */
    @GetMapping("readAllStation")
   @ApiOperation(notes = "",value="读取所有上传过图片和视频的机房id文件夹")
    public ServiceModel ReadAllStation() {
       String fileRoot = "stationsrc";
      ServiceModel model = new ServiceModel();   
@@ -499,6 +493,7 @@
     * @return
     */
    @DeleteMapping("file")
   @ApiOperation(notes = "",value="删除指定的资源文件")
    public ServiceModel deleteFile(@RequestBody MyFile myFile) {
       ServiceModel model = new ServiceModel();
       // MyFile myfile = getGson().fromJson(json, MyFile.class);
@@ -519,7 +514,7 @@
            e.printStackTrace();
         }
         {
            String msg=((User_inf)ActionUtil.getUser()).getUName()+"删除"+myFile.getFilePath()+"机房的"+myFile.getFileName();
            String msg=((User_inf)ActionUtil.getUser()).getuName()+"删除"+myFile.getFilePath()+"机房的"+myFile.getFileName();
            User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
            listU.add(ulog);
            (new User_logService()).addPro(listU);//将用户的操作记录下来
@@ -530,13 +525,13 @@
       return model;
    }
 /*
   public static void main(String[] args) {
      /*String filePath = "D:/test/a/a.txt";
      *//*String filePath = "D:/test/a/a.txt";
      //ActionUtil.createFileRootIFNotExist(filePath);
      
      File file = new File(filePath);
      System.out.println(ActionUtil.tojson(file));*/
      System.out.println(ActionUtil.tojson(file));*//*
      //GraphicsFile("我是鲁星伟","D:\\1.jpg","D:\\2.jpg",0,new Color(255,0,0),"JPG");
      BattMap_information binfmation=new BattMap_information();
      binfmation.setStationId("42000001");
@@ -548,5 +543,5 @@
      String filePath = "D:\\2.jpg";
      //String filename="2.jpg";
      GraphicsFile(binfmation,file,filePath);
   }
   }*/
}