多单位版国产化地质资料管理系统
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package com.zbooksoft.gdmis.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
import com.ruili.wcp.common.StringUtil;
import com.ruili.wcp.data.entity.config.View;
import com.ruili.wcp.data.entity.management.User;
import com.ruili.wcp.engine.form.IFormData;
import com.ruili.wcp.service.config.ModuleService;
import com.ruili.wcp.service.config.ViewService;
import com.ruili.wcp.web.model.AjaxResponse;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @Description
 * @Author fsr
 * @Date 2020/12/12
 * 扫描枪分发
 **/
@Controller
@RequestMapping("/scanPrintController")
public class ScanPrintController {
 
    private static final Logger logger = LoggerFactory.getLogger(ScanPrintController.class);
 
    @Autowired
    ModuleService moduleService;
 
 
    @Autowired
    IFormData iFormData;
 
    @Autowired
    JdbcTemplate jdbcTemplate;
 
    @Autowired
    ViewService viewService;
 
    /**
     * @Description 出库扫描
     * @Date 2020/12/12
     **/
    @RequestMapping(value = "/outScanPrint")
    public ModelAndView outScanPrint(Long viewId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("scanPrint/scanPrint");
        modelAndView.addObject("viewId", viewId);
        modelAndView.addObject("printType", 1);
        return modelAndView;
    }
 
    /**
     * @Description 归还扫描
     * @Date 2020/12/12
     **/
    @RequestMapping(value = "/returnScanPrint")
    public ModelAndView returnScanPrint(Long viewId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("scanPrint/returnPrint");
        modelAndView.addObject("viewId", viewId);
 
        modelAndView.addObject("printType", 2);
        return modelAndView;
    }
 
    /**
     * @Description 入库扫描
     * @Date 2020/12/12
     **/
    @RequestMapping(value = "/inScanPrint")
    public ModelAndView inScanPrint(Long viewId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("scanPrint/scanInPrint");
        modelAndView.addObject("viewId", viewId);
        modelAndView.addObject("printType", 0);
        return modelAndView;
        //ARCHIVAL_TYPE
    }
 
    /**
     * @Description 保存扫描枪数据
     * @Date 2020/12/12
     * printType 扫描类型 1.出 0. 进
     * operationType 操作类型 1 出入库  2 销毁
     **/
    @RequestMapping(value = "/saveScanPrintData")
    @RequiresUser
    @ResponseBody
    public Object saveScanPrintData(@RequestBody List<Map<String, Object>> data, int printType, Long viewId, String boxNum) {
        Subject currentUser = SecurityUtils.getSubject();
        Session session = currentUser.getSession();
        User user = (User) session.getAttribute("user");
 
 
        try {
            View view = viewService.getViewById(viewId);
            String mainTableName = view.getMainTableName();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            if (data != null && data.size() > 0) {
                if (printType == 0) { //入库扫描
                    updateWarehousing(data, boxNum);
                }
                if (printType == 1) { //出库
                    outWarehousing(data);
                }
                if (printType == 2) { //归还
                    returnWarehousing(data);
                }
            }
        } catch (Exception e) {
            return new AjaxResponse(false);
        }
        return new AjaxResponse(true);
    }
 
    private Map<String, Object> getBusinessData(String tableName, String archivalCode) {
        String sql = "SELECT * FROM " + tableName + " WHERE ARCHIVAL_STATE = 3 AND ARCHIVAL_CODE='" + archivalCode + "'";
        Map<String, Object> data = null;
        try {
            data = jdbcTemplate.queryForMap(sql);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return data;
    }
 
    /**
     * @Description 入库
     * @Date 2020/12/13
     **/
    private void updateWarehousing(List<Map<String, Object>> data, String boxNum) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //更新出库状态
        for (int i = 0; i < data.size(); i++) {
            String archivalCode = (String) data.get(i).get("archival_code");
            String sqlSelect = "select * from BUS_PACKING_MANAGE where ITEM_NUM = '" + archivalCode + "'";
            Map<String, Object> packingMap = jdbcTemplate.queryForMap(sqlSelect);
 
            long itemId = Long.parseLong(packingMap.get("ITEM_ID").toString());
            String sql = "select * from BUS_WAREHOUSING where item_id =" + itemId + " and IN_STATUS_CODE =2";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            if (mapList.size() > 0) {
                Map<String, Object> map = mapList.get(0);
 
 
                Date date = new Date();
                String format = sdf.format(date);
                HashMap<String, Object> mapData = new HashMap<>();
                mapData.put("IN_STATUS_CODE", 3);
                mapData.put("OUT_STATUS", "已入库");
                mapData.put("IN_TIME", format);
                iFormData.update(1972515952908148738L, mapData, Long.parseLong(map.get("ID").toString()));
 
                String sqlUpdateBox = "update BUS_PACKING_MANAGE SET BOX_NUMBER='" + boxNum + "', ITEM_STATE='已入库'  WHERE ID=" + packingMap.get("ID");
                jdbcTemplate.update(sqlUpdateBox);
            }
        }
    }
 
    /**
     * @Description 归还
     * @Date 2020/12/13
     **/
    private void returnWarehousing(List<Map<String, Object>> data) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //更新出库状态
        for (int i = 0; i < data.size(); i++) {
            String archivalCode = (String) data.get(i).get("archival_code");
            String sqlSelect = "select * from BUS_PACKING_MANAGE where ITEM_NUM = '" + archivalCode + "'";
            Map<String, Object> packingMap = jdbcTemplate.queryForMap(sqlSelect);
 
            long itemId = Long.parseLong(packingMap.get("ITEM_ID").toString());
            String sql = "select * from BUS_WAREHOUSING where item_id =" + itemId + " and IN_STATUS_CODE =1";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            if (mapList.size() > 0) {
                Map<String, Object> map = mapList.get(0);
                Date date = new Date();
                String format = sdf.format(date);
                String sqlUpdate = "update BUS_WAREHOUSING SET IN_STATUS_CODE=2, OUT_STATUS='待入库', IN_TIME='" + format + "' WHERE ID=" + map.get("ID");
                jdbcTemplate.update(sqlUpdate);
 
                String sqlUpdateBox = "update BUS_PACKING_MANAGE SET ITEM_STATE='已归还'  WHERE ID=" + packingMap.get("ID");
                jdbcTemplate.update(sqlUpdateBox);
            }
        }
    }
 
    /**
     * @Description 出库
     * @Date 2020/12/13
     **/
    private void outWarehousing(List<Map<String, Object>> data) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //更新出库状态
        for (int i = 0; i < data.size(); i++) {
            String archivalCode = (String) data.get(i).get("archival_code");
            String sqlSelect = "select * from BUS_PACKING_MANAGE where ITEM_NUM = '" + archivalCode + "'";
            List<Map<String, Object>> mapList1 = jdbcTemplate.queryForList(sqlSelect);
            Map<String, Object> packingMap = null;
            if (mapList1.size() > 0) {
                packingMap = mapList1.get(0);
            }
 
            long itemId = Long.parseLong(packingMap.get("ITEM_ID").toString());
            String sql = "select * from BUS_WAREHOUSING where item_id =" + itemId + " and IN_STATUS_CODE =0";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            if (mapList.size() > 0) {
                Map<String, Object> map = mapList.get(0);
 
                String boxNumber = packingMap.get("BOX_NUMBER") == null ? "" : packingMap.get("BOX_NUMBER").toString();
                String storageLocation = packingMap.get("STORAGE_LOCATION") == null ? "" : packingMap.get("STORAGE_LOCATION").toString();
                Date date = new Date();
                String format = sdf.format(date);
                HashMap<String, Object> mapData = new HashMap<>();
                mapData.put("IN_STATUS_CODE", 1);
                mapData.put("OUT_STATUS", "已出库");
                mapData.put("OUT_TIME", format);
                mapData.put("BOX_NUM", boxNumber);
                mapData.put("LOCATION_NUMBER", storageLocation);
                iFormData.update(1972515952908148738L, mapData, Long.parseLong(map.get("ID").toString()));
 
                String sqlUpdateBox = "update BUS_PACKING_MANAGE SET ITEM_STATE='借出'  WHERE ID=" + packingMap.get("ID");
                jdbcTemplate.update(sqlUpdateBox);
            }
        }
    }
 
    /**
     * @Description 保存到销毁库
     * @Date 2020/12/13
     **/
    private void saveToDisposeForm(Map<String, Object> businessData) {
 
    }
 
 
}