多单位版国产化地质资料管理系统
zhai
2025-09-17 7a8a84577894b766a95c6cbfa5ac7b51e54ac242
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
package com.zbooksoft.gdmis.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruili.wcp.common.EncryptUtil;
import com.ruili.wcp.common.IdGenerater;
import com.ruili.wcp.common.LogUtils;
import com.ruili.wcp.common.OperateType;
import com.ruili.wcp.data.entity.management.*;
import com.ruili.wcp.engine.form.IFormData;
import com.ruili.wcp.service.management.*;
import com.ruili.wcp.web.common.LicenseException;
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.zbooksoft.gdmis.data.entity.UserCheck;
 
import com.zbooksoft.gdmis.data.entity.UtilizationUnit;
import com.zbooksoft.gdmis.data.entity.UtilizationUser;
import com.zbooksoft.gdmis.service.UserCheckService;
 
import com.zbooksoft.gdmis.service.UtilizationUnitService;
import com.zbooksoft.gdmis.service.UtilizationUserService;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.*;
 
/**
 * @Description:利用用户管理
 * @Author: zhai
 * @Date: 2024/8/22
 **/
@Controller
@RequestMapping("/utilizationUser")
public class UtilizationUserController {
    @Autowired
    DeptService deptService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    UserService userService;
    @Autowired
    RoleService roleService;
    //    @Autowired
//    UserQuestionService userQuestionService;
    @Autowired
    UtilizationUserService utilizationUserService;
    @Autowired
    UtilizationUnitService utilizationUnitService;
    @Autowired
    KeywordParamService keywordParamService;
    @Autowired
    KeywordService keywordService;
    @Autowired
    UserCheckService userCheckService;
 
    @Autowired
    IFormData iform;
 
    private static final Logger logger = LoggerFactory.getLogger(UtilizationUserController.class);
 
    @RequestMapping(value = "/register")
    public Object register() {
        return new ModelAndView("gh/utilizationUser/register3");
    }
 
    //获取部门信息
 
    @RequestMapping({"/getDept"})
    @ResponseBody
    public Object getDept() {
        try {
            List<UtilizationUnit> utilizationUnitList = utilizationUnitService.list();
            return new AjaxResponse(utilizationUnitList);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    @RequestMapping({"/getValue"})
    @ResponseBody
    public Object getValue(String name) {
        try {
            QueryWrapper<Keyword> keywordQueryWrapper = new QueryWrapper<>();
            keywordQueryWrapper.eq("keyword_name", name);
            Keyword keyword = keywordService.getOne(keywordQueryWrapper);
 
            QueryWrapper<KeywordParam> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("keyword_id", keyword.getKeywordId());
            List<KeywordParam> KeywordParamList = keywordParamService.list(queryWrapper);
            return new AjaxResponse(KeywordParamList);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
 
    /**
     * 注册
     *
     * @param formData
     * @param request
     * @return
     */
    @RequestMapping(value = {"/saveRegister"}, produces = {"application/json; charset=utf-8"}, method = {RequestMethod.POST})
    @ResponseBody
    public Object saveRegister(@RequestBody Map<String, Object> formData, HttpServletRequest request) {
        try {
            String cardId = formData.get("ID_CARD").toString();
            String mobile = formData.get("MOBILE").toString();
            //先判断一些条件(身份证唯一等)
            String sql = "select ID from UTL_UTILIZATION_USER where ID_CARD = '" + cardId + "'";
            List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
            if (maps.size() > 0) {
                return new AjaxResponse(new ErrorInfo("该身份证已被注册!"), false);
            }
 
            String sql2 = "select ID from UTL_UTILIZATION_USER where MOBILE = '" + mobile + "'";
            List<Map<String, Object>> maps2 = jdbcTemplate.queryForList(sql2);
            if (maps2.size() > 0) {
                return new AjaxResponse(new ErrorInfo("该手机号已被注册!"), false);
            }
            User user = new User();
            String userName = formData.get("USER_NAME").toString();
            String sex = formData.get("SEX").toString();
            String province = formData.get("PROVINCE").toString();
            String city = formData.get("CITY").toString();
            String deptNames = formData.get("DEPT").toString();
            String deptNature = formData.get("DEPT_NATURE").toString();
            String deptAddress = formData.get("DEPT_ADDRESS").toString();
            String postCode = formData.get("POST_CODE").toString();
            String certificateNumber = formData.get("CERTIFICATE_NUMBER").toString();
            String job = formData.get("JOB").toString();
            String telNumber = formData.get("TEL_NUMBER").toString();
            String email = formData.get("EMAIL").toString();
            String qqNum = formData.get("QQ_NUM").toString();
            String projectType = formData.get("PROJECT_TYPE").toString();
            String projectName = formData.get("PROJECT_NAME").toString();
            String trade = formData.get("TRADE").toString();
            String materialScope = formData.get("MATERIAL_SCOPE").toString();
            String materialPurpose = formData.get("MATERIAL_PURPOSE").toString();
 
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String applyDate = sdf.format(new Date());
 
 
            //登录名为身份证号,唯一性
            user.setUserName(cardId);
            String pwd = cardId.substring(cardId.length() - 6, cardId.length());
            String md5Pwd = EncryptUtil.getInstance().MD5(pwd);
            //默认取身份证后六位作为密码
            user.setPassword(md5Pwd);
            user.setTrueName(userName);
 
            Byte enableLogin = 1;
            user.setEnableLogin(enableLogin);
            user.setUserType(1);
            user.setMobilePhone(mobile);
            user.setCreateTime(new Date());
            //用户设置为外部用户
            LambdaQueryWrapper<Dept> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(Dept::getDeptName, "外部用户");
            Dept dept = deptService.getOne(wrapper);
            user.setDeptId(dept.getDeptId());
            user.setDeptName("外部用户");
 
            //插入系统用户表
            userService.saveUser(user);
            Long userId = user.getUserId();
 
            //初始化用户默认角色
            List<Role> roles = roleService.addUserToDefaultRole(user.getUserId());
            if (roles != null && roles.size() > 0) {
                for (Role role : roles) {
                    LogUtils.insertLog("角色管理", OperateType.安全操作_新增.toString(), "增加角色内用户", "增加角色【" + role.getRoleName() + "】内用户:" + user.getTrueAndUserName(), "", request);
                }
            }
            //插入利用用户表
            long id = IdGenerater.getId();
            HashMap<String, Object> mapData = new HashMap<>();
            mapData.put("ID", id);
            mapData.put("ENABLE_LOGIN", enableLogin);
            mapData.put("PASSWORD", pwd);
            mapData.put("USER_NAME", userName);
            mapData.put("SEX", sex);
            mapData.put("ID_CARD", cardId);
            mapData.put("PROVINCE", province);
            mapData.put("CITY", city);
            mapData.put("DEPT", deptNames);
            mapData.put("POST_CODE", postCode);
            mapData.put("DEPT_ADDRESS", deptAddress);
            mapData.put("MOBILE", mobile);
            mapData.put("TEL_NUMBER", telNumber);
            mapData.put("EMAIL", email);
            mapData.put("QQ_NUM", qqNum);
            mapData.put("PROJECT_TYPE", projectType);
            mapData.put("MATERIAL_SCOPE", materialScope);
            mapData.put("MATERIAL_PURPOSE", materialPurpose);
            mapData.put("JOB", job);
            mapData.put("PROJECT_NAME", projectName);
            mapData.put("DEPT_NATURE", deptNature);
            mapData.put("TRADE", trade);
            mapData.put("CERTIFICATE_NUMBER", certificateNumber);
            mapData.put("USER_ID", userId);
            mapData.put("APPLY_DATE", applyDate);
            mapData.put("LOGIN_NAME", cardId);
            iform.insert(1826177548856377345L, mapData);
 
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error("添加注册用户出错", e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    /**
     * 验收是否已经进行了登记
     *
     * @param userId
     * @return
     */
    @RequestMapping({"/getCheckUserInfo"})
    @ResponseBody
    public Object getCheckUserInfo(String userId) {
        try {
            QueryWrapper<UserCheck> userCheckQueryWrapper = new QueryWrapper<>();
            userCheckQueryWrapper.eq("UTILIZATION_USER_ID", userId);
            userCheckQueryWrapper.ge("VALID_END", new Date());
            int count = userCheckService.count(userCheckQueryWrapper);
            if (count > 0) {
                return new AjaxResponse("该用户已经进行了登记");
            }
            UtilizationUser utilizationUser = utilizationUserService.getById(userId);
            return new AjaxResponse(utilizationUser);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
//    /**
//     * 到馆登记
//     *
//     * @param formData
//     * @param utilizationUserId
//     * @return
//     */
//    @RequestMapping({"/saveCheckUserInfo"})
//    @ResponseBody
//    public Object saveCheckUserInfo(@RequestBody Map<String, Object> formData, String utilizationUserId) {
//        try {
//            UserCheck userCheck = new UserCheck();
//            String userName = formData.get("USER_NAME").toString();
//            String cardId = formData.get("CARD_ID").toString();
//            String deptName = formData.get("DEPT_NAME").toString();
//            String deptNature = formData.get("DEPT_NATURE").toString();
//            String projectName = formData.get("PROJECT_NAME").toString();
//            String projectType = formData.get("PROJECT_TYPE").toString();
//            String borrowUser = formData.get("BORROW_USER").toString();
//            String materialScope = formData.get("MATERIAL_SCOPE").toString();
//            String purpose = formData.get("PURPOSE").toString();
//            String certificateNum = formData.get("CERTIFICATE_NUM").toString();
//            String validStart = formData.get("VALID_START").toString();
//            String validEnd = formData.get("VALID_END").toString();
//            String operatorName = formData.get("OPERATOR_NAME").toString();
//            String userId = formData.get("USER_ID").toString();
//            String loginName = formData.get("LOGIN_NAME").toString();
//
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            userCheck.setUserName(userName);
//            userCheck.setUtilizationUserId(Long.parseLong(utilizationUserId));
//            userCheck.setUserId(Long.parseLong(userId));
//            userCheck.setCardId(cardId);
//            userCheck.setDeptName(deptName);
//            userCheck.setDeptNature(deptNature);
//            userCheck.setProjectName(projectName);
//            userCheck.setProjectType(projectType);
//            userCheck.setBorrowUser(borrowUser);
//            userCheck.setMaterialScope(materialScope);
//            userCheck.setPurpose(purpose);
//            userCheck.setCertificateNum(certificateNum);
//            userCheck.setValidStart(sdf.parse(validStart));
//            userCheck.setValidEnd(sdf.parse(validEnd));
//            userCheck.setOperatorName(operatorName);
//            userCheck.setRegisterDate(new Date());
//            userCheck.setLoginName(loginName);
//            userCheckService.saveOrUpdate(userCheck);
//            return new AjaxResponse(userCheck);
//        } catch (Exception e) {
//            logger.error(e.getMessage(), e);
//            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
//        }
//    }
 
//    /**
//     * 验证是否在有效期内
//     *
//     * @param userName
//     * @return
//     */
//    @RequestMapping({"/userVerify"})
//    @ResponseBody
//    public Object userVerify(@RequestBody String userName) {
//        try {
//            User userByName = userService.getUserByName(userName);
//            String deptName = userByName.getDeptName();
//            if (deptName != null && "外部用户".equals(deptName)) {
//                Date tomorrow = new Date();
//                Calendar calendar = Calendar.getInstance();
//                calendar.setTime(tomorrow);
//                calendar.add(Calendar.DAY_OF_YEAR, -1); // 加一天
//                tomorrow = calendar.getTime();
//                QueryWrapper<UserCheck> userCheckQueryWrapper = new QueryWrapper<>();
//                userCheckQueryWrapper.eq("USER_ID", userByName.getUserId());
//                userCheckQueryWrapper.ge("VALID_END", tomorrow);
//                int count = userCheckService.count(userCheckQueryWrapper);
//                if (count == 0) {
//                    return new AjaxResponse(new ErrorInfo("该用户尚未登记登记"), false);
//                }
//
//            }
//            return new AjaxResponse(true);
//        } catch (Exception e) {
//            logger.error(e.getMessage(), e);
//            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
//        }
//
//    }
 
    /**
     * 满意度调查页面
     *
     * @return
     * @throws LicenseException
     */
    @RequestMapping(value = "/userQuestion")
    public Object userQuestion() {
        ModelAndView mav = new ModelAndView("hn/utilizationUser/userQuestion");
        return mav;
    }
 
 
}