地质所 沉降监测网建设项目
chenhuan
2024-05-16 0fdd42e318f51f9e3c6581473416af1cca69877f
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
package com.javaweb.platform.controller;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.javaweb.common.annotation.Log;
import com.javaweb.common.config.ServerConfig;
import com.javaweb.common.enums.BusinessType;
import com.javaweb.common.json.JSON;
import com.javaweb.platform.constant.FrontUserStatus;
import com.javaweb.platform.domain.FrontUser;
import com.javaweb.platform.domain.UserMsg;
import com.javaweb.platform.service.IFrontUserService;
import com.javaweb.platform.service.IUserMsgService;
import com.javaweb.platform.utils.ValidcodeUtils;
import com.javaweb.common.core.controller.BaseController;
import com.javaweb.common.core.domain.AjaxResult;
import com.javaweb.common.utils.StringUtils;
import com.javaweb.common.utils.poi.ExcelUtil;
import com.javaweb.common.core.page.TableDataInfo;
 
/**
 * 用户管理Controller
 * 
 * @author zmk
 * @date 2022-03-21
 */
@Controller
@RequestMapping("/platform/frontuser")
public class FrontUserController extends BaseController
{
    private String prefix = "platform/frontuser";
 
    @Autowired
    private IFrontUserService frontUserService;
    
    @Autowired
    private IUserMsgService userMsgService;
    
    @Autowired
    private ValidcodeUtils validcodeUtils;
 
    @RequiresPermissions("platform:frontuser:view")
    @GetMapping()
    public String frontuser()
    {
        return prefix + "/frontuser";
    }
 
    /**
     * 查询用户管理列表
     */
    @RequiresPermissions("platform:frontuser:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FrontUser frontUser)
    {
        startPage();
        List<FrontUser> list = frontUserService.selectFrontUserList(frontUser);
        return getDataTable(list);
    }
 
    /**
     * 导出用户管理列表
     */
    @RequiresPermissions("platform:frontuser:export")
    @Log(title = "用户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FrontUser frontUser)
    {
        List<FrontUser> list = frontUserService.selectFrontUserList(frontUser);
        ExcelUtil<FrontUser> util = new ExcelUtil<FrontUser>(FrontUser.class);
        return util.exportExcel(list, "frontuser");
    }
 
    /**
     * 新增用户管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }
 
    /**
     * 新增保存用户管理
     */
    @RequiresPermissions("platform:frontuser:add")
    @Log(title = "用户管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FrontUser frontUser)
    {
        return toAjax(frontUserService.insertFrontUser(frontUser));
    }
    
    
    @Autowired
    private ServerConfig serverConfig;
 
    /**
     * 修改用户管理
     * @throws Exception 
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) throws Exception
    {
        FrontUser frontUser = frontUserService.selectFrontUserById(id);
        mmap.put("frontUser", frontUser);
        
        List<String> list=new ArrayList<>();
        String files =frontUser.getApplyLicense();      
        if(!StringUtils.isEmpty(files)){
             List<String> fList= JSON.unmarshal(files, List.class);
             for (String str : fList) {
                 String addr = serverConfig.getUrl() + str;
                 list.add(addr);
             }
        }          
        mmap.put("files", list);
        return prefix + "/edit";
    }
 
    /**
     * 修改保存用户管理
     */
    @RequiresPermissions("platform:frontuser:edit")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FrontUser frontUser)
    {
        return toAjax(frontUserService.updateFrontUser(frontUser));
    }
    
    /**
     * 驳回的页面
     * @param mmap
     * @return
     * @throws Exception
     */
    @GetMapping("/reject")
    public String rejct(String id, ModelMap mmap) throws Exception
    {
         FrontUser frontUser = frontUserService.selectFrontUserById(Long.parseLong(id));
         mmap.put("frontUser", frontUser);
         return prefix + "/reject"; 
    }
    
    /**
     * 驳回申请信息保存和发送
     * @param frontUser
     * @return
     * @throws Exception 
     */
    @PostMapping("/rejectSave")
    @ResponseBody
    public AjaxResult rejctSave(FrontUser frontUser) throws Exception
    {
        //更新状态
        frontUser.setStatus(FrontUserStatus.REJECT.getCode());
        frontUserService.updateFrontUser(frontUser);
        
        //保存消息
        FrontUser user =frontUserService.selectFrontUserById(frontUser.getId());     
        UserMsg userMsg = new UserMsg();
        userMsg.setUserName(user.getUserName());
        userMsg.setCreateDate(new Date());
        userMsg.setMsg(frontUser.getRemark());    
        userMsgService.insertUserMsg(userMsg);
        
        //发送短信
        try{
            System.out.println(System.currentTimeMillis());
            validcodeUtils.sendMesgToPhone("4", user.getPhone());
            System.out.println(System.currentTimeMillis());
        }catch(Exception e){
               return AjaxResult.warn("发送短信失败");
        }    
        return AjaxResult.success("已驳回申请,并且发送了短信提醒");
                
    }
    
    /**
     * 审核通过并且发送短信
     * @param ids
     * @return
     */
    @PostMapping("/approve")
    @ResponseBody
    public AjaxResult approve(String ids){
        String [] idArray=ids.split(",");
        for(String id : idArray){
            FrontUser frontUser=new FrontUser();
            frontUser.setId(Integer.valueOf(id).longValue());
            frontUserService.approve(frontUser);        
        }
        for(String id : idArray){
            FrontUser frontUser =frontUserService.selectFrontUserById(Long.parseLong(id));
            UserMsg userMsg = new UserMsg();
            userMsg.setUserName(frontUser.getUserName());
            userMsg.setCreateDate(new Date());
            userMsg.setMsg("您的注册申请审核已通过,欢迎使用平台进行查询服务");
            userMsgService.insertUserMsg(userMsg);
            //发送短信
            try{
                validcodeUtils.sendMesgToPhone("3", frontUser.getPhone());
            }catch(Exception e){
                logger.error(e.toString());
                continue;
            }    
            
        }
        //发送短信
        return AjaxResult.success("账号审核通过,已经发送信息提醒!");
    }
    
 
 
    /**
     * 删除用户管理
     */
    @RequiresPermissions("platform:frontuser:remove")
    @Log(title = "用户管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(frontUserService.deleteFrontUserByIds(ids));
    }
}