zhitong.yu
2024-03-15 ebd89b9ffa8980ac944a7e79ecc64c01637d4f17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.hxzk.controller;
 
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.TbAchor;
import com.hxzk.pojo.TbFence;
import com.hxzk.pojo.TbMap;
import com.hxzk.service.DiTuService;
import com.hxzk.udp.Udp_Out;
import com.hxzk.util.MyFile;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@RestController
@RequestMapping("/")
public class DiTuController {
    @Autowired
    DiTuService diTuService;
 
    @GetMapping("findditu")
    result<List<TbMap>>findditu(Integer page, Integer limit){
        PageInfo<TbMap> cz= diTuService.findAll(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @GetMapping("findmap")
    List<TbMap>findmap(){
        List<TbMap> cz= diTuService.findmap();
        return cz;
    }
    //新增地图
    @PostMapping("addDiTu")
    public void addDiTu(TbMap map, HttpServletResponse response, MultipartFile images,HttpServletRequest request) throws IOException {
        String name = request.getParameter("mapname");
        String originalFilename = images.getOriginalFilename();
        String fileExtension = StringUtils.getFilenameExtension(originalFilename);
        map.setMapname(name+"."+fileExtension);
        MyFile.addMap(images,request,name);
//        diTuService.addMap(map);
        response.sendRedirect("/hxzkuwb/HouTai/JiChu/DiTu.jsp");
    }
    //修改地图
    @PostMapping("updateDiTu")
    public void updateDiTu(TbMap map, HttpServletResponse response) throws IOException {
        String xieyi = "BSTOCS1,ALTERMAP," + map.getFloor() + "," + map.getMapname() + "," + map.getXTruelength()+ "," + map.getYTruewidth() + "," + map.getX0Length() + "," + map.getY0Width() + "," + map.getXPixel() + "," + map.getYPixel() + ",END";
        Udp_Out.udp_to_cs(xieyi);
        response.sendRedirect("/hxzkuwb/HouTai/JiChu/DiTu.jsp");
    }
    //删除地图
    @PostMapping("deleteDiTu")
    public void deleteDiTu(TbMap tbMap, HttpServletResponse response) throws IOException {
        String xieyi = "BSTOCS1,DELETEMAP," + tbMap.getId()+ ",END";
        Udp_Out.udp_to_cs(xieyi);
        response.sendRedirect("/hxzkuwb/HouTai/JiChu/DiTu.jsp");
    }
    //表格搜索
    @PostMapping("findDiTuSearch")
    result<List<TbMap>> findDiTuSearch(Integer page, Integer limit, TbMap map){
        PageInfo<TbMap> cz= diTuService.findSearch(page, limit,map);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
    //旧
    @PostMapping("findfloorMap")
    public List<TbMap> findfloorMap(HttpServletRequest request) {
        String floor = request.getParameter("value");
        List<TbMap> map = diTuService.findfloorMap(floor);
        return map;
    }
 
    //旧
    @PostMapping("floornumTomap")
    public List<TbMap> floornumTomap(HttpServletRequest request) {
        String floor = request.getParameter("value");
        List<TbMap> map = diTuService.findfloorMap(floor);
        return map;
    }
 
    public String gettime(){
        Date now = new Date();
        // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm"
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        // 格式化日期对象,输出字符串结果
        String formattedDate = sdf.format(now);
        return formattedDate;
    }
}