fei
2025-11-17 131cd265f4711691fe22ff50c44f523c65cd7022
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
package com.ruoyi.web.controller.archive;
 
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
 
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelExp;
import com.ruoyi.common.utils.poi.ExcelUtilManySheetFour;
import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond;
import com.ruoyi.domain.ArchiveRecords;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.*;
import com.ruoyi.framework.config.ServerConfig;
import com.ruoyi.service.IArchiveRecordsService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.service.impl.BarcodeService;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
 
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
 
import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
 
/**
 * 档案记录Controller
 * 
 * @author ruoyi
 * @date 2025-07-12
 */
@RestController
@RequestMapping("/system/records")
public class ArchiveRecordsController extends BaseController
{
    @Autowired
    private IArchiveRecordsService archiveRecordsService;
    @Autowired
    private BarcodeService barcodeService;
 
    @Autowired
    private IDocumentMaterialsService iDocumentMaterialsService;
    /**
     * 查询档案完成情况
     */
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @GetMapping("/analysisRes")
    public AjaxResult analysis()
    {
        System.out.println("009099");
        return new AjaxResult(200, "查询成功", archiveRecordsService.statisticAya());
    }
 
    @PreAuthorize("@ss.hasPermi('system:records:export')")
    @Log(title = "档案分析结果导出", businessType = BusinessType.EXPORT)
    @PostMapping("/exportAllStatis")
    public void exportAllStatis(HttpServletResponse response)
    {
        List<AnalysisResult> list = archiveRecordsService.statisticAya();
        ExcelUtil<AnalysisResult> util = new ExcelUtil<AnalysisResult>(AnalysisResult.class);
        util.exportExcel(response, list, "档案分析结果");
    }
 
    /**
     * 查询档案记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @GetMapping("/list")
    public AjaxResult list(ArchiveRecords archiveRecords)
    {
 
        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
        return archiveRecordsService.selectDataList(archiveRecords, pageNum, pageSize);
 
    }
    /**
     * 拿到最大id
     */
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @GetMapping("/getMaxId")
    public AjaxResult getMaxId()
    {
        return success(archiveRecordsService.getMaxId()+1);
    }
    /**
     * 导出档案记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:records:export')")
    @Log(title = "档案记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveRecords archiveRecords, @RequestParam(value = "ids", required = false) Long[] ids)
    {
        List<ArchiveRecords> list;
        System.out.println(ids);
        // 如果提供了ids参数,则根据ids导出指定记录
        if (ids != null && ids.length > 0) {
            list = archiveRecordsService.selectArchiveRecordsByIds(ids);
        } else {
            // 否则根据查询条件导出
            list = archiveRecordsService.selectArchiveRecordsList(archiveRecords);
        }
        ExcelUtil<ArchiveRecords> util = new ExcelUtil<ArchiveRecords>(ArchiveRecords.class);
        util.exportExcel(response, list, "档案记录数据");
    }
 
    /**
     * 获取档案记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
 
        ArchiveRecords records = archiveRecordsService.selectArchiveRecordsById(id);
        if(records!=null)
            return new AjaxResult(200, "查询成功", records);
        else
            return new AjaxResult(201, "查询失败!");
    }
 
    /**
     * 新增档案记录
     */
    @PreAuthorize("@ss.hasPermi('system:records:add')")
    @Log(title = "档案记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveRecords archiveRecords)
    {
        int res = archiveRecordsService.insertArchiveRecords(archiveRecords);
        System.out.println(res);
        if(res==0) {
            System.out.println(res);
 
            return new AjaxResult(0, "档案号已经存在了!");
        }
        else
            return new AjaxResult(200, "添加成功了!");
 
 
    }
 
    /**
     * 修改档案记录
     */
    @PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "档案记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveRecords archiveRecords)
    {
        return toAjax(archiveRecordsService.updateArchiveRecords(archiveRecords));
    }
    @PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "档案记录", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/updateSByIds")
    public AjaxResult updateStatusByIds(@RequestBody Long[] ids)
    {
        System.out.println(ids);
        System.out.println("090sdfsdf");
        return new AjaxResult(0, archiveRecordsService.updateStatusByIds(ids)+"");
    }
    /**
     * 删除档案记录
     */
    @PreAuthorize("@ss.hasPermi('system:records:remove')")
    @Log(title = "档案记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(archiveRecordsService.deleteArchiveRecordsByIds(ids));
    }
    @PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "档案记录导入", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
    {
        return archiveRecordsService.importExcel(file);
    }
 
 
    @PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "修改状态", businessType = BusinessType.IMPORT)
    @GetMapping(value = "/updateStatusById/{status}/{id}")
    public AjaxResult updateStatusById(@PathVariable("status") String status,@PathVariable("id") String id)
    {
        return new AjaxResult(200, archiveRecordsService.updateArchiveById(status, Long.parseLong(id))+"");
    }
 
 
 
    @PostMapping("/model")
    public void getExportModel(HttpServletResponse response){
        List<ArchiveRecordModelExp> list = Collections.singletonList(new ArchiveRecordModelExp());
        ExcelUtil<ArchiveRecordModelExp> util = new ExcelUtil<>(ArchiveRecordModelExp.class);
        util.exportExcel(response,list,"档案信息导入模板");
    }
 
 
    @PostMapping("/modelOther")
    public void getExportModelOther(HttpServletResponse response){
        List<ArchiveRecordModelOther> list = Collections.singletonList(new ArchiveRecordModelOther());
        ExcelUtil<ArchiveRecordModelOther> util = new ExcelUtil<>(ArchiveRecordModelOther.class);
        util.exportExcel(response,list,"档案信息导入模板");
    }
 
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @Log(title = "是否允许提交", businessType = BusinessType.IMPORT)
    @GetMapping(value = "/whether/{recordId}")
    public AjaxResult whether(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success( archiveRecordsService.whether(recordId));
    }
 
    @PostMapping(value={"/recordFileList/{includeQrCode}/{selectedSignatures}/{selectedAnnotations}", "/recordFileList/{includeQrCode}", "/recordFileList/{includeQrCode}/{selectedSignatures}","/recordFileList/{includeQrCode}/{selectedAnnotations}"})
    //导出excle
    public void getSpecialArchiveInfo(HttpServletResponse response, @RequestParam("recordId")Long recordId, @PathVariable(name = "includeQrCode",required = false) boolean includeQrCode, @PathVariable(name = "selectedSignatures",required = false) int[] selectedSignatures, @PathVariable(name = "selectedAnnotations",required = false) int[] selectedAnnotations) throws IOException {
        System.out.println("uuuuuuuuuuuuuuuuuuusssss88888888888888");
//        System.out.println(selectedSignatures[0]);
//        System.out.println(selectedAnnotations[0]);
        System.out.println(includeQrCode);
        //二维码是否生成
        String code = "2024050000029250";
        byte [] bt = barcodeService.generateBarcodeImage(code);
        //签名选择
        String [] sig = {"业务科室移交人:","审批科移交人:","档案整理公司:"};
        List<String> arrLis = new ArrayList<>();
        if(selectedSignatures!=null){
            for(int si: selectedSignatures)
            {
                arrLis.add(sig[si]);
            }
        }
        //注选择
        String [] ann = { "本清单由档案形成部门完成",
                "文件类型必须录入,包括结论材料、过程材料、申请材料,其他材料",
                "公开属性必须录入,主动公开、依申请公开、免予公开",
                "保管期限:30年或永久",
                "页号按照正式录入页码为准"};
        List<String> arrAn = new ArrayList<>();
        if(selectedAnnotations!=null) {
            for (int ar : selectedAnnotations) {
                arrAn.add(ann[ar]);
            }
        }
        List<DocumentMaterialsFileList> arsi = new ArrayList<>();
//        DocumentMaterials documentMaterials = new DocumentMaterials();
//        documentMaterials.setRecordId(recordId);
        List<DocumentMaterialsFileList> lst = iDocumentMaterialsService.selectDocumentMaterialsFileList(recordId);
 
 
 
        // 复制属性到SmallObject列表
        for (DocumentMaterialsFileList bigObject : lst) {
            DocumentMaterialsFileList smallObject = new DocumentMaterialsFileList();
            BeanUtil.copyProperties(bigObject, smallObject); // 复制属性
            arsi.add(smallObject);
        }
 
      //  arsi.add(aIV);
        ExcelExp e3 = new ExcelExp("文件材料移交目录清单",arsi, DocumentMaterialsFileList.class);
       // ExcelExp e4 = new ExcelExp("案卷封面",  arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
        List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>();
        mysheet1.add(e3);
       // mysheet1.add(e4);
        //ByteOutputStream bos2 = new ByteOutputStream();
        ExcelUtilManySheetFour<List<ExcelExp>> util3 = new ExcelUtilManySheetFour<List<ExcelExp>>(mysheet1);
 
 
        //拿到caseTitle和inquiryNumber
        String inquiryNumber = "";
        String caseTitle = "";
        if(!arsi.isEmpty())
        {
            inquiryNumber = arsi.get(0).getInquiryNumber();
            caseTitle = arsi.get(0).getCaseTitle();
        }
        util3.exportExcelManySheet(response, mysheet1, includeQrCode,bt, arrLis, arrAn, inquiryNumber, caseTitle);
    }
}