多单位版国产化地质资料管理系统
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
package com.zbooksoft.gdmis.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruili.wcp.common.CustomConfigUtil;
import com.ruili.wcp.data.entity.config.Module;
import com.ruili.wcp.data.entity.management.*;
import com.ruili.wcp.engine.flow.HistoryService;
import com.ruili.wcp.engine.flow.RuntimeService;
import com.ruili.wcp.engine.flow.TaskService;
import com.ruili.wcp.service.config.ModuleService;
import com.ruili.wcp.web.common.UserFriendlyException;
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.ruili.wcp.web.model.easyui.DataTableVO;
import com.ruili.wcp.web.model.easyui.PagedSortedAndFilteredInputDto;
import com.zbooksoft.gdmis.config.ArchivesCustomConfig;
import com.zbooksoft.gdmis.data.entity.CatSwajxx;
import com.zbooksoft.gdmis.data.entity.PhysicalDetail;
import com.zbooksoft.gdmis.data.entity.PhysicalForm;
import com.zbooksoft.gdmis.data.entity.UtilizationUser;
import com.zbooksoft.gdmis.data.vo.ParentPhysicalInfo;
import com.zbooksoft.gdmis.data.vo.PhysicalInfo;
import com.zbooksoft.gdmis.service.*;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.apache.shiro.session.InvalidSessionException;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
 
 
/**
 * @Description: 加工、借阅、实物利用管理
 * @Author: zhai
 * @Date: 2024/8/28
 **/
 
@Controller
@RequestMapping("/physical")
public class PhysicalController {
    @Autowired
    CatAjjxxService catAjjxxService;
    @Autowired
    CatSwajxxService catSwajxxService;
    @Autowired
    CatCgwjxxService catCgwjxxService;
    @Autowired
    CatYswjxxService catYswjxxService;
    @Autowired
    PhysicalDetailService physicalDetailService;
    @Autowired
    PhysicalFormService physicalFormService;
    @Autowired
    RuntimeService runtimeService;
    @Autowired
    TaskService taskService;
    @Autowired
    CustomConfigUtil customConfigUtil;
    @Autowired
    ModuleService moduleService;
    @Autowired
    HistoryService historyService;
    @Autowired
    UtilizationUserService utilizationUserService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    private static final Logger logger = LoggerFactory.getLogger(PhysicalController.class);
 
 
    @RequestMapping({"/addPhysicalDetail"})
    @ResponseBody
    @RequiresUser
    public AjaxResponse addPhysicalDetail(String keyId) {
        try {
            Subject currentUser = SecurityUtils.getSubject();
            Session session = currentUser.getSession();
            User user = (User) session.getAttribute("user");
 
            Map<String, Object> resultMap = new HashMap<>();
            QueryWrapper<PhysicalDetail> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("form_id", 0);
            queryWrapper.eq("create_user_id", user.getUserId());
            int itemCount = physicalDetailService.count(queryWrapper);
            queryWrapper.eq("file_id", keyId);
            List<PhysicalDetail> physicalDetailList = physicalDetailService.list(queryWrapper);
            if (physicalDetailList.size() == 0) {
                CatSwajxx catSwajxx = catSwajxxService.getById(keyId);
                Integer swajxxCount = physicalDetailService.setSwajxx(catSwajxx);
                resultMap.put("addNum", 1);
                resultMap.put("repeatNum", 0);
                resultMap.put("existItemNum", itemCount + swajxxCount);
            } else {
                resultMap.put("addNum", 0);
                resultMap.put("repeatNum", 1);
                resultMap.put("existItemNum", itemCount);
            }
            String strSql = "select distinct file_id from UTL_PHYSICAL_DETAIL  where form_id=0 and create_user_id=" + user.getUserId();
            List<Map<String, Object>> parentMapList = jdbcTemplate.queryForList(strSql);
            resultMap.put("existFileNum", parentMapList.size());
            AjaxResponse ajaxResponse = new AjaxResponse(true);
            if (resultMap != null) {
                StringBuilder sb = new StringBuilder();
                sb.append("top.layer.open({");
                sb.append("   title : '提示',");
                sb.append("   type : 2,");
                sb.append("   area : [ '700px', '220px' ],");
                sb.append("   fixed : true, ");
                sb.append("   content : 'common/commonTips?addNum=" + resultMap.get("addNum") + "&type=实物利用&repeatNum=" + resultMap.get("repeatNum") + "&existFileNum=" + resultMap.get("existFileNum") + "&existItemNum=" + resultMap.get("existItemNum") + "&urlPath=physical'");
                sb.append("});");
                Map<String, String> result = new HashMap<String, String>();
                result.put("jsExpression", sb.toString());
                ajaxResponse.setResult(result);
            }
            return ajaxResponse;
        } catch (InvalidSessionException e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    /**
     * 资料借阅申请首页
     *
     * @return
     */
    @RequestMapping(value = {"", "index"})
    @RequiresUser
    public ModelAndView index() {
        Subject currentUser = SecurityUtils.getSubject();
        Session session = currentUser.getSession();
        User user = (User) session.getAttribute("user");
        List<PhysicalInfo> physicalInfoList = new ArrayList<>();
        List<PhysicalDetail> allPhysicalDetailList = new ArrayList<>();
        if (user != null) {
            List<ParentPhysicalInfo> parentPhysicalInfoList = physicalDetailService.selectDistinctParentPhysicalInfo(user.getUserId());
            // 通过distinct获取案卷
            for (ParentPhysicalInfo parentPhysicalInfo : parentPhysicalInfoList) {
                QueryWrapper<PhysicalDetail> queryWrapper = new QueryWrapper<>();
                queryWrapper.eq("form_id", 0).eq("create_user_id", user.getUserId()).eq("file_id", parentPhysicalInfo.getFileId());
                queryWrapper.orderByAsc("sample_num");
                List<PhysicalDetail> physicalDetailList = physicalDetailService.list(queryWrapper);
                PhysicalInfo physicalInfo = new PhysicalInfo();
                physicalInfo.setParentPhysicalInfo(parentPhysicalInfo);
                physicalInfo.setPhysicalDetailList(physicalDetailList);
                physicalInfoList.add(physicalInfo);
                allPhysicalDetailList.addAll(physicalDetailList);
            }
        }
        ModelAndView mav = new ModelAndView("gh/physical/index");
        mav.addObject("curUserId", user.getUserId());
        mav.addObject("curUserName", user.getTrueName());
        mav.addObject("curUserTel", user.getMobilePhone());
        mav.addObject("curDeptName", user.getDeptName());
        mav.addObject("curDeptId", user.getDeptId());
 
        mav.addObject("physicalInfoList", physicalInfoList);
        mav.addObject("allPhysicalDetailList", allPhysicalDetailList);
        return mav;
    }
 
    /**
     * 保存明细信息
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/savePhysicalDetail", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    @RequiresUser
    public Object savePhysicalDetail(Long formId, @RequestBody ArrayList<PhysicalDetail> physicalDetailList) {
        try {
            physicalDetailService.saveOrUpdateBatch(physicalDetailList);
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    /**
     * 保存申请单信息
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/savePhysicalForm", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    @RequiresUser
    public Object savePhysicalForm(@RequestBody PhysicalForm physicalForm) {
        try {
 
            Subject currentUser = SecurityUtils.getSubject();
            Session session = currentUser.getSession();
            User user = (User) session.getAttribute("user");
            physicalForm.setCreateUserId(user.getUserId());
            physicalForm.setCreateUserName(user.getTrueName());
            physicalForm.setCreateTime(new Date());
 
            // 生成利用单编号
            Date date = new Date();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
            String preNum = dateFormat.format(date);
            String maxApplyCode = physicalFormService.selectMaxApplyCode(preNum);
            String applyCode = preNum + "0001";
            if (StringUtils.isNotEmpty(maxApplyCode)) {
                Integer newApplyCode = Integer.parseInt(maxApplyCode) + 1;
                applyCode = newApplyCode.toString();
            }
            physicalForm.setApplyCode(applyCode);
            physicalForm.setFlowState(0);
            physicalForm.setState(0);
            physicalForm.setPhysicalDate(new Date());
            physicalFormService.saveOrUpdate(physicalForm);
            QueryWrapper<PhysicalDetail> query = new QueryWrapper<>();
            query.eq("form_id", 0).eq("survey", 0).eq("sampling", 0).eq("create_user_id", user.getUserId());
            physicalDetailService.remove(query);
            // 修改明细表formid
            QueryWrapper<PhysicalDetail> updateWrapper = new QueryWrapper<>();
            updateWrapper.eq("form_id", 0).eq("create_user_id", user.getUserId());
            PhysicalDetail physicalDetail = new PhysicalDetail();
            physicalDetail.setFormId(physicalForm.getFormId());
 
            physicalDetailService.update(physicalDetail, updateWrapper);
 
            List<ParentPhysicalInfo> parentPhysicalInfos = physicalDetailService.selectDistinctParentPhysicalInfoByFormId(physicalForm.getFormId());
            physicalForm.setFileCount(parentPhysicalInfos.size());
            QueryWrapper<PhysicalDetail> wrapper = new QueryWrapper<>();
            wrapper.eq("form_id", physicalForm.getFormId());
            int count = physicalDetailService.count(wrapper);
            physicalForm.setItemCount(count);
            physicalFormService.saveOrUpdate(physicalForm);
 
            // 生成流程信息
            Long moduleId = 1834402236946464769L;
            Long tableId = 1834404937772056577L;
            Long keyId = physicalForm.getFormId();
 
            Long processDefinitionId = 1834468968411238402L;
            String businessViewUrl = "physical/physicalForm?formId=" + keyId;
 
            Map<String, Object> dataMap = new HashMap<String, Object>();
            dataMap.put("applyCode", physicalForm.getApplyCode());
            dataMap.put("createTime", physicalForm.getCreateTime());
            dataMap.put("createUserId", physicalForm.getCreateUserId());
            dataMap.put("formId", physicalForm.getFormId());
            dataMap.put("remark", physicalForm.getRemark());
            FlowRuntimeExecution processInstance = runtimeService.startProcessInstanceById(processDefinitionId, moduleId, tableId, keyId, user.getUserId(), user.getTrueName(), businessViewUrl, dataMap);
            // 完成第一步
            List<FlowRuntimeTask> taskList = taskService.getTaskByProcessInstanceId(processInstance.getProcessInstanceId());
            if (taskList != null && taskList.size() > 0) {
                for (FlowRuntimeTask task : taskList) {
                    taskService.complete(task.getTaskId(), "", null, dataMap, null);
                }
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
 
    /**
     * 档案利用申请单审核
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/physicalForm")
    @RequiresUser
    public ModelAndView physicalForm(Long formId, Long processInstanceId, Long taskId, HttpServletRequest request, HttpServletResponse response) throws Exception {
        ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
        ModelAndView mav = new ModelAndView("gh/physical/physicalForm");
        PhysicalForm physicalForm = physicalFormService.getById(formId);
        List<PhysicalInfo> physicalInfoList = new ArrayList<>();
        List<ParentPhysicalInfo> parentPhysicalInfoList = physicalDetailService.selectDistinctParentPhysicalInfoByFormId(formId);
        List<PhysicalDetail> allPhysicalDetailList = new ArrayList<>();
        if (physicalForm == null) {
            throw new UserFriendlyException("申请单不存在", "申请单已被删除,无法打开!");
        }
        // 通过distinct获取案卷
        for (ParentPhysicalInfo parentPhysicalInfo : parentPhysicalInfoList) {
            QueryWrapper<PhysicalDetail> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("form_id", formId).eq("file_id", parentPhysicalInfo.getFileId());
            queryWrapper.orderByAsc("item_number");
            List<PhysicalDetail> physicalDetailList = physicalDetailService.list(queryWrapper);
            PhysicalInfo physicalInfo = new PhysicalInfo();
            physicalInfo.setParentPhysicalInfo(parentPhysicalInfo);
            physicalInfo.setPhysicalDetailList(physicalDetailList);
            physicalInfoList.add(physicalInfo);
            allPhysicalDetailList.addAll(physicalDetailList);
        }
 
        // 获取利用单模块
        QueryWrapper<Module> physicalFormWrapper = new QueryWrapper<Module>();
        physicalFormWrapper.eq("module_identify", "physicalForm");
        Module physicalFormModule = moduleService.getOne(physicalFormWrapper);
 
        mav.addObject("physicalFormModule", physicalFormModule);
        mav.addObject("physicalInfoList", physicalInfoList);
        mav.addObject("allPhysicalDetailList", allPhysicalDetailList);
 
        mav.addObject("physicalForm", physicalForm);
        mav.addObject("archivesCustomConfig", archivesCustomConfig);
        // 处理流程信息
        Subject currentUser = SecurityUtils.getSubject();
        Session session = currentUser.getSession();
        User user = (User) session.getAttribute("user");
 
        Long moduleId = 1834402236946464769L;
        Long tableId = 1834404937772056577L;
 
        FlowRuntimeTask task = null;
        FlowHistoryProcess historyProcess = null;
 
        if (taskId != null) {
            task = taskService.getTaskById(taskId);
 
            if (task != null) {
                processInstanceId = task.getProcessInstanceId();
                mav.addObject("task", task);
                mav.addObject("processInstanceId", processInstanceId);
                mav.addObject("isEnd", false);
 
            } else {
                // 查找是否有历史任务记录
                FlowHistoryTask historyTask = historyService.getHistoryTaskById(taskId);
                if (historyTask != null) {
                    processInstanceId = historyTask.getProcessInstanceId();
                } else {
 
                }
            }
        }
 
        // 查找流程是否已经结束
        if (processInstanceId != null) {
            historyProcess = historyService.getHistoryProcessByProcessInstanceId(processInstanceId);
        } else if (moduleId != null && tableId != null && formId != null) {
            historyProcess = historyService.getHistoryProcessByBusinessInfo(moduleId, tableId, formId);
        }
 
        if (historyProcess != null) {
            processInstanceId = historyProcess.getProcessInstanceId();
            mav.addObject("processInstanceId", processInstanceId);
 
            // 如果流程已经结束
            if (historyProcess.getEndTime() != null) {
 
                mav.addObject("isEnd", true);
            } else {
                mav.addObject("isEnd", false);
                // 查找是否为自己待办
                List<FlowRuntimeTask> taskList = taskService.findTasksByProcessInstanceIdAndUserId(user.getUserId(), historyProcess.getProcessInstanceId());
                if (taskList != null && taskList.size() > 0) {
                    mav.addObject("task", taskList.get(0));
                    mav.addObject("isEnd", false);
                }
            }
        } else {
//            throw new UserFriendlyException("找不到流程实例", "流程实例不存在或已完成!");
        }
 
        // 读取流程历史信息
        if (task != null || historyProcess != null) {
            List<FlowHistoryTask> historyTaskList = historyService.getFlowHistoryTaskByProcessInstanceId(processInstanceId);
            mav.addObject("historyTaskList", historyTaskList);
        }
//
//        String utilizeApprovePermission = "BusinessManage.ArchivesUtilizationForm.UtilizeApprove";
//        boolean permitted = currentUser.isPermitted(utilizeApprovePermission);
 
//        mav.addObject("approvePermission", currentUser.isPermitted(utilizeApprovePermission));
        mav.addObject("approvePermission", true);
 
        return mav;
    }
 
 
    /**
     * 我的借阅单首页
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/myPhysicalFormIndex")
    @RequiresUser
    public ModelAndView myPhysicalFormIndex(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView mav = new ModelAndView("gh/physical/myPhysicalFormIndex");
        return mav;
    }
 
 
    /**
     * 分页获取我的利用申请列表
     *
     * @param
     * @param pageInput
     * @return
     */
    @RequestMapping("/getMyPhysicalFormList")
    @ResponseBody
    @RequiresUser
    public Object getMyPhysicalFormList(Integer flowState, PagedSortedAndFilteredInputDto pageInput) {
        Subject currentUser = SecurityUtils.getSubject();
        Session session = currentUser.getSession();
        User user = (User) session.getAttribute("user");
        QueryWrapper<PhysicalForm> query = new QueryWrapper<>();
        if (flowState != null && flowState != -2) {
            query.eq("flow_state", flowState);
        }
 
        query.nested(qy -> qy.eq("create_user_id", user.getUserId()).or().eq("apply_user_id", user.getUserId()));
 
        IPage<PhysicalForm> utilizationFormIPage;
        String searchText = pageInput.getSearchText();
        if (searchText != null && searchText != "") {
            query.nested(i -> i.like("apply_code", searchText).or().like("borrow_apply_user_name", searchText));
        }
        String sort = pageInput.getSort();
        String order = pageInput.getOrder();
        if (sort != null && sort != "") {
            query.orderBy(true, !order.equals("desc"), "apply_code");
        }
        DataTableVO<PhysicalForm> dto = new DataTableVO<>();
        if (pageInput.getPage() != 0 && pageInput.getRows() != 0) {
            Page<PhysicalForm> page = new Page<>(pageInput.getPage(), pageInput.getRows());
            utilizationFormIPage = physicalFormService.page(page, query);
            dto.setTotal(utilizationFormIPage.getTotal());
            dto.setRows(utilizationFormIPage.getRecords());
        } else {
            List<PhysicalForm> utilizationFormList = physicalFormService.list(query);
            dto.setTotal(utilizationFormList.size());
            dto.setRows(utilizationFormList);
        }
        return dto;
    }
 
    /**
     * 删除借阅单
     *
     * @param formIdList
     * @return
     */
    @RequestMapping(value = "/deletePhysicalForm", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    @RequiresUser
    public Object deletePhysicalForm(@RequestBody ArrayList<Long> formIdList) {
        try {
            physicalFormService.removeByIds(formIdList);
            for (Long formId : formIdList) {
                QueryWrapper<PhysicalDetail> query = new QueryWrapper<>();
                query.eq("form_id", formId);
                physicalDetailService.remove(query);
                // 删除流程实例
                runtimeService.deleteProcessInstanceByBusinessInfo(1834402236946464769L, 1834404937772056577L, formId);
            }
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
 
    @RequestMapping(value = "/getBorrowUserInfo", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    @RequiresUser
    public Object getBorrowUserInfo(String userId) {
        try {
            QueryWrapper<UtilizationUser> utilizationUserQueryWrapper = new QueryWrapper<>();
            utilizationUserQueryWrapper.eq("user_id", userId);
            UtilizationUser utilizationUser = utilizationUserService.getOne(utilizationUserQueryWrapper);
            return new AjaxResponse(utilizationUser);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    /**
     * 删除明细信息
     *
     * @param fileId
     * @return
     */
    @RequestMapping(value = "/deletePhysicalDetail", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    @RequiresUser
    public Object deletePhysicalDetail(Long fileId) {
        try {
            QueryWrapper<PhysicalDetail> query = new QueryWrapper<>();
            query.eq("file_id", fileId);
            query.eq("form_id", 0L);
            physicalDetailService.remove(query);
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    /**
     * 人工添加实物利用单
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/addPhysicalForm")
    @RequiresUser
    public ModelAndView addProcessingForm() {
        ModelAndView mav = new ModelAndView("gh/physical/addPhysicalForm");
        Subject currentUser = SecurityUtils.getSubject();
        Session session = currentUser.getSession();
        User user = (User) session.getAttribute("user");
        mav.addObject("curUserId", user.getUserId());
        mav.addObject("curUserName", user.getTrueName());
        mav.addObject("curUserTel", user.getMobilePhone());
        mav.addObject("curDeptName", user.getDeptName());
        mav.addObject("curDeptId", user.getDeptId());
        return mav;
    }
 
    /**
     * 分页获取人工添加明细列表
     *
     * @param
     * @param pageInput
     * @return
     */
    @RequestMapping("/getPhysicalDetailListByPeople")
    @ResponseBody
    @RequiresUser
    public Object getPhysicalDetailListByPeople(PagedSortedAndFilteredInputDto pageInput, Long formId) {
        Subject currentUser = SecurityUtils.getSubject();
        Session session = currentUser.getSession();
        User user = (User) session.getAttribute("user");
        QueryWrapper<PhysicalDetail> query = new QueryWrapper<>();
        if (formId != null && formId > 0) {
            query.eq("form_id", formId);
        } else if (formId != null && formId < 0) {
            query.gt("form_id", 0);
        } else {
            query.eq("form_id", 0).eq("create_user_id", user.getUserId());
        }
        query.eq("file_title", "人工添加");
        List<PhysicalDetail> list = physicalDetailService.list(query);
        return list;
    }
 
    /**
     * 删除明细信息通过明细id
     *
     * @param detailId
     * @return
     */
    @RequestMapping(value = "/deletePhysicalDetailById", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    @RequiresUser
    public Object deletePhysicalDetailById(Long detailId) {
        try {
            physicalDetailService.removeById(detailId);
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
}