多单位版国产化地质资料管理系统
zs
2025-12-18 4f0d9bde31a80f6279e26466250da7716eec627f
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.zbooksoft.gdmis.controller;
 
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.zbooksoft.gdmis.common.BoxEnum;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.List;
import java.util.Map;
 
import static com.zbooksoft.gdmis.common.ShelveOpForAndroid.shelveOperate;
 
 
/**
 * @Description: 库房
 * @Author: zhai
 * @Date: 2024/8/28
 **/
 
@Controller
@RequestMapping("/depot")
public class DepotController {
 
    @Autowired
    JdbcTemplate jdbcTemplate;
 
    private static final Logger logger = LoggerFactory.getLogger(DepotController.class);
 
 
    /**
     * depot/openShelve
     * 密集架开关
     *
     * @param id
     * @param actionType
     * @return
     */
    @RequestMapping(value = "/openShelve")
    @RequiresUser
    @ResponseBody
    public Object openShelve(Long id, String actionType) {
        String sql = "SELECT * FROM BUS_DEPOT_MANAGEMENT WHERE ID = " + id;
        Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(sql);
        String ip = stringObjectMap.get("IP").toString();
        int column = Integer.parseInt(stringObjectMap.get("COLUMN_NUMBER").toString());
        shelveOperate(ip, 10086, column, actionType);
        return new AjaxResponse(true);
    }
 
    /**
     * depot/openShelve
     * 密集架开关
     *
     * @param id
     * @param actionType
     * @return
     */
    @RequestMapping(value = "/openShelveByUser")
    @RequiresUser
    @ResponseBody
    public Object openShelveByUser(Long id) {
        try {
            String sqlWarehousing = " select * from BUS_WAREHOUSING where id =" + id;
 
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sqlWarehousing);
            if (mapList.size() > 0) {
                Map<String, Object> stringObjectMap = mapList.get(0);
                String locationNumber = stringObjectMap.get("LOCATION_NUMBER").toString();
                String newCode = generateStorageLocationCode(locationNumber);
                //取最后一位
                String newActionType = newCode.substring(newCode.length() - 1);
                String actionType = "4";
                if (newActionType.equals("0")) {
                    actionType = "5";
                }
                String sql = "SELECT * FROM BUS_DEPOT_MANAGEMENT WHERE CODE = '" + newCode + "'";
                Map<String, Object> stringObjectMaps = jdbcTemplate.queryForMap(sql);
                String ip = stringObjectMaps.get("IP").toString();
                int column = Integer.parseInt(stringObjectMap.get("COLUMN_NUMBER").toString());
                shelveOperate(ip, 10086, column, actionType);
 
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            return new AjaxResponse(new ErrorInfo("开启失败"));
        }
    }
 
    public static String generateStorageLocationCode(String location) {
        // 示例输入: Z01-A01左-08列-02层
        String[] parts = location.split("-");
 
        String zoneStr = parts[0];           // Z01
        String rackAndSide = parts[1];       // A01左
 
        // 区域代码 (例如 Z01 -> 04)
        String zoneCode = BoxEnum.getCodeByName(zoneStr);
 
        // 架号中的字母与数字 (例如 A01 -> A=1, 01)
        String rackLetter = rackAndSide.substring(0, 1);   // A
        String rackNumber = rackAndSide.substring(1, 3); // 01
        String sideStr = rackAndSide.substring(3); // 左 or 右
 
        // 获取字母对应的数字 (例如 A -> 1)
        // 根据数字获取对应字母
        String rackLetterNum = BoxEnum.RackLetter.getNumberByLetter(rackLetter); // 返回 "A"
 
 
        // 方向代码 (左 -> 1, 右 -> 2)
        String sideCode = "左".equals(sideStr) ? "1" : "0";
 
 
        // 拼接最终结果
        return zoneCode + rackLetterNum + rackNumber + sideCode;
    }
}