Kaynağa Gözat

临时性人员选择

ly 11 ay önce
ebeveyn
işleme
7f0e4fe060

+ 99 - 7
src/main/java/com/liang/controller/LsUserController.java

@@ -10,22 +10,27 @@ import com.liang.entity.SysLsUserEntity;
10 10
 import com.liang.service.BaseAreaService;
11 11
 import com.liang.service.BaseEducationService;
12 12
 import com.liang.service.LsUserService;
13
+import com.spire.pdf.tables.DataView;
13 14
 import io.swagger.annotations.ApiOperation;
14 15
 import io.swagger.models.auth.In;
15 16
 import org.apache.ibatis.annotations.Delete;
17
+import org.apache.poi.ss.usermodel.CellType;
18
+import org.apache.poi.xssf.usermodel.XSSFCell;
19
+import org.apache.poi.xssf.usermodel.XSSFRow;
20
+import org.apache.poi.xssf.usermodel.XSSFSheet;
21
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
16 22
 import org.springframework.beans.factory.annotation.Autowired;
17 23
 import org.springframework.http.ResponseEntity;
18 24
 import org.springframework.stereotype.Controller;
19 25
 import org.springframework.ui.Model;
20 26
 import org.springframework.web.bind.annotation.*;
27
+import org.springframework.web.multipart.MultipartFile;
21 28
 
22 29
 import javax.annotation.Resource;
23 30
 import javax.xml.transform.Result;
31
+import java.io.IOException;
24 32
 import java.text.SimpleDateFormat;
25
-import java.util.Date;
26
-import java.util.HashMap;
27
-import java.util.List;
28
-import java.util.Map;
33
+import java.util.*;
29 34
 
30 35
 import static com.liang.common.base.BaseController.RESULT_ROWS;
31 36
 import static com.liang.common.base.BaseController.RESULT_TOTAL;
@@ -122,9 +127,6 @@ public class LsUserController {
122 127
     @RequestMapping(value = "/save",method = RequestMethod.POST)
123 128
     @ResponseBody
124 129
     public Object saveOperLog(@RequestBody SysLsUserEntity sysLsUserEntity) {
125
-
126
-
127
-
128 130
         List<SysLsUserEntity> list = lsUserService.getUserxm(sysLsUserEntity.getXm());
129 131
 
130 132
 
@@ -213,6 +215,96 @@ public class LsUserController {
213 215
         return BaseResult.failure("没有需要导出的数据");
214 216
 
215 217
     }
218
+    @RequestMapping("/excelImportStudent")
219
+    @ResponseBody
220
+    public BaseResult excelImportStudent(@RequestParam("file") MultipartFile file) {
221
+
222
+
223
+        // 文件不能为空
224
+        if (file.isEmpty()) {
225
+
226
+            return BaseResult.failure("文件为空,不能上传");
227
+        }
228
+
229
+        try (XSSFWorkbook wb = new XSSFWorkbook(file.getInputStream())) {
230
+            XSSFSheet sheet = wb.getSheetAt(0);
231
+            List<SysLsUserEntity> list = new ArrayList<>();
232
+
233
+            // 解析数据,装到集合里面
234
+            for (int i = 0; i <= sheet.getLastRowNum(); i++) {
235
+                XSSFRow row = sheet.getRow(i);
236
+                if (row == null) {
237
+                    continue; // 跳过空行
238
+                }
239
+
240
+                SysLsUserEntity student = new SysLsUserEntity();
241
+
242
+                // 确保所有单元格都按字符串处理
243
+                for (int j = 0; j < 6; j++) { // 假设前6列都是字符串类型
244
+                    XSSFCell cell = row.getCell(j);
245
+                    if (cell != null) {
246
+                        cell.setCellType(CellType.STRING);
247
+                        String cellValue = cell.getStringCellValue();
248
+                        switch (j) {
249
+                            case 1:
250
+                                student.setXm(cellValue);
251
+                                break;
252
+                            case 2:
253
+                                student.setXb(cellValue);
254
+                                break;
255
+                            case 3:
256
+                                student.setPhone(cellValue);
257
+                                break;
258
+                            case 4:
259
+                                student.setSfzh(cellValue);
260
+                                break;
261
+                            case 5:
262
+                                student.setXl(cellValue);
263
+                                break;
264
+                            case 6:
265
+                                student.setByxy(cellValue);
266
+                                break;
267
+                            case 8:
268
+                                student.setZy(cellValue);
269
+                                break;
270
+                            case 9:
271
+                                student.setQpsj(cellValue);
272
+                                break;
273
+                            case 10:
274
+                                student.setDqsj(cellValue);
275
+                                break;
276
+                            case 11:
277
+                                student.setGznr(cellValue);
278
+                                break;
279
+                            default:
280
+                                break;
281
+                        }
282
+                    }
283
+                }
284
+/*                // 处理数值类型的学院ID列
285
+                XSSFCell collegeIdCell = row.getCell(6);
286
+                if (collegeIdCell != null) {
287
+                    collegeIdCell.setCellType(CellType.NUMERIC);
288
+                    student.setCollegeId((int) collegeIdCell.getNumericCellValue());
289
+                }*/
290
+
291
+                list.add(student);
292
+            }
293
+
294
+            // 插入数据库
295
+/*            studentService.saveBatch(list);
296
+
297
+            // 设置返回代码和消息
298
+            dataView.setCode(200);
299
+            dataView.setMsg("插入成功");*/
300
+        } catch (IOException e) {
301
+        /*    dataView.setMsg("文件读取错误: " + e.getMessage());*/
302
+        }
303
+
304
+        return BaseResult.success("文件导入成功");
305
+    }
306
+
307
+
216 308
 
217 309
 
218 310
 }

+ 1 - 1
src/main/resources/mapper/StaBudgetapprovalDao.xml

@@ -340,7 +340,7 @@
340 340
             </if>
341 341
             <if test="bhsje != null and bhsje != ''">
342 342
             ,BHSJE = #{bhsje}
343
-            </if>
343
+              </if>
344 344
         where ID = #{id}
345 345
     </update>
346 346
     <!--    修改方法-->

+ 27 - 1
src/main/resources/templates/lsuserinfo/list.html

@@ -69,7 +69,20 @@
69 69
                 <button class="layui-btn layui-btn-sm" lay-event="export" >
70 70
                     <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>全部导出
71 71
                 </button>
72
+                <button class="layui-btn layui-btn-sm" lay-event="download"  style="background-color: purple">
73
+                    <i class="layui-icon layui-icon-download-circle" style="font-size: 10px;"></i>模板下载
74
+                </button>
75
+            </div>
76
+            <!--文件上传的div-->
77
+            <div class="layui-upload-drag" id="excel">
78
+                <i class="layui-icon"></i>
79
+                <p>点击上传,或将文件拖拽到此处</p>
80
+                <div class="layui-hide" id="uploadDemoView">
81
+                    <hr>
82
+                    <img src="" alt="上传成功后渲染" style="max-width: 196px">
83
+                </div>
72 84
             </div>
85
+
73 86
         </script>
74 87
 
75 88
 
@@ -99,7 +112,18 @@
99 112
     layui.use(['form', 'table'], function () {
100 113
         var form = layui.form,
101 114
             table = layui.table,
102
-            layer = layui.layer;
115
+            layer = layui.layer,
116
+            upload = layui.upload;
117
+        upload.render({
118
+            elem: '#excel',
119
+            url:AjaxUtil.ctx +'',
120
+            accept:'file',
121
+            done: function (res) {
122
+                layer.msg(res.msg);
123
+                console.log(res);
124
+                
125
+            }
126
+        });
103 127
 
104 128
         var currTable = table.render({
105 129
             elem: '#currentTableId',
@@ -246,6 +270,8 @@
246 270
                     }
247 271
                 });
248 272
 
273
+            }else if (obj.event === 'download'){
274
+                table.exportFile('currentTableId',' ','xls');
249 275
             }
250 276
         });
251 277
 

+ 49 - 14
src/main/resources/templates/tempmember/add.html

@@ -1,4 +1,3 @@
1
-<!DOCTYPE html>
2 1
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
3 2
 <head>
4 3
     <meta charset="UTF-8">
@@ -20,34 +19,39 @@
20 19
         <div class="layui-form-item layui-inline" style="width: 100%">
21 20
             <label class="layui-form-label required" style="width: 70px">人员姓名</label>
22 21
             <div class="layui-input-inline" style="width: 270px">
23
-                <input type="text" id="xm" name="xm" lay-verify="required" lay-reqtext="人员姓名不能为空" autocomplete="off" class="layui-input">
22
+                <input type="text" id="xm" name="xm"  lay-reqtext="人员姓名不能为空" autocomplete="off" class="layui-input" style="display:none">
23
+                <select name="xms" id="xms" lay-filter="xms" lay-search>
24
+                    <option value="">请选择</option>
25
+                    <option th:each="item:${list}" th:text="${item.xm}" th:value="${item.id}"></option>
26
+                </select>
24 27
             </div>
25
-            <label class="layui-form-label required" style="width: 70px">工作地点</label>
28
+            <label class="layui-form-label required" style="width: 70px">电话</label>
26 29
             <div class="layui-input-inline" style="width: 270px">
27
-                <input type="text" id="gzdd" name="gzdd" lay-verify="required"  autocomplete="off" class="layui-input">
30
+                <input type="text" id="phone" name="phone" lay-verify="required" autocomplete="off" class="layui-input" disabled>
28 31
             </div>
29 32
         </div>
30 33
         <div class="layui-form-item layui-inline" style="width: 100%">
31 34
             <label class="layui-form-label required" style="width: 70px">毕业学校</label>
32 35
             <div class="layui-input-inline" style="width: 270px">
33
-                <input type="text" id="byxx" name="byxx" lay-verify="required" autocomplete="off" class="layui-input">
36
+                <input type="text" id="byxx" name="byxx" lay-verify="required" autocomplete="off" class="layui-input" disabled>
34 37
             </div>
35 38
             <label class="layui-form-label" style="width: 70px">专业</label>
36 39
             <div class="layui-input-inline" style="width: 270px">
37
-                <input type="text" id="zy" name="zy" lay-verify="required" autocomplete="off" class="layui-input">
40
+                <input type="text" id="zy" name="zy" lay-verify="required" autocomplete="off" class="layui-input" disabled>
38 41
             </div>
39 42
         </div>
40 43
         <div class="layui-form-item layui-inline" style="width: 100%">
41 44
             <label class="layui-form-label " style="width: 70px">学历</label>
42 45
             <div class="layui-input-inline" style="width: 270px">
43
-                <select name="xl" id="xl" >
46
+                <input type="text" id="xl" name="xl" lay-verify="required" lay-reqtext="人员姓名不能为空" autocomplete="off" class="layui-input" disabled>
47
+               <!-- <select name="xl" id="xl" >
44 48
                     <option value="">请选择</option>
45 49
                     <option th:each="item:${xlList}" th:text="${item.name}" th:value="${item.name}"></option>
46
-                </select>
50
+                </select>-->
47 51
             </div>
48 52
             <label class="layui-form-label required" style="width: 70px">身份证号</label>
49 53
             <div class="layui-input-inline" style="width: 270px">
50
-                <input type="text" id="sfzh" name="sfzh" lay-verify="required" lay-reqtext="身份证号不能为空" autocomplete="off" class="layui-input" maxlength="18">
54
+                <input type="text" id="sfzh" name="sfzh" lay-verify="required" lay-reqtext="身份证号不能为空" autocomplete="off" class="layui-input" maxlength="18" disabled>
51 55
             </div>
52 56
 <!--            <label class="layui-form-label" style="width: 70px">科研费号</label>-->
53 57
 <!--            <div class="layui-input-inline" style="width: 270px">-->
@@ -74,12 +78,12 @@
74 78
             <div class="layui-form-item layui-inline" style="width: auto">
75 79
                 <div class="layui-input-inline" style="width: 150px">
76 80
                     <input type="text" name="qsrq" id="qsrq" lay-verify="required|date" placeholder="开始日期"
77
-                           lay-reqtext="开始日期不能为空" autocomplete="off" class="layui-input">
81
+                           lay-reqtext="开始日期不能为空" autocomplete="off" class="layui-input" disabled>
78 82
                 </div>
79 83
                 <div class="layui-form-mid">-</div>
80 84
                 <div class="layui-input-inline" style="width: 150px">
81 85
                     <input type="text" name="jsrq" id="jsrq" lay-verify="required|date" placeholder="结束日期"
82
-                           lay-reqtext="结束日期不能为空" autocomplete="off" class="layui-input">
86
+                           lay-reqtext="结束日期不能为空" autocomplete="off" class="layui-input" disabled>
83 87
                 </div>
84 88
                 <br>
85 89
                 <tip>日期格式:yyyy-MM-dd</tip>
@@ -119,7 +123,7 @@
119 123
             laydate = layui.laydate;
120 124
 
121 125
         //日期
122
-        laydate.render({
126
+/*        laydate.render({
123 127
             elem: '#qsrq',
124 128
             value: new Date()
125 129
         });
@@ -135,7 +139,7 @@
135 139
                     }
136 140
                 }
137 141
             }
138
-        });
142
+        });*/
139 143
 
140 144
         //监听学历
141 145
         // form.on('select(xl)', function (data) {
@@ -143,6 +147,36 @@
143 147
             // $("#xlmc").val(text);
144 148
         // });
145 149
 
150
+        // 监听下拉框
151
+        form.on('select(xms)',function (){
152
+            console.log('进来了')
153
+            var  va = document.getElementById('xms').value;
154
+            console.log(va);
155
+          // 根据姓名 id 查询 并赋值
156
+            AjaxUtil.get({
157
+                url: AjaxUtil.ctx + "lsUser/getId/" + va,
158
+                contentType: "application/json",
159
+                data: JSON.stringify(va),
160
+                success: function (res) {
161
+                    console.log(res.data.rows.xm);
162
+
163
+                   $('#byxx').val(res.data.rows.byxy);
164
+                   $('#zy').val(res.data.rows.zy);
165
+                   $('#qsrq').val(res.data.rows.qpsj);
166
+                   $('#jsrq').val(res.data.rows.dqsj);
167
+                   $('#sfzh').val(res.data.rows.sfzh);
168
+                   $('#xl').val(res.data.rows.xl);
169
+                   $('#phone').val(res.data.rows.phone);
170
+                   $('#xm').val(res.data.rows.xm);
171
+
172
+                },
173
+                error: function (error) {
174
+                    layer.alert('服务器睡着了', {icon: 5});
175
+                    console.log(error);
176
+                }
177
+            });
178
+
179
+        });
146 180
         //监听提交
147 181
         form.on('submit(saveBtn)', function (data) {
148 182
             // 获取身份证号
@@ -180,7 +214,6 @@
180 214
                 return false; // 阻止表单提交
181 215
             }
182 216
 
183
-
184 217
             // 如果身份证号和日期范围都合法,执行提交操作
185 218
             parent.setMember(data.field);
186 219
             parent.setUpdateFlag();
@@ -193,6 +226,8 @@
193 226
             parent.layer.close(iframeIndex);
194 227
         });
195 228
     });
229
+
230
+
196 231
 </script>
197 232
 </body>
198 233
 </html>