| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.OffsetTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | import javax.annotation.Resource; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.databind.BeanProperty; |
| | | import com.itextpdf.text.Document; |
| | | import com.itextpdf.text.DocumentException; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.common.core.domain.entity.SysUser; |
| | | import com.ltkj.common.core.redis.RedisCache; |
| | | import com.ltkj.common.enums.DataSourceType; |
| | | import com.ltkj.common.utils.PDFDocumentUtil; |
| | | import com.ltkj.common.utils.SecurityUtils; |
| | | import com.ltkj.framework.config.MatchUtils; |
| | | import com.ltkj.framework.config.UserHoder; |
| | |
| | | @PostMapping("/addPlOrderAndDetail") |
| | | @ApiOperation(value = "体检批量签到登记接口") |
| | | @Transactional //(切换数据库出错,所以注释) |
| | | public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto) { |
| | | public AjaxResult addPlOrderAndDetail(@RequestBody QianDaoDto daoDto,HttpServletResponse response) { |
| | | SysUser sysUser = UserHoder.getLoginUser().getUser(); |
| | | List<String> cusIds = daoDto.getCusIds(); |
| | | ArrayList<String> tjNumbers = new ArrayList<>(); |
| | | if (null != cusIds && cusIds.size() > 0) { |
| | | ExecutorService threadPools = Executors.newFixedThreadPool(cusIds.size()); |
| | | for (String cusId : cusIds) { |
| | |
| | | if (list.size() > 0) { |
| | | ExecutorService threadPool = Executors.newFixedThreadPool(list.size()); |
| | | for (Long aLong : list) { |
| | | threadPool.execute(new Runnable() { |
| | | // threadPool.execute(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // try { |
| | | // AjaxResult result = getAjaxResult(aLong, sysUser, daoDto.getTjCategory()); |
| | | // threadPool.shutdown(); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // }); |
| | | Future<AjaxResult> future = threadPool.submit(new Callable<AjaxResult>() { |
| | | @Override |
| | | public void run() { |
| | | public AjaxResult call() throws Exception { |
| | | return getAjaxResult(aLong, sysUser, daoDto.getTjCategory()); |
| | | } |
| | | }); |
| | | try { |
| | | getAjaxResult(aLong, sysUser, daoDto.getTjCategory()); |
| | | threadPool.shutdown(); |
| | | } catch (IOException e) { |
| | | AjaxResult result = future.get(); |
| | | String tjNumber = result.get("tjNumber").toString(); |
| | | tjNumbers.add(tjNumber); |
| | | } catch (InterruptedException | ExecutionException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | threadPool.shutdown(); |
| | | } |
| | | } |
| | | System.out.println("tjNumbers = " + tjNumbers); |
| | | // TODO 因为有体检号会查出空数据 先使用死数据 |
| | | tjNumbers = new ArrayList<>(); |
| | | tjNumbers.add("02095240229171627"); |
| | | tjNumbers.add("02095240229173104"); |
| | | tjNumbers.add("10001240524172002"); |
| | | tjNumbers.add("10001240304124410"); |
| | | tjNumbers.add("00325240304160123"); |
| | | tjNumbers.add("02095240304162044"); |
| | | tjNumbers.add("02095240304162152"); |
| | | tjNumbers.add("10001240304163505"); |
| | | Map<String, Object> map = null; |
| | | try { |
| | | map = PDFDocumentUtil.getDocument(); |
| | | Document document = (Document) map.get("document"); |
| | | for (int i = 0; i < tjNumbers.size(); i++) { |
| | | try { |
| | | List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumbers.get(i)); |
| | | Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumbers.get(i)); |
| | | System.out.println(userInfo); |
| | | LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj"); |
| | | DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); |
| | | PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex") |
| | | , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), dateFormat.format(tjsj)); |
| | | PDFDocumentUtil.makeTjInfo(document, djdInfos); |
| | | // 多条则换页 |
| | | if (i + 1 < tjNumbers.size()) { |
| | | document.newPage(); |
| | | } |
| | | } catch (DocumentException | IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | document.close(); |
| | | // TODO 修改返回文件base64 |
| | | ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream"); |
| | | // 设置HTTP响应头 |
| | | response.setContentType("application/pdf"); |
| | | response.setHeader("Content-Disposition", "inline; filename=\"downloaded.pdf\""); |
| | | response.getOutputStream().write(outputStream.toByteArray()); |
| | | response.getOutputStream().flush(); |
| | | } catch (IOException | DocumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return AjaxResult.success("操作成功"); |
| | | } |
| | |
| | | tjOrder.setStatus(TjConstants.TJ_BEGIN); |
| | | tjOrder.setCardId(tjCustomer.getCardId()); |
| | | tjOrder.setTjType("1"); |
| | | |
| | | if (tjOrderService.save(tjOrder)) { |
| | | |
| | | //保存收货地址 |
| | | if ("2".equals(tjOrder.getGetType())) { |
| | | final TjReportGetAddress address = tjOrder.getAddAddress(); |
| | |
| | | |
| | | tjCustomer.setCardId("0"); |
| | | tjCustomerService.updateById(tjCustomer); |
| | | return AjaxResult.success(tjNumber); |
| | | return AjaxResult.success().put("tjNumber",tjNumber); |
| | | } |
| | | } |
| | | return AjaxResult.error(); |
| | |
| | | return AjaxResult.error("请选择要撤销的人员!"); |
| | | } |
| | | |
| | | // @PostMapping("makeTjPDF1") |
| | | // @ApiOperation(value = "根据体检号生成PDF") |
| | | // public AjaxResult makeTjPDF(@RequestBody List<String> tjNumbers, HttpServletResponse response) { |
| | | // System.out.println("tjNumbers = " + tjNumbers); |
| | | // Map<String, Object> map = null; |
| | | // try { |
| | | // map = PDFDocumentUtil.getDocument(); |
| | | // Document document = (Document) map.get("document"); |
| | | // for (int i = 0; i < tjNumbers.size(); i++) { |
| | | // try { |
| | | // List<Map<String, String>> djdInfos = tjOrderService.selectDjdInfo(tjNumbers.get(i)); |
| | | // Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumbers.get(i)); |
| | | // PDFDocumentUtil.makeUserInfoTable(document, userInfo.get("tjname"), userInfo.get("sex"), userInfo.get("tjh"), userInfo.get("lxdh"), userInfo.get("tjname"), userInfo.get("tjsj")); |
| | | // PDFDocumentUtil.makeTjInfo(document, djdInfos); |
| | | // // 多条则换页 |
| | | // if (i + 1 < tjNumbers.size()) { |
| | | // document.newPage(); |
| | | // } |
| | | // } catch (DocumentException | IOException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // document.close(); |
| | | // } catch (IOException | DocumentException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // return AjaxResult.success(); |
| | | // } |
| | | |
| | | } |
| | | |