Commit 416e1e27f0845715d2f853e7bef70c257477361e
1 parent
106c9657
未检人员删除、源数据管理查看
Showing
14 changed files
with
687 additions
and
162 deletions
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/MinorController.java
... | ... | @@ -3,6 +3,7 @@ package org.jeecg.modules.system.controller; |
3 | 3 | import java.io.OutputStream; |
4 | 4 | import java.io.UnsupportedEncodingException; |
5 | 5 | import java.io.IOException; |
6 | +import java.lang.reflect.Field; | |
6 | 7 | import java.net.URLDecoder; |
7 | 8 | import java.util.*; |
8 | 9 | import java.util.stream.Collectors; |
... | ... | @@ -10,28 +11,44 @@ import java.util.stream.Collectors; |
10 | 11 | import javax.servlet.http.HttpServletRequest; |
11 | 12 | import javax.servlet.http.HttpServletResponse; |
12 | 13 | |
13 | -import org.apache.poi.ss.usermodel.Workbook; | |
14 | +import com.alibaba.fastjson.JSONObject; | |
15 | +import org.apache.commons.lang3.StringUtils; | |
16 | +import org.apache.poi.ss.formula.functions.T; | |
17 | +import org.apache.poi.ss.usermodel.*; | |
14 | 18 | import org.jeecg.modules.system.entity.Family; |
15 | 19 | import org.jeecg.modules.system.entity.Minor; |
20 | +import org.jeecg.modules.system.entity.SysDepart; | |
16 | 21 | import org.jeecg.modules.system.entity.SysUser; |
17 | 22 | import org.jeecg.modules.system.service.IFamilyService; |
18 | 23 | import org.jeecg.modules.system.service.IMinorService; |
24 | +import org.jeecg.modules.system.service.ISysDepartService; | |
25 | +import org.jeecg.modules.system.util.ExcelImportServiceUtil; | |
19 | 26 | import org.jeecg.modules.system.vo.MinorPage; |
20 | 27 | import org.jeecg.modules.system.vo.MinorVo; |
21 | 28 | import org.jeecgframework.poi.excel.ExcelExportUtil; |
22 | 29 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
30 | +import org.jeecgframework.poi.excel.annotation.ExcelTarget; | |
23 | 31 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
24 | 32 | import org.jeecgframework.poi.excel.entity.ExportParams; |
25 | 33 | import org.jeecgframework.poi.excel.entity.ImportParams; |
26 | 34 | import org.jeecgframework.poi.excel.entity.enmus.ExcelType; |
35 | +import org.jeecgframework.poi.excel.entity.params.ExcelCollectionParams; | |
36 | +import org.jeecgframework.poi.excel.entity.params.ExcelImportEntity; | |
37 | +import org.jeecgframework.poi.excel.entity.result.ExcelImportResult; | |
38 | +import org.jeecgframework.poi.excel.imports.ExcelImportServer; | |
39 | +import org.jeecgframework.poi.excel.imports.base.ImportBaseService; | |
27 | 40 | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
28 | 41 | import org.jeecg.common.system.vo.LoginUser; |
29 | 42 | import org.apache.shiro.SecurityUtils; |
30 | 43 | import org.jeecg.common.api.vo.Result; |
31 | 44 | import org.jeecg.common.system.query.QueryGenerator; |
32 | 45 | import org.jeecg.common.util.oConvertUtils; |
46 | +import org.jeecgframework.poi.exception.excel.ExcelImportException; | |
47 | +import org.jeecgframework.poi.exception.excel.enums.ExcelImportEnum; | |
48 | +import org.jeecgframework.poi.util.PoiPublicUtil; | |
33 | 49 | import org.springframework.beans.BeanUtils; |
34 | 50 | import org.springframework.beans.factory.annotation.Autowired; |
51 | +import org.springframework.beans.factory.annotation.Value; | |
35 | 52 | import org.springframework.web.bind.annotation.*; |
36 | 53 | import org.springframework.web.servlet.ModelAndView; |
37 | 54 | import org.springframework.web.multipart.MultipartFile; |
... | ... | @@ -60,6 +77,11 @@ public class MinorController { |
60 | 77 | private IMinorService minorService; |
61 | 78 | @Autowired |
62 | 79 | private IFamilyService familyService; |
80 | + @Autowired | |
81 | + private ISysDepartService sysDepartService; | |
82 | + | |
83 | + @Value("${jeecg.path.upload}") | |
84 | + private String upLoadPath; | |
63 | 85 | |
64 | 86 | /** |
65 | 87 | * 分页列表查询 |
... | ... | @@ -80,8 +102,12 @@ public class MinorController { |
80 | 102 | QueryWrapper<Minor> queryWrapper = QueryGenerator.initQueryWrapper(minor, req.getParameterMap()); |
81 | 103 | Page<Minor> page = new Page<Minor>(pageNo, pageSize); |
82 | 104 | // IPage<Minor> pageList = minorService.page(page, queryWrapper); |
83 | - | |
84 | - IPage<Minor> pageList = minorService.queryPageList(page,minor.getName()); | |
105 | + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | |
106 | + String sysOrgCode=""; | |
107 | + if(oConvertUtils.isNotEmpty(sysUser) && oConvertUtils.isNotEmpty(sysUser.getOrgCode())){ | |
108 | + sysOrgCode=sysUser.getOrgCode(); | |
109 | + } | |
110 | + IPage<Minor> pageList = minorService.queryPageList(page,minor.getName(),sysOrgCode); | |
85 | 111 | return Result.OK(pageList); |
86 | 112 | } |
87 | 113 | |
... | ... | @@ -189,113 +215,52 @@ public class MinorController { |
189 | 215 | */ |
190 | 216 | @RequestMapping(value = "/exportXls") |
191 | 217 | public ModelAndView exportXls(HttpServletRequest request, Minor minor) { |
192 | - // Step.1 组装查询条件查询数据 | |
193 | - QueryWrapper<Minor> queryWrapper = QueryGenerator.initQueryWrapper(minor, request.getParameterMap()); | |
194 | - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | |
195 | - | |
196 | - //Step.2 获取导出数据 | |
197 | - List<Minor> queryList = minorService.list(queryWrapper); | |
198 | - // 过滤选中数据 | |
199 | - String selections = request.getParameter("selections"); | |
200 | - List<Minor> minorList = new ArrayList<Minor>(); | |
201 | - if(oConvertUtils.isEmpty(selections)) { | |
202 | - minorList = queryList; | |
203 | - }else { | |
204 | - List<String> selectionList = Arrays.asList(selections.split(",")); | |
205 | - minorList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); | |
206 | - } | |
207 | - // Step.3 组装pageList | |
208 | - List<MinorPage> pageList = new ArrayList<MinorPage>(); | |
209 | - for (Minor main : minorList) { | |
210 | - MinorPage vo = new MinorPage(); | |
211 | - BeanUtils.copyProperties(main, vo); | |
212 | - List<Family> familyList = familyService.selectByHouseholdNum(main.getHouseholdNum()); | |
213 | - vo.setFamilyList(familyList); | |
214 | - pageList.add(vo); | |
215 | - } | |
216 | - | |
217 | - // Step.4 AutoPoi 导出Excel | |
218 | - ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); | |
219 | - mv.addObject(NormalExcelConstants.FILE_NAME, "未成年人列表"); | |
220 | - mv.addObject(NormalExcelConstants.CLASS, MinorPage.class); | |
221 | - mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("未成年人数据", "导出人:"+sysUser.getRealname(), "未成年人")); | |
222 | - mv.addObject(NormalExcelConstants.DATA_LIST, pageList); | |
223 | - return mv; | |
218 | + // Step.1 组装查询条件查询数据 | |
219 | + Page<Minor> page = new Page<Minor>(1, 1); | |
220 | + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | |
221 | + String sysOrgCode=""; | |
222 | + if(oConvertUtils.isNotEmpty(sysUser) && oConvertUtils.isNotEmpty(sysUser.getOrgCode())){ | |
223 | + sysOrgCode=sysUser.getOrgCode(); | |
224 | + } | |
225 | + IPage<Minor> pageList = minorService.queryPageList(page,minor.getName(),sysOrgCode); | |
226 | + //Step.2 获取导出数据 | |
227 | + List<Minor> queryList = pageList.getRecords(); | |
228 | + // 过滤选中数据 | |
229 | + String selections = request.getParameter("selections"); | |
230 | + List<Minor> minorList = new ArrayList<Minor>(); | |
231 | + if (oConvertUtils.isEmpty(selections)) { | |
232 | + minorList = queryList; | |
233 | + } else { | |
234 | + List<String> selectionList = Arrays.asList(selections.split(",")); | |
235 | + minorList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); | |
236 | + } | |
237 | + List<Family> familyList = new ArrayList<>(); | |
238 | + for (Minor main : minorList) { | |
239 | + familyList = familyService.selectByHouseholdNum(main.getHouseholdNum()); | |
240 | + } | |
241 | + // Step.3 多sheet处理 | |
242 | + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | |
243 | + Map<String, Object> minorMap = new HashMap<String, Object>(); | |
244 | + ExportParams minorExportParams=new ExportParams( "未成年人信息", "导出人:" + sysUser.getRealname(), "未成年人信息",upLoadPath); | |
245 | + minorExportParams.setType(ExcelType.XSSF); | |
246 | + minorMap.put(NormalExcelConstants.PARAMS,minorExportParams);//表格Title | |
247 | + minorMap.put(NormalExcelConstants.CLASS,Minor.class);//表格对应实体 | |
248 | + minorMap.put(NormalExcelConstants.DATA_LIST, minorList);//数据集合 | |
249 | + listMap.add(minorMap); | |
250 | + Map<String, Object> familyMap = new HashMap<String, Object>(); | |
251 | + ExportParams familyExportParams=new ExportParams( "家庭成员信息", "导出人:" + sysUser.getRealname(), "家庭成员信息",upLoadPath); | |
252 | + familyExportParams.setType(ExcelType.XSSF); | |
253 | + familyMap.put(NormalExcelConstants.PARAMS,familyExportParams);//表格Title | |
254 | + familyMap.put(NormalExcelConstants.CLASS,Family.class);//表格对应实体 | |
255 | + familyMap.put(NormalExcelConstants.DATA_LIST, familyList);//数据集合 | |
256 | + listMap.add(familyMap); | |
257 | + // Step.4 AutoPoi 导出Excel | |
258 | + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); | |
259 | + mv.addObject(NormalExcelConstants.FILE_NAME, "未成年人信息"); //此处设置的filename无效 ,前端会重更新设置一下 | |
260 | + mv.addObject(NormalExcelConstants.MAP_LIST, listMap); | |
261 | + return mv; | |
224 | 262 | } |
225 | 263 | |
226 | -// /** | |
227 | -// * 导出excel | |
228 | -// * | |
229 | -// * @param request | |
230 | -// * @param minor | |
231 | -// */ | |
232 | -// @RequestMapping(value = "/exportXls") | |
233 | -// public void exportXls(HttpServletRequest request, Minor minor, HttpServletResponse response) throws IOException { | |
234 | -// | |
235 | -// OutputStream outputStream = response.getOutputStream(); | |
236 | -// // Step.1 组装查询条件查询数据 | |
237 | -// QueryWrapper<Minor> queryWrapper = QueryGenerator.initQueryWrapper(minor, request.getParameterMap()); | |
238 | -// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | |
239 | -// queryWrapper.last("limit 1"); | |
240 | -// //Step.2 获取导出数据 | |
241 | -// List<Minor> queryList = minorService.list(queryWrapper); | |
242 | -// // 过滤选中数据 | |
243 | -// String selections = request.getParameter("selections"); | |
244 | -// List<Minor> minorList = new ArrayList<Minor>(); | |
245 | -// if (oConvertUtils.isEmpty(selections)) { | |
246 | -// minorList = queryList; | |
247 | -// } else { | |
248 | -// List<String> selectionList = Arrays.asList(selections.split(",")); | |
249 | -// minorList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); | |
250 | -// } | |
251 | -// // Step.3 组装pageList | |
252 | -// List<MinorPage> pageList = new ArrayList<MinorPage>(); | |
253 | -// List<Family> familyList = new ArrayList<>(); | |
254 | -// for (Minor main : minorList) { | |
255 | -// familyList = familyService.selectByHouseholdNum(main.getHouseholdNum()); | |
256 | -// } | |
257 | -// //多个map,对应了多个sheet | |
258 | -// List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | |
259 | -// Map<String, Object> minorMap = new HashMap<String, Object>(); | |
260 | -// minorMap.put("title", getExportParams("未成年人表"));//表格title | |
261 | -// minorMap.put("entity", Minor.class);//表格对应实体 | |
262 | -// //数据封装方式二:实体类 | |
263 | -// minorMap.put("data", minorList); | |
264 | -// listMap.add(minorMap); | |
265 | -// Map<String, Object> familyMap = new HashMap<String, Object>(); | |
266 | -// familyMap.put("title", getExportParams("家庭成员表"));//表格title | |
267 | -// familyMap.put("entity", Family.class);//表格对应实体 | |
268 | -// //数据封装方式二:实体类 | |
269 | -// familyMap.put("data", familyList); | |
270 | -// listMap.add(familyMap); | |
271 | -// try { | |
272 | -// Workbook wb = ExcelExportUtil.exportExcel(listMap, ExcelType.XSSF); | |
273 | -// response.reset(); | |
274 | -// response.setHeader("Content-disposition", "attachment; filename=details.xls"); | |
275 | -// response.setContentType("application/msexcel"); | |
276 | -// wb.write(outputStream); | |
277 | -// outputStream.close(); | |
278 | -// } catch (IOException e) { | |
279 | -// log.error("模板下载失败" + e.getMessage()); | |
280 | -// response.setStatus(404); | |
281 | -// e.printStackTrace(); | |
282 | -// } finally { | |
283 | -// if (outputStream != null) { | |
284 | -// try { | |
285 | -// outputStream.close(); | |
286 | -// } catch (IOException e) { | |
287 | -// log.error(e.getMessage(), e); | |
288 | -// } | |
289 | -// } | |
290 | -// } | |
291 | -// } | |
292 | - | |
293 | - //导出参数 | |
294 | - public static ExportParams getExportParams(String name) { | |
295 | - //表格名称,sheet名称,导出版本 | |
296 | - return new ExportParams(name, name, ExcelType.XSSF); | |
297 | - } | |
298 | - | |
299 | 264 | /** |
300 | 265 | * 通过excel导入数据 |
301 | 266 | * |
... | ... | @@ -306,6 +271,11 @@ public class MinorController { |
306 | 271 | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
307 | 272 | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
308 | 273 | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
274 | + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | |
275 | + String sysOrgCode=""; | |
276 | + if(oConvertUtils.isNotEmpty(sysUser) && oConvertUtils.isNotEmpty(sysUser.getOrgCode())){ | |
277 | + sysOrgCode=sysUser.getOrgCode(); | |
278 | + } | |
309 | 279 | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
310 | 280 | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
311 | 281 | MultipartFile file = entity.getValue();// 获取上传文件对象 |
... | ... | @@ -314,25 +284,42 @@ public class MinorController { |
314 | 284 | params.setHeadRows(1); |
315 | 285 | params.setNeedSave(true); |
316 | 286 | try { |
317 | - List<MinorPage> list = ExcelImportUtil.importExcel(file.getInputStream(), MinorPage.class, params); | |
318 | - for (MinorPage page : list) { | |
319 | - Minor po = new Minor(); | |
320 | - BeanUtils.copyProperties(page, po); | |
321 | - minorService.saveMain(po, page.getFamilyList()); | |
287 | + ExcelImportResult<MinorPage> excelImportResult = ExcelImportUtil.importExcelVerify(file.getInputStream(), Minor.class, params); | |
288 | + List<MinorPage> minorList = new ArrayList<>(); | |
289 | + Workbook workbook = excelImportResult.getWorkbook(); | |
290 | + Map pictures=new HashMap<>(); | |
291 | + //获取Excel文档中的第一个表单 | |
292 | + Sheet sht0 = workbook.getSheetAt(0); | |
293 | + List<Minor> minorPages=new ExcelImportServiceUtil().importExcel(new ArrayList<>(),sht0, Minor.class, params,pictures); | |
294 | + if(oConvertUtils.isNotEmpty(minorPages) && oConvertUtils.isNotEmpty(sysOrgCode)){ | |
295 | + String finalSysOrgCode = sysOrgCode; | |
296 | + minorPages.stream().forEach(minor -> { | |
297 | + minor.setSysOrgCode(finalSysOrgCode); | |
298 | + }); | |
299 | + } | |
300 | + //获取Excel文档中的第二个表单 | |
301 | + Sheet sht1 = workbook.getSheetAt(1); | |
302 | + List<Family> families=new ExcelImportServiceUtil().importExcel(new ArrayList<>(),sht1, Family.class, params,pictures); | |
303 | + if(oConvertUtils.isNotEmpty(families) && oConvertUtils.isNotEmpty(sysOrgCode)){ | |
304 | + String finalSysOrgCode = sysOrgCode; | |
305 | + minorPages.stream().forEach(family -> { | |
306 | + family.setSysOrgCode(finalSysOrgCode); | |
307 | + }); | |
322 | 308 | } |
323 | - return Result.OK("文件导入成功!数据行数:" + list.size()); | |
309 | + minorService.saveMain(minorPages,families); | |
310 | + return Result.OK(); | |
324 | 311 | } catch (Exception e) { |
325 | 312 | log.error(e.getMessage(), e); |
326 | - return Result.error("文件导入失败:" + e.getMessage()); | |
313 | + return Result.error("文件导入失败:" + e.getMessage()); | |
327 | 314 | } finally { |
328 | 315 | try { |
329 | 316 | file.getInputStream().close(); |
330 | - } catch (IOException e) { | |
317 | + } catch (Exception e) { | |
331 | 318 | e.printStackTrace(); |
332 | 319 | } |
333 | 320 | } |
334 | 321 | } |
335 | - return Result.OK("文件导入失败!"); | |
322 | + return Result.error("文件导入失败!"); | |
336 | 323 | } |
337 | - | |
338 | 324 | } |
325 | + | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/FamilyMapper.java
... | ... | @@ -15,7 +15,7 @@ import java.util.Set; |
15 | 15 | */ |
16 | 16 | public interface FamilyMapper extends BaseMapper<Family> { |
17 | 17 | |
18 | - public boolean deleteByMainId(@Param("mainId") String mainId); | |
18 | + public boolean deleteByHouseholdNum(@Param("householdNum") String householdNum); | |
19 | 19 | |
20 | 20 | public List<Family> selectByHouseholdNum(@Param("householdNum") String householdNum); |
21 | 21 | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/MinorMapper.java
... | ... | @@ -26,7 +26,7 @@ public interface MinorMapper extends BaseMapper<Minor> { |
26 | 26 | * @param page |
27 | 27 | * @return |
28 | 28 | */ |
29 | - IPage<Minor> queryPageList(Page page,@Param("name") String name); | |
29 | + IPage<Minor> queryPageList(Page page,@Param("name") String name,@Param("sysOrgCode") String sysOrgCode); | |
30 | 30 | |
31 | 31 | |
32 | 32 | } | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/FamilyMapper.xml
... | ... | @@ -2,11 +2,11 @@ |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 | <mapper namespace="org.jeecg.modules.system.mapper.FamilyMapper"> |
4 | 4 | |
5 | - <delete id="deleteByMainId" parameterType="java.lang.String"> | |
5 | + <delete id="deleteByHouseholdNum" parameterType="java.lang.String"> | |
6 | 6 | DELETE |
7 | 7 | FROM mr_family |
8 | 8 | WHERE |
9 | - minor_id = #{mainId} </delete> | |
9 | + household_num = #{householdNum} </delete> | |
10 | 10 | |
11 | 11 | <select id="selectByHouseholdNum" parameterType="java.lang.String" resultType="org.jeecg.modules.system.entity.Family"> |
12 | 12 | SELECT * |
... | ... | @@ -22,10 +22,4 @@ |
22 | 22 | </foreach> |
23 | 23 | </insert> |
24 | 24 | |
25 | -<!-- <insert id="insertBatch" >--> | |
26 | -<!-- INSERT INTO mr_family (id, create_time, sys_org_code, household_num, number, name,identity, gender, relation, address,crime,reason, other)VALUES--> | |
27 | -<!-- <foreach collection="list" item="b" separator=",">--> | |
28 | -<!-- (#{b.id},#{b.createTime},#{b.sysOrgCode},#{b.householdNum},#{b.number},#{b.name},#{b.identity},#{b.gender},#{b.relation},#{b.address},#{b.crime},#{b.reason},#{b.other})--> | |
29 | -<!-- </foreach>--> | |
30 | -<!-- </insert>--> | |
31 | 25 | </mapper> | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/MinorMapper.xml
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | |
26 | 26 | <insert id="insertBatch" > |
27 | 27 | INSERT INTO mr_minor (id, create_time, sys_org_code, household_num, number, name,identity, gender, relation, address,guardian, |
28 | - school,schoolName, startYear,reason,specialReason,remark)VALUES | |
28 | + school,school_name, start_year,reason,special_reason,remark)VALUES | |
29 | 29 | <foreach collection="list" item="b" separator=","> |
30 | 30 | (#{b.id},#{b.createTime},#{b.sysOrgCode},#{b.householdNum},#{b.number},#{b.name},#{b.identity},#{b.gender},#{b.relation},#{b.address},#{b.guardian}, |
31 | 31 | #{b.school},#{b.schoolName},#{b.startYear},#{b.reason},#{b.specialReason},#{b.remark}) |
... | ... | @@ -33,13 +33,17 @@ |
33 | 33 | </insert> |
34 | 34 | <!-- ORDER BY create_time desc LIMIT #{pageNum},#{pageSize}--> |
35 | 35 | <select id="queryPageList" resultMap="minor"> |
36 | - select timestampdiff(year, substring(identity, 7, 8), now()) as age,identity,create_time as createTime,sys_org_code as sysOrgCode,household_num as householdNum, | |
36 | + select id,timestampdiff(year, substring(identity, 7, 8), now()) as age,identity,create_time as createTime,sys_org_code as sysOrgCode,household_num as householdNum, | |
37 | 37 | number,name,gender,school,school_name as schoolName,start_year as startYear,address,guardian,relation,reason,special_reason as specialReason,remark |
38 | 38 | FROM mr_minor |
39 | 39 | WHERE (timestampdiff(year, substring(identity, 7, 8), now())) < 18 |
40 | 40 | <if test="name!=null and name!=''"> |
41 | 41 | and name like concat('%',#{name},'%') |
42 | 42 | </if> |
43 | + <if test="sysOrgCode!=null and sysOrgCode!=''"> | |
44 | + and sys_org_code like concat(#{sysOrgCode},'%') | |
45 | + </if> | |
46 | + ORDER BY create_time | |
43 | 47 | </select> |
44 | 48 | |
45 | 49 | </mapper> |
46 | 50 | \ No newline at end of file | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IMinorService.java
... | ... | @@ -45,5 +45,11 @@ public interface IMinorService extends IService<Minor> { |
45 | 45 | |
46 | 46 | public Integer insertBatch(List<Minor> list); |
47 | 47 | |
48 | - IPage<Minor> queryPageList(Page<Minor> page,String name); | |
48 | + IPage<Minor> queryPageList(Page<Minor> page,String name,String sysOrgCode); | |
49 | + | |
50 | + /** | |
51 | + * 添加多对多 | |
52 | + * | |
53 | + */ | |
54 | + public void saveMain(List<Minor> minor,List<Family> familyList) ; | |
49 | 55 | } | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/MinorServiceImpl.java
... | ... | @@ -67,13 +67,11 @@ public class MinorServiceImpl extends ServiceImpl<MinorMapper, Minor> implements |
67 | 67 | falg = false; |
68 | 68 | } |
69 | 69 | //外键设置 |
70 | - entity.setMinorId(minor.getId()); | |
71 | 70 | familyMapper.insert(entity); |
72 | 71 | } |
73 | 72 | if(!falg){ |
74 | 73 | Family family=new Family(); |
75 | 74 | family.setCrime(Family.IS_NOT_CRIME); |
76 | - family.setMinorId(minor.getId()); | |
77 | 75 | family.setName(minor.getName()); |
78 | 76 | family.setHouseholdNum(minor.getHouseholdNum()); |
79 | 77 | family.setIdentity(minor.getIdentity()); |
... | ... | @@ -91,7 +89,9 @@ public class MinorServiceImpl extends ServiceImpl<MinorMapper, Minor> implements |
91 | 89 | minorMapper.updateById(minor); |
92 | 90 | |
93 | 91 | //1.先删除子表数据 |
94 | - familyMapper.deleteByMainId(minor.getId()); | |
92 | + if(oConvertUtils.isNotEmpty(minor) && oConvertUtils.isNotEmpty(minor.getHouseholdNum())){ | |
93 | + familyMapper.deleteByHouseholdNum(minor.getHouseholdNum()); | |
94 | + } | |
95 | 95 | |
96 | 96 | //2.子表数据重新插入 |
97 | 97 | if(familyList!=null && familyList.size()>0) { |
... | ... | @@ -108,7 +108,10 @@ public class MinorServiceImpl extends ServiceImpl<MinorMapper, Minor> implements |
108 | 108 | @Override |
109 | 109 | @Transactional |
110 | 110 | public void delMain(String id) { |
111 | - familyMapper.deleteByMainId(id); | |
111 | + Minor minor=minorMapper.selectById(id); | |
112 | + if(oConvertUtils.isNotEmpty(minor) && oConvertUtils.isNotEmpty(minor.getHouseholdNum())){ | |
113 | + familyMapper.deleteByHouseholdNum(minor.getHouseholdNum()); | |
114 | + } | |
112 | 115 | minorMapper.deleteById(id); |
113 | 116 | } |
114 | 117 | |
... | ... | @@ -116,7 +119,10 @@ public class MinorServiceImpl extends ServiceImpl<MinorMapper, Minor> implements |
116 | 119 | @Transactional |
117 | 120 | public void delBatchMain(Collection<? extends Serializable> idList) { |
118 | 121 | for(Serializable id:idList) { |
119 | - familyMapper.deleteByMainId(id.toString()); | |
122 | + Minor minor=minorMapper.selectById(id); | |
123 | + if(oConvertUtils.isNotEmpty(minor) && oConvertUtils.isNotEmpty(minor.getHouseholdNum())){ | |
124 | + familyMapper.deleteByHouseholdNum(minor.getHouseholdNum()); | |
125 | + } | |
120 | 126 | minorMapper.deleteById(id); |
121 | 127 | } |
122 | 128 | } |
... | ... | @@ -135,8 +141,20 @@ public class MinorServiceImpl extends ServiceImpl<MinorMapper, Minor> implements |
135 | 141 | } |
136 | 142 | |
137 | 143 | @Override |
138 | - public IPage<Minor> queryPageList(Page<Minor> page,String name) { | |
139 | - return minorMapper.queryPageList(page,name); | |
144 | + public IPage<Minor> queryPageList(Page<Minor> page,String name,String sysOrgCode) { | |
145 | + return minorMapper.queryPageList(page,name,sysOrgCode); | |
146 | + } | |
147 | + | |
148 | + | |
149 | + /** | |
150 | + * 添加多对多 | |
151 | + * | |
152 | + */ | |
153 | + @Override | |
154 | + @Transactional | |
155 | + public void saveMain(List<Minor> minors, List<Family> familyList) { | |
156 | + minorMapper.insertBatch(minors); | |
157 | + familyMapper.insertBatch(familyList); | |
140 | 158 | } |
141 | 159 | |
142 | 160 | |
... | ... | @@ -166,7 +184,7 @@ public class MinorServiceImpl extends ServiceImpl<MinorMapper, Minor> implements |
166 | 184 | |
167 | 185 | public void updateStudentWithThreads(List<Minor> list) { |
168 | 186 | // 线程数量 |
169 | - final Integer threadCount = 5; | |
187 | + final Integer threadCount = 12; | |
170 | 188 | |
171 | 189 | //每个线程处理的数据量 |
172 | 190 | final Integer dataPartionLength = (list.size() + threadCount - 1) / threadCount; | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/MrSchoolServiceImpl.java
... | ... | @@ -79,7 +79,7 @@ public class MrSchoolServiceImpl extends ServiceImpl<MrSchoolMapper, MrSchool> i |
79 | 79 | |
80 | 80 | public void updateStudentWithThreads(List<MrSchool> list) { |
81 | 81 | // 线程数量 |
82 | - final Integer threadCount = 5; | |
82 | + final Integer threadCount = 8; | |
83 | 83 | |
84 | 84 | //每个线程处理的数据量 |
85 | 85 | final Integer dataPartionLength = (list.size() + threadCount - 1) / threadCount; | ... | ... |
juvenile-prosecution-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/ExcelImportServiceUtil.java
0 → 100644
1 | +package org.jeecg.modules.system.util; | |
2 | + | |
3 | +import java.io.ByteArrayOutputStream; | |
4 | +import java.io.File; | |
5 | +import java.io.FileOutputStream; | |
6 | +import java.io.IOException; | |
7 | +import java.io.InputStream; | |
8 | +import java.io.PushbackInputStream; | |
9 | +import java.lang.reflect.Field; | |
10 | +import java.lang.reflect.InvocationTargetException; | |
11 | +import java.lang.reflect.Method; | |
12 | +import java.util.ArrayList; | |
13 | +import java.util.Collection; | |
14 | +import java.util.Collections; | |
15 | +import java.util.Date; | |
16 | +import java.util.HashMap; | |
17 | +import java.util.Iterator; | |
18 | +import java.util.List; | |
19 | +import java.util.Map; | |
20 | +import java.util.Set; | |
21 | +import org.apache.commons.lang3.StringUtils; | |
22 | +import org.apache.poi.hssf.usermodel.HSSFSheet; | |
23 | +import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |
24 | +import org.apache.poi.ss.formula.functions.T; | |
25 | +import org.apache.poi.ss.usermodel.Cell; | |
26 | +import org.apache.poi.ss.usermodel.CellStyle; | |
27 | +import org.apache.poi.ss.usermodel.Font; | |
28 | +import org.apache.poi.ss.usermodel.PictureData; | |
29 | +import org.apache.poi.ss.usermodel.Row; | |
30 | +import org.apache.poi.ss.usermodel.Sheet; | |
31 | +import org.apache.poi.ss.usermodel.Workbook; | |
32 | +import org.apache.poi.ss.usermodel.WorkbookFactory; | |
33 | +import org.apache.poi.xssf.usermodel.XSSFSheet; | |
34 | +import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |
35 | +import org.jeecgframework.core.util.ApplicationContextUtil; | |
36 | +import org.jeecgframework.poi.excel.annotation.ExcelTarget; | |
37 | +import org.jeecgframework.poi.excel.entity.ImportParams; | |
38 | +import org.jeecgframework.poi.excel.entity.params.ExcelCollectionParams; | |
39 | +import org.jeecgframework.poi.excel.entity.params.ExcelImportEntity; | |
40 | +import org.jeecgframework.poi.excel.entity.result.ExcelImportResult; | |
41 | +import org.jeecgframework.poi.excel.entity.result.ExcelVerifyHanlderResult; | |
42 | +import org.jeecgframework.poi.excel.imports.CellValueServer; | |
43 | +import org.jeecgframework.poi.excel.imports.base.ImportBaseService; | |
44 | +import org.jeecgframework.poi.excel.imports.base.ImportFileServiceI; | |
45 | +import org.jeecgframework.poi.excel.imports.verifys.VerifyHandlerServer; | |
46 | +import org.jeecgframework.poi.exception.excel.ExcelImportException; | |
47 | +import org.jeecgframework.poi.exception.excel.enums.ExcelImportEnum; | |
48 | +import org.jeecgframework.poi.util.ExcelUtil; | |
49 | +import org.jeecgframework.poi.util.PoiPublicUtil; | |
50 | +import org.slf4j.Logger; | |
51 | +import org.slf4j.LoggerFactory; | |
52 | + | |
53 | +/** | |
54 | + * @author Administrator | |
55 | + */ | |
56 | +public class ExcelImportServiceUtil extends ImportBaseService { | |
57 | + private static final Logger LOGGER = LoggerFactory.getLogger(org.jeecgframework.poi.excel.imports.ExcelImportServer.class); | |
58 | + private CellValueServer cellValueServer = new CellValueServer(); | |
59 | + private VerifyHandlerServer verifyHandlerServer = new VerifyHandlerServer(); | |
60 | + private boolean verfiyFail = false; | |
61 | + private CellStyle errorCellStyle; | |
62 | + | |
63 | + public ExcelImportServiceUtil() { | |
64 | + } | |
65 | + | |
66 | + private void addListContinue(Object object, ExcelCollectionParams param, Row row, Map<Integer, String> titlemap, String targetId, Map<String, PictureData> pictures, ImportParams params) throws Exception { | |
67 | + Collection collection = (Collection)PoiPublicUtil.getMethod(param.getName(), object.getClass()).invoke(object); | |
68 | + Object entity = PoiPublicUtil.createObject(param.getType(), targetId); | |
69 | + boolean isUsed = false; | |
70 | + | |
71 | + for(int i = row.getFirstCellNum(); i < row.getLastCellNum(); ++i) { | |
72 | + Cell cell = row.getCell(i); | |
73 | + String titleString = (String)titlemap.get(i); | |
74 | + if (param.getExcelParams().containsKey(titleString)) { | |
75 | + if (((ExcelImportEntity)param.getExcelParams().get(titleString)).getType() == 2) { | |
76 | + String picId = row.getRowNum() + "_" + i; | |
77 | + this.saveImage(object, picId, param.getExcelParams(), titleString, pictures, params); | |
78 | + } else { | |
79 | + this.saveFieldValue(params, entity, cell, param.getExcelParams(), titleString, row); | |
80 | + } | |
81 | + | |
82 | + isUsed = true; | |
83 | + } | |
84 | + } | |
85 | + | |
86 | + if (isUsed) { | |
87 | + collection.add(entity); | |
88 | + } | |
89 | + | |
90 | + } | |
91 | + | |
92 | + private String getKeyValue(Cell cell) { | |
93 | + if (cell == null) { | |
94 | + return null; | |
95 | + } else { | |
96 | + Object obj = null; | |
97 | + switch(cell.getCellTypeEnum()) { | |
98 | + case STRING: | |
99 | + obj = cell.getStringCellValue(); | |
100 | + break; | |
101 | + case BOOLEAN: | |
102 | + obj = cell.getBooleanCellValue(); | |
103 | + break; | |
104 | + case NUMERIC: | |
105 | + obj = cell.getNumericCellValue(); | |
106 | + break; | |
107 | + case FORMULA: | |
108 | + obj = cell.getCellFormula(); | |
109 | + } | |
110 | + | |
111 | + return obj == null ? null : obj.toString().trim(); | |
112 | + } | |
113 | + } | |
114 | + | |
115 | + private String getSaveUrl(ExcelImportEntity excelImportEntity, Object object) throws Exception { | |
116 | + String url = ""; | |
117 | + if (excelImportEntity.getSaveUrl().equals("upload")) { | |
118 | + if (excelImportEntity.getMethods() != null && excelImportEntity.getMethods().size() > 0) { | |
119 | + object = this.getFieldBySomeMethod(excelImportEntity.getMethods(), object); | |
120 | + } | |
121 | + | |
122 | + url = object.getClass().getName().split("\\.")[object.getClass().getName().split("\\.").length - 1]; | |
123 | + return excelImportEntity.getSaveUrl() + "/" + url.substring(0, url.lastIndexOf("Entity")); | |
124 | + } else { | |
125 | + return excelImportEntity.getSaveUrl(); | |
126 | + } | |
127 | + } | |
128 | + | |
129 | + public <T> List<T> importExcel(Collection<T> result, Sheet sheet, Class<?> pojoClass, ImportParams params, Map<String, PictureData> pictures) throws Exception { | |
130 | + List collection = new ArrayList(); | |
131 | + Map<String, ExcelImportEntity> excelParams = new HashMap(); | |
132 | + List<ExcelCollectionParams> excelCollection = new ArrayList(); | |
133 | + String targetId = null; | |
134 | + if (!Map.class.equals(pojoClass)) { | |
135 | + Field[] fileds = PoiPublicUtil.getClassFields(pojoClass); | |
136 | + ExcelTarget etarget = (ExcelTarget)pojoClass.getAnnotation(ExcelTarget.class); | |
137 | + if (etarget != null) { | |
138 | + targetId = etarget.value(); | |
139 | + } | |
140 | + | |
141 | + this.getAllExcelField(targetId, fileds, excelParams, excelCollection, pojoClass, (List)null); | |
142 | + } | |
143 | + | |
144 | + this.ignoreHeaderHandler(excelParams, params); | |
145 | + Iterator<Row> rows = sheet.rowIterator(); | |
146 | + Map<Integer, String> titlemap = this.getTitleMap(sheet, rows, params, excelCollection); | |
147 | + Set<Integer> columnIndexSet = titlemap.keySet(); | |
148 | + Integer maxColumnIndex = (Integer)Collections.max(columnIndexSet); | |
149 | + Integer minColumnIndex = (Integer)Collections.min(columnIndexSet); | |
150 | + Row row = null; | |
151 | + | |
152 | + for(int j = 0; j < params.getTitleRows() + params.getHeadRows(); ++j) { | |
153 | + row = (Row)rows.next(); | |
154 | + } | |
155 | + | |
156 | + Object object = null; | |
157 | + | |
158 | + while(rows.hasNext() && (row == null || sheet.getLastRowNum() - row.getRowNum() > params.getLastOfInvalidRow())) { | |
159 | + row = (Row)rows.next(); | |
160 | + Cell keyIndexCell = row.getCell(params.getKeyIndex()); | |
161 | + if (excelCollection.size() > 0 && StringUtils.isEmpty(this.getKeyValue(keyIndexCell)) && object != null && !Map.class.equals(pojoClass)) { | |
162 | + Iterator var31 = excelCollection.iterator(); | |
163 | + | |
164 | + while(var31.hasNext()) { | |
165 | + ExcelCollectionParams param = (ExcelCollectionParams)var31.next(); | |
166 | + this.addListContinue(object, param, row, titlemap, targetId, pictures, params); | |
167 | + } | |
168 | + } else { | |
169 | + object = PoiPublicUtil.createObject(pojoClass, targetId); | |
170 | + | |
171 | + try { | |
172 | + int firstCellNum = row.getFirstCellNum(); | |
173 | + if (firstCellNum > minColumnIndex) { | |
174 | + firstCellNum = minColumnIndex; | |
175 | + } | |
176 | + | |
177 | + int lastCellNum = row.getLastCellNum(); | |
178 | + if (lastCellNum < maxColumnIndex + 1) { | |
179 | + lastCellNum = maxColumnIndex + 1; | |
180 | + } | |
181 | + | |
182 | + int i = firstCellNum; | |
183 | + | |
184 | + for(int le = lastCellNum; i < le; ++i) { | |
185 | + Cell cell = row.getCell(i); | |
186 | + String titleString = (String)titlemap.get(i); | |
187 | + if (excelParams.containsKey(titleString) || Map.class.equals(pojoClass)) { | |
188 | + String picId; | |
189 | + if (excelParams.get(titleString) != null && ((ExcelImportEntity)excelParams.get(titleString)).getType() == 2) { | |
190 | + picId = row.getRowNum() + "_" + i; | |
191 | + this.saveImage(object, picId, excelParams, titleString, pictures, params); | |
192 | + } else if (params.getImageList() != null && params.getImageList().contains(titleString)) { | |
193 | + if (pictures != null) { | |
194 | + picId = row.getRowNum() + "_" + i; | |
195 | + PictureData image = (PictureData)pictures.get(picId); | |
196 | + if (image != null) { | |
197 | + byte[] data = image.getData(); | |
198 | + params.getDataHanlder().setMapValue((Map)object, titleString, data); | |
199 | + } | |
200 | + } | |
201 | + } else { | |
202 | + this.saveFieldValue(params, object, cell, excelParams, titleString, row); | |
203 | + } | |
204 | + } | |
205 | + } | |
206 | + | |
207 | + Iterator var33 = excelCollection.iterator(); | |
208 | + | |
209 | + while(var33.hasNext()) { | |
210 | + ExcelCollectionParams param = (ExcelCollectionParams)var33.next(); | |
211 | + this.addListContinue(object, param, row, titlemap, targetId, pictures, params); | |
212 | + } | |
213 | + | |
214 | + if (this.isNotNullObject(pojoClass, object)) { | |
215 | + collection.add(object); | |
216 | + } | |
217 | + } catch (ExcelImportException var27) { | |
218 | + if (!var27.getType().equals(ExcelImportEnum.VERIFY_ERROR)) { | |
219 | + throw new ExcelImportException(var27.getType(), var27); | |
220 | + } | |
221 | + } | |
222 | + } | |
223 | + } | |
224 | + | |
225 | + return collection; | |
226 | + } | |
227 | + | |
228 | + private boolean isNotNullObject(Class pojoClass, Object object) { | |
229 | + try { | |
230 | + Method method = pojoClass.getMethod("isNullObject"); | |
231 | + if (method != null) { | |
232 | + Object flag = method.invoke(object); | |
233 | + if (flag != null && Boolean.parseBoolean(flag.toString())) { | |
234 | + return false; | |
235 | + } | |
236 | + } | |
237 | + } catch (NoSuchMethodException var5) { | |
238 | + System.out.println("没有该方法 isNullObject"); | |
239 | + } catch (IllegalAccessException var6) { | |
240 | + System.out.println("没有权限访问该方法 isNullObject"); | |
241 | + } catch (InvocationTargetException var7) { | |
242 | + System.out.println("方法调用失败 isNullObject"); | |
243 | + } | |
244 | + | |
245 | + return true; | |
246 | + } | |
247 | + | |
248 | + private void ignoreHeaderHandler(Map<String, ExcelImportEntity> excelParams, ImportParams params) { | |
249 | + List<String> ignoreList = new ArrayList(); | |
250 | + Iterator var4 = excelParams.keySet().iterator(); | |
251 | + | |
252 | + while(var4.hasNext()) { | |
253 | + String key = (String)var4.next(); | |
254 | + String temp = ((ExcelImportEntity)excelParams.get(key)).getGroupName(); | |
255 | + if (temp != null && temp.length() > 0) { | |
256 | + ignoreList.add(temp); | |
257 | + } | |
258 | + } | |
259 | + | |
260 | + params.setIgnoreHeaderList(ignoreList); | |
261 | + } | |
262 | + | |
263 | + private Map<Integer, String> getTitleMap(Sheet sheet, Iterator<Row> rows, ImportParams params, List<ExcelCollectionParams> excelCollection) throws Exception { | |
264 | + Map<Integer, String> titlemap = new HashMap(); | |
265 | + Iterator<Cell> cellTitle = null; | |
266 | + String collectionName = null; | |
267 | + ExcelCollectionParams collectionParams = null; | |
268 | + Row headRow = null; | |
269 | + int headBegin = params.getTitleRows(); | |
270 | + | |
271 | + for(int allRowNum = sheet.getPhysicalNumberOfRows(); headRow == null && headBegin < allRowNum; headRow = sheet.getRow(headBegin++)) { | |
272 | + } | |
273 | + | |
274 | + if (headRow == null) { | |
275 | + throw new Exception("不识别该文件"); | |
276 | + } else { | |
277 | + if (ExcelUtil.isMergedRegion(sheet, headRow.getRowNum(), 0)) { | |
278 | + params.setHeadRows(2); | |
279 | + } else { | |
280 | + params.setHeadRows(1); | |
281 | + } | |
282 | + | |
283 | + cellTitle = headRow.cellIterator(); | |
284 | + | |
285 | + while(cellTitle.hasNext()) { | |
286 | + Cell cell = (Cell)cellTitle.next(); | |
287 | + String value = this.getKeyValue(cell); | |
288 | + if (StringUtils.isNotEmpty(value)) { | |
289 | + titlemap.put(cell.getColumnIndex(), value); | |
290 | + } | |
291 | + } | |
292 | + | |
293 | + for(int j = headBegin; j < headBegin + params.getHeadRows() - 1; ++j) { | |
294 | + headRow = sheet.getRow(j); | |
295 | + cellTitle = headRow.cellIterator(); | |
296 | + | |
297 | + while(cellTitle.hasNext()) { | |
298 | + Cell cell = (Cell)cellTitle.next(); | |
299 | + String value = this.getKeyValue(cell); | |
300 | + if (StringUtils.isNotEmpty(value)) { | |
301 | + int columnIndex = cell.getColumnIndex(); | |
302 | + if (ExcelUtil.isMergedRegion(sheet, cell.getRowIndex() - 1, columnIndex)) { | |
303 | + collectionName = ExcelUtil.getMergedRegionValue(sheet, cell.getRowIndex() - 1, columnIndex); | |
304 | + if (params.isIgnoreHeader(collectionName)) { | |
305 | + titlemap.put(cell.getColumnIndex(), value); | |
306 | + } else { | |
307 | + titlemap.put(cell.getColumnIndex(), collectionName + "_" + value); | |
308 | + } | |
309 | + } else { | |
310 | + titlemap.put(cell.getColumnIndex(), value); | |
311 | + } | |
312 | + } | |
313 | + } | |
314 | + } | |
315 | + | |
316 | + return titlemap; | |
317 | + } | |
318 | + } | |
319 | + | |
320 | + private ExcelCollectionParams getCollectionParams(List<ExcelCollectionParams> excelCollection, String collectionName) { | |
321 | + Iterator var3 = excelCollection.iterator(); | |
322 | + | |
323 | + ExcelCollectionParams excelCollectionParams; | |
324 | + do { | |
325 | + if (!var3.hasNext()) { | |
326 | + return null; | |
327 | + } | |
328 | + | |
329 | + excelCollectionParams = (ExcelCollectionParams)var3.next(); | |
330 | + } while(!collectionName.equals(excelCollectionParams.getExcelName())); | |
331 | + | |
332 | + return excelCollectionParams; | |
333 | + } | |
334 | + | |
335 | + public ExcelImportResult importExcelByIs(InputStream inputstream, Class<?> pojoClass, ImportParams params) throws Exception { | |
336 | + if (LOGGER.isDebugEnabled()) { | |
337 | + LOGGER.debug("Excel import start ,class is {}", pojoClass); | |
338 | + } | |
339 | + | |
340 | + List<T> result = new ArrayList(); | |
341 | + Workbook book = null; | |
342 | + boolean isXSSFWorkbook = false; | |
343 | + if (!((InputStream)inputstream).markSupported()) { | |
344 | + inputstream = new PushbackInputStream((InputStream)inputstream, 8); | |
345 | + } | |
346 | + | |
347 | + book = WorkbookFactory.create((InputStream)inputstream); | |
348 | + if (book instanceof XSSFWorkbook) { | |
349 | + isXSSFWorkbook = true; | |
350 | + } | |
351 | + | |
352 | + LOGGER.info(" >>> poi3升级到4.0兼容改造工作, isXSSFWorkbook = " + isXSSFWorkbook); | |
353 | + int sheetNum = book.getNumberOfSheets(); | |
354 | + if (sheetNum > 1) { | |
355 | + params.setSheetNum(sheetNum); | |
356 | + } | |
357 | + | |
358 | + this.createErrorCellStyle(book); | |
359 | + | |
360 | + for(int i = 0; i < params.getSheetNum(); ++i) { | |
361 | + if (LOGGER.isDebugEnabled()) { | |
362 | + LOGGER.debug(" start to read excel by is ,startTime is {}", System.currentTimeMillis()); | |
363 | + } | |
364 | + | |
365 | + Map pictures; | |
366 | + if (isXSSFWorkbook) { | |
367 | + pictures = PoiPublicUtil.getSheetPictrues07((XSSFSheet)book.getSheetAt(i), (XSSFWorkbook)book); | |
368 | + } else { | |
369 | + pictures = PoiPublicUtil.getSheetPictrues03((HSSFSheet)book.getSheetAt(i), (HSSFWorkbook)book); | |
370 | + } | |
371 | + | |
372 | + if (LOGGER.isDebugEnabled()) { | |
373 | + LOGGER.debug(" end to read excel by is ,endTime is {}", (new Date()).getTime()); | |
374 | + } | |
375 | + | |
376 | + result.addAll(this.importExcel(result, book.getSheetAt(i), pojoClass, params, pictures)); | |
377 | + if (LOGGER.isDebugEnabled()) { | |
378 | + LOGGER.debug(" end to read excel list by pos ,endTime is {}", (new Date()).getTime()); | |
379 | + } | |
380 | + } | |
381 | + | |
382 | + if (params.isNeedSave()) { | |
383 | + this.saveThisExcel(params, pojoClass, isXSSFWorkbook, book); | |
384 | + } | |
385 | + | |
386 | + return new ExcelImportResult(result, this.verfiyFail, book); | |
387 | + } | |
388 | + | |
389 | + public static byte[] getBytes(InputStream is) throws IOException { | |
390 | + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | |
391 | + byte[] data = new byte[100000]; | |
392 | + | |
393 | + int len; | |
394 | + while((len = is.read(data, 0, data.length)) != -1) { | |
395 | + buffer.write(data, 0, len); | |
396 | + } | |
397 | + | |
398 | + buffer.flush(); | |
399 | + return buffer.toByteArray(); | |
400 | + } | |
401 | + | |
402 | + private void saveFieldValue(ImportParams params, Object object, Cell cell, Map<String, ExcelImportEntity> excelParams, String titleString, Row row) throws Exception { | |
403 | + Object value = this.cellValueServer.getValue(params.getDataHanlder(), object, cell, excelParams, titleString); | |
404 | + if (object instanceof Map) { | |
405 | + if (params.getDataHanlder() != null) { | |
406 | + params.getDataHanlder().setMapValue((Map)object, titleString, value); | |
407 | + } else { | |
408 | + ((Map)object).put(titleString, value); | |
409 | + } | |
410 | + } else { | |
411 | + ExcelVerifyHanlderResult verifyResult = this.verifyHandlerServer.verifyData(object, value, titleString, ((ExcelImportEntity)excelParams.get(titleString)).getVerify(), params.getVerifyHanlder()); | |
412 | + if (!verifyResult.isSuccess()) { | |
413 | + Cell errorCell = row.createCell(row.getLastCellNum()); | |
414 | + errorCell.setCellValue(verifyResult.getMsg()); | |
415 | + errorCell.setCellStyle(this.errorCellStyle); | |
416 | + this.verfiyFail = true; | |
417 | + throw new ExcelImportException(ExcelImportEnum.VERIFY_ERROR); | |
418 | + } | |
419 | + | |
420 | + this.setValues((ExcelImportEntity)excelParams.get(titleString), object, value); | |
421 | + } | |
422 | + | |
423 | + } | |
424 | + | |
425 | + private void saveImage(Object object, String picId, Map<String, ExcelImportEntity> excelParams, String titleString, Map<String, PictureData> pictures, ImportParams params) throws Exception { | |
426 | + if (pictures != null && pictures.get(picId) != null) { | |
427 | + PictureData image = (PictureData)pictures.get(picId); | |
428 | + byte[] data = image.getData(); | |
429 | + String fileName = "pic" + Math.round(Math.random() * 1.0E11D); | |
430 | + fileName = fileName + "." + PoiPublicUtil.getFileExtendName(data); | |
431 | + int saveType = ((ExcelImportEntity)excelParams.get(titleString)).getSaveType(); | |
432 | + if (saveType == 1) { | |
433 | + String path = PoiPublicUtil.getWebRootPath(this.getSaveUrl((ExcelImportEntity)excelParams.get(titleString), object)); | |
434 | + File savefile = new File(path); | |
435 | + if (!savefile.exists()) { | |
436 | + savefile.mkdirs(); | |
437 | + } | |
438 | + | |
439 | + savefile = new File(path + "/" + fileName); | |
440 | + FileOutputStream fos = new FileOutputStream(savefile); | |
441 | + fos.write(data); | |
442 | + fos.close(); | |
443 | + this.setValues((ExcelImportEntity)excelParams.get(titleString), object, this.getSaveUrl((ExcelImportEntity)excelParams.get(titleString), object) + "/" + fileName); | |
444 | + } else if (saveType == 2) { | |
445 | + this.setValues((ExcelImportEntity)excelParams.get(titleString), object, data); | |
446 | + } else { | |
447 | + ImportFileServiceI importFileService = null; | |
448 | + | |
449 | + try { | |
450 | + importFileService = (ImportFileServiceI)ApplicationContextUtil.getContext().getBean(ImportFileServiceI.class); | |
451 | + } catch (Exception var14) { | |
452 | + System.err.println(var14.getMessage()); | |
453 | + } | |
454 | + | |
455 | + if (importFileService != null) { | |
456 | + String dbPath = importFileService.doUpload(data); | |
457 | + this.setValues((ExcelImportEntity)excelParams.get(titleString), object, dbPath); | |
458 | + } | |
459 | + } | |
460 | + | |
461 | + } | |
462 | + } | |
463 | + | |
464 | + private void createErrorCellStyle(Workbook workbook) { | |
465 | + this.errorCellStyle = workbook.createCellStyle(); | |
466 | + Font font = workbook.createFont(); | |
467 | + font.setColor((short)10); | |
468 | + this.errorCellStyle.setFont(font); | |
469 | + } | |
470 | +} | ... | ... |
juvenile-prosecution-vue/src/utils/request.js
... | ... | @@ -17,7 +17,7 @@ let apiBaseUrl = window._CONFIG['domianURL'] || "/jeecg-boot"; |
17 | 17 | const service = axios.create({ |
18 | 18 | //baseURL: '/jeecg-boot', |
19 | 19 | baseURL: apiBaseUrl, // api base_url |
20 | - timeout: 9000 // 请求超时时间 | |
20 | + timeout: 250000 // 请求超时时间 | |
21 | 21 | }) |
22 | 22 | |
23 | 23 | const err = (error) => { | ... | ... |
juvenile-prosecution-vue/src/views/business/MinorList.vue
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | <a-row :gutter="24"> |
7 | 7 | <a-col :md="6" :sm="12"> |
8 | 8 | <a-form-item label="姓名"> |
9 | - <j-input placeholder="输入姓名查询" v-model="queryParam.name"></j-input> | |
9 | + <a-input placeholder="输入姓名查询" v-model="queryParam.name"></a-input> | |
10 | 10 | </a-form-item> |
11 | 11 | </a-col> |
12 | 12 | <a-col :md="6" :sm="8"> |
... | ... | @@ -66,6 +66,10 @@ |
66 | 66 | <a @click="handleEdit(record)">编辑</a> |
67 | 67 | <a-divider type="vertical" /> |
68 | 68 | <a @click="handleDetail(record)">查看</a> |
69 | + <a-divider type="vertical" /> | |
70 | + <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)"> | |
71 | + <a>删除</a> | |
72 | + </a-popconfirm> | |
69 | 73 | </span> |
70 | 74 | </a-table> |
71 | 75 | </div> |
... | ... | @@ -337,7 +341,7 @@ export default { |
337 | 341 | } |
338 | 342 | let param = { 'fileName': name, 'type': type } |
339 | 343 | console.log('导出参数', param) |
340 | - downFile(this.url.importExcelUrl, param).then((data) => { | |
344 | + downFile(this.url.exportXlsUrl, param).then((data) => { | |
341 | 345 | console.log(data) |
342 | 346 | if (!data) { |
343 | 347 | this.$message.warning('文件下载失败') | ... | ... |
juvenile-prosecution-vue/src/views/business/SourceCom.vue
0 → 100644
1 | +<template> | |
2 | + <a-card :bordered="false"> | |
3 | + <source-statistics ref="sourceStatistics" v-if="show" @to_source_list="toSourceList"/> | |
4 | + <source-list ref="sourceList" v-if="!show" @to_statistics="toStatistics"/> | |
5 | + </a-card> | |
6 | +</template> | |
7 | + | |
8 | +<script> | |
9 | + import '@/assets/less/TableExpand.less' | |
10 | + import SourceStatistics from './SourceStatistics' | |
11 | + import SourceList from './SourceList' | |
12 | + | |
13 | + export default { | |
14 | + name: 'SourceCom', | |
15 | + components: { | |
16 | + SourceStatistics,SourceList | |
17 | + }, | |
18 | + data () { | |
19 | + return { | |
20 | + description: '来源数据管理管理页面', | |
21 | + show:true, | |
22 | + } | |
23 | + }, | |
24 | + created() { | |
25 | + this.show=true; | |
26 | + }, | |
27 | + computed: { | |
28 | + }, | |
29 | + methods: { | |
30 | + toStatistics(){ | |
31 | + this.show=true; | |
32 | + }, | |
33 | + toSourceList(record){ | |
34 | + this.show=false; | |
35 | + this.$nextTick(() => { | |
36 | + this.$refs.sourceList.getData(record.name); | |
37 | + }) | |
38 | + } | |
39 | + } | |
40 | + } | |
41 | +</script> | |
42 | +<style scoped> | |
43 | + @import '~@assets/less/common.less'; | |
44 | +</style> | |
0 | 45 | \ No newline at end of file | ... | ... |
juvenile-prosecution-vue/src/views/business/SourceList.vue
1 | 1 | <template> |
2 | 2 | <a-card :bordered="false"> |
3 | -<!-- <a-page-header--> | |
4 | -<!-- class="demo-page-header"--> | |
5 | -<!-- style="border: 1px solid rgb(235, 237, 240)"--> | |
6 | -<!-- title="返回"--> | |
7 | -<!-- sub-title="数据批次"--> | |
8 | -<!-- @back="goBack"--> | |
9 | -<!-- ></a-page-header>--> | |
3 | + <a-page-header | |
4 | + class="demo-page-header" | |
5 | + title="数据批次" | |
6 | + @back="goBack" | |
7 | + ></a-page-header> | |
10 | 8 | |
11 | 9 | <!-- table区域-begin --> |
12 | 10 | <div> |
... | ... | @@ -117,11 +115,6 @@ |
117 | 115 | } |
118 | 116 | }, |
119 | 117 | created() { |
120 | - this.getSuperFieldList(); | |
121 | - this.queryParam={ | |
122 | - name:this.$route.query.unitName | |
123 | - } | |
124 | - this.loadData(1) | |
125 | 118 | }, |
126 | 119 | computed: { |
127 | 120 | importExcelUrl: function(){ |
... | ... | @@ -129,10 +122,14 @@ |
129 | 122 | }, |
130 | 123 | }, |
131 | 124 | methods: { |
125 | + getData(unitName){ | |
126 | + this.queryParam={ | |
127 | + name:unitName | |
128 | + } | |
129 | + this.loadData(1) | |
130 | + }, | |
132 | 131 | goBack(){ |
133 | - this.$router.go(-1); | |
134 | - | |
135 | - // this.$router.re({name:'business-SourceList',query: {unitName:record.name}}) | |
132 | + this.$emit('to_statistics'); | |
136 | 133 | }, |
137 | 134 | loadData(arg) { |
138 | 135 | if(!this.url.list){ |
... | ... | @@ -205,4 +202,8 @@ |
205 | 202 | </script> |
206 | 203 | <style scoped> |
207 | 204 | @import '~@assets/less/common.less'; |
205 | + .demo-page-header{ | |
206 | + opacity: 0.6; | |
207 | + } | |
208 | + | |
208 | 209 | </style> |
209 | 210 | \ No newline at end of file | ... | ... |
juvenile-prosecution-vue/src/views/business/SourceStatistics.vue
... | ... | @@ -112,10 +112,7 @@ |
112 | 112 | }, |
113 | 113 | methods: { |
114 | 114 | handleDetail(record){ |
115 | - console.log(record.name) | |
116 | - // this.$router.push({ name: 'business-SourceList',params:{'unitName':record.name}}) | |
117 | - this.$router.push({name:'business-SourceList',query: {unitName:record.name}}) | |
118 | - console.log(this.$router) | |
115 | + this.$emit('to_source_list', record); | |
119 | 116 | }, |
120 | 117 | initDictConfig(){ |
121 | 118 | }, | ... | ... |