|
@@ -52,7 +52,6 @@ import java.util.stream.Collectors;
|
|
|
* <p>
|
|
|
* 报告审核导出
|
|
|
* </p>
|
|
|
- *
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@RestController
|
|
@@ -60,798 +59,788 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping("/reportExport")
|
|
|
public class ReportExportController {
|
|
|
|
|
|
- private final WmTaskService wmTaskService;
|
|
|
+ private final WmTaskService wmTaskService;
|
|
|
+ private final ReportExportService reportExportService;
|
|
|
+ private final SysDeptService sysDeptService;
|
|
|
+ private final WmScorePackageService wmScorePackageService;
|
|
|
+ private final ReportHandlerDeptRelationMapper reportHandlerDeptRelationMapper;
|
|
|
+ private final JavaMailSender sender;
|
|
|
+ private final UpmsConfig upmsConfig;
|
|
|
+ private final RedisTemplate<String, String> redisTemplate;
|
|
|
+ private final RabbitMqClient rabbitMqClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报告导出--个人报告导出分页查询 用于BC
|
|
|
+ *
|
|
|
+ * @param page 分页对象
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getExportPackageZbTotalListForBC")
|
|
|
+ public R getExportPackageZbTotalListForBC(Page page, WmScorePackage wmScorePackage) {
|
|
|
+
|
|
|
+ return reportExportService.getExportPackageZbTotalList(page, wmScorePackage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报告导出--个人报告导出分页查询
|
|
|
+ *
|
|
|
+ * @param page 分页对象
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getExportPackageZbTotalList")
|
|
|
+ public R getExportPackageZbTotalList(Page page, WmScorePackage wmScorePackage) {
|
|
|
+
|
|
|
+ wmScorePackage.setSendPackageDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
+
|
|
|
+ return reportExportService.getExportPackageZbTotalList(page, wmScorePackage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报告导出--查看任务
|
|
|
+ *
|
|
|
+ * @param page 分页对象
|
|
|
+ * @param wmTask
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getExportPackageZbTaskList")
|
|
|
+ public R getExportPackageZbTaskList(Page page, WmTask wmTask) {
|
|
|
+ if (StringUtil.isEmpty(wmTask.getScorePackageId())) {
|
|
|
+ return R.failed("积分包ID不能为空");
|
|
|
+ }
|
|
|
+ return reportExportService.getExportPackageZbTaskList(page, wmTask);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 结算报告管理--导出汇总或详情
|
|
|
+ *
|
|
|
+ * @param wmReport
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SysLog("报告导出exportNbReviewReport")
|
|
|
+ @GetMapping("/exportNbReviewReport")
|
|
|
+ public R exportNbReviewReport(WmReport wmReport) {
|
|
|
+ log.info("报告导出请求参数:{}", wmReport);
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.EXPORT_NB_REVIEW_REPORT_CACHE, wmReport.getId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(wmReport));
|
|
|
+ map.put("username", user.getUsername());
|
|
|
+ map.put("deptId", user.getDeptId());
|
|
|
+ map.put("approvalOpinion", null);
|
|
|
+
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_NB_REVIEW_QUEUE, map);
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
+ CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 结算报告管理--导出汇总或详情
|
|
|
+ *
|
|
|
+ * @param wmReport
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @GetMapping("/exportNbReviewReport/status")
|
|
|
+ public R exportNbReviewReportStatus(WmReport wmReport) {
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.EXPORT_NB_REVIEW_REPORT_CACHE, wmReport.getId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+ WmReportOpt opt = new WmReportOpt();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o)) {
|
|
|
+ // 生成中的
|
|
|
+ if ("GENERATING".equals(o)) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
+ }
|
|
|
+ // 生成失败的
|
|
|
+ else if (o.startsWith("ERROR")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
+ }
|
|
|
+ // 生成失败的2
|
|
|
+ else if (!o.startsWith("http")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o);
|
|
|
+ }
|
|
|
+ // 成功的
|
|
|
+ else {
|
|
|
+ Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
+ opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
+ opt.setLatestUrl(o);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(opt);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 结算报告管理--导出汇总或详情
|
|
|
+ *
|
|
|
+ * @param wmReport
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @GetMapping("/exportNbReport")
|
|
|
+ public R exportNbReport(WmReport wmReport) throws IOException {
|
|
|
+ log.info("报告导出请求参数:{}", wmReport);
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.EXPORT_NB_REPORT_CACHE, wmReport.getId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
+
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(wmReport));
|
|
|
+ map.put("username", user.getUsername());
|
|
|
+ map.put("deptId", user.getDeptId());
|
|
|
+
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_NB_QUEUE, map);
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
+ CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人报告导出状态
|
|
|
+ *
|
|
|
+ * @param wmTask
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @GetMapping("/exportZbReport/status")
|
|
|
+ public R exportZbReportStatus(WmTask wmTask) throws IOException {
|
|
|
+
|
|
|
+ String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
+
|
|
|
+ // 判断是否是合并导出
|
|
|
+ if (scorePackageDrugId.contains(StrUtil.COMMA)) {
|
|
|
+ String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
+ scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
+ wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.EXPORT_ZB_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+ WmReportOpt opt = new WmReportOpt();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o)) {
|
|
|
+ // 生成中的
|
|
|
+ if ("GENERATING".equals(o)) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
+ }
|
|
|
+ // 生成失败的
|
|
|
+ else if (o.startsWith("ERROR")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
+ }
|
|
|
+ // 生成失败的2
|
|
|
+ else if (!o.startsWith("http")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o);
|
|
|
+ }
|
|
|
+ // 成功的
|
|
|
+ else {
|
|
|
+ Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
+ opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
+ opt.setLatestUrl(o);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(opt);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人报告导出状态
|
|
|
+ *
|
|
|
+ * @param wmTask
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @GetMapping("/exportZbReviewReport/status")
|
|
|
+ public R exportZbReviewReportStatus(WmTask wmTask) {
|
|
|
+
|
|
|
+ String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
+
|
|
|
+ // 判断是否是合并导出
|
|
|
+ if (scorePackageDrugId.contains(StrUtil.COMMA)) {
|
|
|
+ String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
+ scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
+ wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.EXPORT_ZB_REVIEW_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+ WmReportOpt opt = new WmReportOpt();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o)) {
|
|
|
+ // 生成中的
|
|
|
+ if ("GENERATING".equals(o)) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
+ }
|
|
|
+ // 生成失败的
|
|
|
+ else if (o.startsWith("ERROR")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
+ }
|
|
|
+ // 生成失败的2
|
|
|
+ else if (!o.startsWith("http")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o);
|
|
|
+ }
|
|
|
+ // 成功的
|
|
|
+ else {
|
|
|
+ Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
+ opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
+ opt.setLatestUrl(o);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(opt);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版(只导出待审核的任务)
|
|
|
+ *
|
|
|
+ * @param wmTask
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @GetMapping("/exportZbReviewReport")
|
|
|
+ public R<?> exportZbReviewReport(WmTask wmTask) {
|
|
|
+ log.info("报告导出请求参数:{}", wmTask);
|
|
|
+
|
|
|
+ String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
+
|
|
|
+ // 判断是否是合并导出
|
|
|
+ if (scorePackageDrugId.contains(StrUtil.COMMA)) {
|
|
|
+ String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
+ scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
+ wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.EXPORT_ZB_REVIEW_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
+
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(wmTask));
|
|
|
+ map.put("username", user.getUsername());
|
|
|
+ map.put("deptId", user.getDeptId());
|
|
|
+ map.put("taskStatus", "2");
|
|
|
+
|
|
|
+ SysDept dept = sysDeptService.getById(user.getDeptId());
|
|
|
+ map.put("isGuangshengtang", "913500007297027606".equals(dept.getTaxCode()));
|
|
|
+
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_ZB_REVIEW_QUEUE, map);
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
+ CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版
|
|
|
+ *
|
|
|
+ * @param wmTask 参数
|
|
|
+ * @return 导出信息
|
|
|
+ */
|
|
|
+ @GetMapping("/exportZbReport")
|
|
|
+ public R<String> exportZbReport(WmTask wmTask) {
|
|
|
+ log.info("报告导出请求参数:{}", wmTask);
|
|
|
+
|
|
|
+ String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
+
|
|
|
+ // 判断是否是合并导出
|
|
|
+ if (scorePackageDrugId.contains(StrUtil.COMMA)) {
|
|
|
+ String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
+ scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
+ wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.EXPORT_ZB_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+ }
|
|
|
+
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(wmTask));
|
|
|
+ map.put("username", user.getUsername());
|
|
|
+ map.put("deptId", user.getDeptId());
|
|
|
+ map.put("isGuangshengtang", false);
|
|
|
+
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_ZB_QUEUE, map);
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(), CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
|
|
|
- private final ReportExportService reportExportService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版
|
|
|
+ *
|
|
|
+ * @param packageId 积分包id
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @SysLog("报告导出exportHCPReport")
|
|
|
+ @GetMapping("/exportHCPReport")
|
|
|
+ public R exportHCPReport(String packageId) throws IOException {
|
|
|
+ log.info("报告导出请求参数:packageId={}", packageId);
|
|
|
+
|
|
|
+ if (null == packageId) {
|
|
|
+ return R.failed("积分包ID不能为空");
|
|
|
+ }
|
|
|
|
|
|
- private final SysDeptService sysDeptService;
|
|
|
+ return reportExportService.exportHCP(packageId);
|
|
|
+ }
|
|
|
|
|
|
- private final WmScorePackageService wmScorePackageService;
|
|
|
-
|
|
|
- private final ReportHandlerDeptRelationMapper reportHandlerDeptRelationMapper;
|
|
|
-
|
|
|
- private final JavaMailSender sender;
|
|
|
-
|
|
|
- private final UpmsConfig upmsConfig;
|
|
|
- private final RedisTemplate<String,String> redisTemplate;
|
|
|
- private final RabbitMqClient rabbitMqClient;
|
|
|
-
|
|
|
- /**
|
|
|
- * 报告导出--个人报告导出分页查询 用于BC
|
|
|
- *
|
|
|
- * @param page 分页对象
|
|
|
- * @param wmScorePackage 积分包
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping("/getExportPackageZbTotalListForBC")
|
|
|
- public R getExportPackageZbTotalListForBC(Page page, WmScorePackage wmScorePackage) {
|
|
|
-
|
|
|
- return reportExportService.getExportPackageZbTotalList(page,wmScorePackage);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 报告导出--个人报告导出分页查询
|
|
|
- *
|
|
|
- * @param page 分页对象
|
|
|
- * @param wmScorePackage 积分包
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping("/getExportPackageZbTotalList")
|
|
|
- public R getExportPackageZbTotalList(Page page, WmScorePackage wmScorePackage) {
|
|
|
-
|
|
|
- wmScorePackage.setSendPackageDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
-
|
|
|
- return reportExportService.getExportPackageZbTotalList(page,wmScorePackage);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 报告导出--查看任务
|
|
|
- *
|
|
|
- * @param page 分页对象
|
|
|
- * @param wmTask
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping("/getExportPackageZbTaskList")
|
|
|
- public R getExportPackageZbTaskList(Page page, WmTask wmTask) {
|
|
|
- if(StringUtil.isEmpty(wmTask.getScorePackageId())){
|
|
|
- return R.failed("积分包ID不能为空");
|
|
|
- }
|
|
|
- return reportExportService.getExportPackageZbTaskList(page,wmTask);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 结算报告管理--导出汇总或详情
|
|
|
- * @param wmReport
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @SysLog("报告导出exportNbReviewReport")
|
|
|
- @GetMapping("/exportNbReviewReport")
|
|
|
- public R exportNbReviewReport(WmReport wmReport) {
|
|
|
- log.info("报告导出请求参数:{}", wmReport);
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_NB_REVIEW_REPORT_CACHE, wmReport.getId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
-
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- map.put("requestBody", JSONUtil.toJsonStr(wmReport));
|
|
|
- map.put("username",user.getUsername());
|
|
|
- map.put("deptId",user.getDeptId());
|
|
|
- map.put("approvalOpinion", null);
|
|
|
-
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_NB_REVIEW_QUEUE,map);
|
|
|
-
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
-
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 结算报告管理--导出汇总或详情
|
|
|
- *
|
|
|
- * @param wmReport
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @GetMapping("/exportNbReviewReport/status")
|
|
|
- public R exportNbReviewReportStatus(WmReport wmReport) {
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_NB_REVIEW_REPORT_CACHE, wmReport.getId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
- WmReportOpt opt = new WmReportOpt();
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o)) {
|
|
|
- // 生成中的
|
|
|
- if ("GENERATING".equals(o)) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
- }
|
|
|
- // 生成失败的
|
|
|
- else if (o.startsWith("ERROR")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
- }
|
|
|
- // 生成失败的2
|
|
|
- else if (!o.startsWith("http")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o);
|
|
|
- }
|
|
|
- // 成功的
|
|
|
- else {
|
|
|
- Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
- opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
- opt.setLatestUrl(o);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
- }
|
|
|
-
|
|
|
- return R.ok(opt);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 结算报告管理--导出汇总或详情
|
|
|
- * @param wmReport
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @GetMapping("/exportNbReport")
|
|
|
- public R exportNbReport(WmReport wmReport ) throws IOException {
|
|
|
- log.info("报告导出请求参数:{}", wmReport);
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_NB_REPORT_CACHE, wmReport.getId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
-
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- map.put("requestBody", JSONUtil.toJsonStr(wmReport));
|
|
|
- map.put("username",user.getUsername());
|
|
|
- map.put("deptId",user.getDeptId());
|
|
|
-
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_NB_QUEUE,map);
|
|
|
-
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
-
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 个人报告导出状态
|
|
|
- *
|
|
|
- * @param wmTask
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @GetMapping("/exportZbReport/status")
|
|
|
- public R exportZbReportStatus(WmTask wmTask) throws IOException {
|
|
|
-
|
|
|
- String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
-
|
|
|
- // 判断是否是合并导出
|
|
|
- if (scorePackageDrugId.contains(StrUtil.COMMA)) {
|
|
|
- String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
- scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
- wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_ZB_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
- WmReportOpt opt = new WmReportOpt();
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o)) {
|
|
|
- // 生成中的
|
|
|
- if ("GENERATING".equals(o)) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
- }
|
|
|
- // 生成失败的
|
|
|
- else if (o.startsWith("ERROR")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
- }
|
|
|
- // 生成失败的2
|
|
|
- else if (!o.startsWith("http")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o);
|
|
|
- }
|
|
|
- // 成功的
|
|
|
- else {
|
|
|
- Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
- opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
- opt.setLatestUrl(o);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
- }
|
|
|
-
|
|
|
- return R.ok(opt);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 个人报告导出状态
|
|
|
- *
|
|
|
- * @param wmTask
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @GetMapping("/exportZbReviewReport/status")
|
|
|
- public R exportZbReviewReportStatus(WmTask wmTask) {
|
|
|
-
|
|
|
- String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
-
|
|
|
- // 判断是否是合并导出
|
|
|
- if (scorePackageDrugId.contains(StrUtil.COMMA)) {
|
|
|
- String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
- scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
- wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_ZB_REVIEW_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
- WmReportOpt opt = new WmReportOpt();
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o)) {
|
|
|
- // 生成中的
|
|
|
- if ("GENERATING".equals(o)) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
- }
|
|
|
- // 生成失败的
|
|
|
- else if (o.startsWith("ERROR")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
- }
|
|
|
- // 生成失败的2
|
|
|
- else if (!o.startsWith("http")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o);
|
|
|
- }
|
|
|
- // 成功的
|
|
|
- else {
|
|
|
- Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
- opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
- opt.setLatestUrl(o);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
- }
|
|
|
-
|
|
|
- return R.ok(opt);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版(只导出待审核的任务)
|
|
|
- * @param wmTask
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @GetMapping("/exportZbReviewReport")
|
|
|
- public R<?> exportZbReviewReport(WmTask wmTask) {
|
|
|
- log.info("报告导出请求参数:{}", wmTask);
|
|
|
-
|
|
|
- String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
-
|
|
|
- // 判断是否是合并导出
|
|
|
- if (scorePackageDrugId.contains(StrUtil.COMMA)){
|
|
|
- String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
- scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
- wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_ZB_REVIEW_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
-
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- map.put("requestBody", JSONUtil.toJsonStr(wmTask));
|
|
|
- map.put("username",user.getUsername());
|
|
|
- map.put("deptId",user.getDeptId());
|
|
|
- map.put("taskStatus", "2");
|
|
|
-
|
|
|
- SysDept dept = sysDeptService.getById(user.getDeptId());
|
|
|
- map.put("isGuangshengtang", "913500007297027606".equals(dept.getTaxCode()));
|
|
|
-
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_ZB_REVIEW_QUEUE, map);
|
|
|
-
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
-
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版
|
|
|
- * @param wmTask
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @GetMapping("/exportZbReport")
|
|
|
- public R exportZbReport(WmTask wmTask) throws IOException {
|
|
|
- log.info("报告导出请求参数:{}", wmTask);
|
|
|
-
|
|
|
- String scorePackageDrugId = wmTask.getScorePackageDrugId();
|
|
|
-
|
|
|
- // 判断是否是合并导出
|
|
|
- if (scorePackageDrugId.contains(StrUtil.COMMA)){
|
|
|
- String[] idArr = scorePackageDrugId.split(StrUtil.COMMA);
|
|
|
- scorePackageDrugId = Arrays.stream(idArr).sorted().collect(Collectors.joining(StrUtil.COMMA));
|
|
|
- wmTask.setScorePackageDrugId(scorePackageDrugId);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_ZB_REPORT_CACHE, wmTask.getScorePackageDrugId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
-
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- map.put("requestBody", JSONUtil.toJsonStr(wmTask));
|
|
|
- map.put("username",user.getUsername());
|
|
|
- map.put("deptId",user.getDeptId());
|
|
|
-
|
|
|
- SysDept dept = sysDeptService.getById(user.getDeptId());
|
|
|
- map.put("isGuangshengtang", "913500007297027606".equals(dept.getTaxCode()));
|
|
|
-
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_ZB_QUEUE,map);
|
|
|
-
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
-
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版
|
|
|
- * @param packageId 积分包id
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @SysLog("报告导出exportHCPReport")
|
|
|
- @GetMapping("/exportHCPReport")
|
|
|
- public R exportHCPReport(String packageId) throws IOException {
|
|
|
- log.info("报告导出请求参数:packageId={}", packageId);
|
|
|
-
|
|
|
- if (null == packageId) {
|
|
|
- return R.failed("积分包ID不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- return reportExportService.exportHCP(packageId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版
|
|
|
- * @param input
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @SysLog("报告导出exportZbInfoFormWeiNew")
|
|
|
- @GetMapping("/exportZbInfoFormWeiNew")
|
|
|
- public R exportZbInfoFormWeiNew(WmPackageExportApiInput input) {
|
|
|
- log.info("报告导出请求参数:{}", input);
|
|
|
-
|
|
|
- String packageId=input.getId();
|
|
|
- if (null == packageId) {
|
|
|
- return R.failed("积分包ID不能为空");
|
|
|
- }
|
|
|
- LambdaQueryWrapper<WmTask> queryWrapper=new LambdaQueryWrapper();
|
|
|
- queryWrapper.in(WmTask::getScorePackageId, Arrays.asList(packageId.split(",")));
|
|
|
- queryWrapper.eq(WmTask::getTaskStatus,"3");
|
|
|
- queryWrapper.eq(WmTask::getDelFlag,"0");
|
|
|
- queryWrapper.eq(WmTask::getEnableFlag,"0");
|
|
|
- queryWrapper.eq(WmTask::getRealFlag,"0");
|
|
|
- List<WmTask> taskList=wmTaskService.list(queryWrapper);
|
|
|
- if(taskList.isEmpty()){
|
|
|
- return R.failed("未查询到审核通过的任务");
|
|
|
- }
|
|
|
- String ids = taskList.stream().map(WmTask::getId).collect(Collectors.joining("," ));
|
|
|
-
|
|
|
- WmTask wmTask = new WmTask();
|
|
|
- wmTask.setScorePackageId(packageId);
|
|
|
- wmTask.setId(ids);
|
|
|
+ /**
|
|
|
+ * 个人报告导出--导出汇总或详情 汇总和详情合为一个模版
|
|
|
+ *
|
|
|
+ * @param input
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @SysLog("报告导出exportZbInfoFormWeiNew")
|
|
|
+ @GetMapping("/exportZbInfoFormWeiNew")
|
|
|
+ public R exportZbInfoFormWeiNew(WmPackageExportApiInput input) {
|
|
|
+ log.info("报告导出请求参数:{}", input);
|
|
|
+
|
|
|
+ String packageId = input.getId();
|
|
|
+ if (null == packageId) {
|
|
|
+ return R.failed("积分包ID不能为空");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<WmTask> queryWrapper = new LambdaQueryWrapper();
|
|
|
+ queryWrapper.in(WmTask::getScorePackageId, Arrays.asList(packageId.split(",")));
|
|
|
+ queryWrapper.eq(WmTask::getTaskStatus, "3");
|
|
|
+ queryWrapper.eq(WmTask::getDelFlag, "0");
|
|
|
+ queryWrapper.eq(WmTask::getEnableFlag, "0");
|
|
|
+ queryWrapper.eq(WmTask::getRealFlag, "0");
|
|
|
+ List<WmTask> taskList = wmTaskService.list(queryWrapper);
|
|
|
+ if (taskList.isEmpty()) {
|
|
|
+ return R.failed("未查询到审核通过的任务");
|
|
|
+ }
|
|
|
+ String ids = taskList.stream().map(WmTask::getId).collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ WmTask wmTask = new WmTask();
|
|
|
+ wmTask.setScorePackageId(packageId);
|
|
|
+ wmTask.setId(ids);
|
|
|
|
|
|
// return reportExportService.exportZb(wmTask);//报告汇总
|
|
|
|
|
|
- R r = R.ok();
|
|
|
- try {
|
|
|
- r = reportExportService.exportZb(wmTask);//报告汇总
|
|
|
+ R r = R.ok();
|
|
|
+ try {
|
|
|
+ r = reportExportService.exportZb(wmTask);// 报告汇总
|
|
|
|
|
|
- if (r.getCode() == 0) {
|
|
|
- log.info("文件生成成功");
|
|
|
- } else {
|
|
|
- return r;
|
|
|
- }
|
|
|
- Map<String, String> resultMap = (Map<String, String>) r.getData();
|
|
|
+ if (r.getCode() == 0) {
|
|
|
+ log.info("文件生成成功");
|
|
|
+ } else {
|
|
|
+ return r;
|
|
|
+ }
|
|
|
+ Map<String, String> resultMap = (Map<String, String>) r.getData();
|
|
|
|
|
|
- MimeMessage mail = sender.createMimeMessage();
|
|
|
- try {
|
|
|
+ MimeMessage mail = sender.createMimeMessage();
|
|
|
+ try {
|
|
|
|
|
|
- MimeMessageHelper helper = new MimeMessageHelper(mail, true);
|
|
|
+ MimeMessageHelper helper = new MimeMessageHelper(mail, true);
|
|
|
|
|
|
- helper.setFrom(upmsConfig.getFormMail());
|
|
|
- helper.setTo(input.getEmail());
|
|
|
+ helper.setFrom(upmsConfig.getFormMail());
|
|
|
+ helper.setTo(input.getEmail());
|
|
|
|
|
|
- helper.setSubject("要易云平台学术信息沟通专员业绩报告");
|
|
|
+ helper.setSubject("要易云平台学术信息沟通专员业绩报告");
|
|
|
|
|
|
- helper.setText("要易云平台学术信息沟通专员业绩报告","尊敬的学术信息沟通专员:" +
|
|
|
- "<br/> 感谢您使用要易平台,下载业绩报告请<a href=" + resultMap.get("url") + ">点击链接</a >");
|
|
|
- /**
|
|
|
- * 附件
|
|
|
- */
|
|
|
+ helper.setText("要易云平台学术信息沟通专员业绩报告", "尊敬的学术信息沟通专员:" +
|
|
|
+ "<br/> 感谢您使用要易平台,下载业绩报告请<a href=" + resultMap.get("url") + ">点击链接</a >");
|
|
|
+ /**
|
|
|
+ * 附件
|
|
|
+ */
|
|
|
// helper.addAttachment("众包代表业绩报告明细", multipartFile);
|
|
|
|
|
|
- sender.send(mail);
|
|
|
- } catch (MessagingException ex) {
|
|
|
- log.error("邮件发送失败");
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return R.failed();
|
|
|
- }
|
|
|
- return r;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 结算包-报告导出--导出汇总或详情
|
|
|
- * @param wmTask
|
|
|
- *@param exportType 1 导出汇总 2导出详情
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @SysLog("报告导出exportZbInfoJs")
|
|
|
- @GetMapping("/exportZbInfoJs")
|
|
|
- public R exportZbInfoJs(WmTask wmTask, String exportType) throws IOException {
|
|
|
- log.info("报告导出请求参数:{}", wmTask);
|
|
|
-
|
|
|
- String packageId=wmTask.getScorePackageDrugId();
|
|
|
- if (null == packageId) {
|
|
|
- return R.failed("积分包ID不能为空");
|
|
|
- }
|
|
|
- LambdaQueryWrapper<WmTask> queryWrapper=new LambdaQueryWrapper();
|
|
|
- queryWrapper.in(WmTask::getScorePackageId, Arrays.asList(packageId.split(",")));
|
|
|
- queryWrapper.eq(WmTask::getTaskStatus,"3");
|
|
|
- queryWrapper.eq(WmTask::getDelFlag,"0");
|
|
|
- queryWrapper.eq(WmTask::getEnableFlag,"0");
|
|
|
- List<WmTask> taskList=wmTaskService.list(queryWrapper);
|
|
|
- if(taskList.isEmpty()){
|
|
|
- return R.failed("未查询到审核通过的任务");
|
|
|
- }
|
|
|
- String ids = taskList.stream().map(WmTask::getId).collect(Collectors.joining("," ));
|
|
|
- wmTask.setScorePackageId(packageId);
|
|
|
- wmTask.setId(ids);
|
|
|
-
|
|
|
- return reportExportService.exportZbJs(wmTask);//报告汇总
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 历史数据导出报告
|
|
|
- * @param wmScorePackage
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- @SysLog("报告导出exportNbaHistory")
|
|
|
- @GetMapping("/exportNbaHistory")
|
|
|
- public R exportNbaHistory(WmScorePackage wmScorePackage) throws IOException {
|
|
|
- log.info("报告导出请求参数:{}", wmScorePackage);
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.EXPORT_NBA_HISTORY_REPORT_CACHE,wmScorePackage.getId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
-
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- map.put("requestBody",JSONUtil.toJsonStr(wmScorePackage));
|
|
|
- map.put("username",user.getUsername());
|
|
|
- map.put("deptId",user.getDeptId());
|
|
|
-
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_NBA_HISTORY_QUEUE,map);
|
|
|
-
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL,TimeUnit.MILLISECONDS);
|
|
|
+ sender.send(mail);
|
|
|
+ } catch (MessagingException ex) {
|
|
|
+ log.error("邮件发送失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.failed();
|
|
|
+ }
|
|
|
+ return r;
|
|
|
+
|
|
|
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ /**
|
|
|
+ * 结算包-报告导出--导出汇总或详情
|
|
|
+ *
|
|
|
+ * @param wmTask
|
|
|
+ * @param exportType 1 导出汇总 2导出详情
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @SysLog("报告导出exportZbInfoJs")
|
|
|
+ @GetMapping("/exportZbInfoJs")
|
|
|
+ public R exportZbInfoJs(WmTask wmTask, String exportType) throws IOException {
|
|
|
+ log.info("报告导出请求参数:{}", wmTask);
|
|
|
|
|
|
- /**
|
|
|
- * 新版企业承接任务的导出、任务中心单的导出
|
|
|
- *
|
|
|
- * @param newReportExportDTO 参数
|
|
|
- * @return 结果
|
|
|
- */
|
|
|
- @SysLog("新版企业的报告导出")
|
|
|
- @GetMapping("/new-nba-export")
|
|
|
- public R<?> newDrugEntExport(NewReportExportDTO newReportExportDTO) {
|
|
|
- // 查询是否配置了模板
|
|
|
- Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
- int count = reportHandlerDeptRelationMapper.selectCount(Wrappers.<ReportHandlerDeptRelation>lambdaQuery()
|
|
|
- .eq(ReportHandlerDeptRelation::getDetpId, deptId)
|
|
|
- .eq(ReportHandlerDeptRelation::getReportType, ReportTypeEnum.NEW_DRUG_ENT.getType()));
|
|
|
- if (count <= 0) {
|
|
|
- return R.failed("该企业尚未配置新模版,请联系客服人员进行模版配置");
|
|
|
- }
|
|
|
+ String packageId = wmTask.getScorePackageDrugId();
|
|
|
+ if (null == packageId) {
|
|
|
+ return R.failed("积分包ID不能为空");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<WmTask> queryWrapper = new LambdaQueryWrapper();
|
|
|
+ queryWrapper.in(WmTask::getScorePackageId, Arrays.asList(packageId.split(",")));
|
|
|
+ queryWrapper.eq(WmTask::getTaskStatus, "3");
|
|
|
+ queryWrapper.eq(WmTask::getDelFlag, "0");
|
|
|
+ queryWrapper.eq(WmTask::getEnableFlag, "0");
|
|
|
+ List<WmTask> taskList = wmTaskService.list(queryWrapper);
|
|
|
+ if (taskList.isEmpty()) {
|
|
|
+ return R.failed("未查询到审核通过的任务");
|
|
|
+ }
|
|
|
+ String ids = taskList.stream().map(WmTask::getId).collect(Collectors.joining(","));
|
|
|
+ wmTask.setScorePackageId(packageId);
|
|
|
+ wmTask.setId(ids);
|
|
|
+
|
|
|
+ return reportExportService.exportZbJs(wmTask);// 报告汇总
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 历史数据导出报告
|
|
|
+ *
|
|
|
+ * @param wmScorePackage
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @SysLog("报告导出exportNbaHistory")
|
|
|
+ @GetMapping("/exportNbaHistory")
|
|
|
+ public R exportNbaHistory(WmScorePackage wmScorePackage) throws IOException {
|
|
|
+ log.info("报告导出请求参数:{}", wmScorePackage);
|
|
|
|
|
|
- String key = String.format(CacheConstants.NEW_DRUG_ENT_REPORT_CACHE, newReportExportDTO.getId());
|
|
|
+ String key = String.format(CacheConstants.EXPORT_NBA_HISTORY_REPORT_CACHE, wmScorePackage.getId());
|
|
|
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- if (StrUtil.isBlank(newReportExportDTO.getTaskStatus())) {
|
|
|
- newReportExportDTO.setTaskStatus("3");
|
|
|
- }
|
|
|
- newReportExportDTO.setDeptId(deptId);
|
|
|
- map.put("requestBody", JSONUtil.toJsonStr(newReportExportDTO));
|
|
|
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_NEW_DRUG_ENT_REPORT_EXPORT_QUEUE, map);
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(wmScorePackage));
|
|
|
+ map.put("username", user.getUsername());
|
|
|
+ map.put("deptId", user.getDeptId());
|
|
|
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL , TimeUnit.MILLISECONDS);
|
|
|
-
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
- }
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_REPORT_EXPORT_NBA_HISTORY_QUEUE, map);
|
|
|
|
|
|
- /**
|
|
|
- * 新版个人承接任务-按积分值,个人承接任务-按任务量,个人承接任务-通用,个人报告管理-个人报告导出的导出
|
|
|
- *
|
|
|
- * @param newReportExportDTO 参数
|
|
|
- * @return 结果
|
|
|
- */
|
|
|
- @SysLog("新版个人的报告导出")
|
|
|
- @GetMapping("/new-personal-export")
|
|
|
- public R<?> newPersonalExport(NewReportExportDTO newReportExportDTO) {
|
|
|
- // 查询是否配置了模板
|
|
|
- Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
- int count = reportHandlerDeptRelationMapper.selectCount(Wrappers.<ReportHandlerDeptRelation>lambdaQuery()
|
|
|
- .eq(ReportHandlerDeptRelation::getDetpId, deptId)
|
|
|
- .eq(ReportHandlerDeptRelation::getReportType, ReportTypeEnum.NEW_PERSONAL.getType()));
|
|
|
- if (count <= 0) {
|
|
|
- return R.failed("该企业尚未配置新模版,请联系客服人员进行模版配置");
|
|
|
- }
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.NEW_PERSONAL_REPORT_CACHE, newReportExportDTO.getId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
-
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- if (StrUtil.isBlank(newReportExportDTO.getTaskStatus())) {
|
|
|
- newReportExportDTO.setTaskStatus("3");
|
|
|
- }
|
|
|
- newReportExportDTO.setDeptId(deptId);
|
|
|
- map.put("requestBody", JSONUtil.toJsonStr(newReportExportDTO));
|
|
|
-
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_NEW_PERSONAL_REPORT_EXPORT_QUEUE, map);
|
|
|
-
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL , TimeUnit.MILLISECONDS);
|
|
|
-
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新版excel通用版的导出
|
|
|
- *
|
|
|
- * @param newReportExportDTO 参数
|
|
|
- * @return 结果
|
|
|
- */
|
|
|
- @SysLog("新版excel通用版的导出")
|
|
|
- @GetMapping("/new-excel-export")
|
|
|
- public R<?> newExcelCommonExport(NewReportExportDTO newReportExportDTO) {
|
|
|
- // 查询是否配置了模板
|
|
|
- Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
- int count = reportHandlerDeptRelationMapper.selectCount(Wrappers.<ReportHandlerDeptRelation>lambdaQuery()
|
|
|
- .eq(ReportHandlerDeptRelation::getDetpId, deptId)
|
|
|
- .eq(ReportHandlerDeptRelation::getReportType, ReportTypeEnum.NEW_EXCEL_COMMON.getType()));
|
|
|
- if (count <= 0) {
|
|
|
- return R.failed("该企业尚未配置新模版,请联系客服人员进行模版配置");
|
|
|
- }
|
|
|
-
|
|
|
- String key = String.format(CacheConstants.NEW_EXCEL_COMMON_REPORT_CACHE, newReportExportDTO.getId());
|
|
|
-
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)){
|
|
|
-
|
|
|
- return R.failed("已有在途生成记录,能耐心等待");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- BaseMap map = new BaseMap();
|
|
|
- if (StrUtil.isBlank(newReportExportDTO.getTaskStatus())) {
|
|
|
- newReportExportDTO.setTaskStatus("3");
|
|
|
- }
|
|
|
- newReportExportDTO.setDeptId(deptId);
|
|
|
- map.put("requestBody", JSONUtil.toJsonStr(newReportExportDTO));
|
|
|
-
|
|
|
- rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_NEW_EXCEL_COMMON_REPORT_EXPORT_QUEUE, map);
|
|
|
-
|
|
|
- redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
- CacheConstants.DEF_REPORT_CREATING_TTL , TimeUnit.MILLISECONDS);
|
|
|
-
|
|
|
- return R.ok("开始导出,请耐心等待");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取新版报告导出状态
|
|
|
- *
|
|
|
- * @param reportType 报告类型
|
|
|
- * @param packageId 积分包id
|
|
|
- * @return {@link WmReportOpt} 结果
|
|
|
- */
|
|
|
- @GetMapping("/new-report-status")
|
|
|
- public WmReportOpt getNewReportStatus(@RequestParam("reportType") ReportTypeEnum reportType,
|
|
|
- @RequestParam("id") String packageId) {
|
|
|
- WmReportOpt opt = new WmReportOpt();
|
|
|
-
|
|
|
- String reportCacheKey = null;
|
|
|
- switch (reportType) {
|
|
|
- case NEW_DRUG_ENT:
|
|
|
- reportCacheKey = CacheConstants.NEW_DRUG_ENT_REPORT_CACHE;
|
|
|
- break;
|
|
|
- case NEW_PERSONAL:
|
|
|
- reportCacheKey = CacheConstants.NEW_PERSONAL_REPORT_CACHE;
|
|
|
- break;
|
|
|
- case NEW_EXCEL_COMMON:
|
|
|
- reportCacheKey = CacheConstants.NEW_EXCEL_COMMON_REPORT_CACHE;
|
|
|
- break;
|
|
|
- default:
|
|
|
- reportCacheKey = CacheConstants.NEW_PERSONAL_REPORT_CACHE;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取生成记录
|
|
|
- String key = String.format(reportCacheKey, packageId);
|
|
|
- String o = redisTemplate.opsForValue().get(key);
|
|
|
-
|
|
|
- if (StrUtil.isNotEmpty(o)) {
|
|
|
-
|
|
|
- if (StrUtil.contains(o, "https")) {
|
|
|
- // 临时解决url 前出现的字符~
|
|
|
- Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
- opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
- opt.setLatestUrl(o.substring(o.indexOf("https")));
|
|
|
- } else if (StrUtil.contains(o, "ERROR")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
- }
|
|
|
- // 生成中的
|
|
|
- else if ("GENERATING".equals(o)) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
- }
|
|
|
- // 生成失败的
|
|
|
- else if (o.startsWith("ERROR")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
- }
|
|
|
- // 生成失败的2
|
|
|
- else if (!o.startsWith("http")) {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
- opt.setErrorMsg(o);
|
|
|
- }
|
|
|
- // 成功的
|
|
|
- else {
|
|
|
- Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
- opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
- // o = "https://pre.yaoyi.net/admin/sys-file/wmkj/兼职学术信息沟通专员业绩报告(2249)-20211116191527.doc";
|
|
|
- opt.setLatestUrl(o);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
- }
|
|
|
-
|
|
|
- return opt;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取所有个人报告导出状态
|
|
|
- *
|
|
|
- * @param packageId 积分包id
|
|
|
- * @return {@link WmReportOpt} 结果
|
|
|
- */
|
|
|
- @GetMapping("/all-personal-report-status")
|
|
|
- public R<Map<String, WmReportOpt>> getAllPersonalReportStatus(@RequestParam("id") String packageId) {
|
|
|
- Map<String, WmReportOpt> result = new HashMap<>();
|
|
|
-
|
|
|
- WmScorePackage scorePackage = new WmScorePackage();
|
|
|
- scorePackage.setId(packageId);
|
|
|
- scorePackage.setReportMqName(CacheConstants.EXPORT_ZB_REPORT_CACHE);
|
|
|
- wmScorePackageService.getReportOpt(scorePackage);
|
|
|
- result.put("reportOpt", scorePackage.getReportOpt());
|
|
|
-
|
|
|
- // 封装excel报告状态
|
|
|
- wmScorePackageService.getExcelReportOpt(scorePackage, CacheConstants.EXCEL_EXPORT_ZB_REPORT_CACHE);
|
|
|
- result.put("excelReportOpt", scorePackage.getExcelReportOpt());
|
|
|
-
|
|
|
- // 封装新版报告状态
|
|
|
- WmReportOpt newReportOpt = wmScorePackageService.getNewReportOpt(scorePackage, CacheConstants.NEW_PERSONAL_REPORT_CACHE);
|
|
|
- result.put("newReportOpt", newReportOpt);
|
|
|
-
|
|
|
- // 封装新版excel报告状态
|
|
|
- WmReportOpt newExcelReportOpt = wmScorePackageService.getNewReportOpt(scorePackage, CacheConstants.NEW_EXCEL_COMMON_REPORT_CACHE);
|
|
|
- result.put("newExcelReportOpt", newExcelReportOpt);
|
|
|
-
|
|
|
- return R.ok(result);
|
|
|
- }
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
+ CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新版企业承接任务的导出、任务中心单的导出
|
|
|
+ *
|
|
|
+ * @param newReportExportDTO 参数
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @SysLog("新版企业的报告导出")
|
|
|
+ @GetMapping("/new-nba-export")
|
|
|
+ public R<?> newDrugEntExport(NewReportExportDTO newReportExportDTO) {
|
|
|
+ // 查询是否配置了模板
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+ int count = reportHandlerDeptRelationMapper.selectCount(Wrappers.<ReportHandlerDeptRelation>lambdaQuery()
|
|
|
+ .eq(ReportHandlerDeptRelation::getDetpId, deptId)
|
|
|
+ .eq(ReportHandlerDeptRelation::getReportType, ReportTypeEnum.NEW_DRUG_ENT.getType()));
|
|
|
+ if (count <= 0) {
|
|
|
+ return R.failed("该企业尚未配置新模版,请联系客服人员进行模版配置");
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.NEW_DRUG_ENT_REPORT_CACHE, newReportExportDTO.getId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
+
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ if (StrUtil.isBlank(newReportExportDTO.getTaskStatus())) {
|
|
|
+ newReportExportDTO.setTaskStatus("3");
|
|
|
+ }
|
|
|
+ newReportExportDTO.setDeptId(deptId);
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(newReportExportDTO));
|
|
|
+
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_NEW_DRUG_ENT_REPORT_EXPORT_QUEUE, map);
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
+ CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新版个人承接任务-按积分值,个人承接任务-按任务量,个人承接任务-通用,个人报告管理-个人报告导出的导出
|
|
|
+ *
|
|
|
+ * @param newReportExportDTO 参数
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @SysLog("新版个人的报告导出")
|
|
|
+ @GetMapping("/new-personal-export")
|
|
|
+ public R<?> newPersonalExport(NewReportExportDTO newReportExportDTO) {
|
|
|
+ // 查询是否配置了模板
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+ int count = reportHandlerDeptRelationMapper.selectCount(Wrappers.<ReportHandlerDeptRelation>lambdaQuery()
|
|
|
+ .eq(ReportHandlerDeptRelation::getDetpId, deptId)
|
|
|
+ .eq(ReportHandlerDeptRelation::getReportType, ReportTypeEnum.NEW_PERSONAL.getType()));
|
|
|
+ if (count <= 0) {
|
|
|
+ return R.failed("该企业尚未配置新模版,请联系客服人员进行模版配置");
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.NEW_PERSONAL_REPORT_CACHE, newReportExportDTO.getId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
+
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ if (StrUtil.isBlank(newReportExportDTO.getTaskStatus())) {
|
|
|
+ newReportExportDTO.setTaskStatus("3");
|
|
|
+ }
|
|
|
+ newReportExportDTO.setDeptId(deptId);
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(newReportExportDTO));
|
|
|
+
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_NEW_PERSONAL_REPORT_EXPORT_QUEUE, map);
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
+ CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新版excel通用版的导出
|
|
|
+ *
|
|
|
+ * @param newReportExportDTO 参数
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @SysLog("新版excel通用版的导出")
|
|
|
+ @GetMapping("/new-excel-export")
|
|
|
+ public R<?> newExcelCommonExport(NewReportExportDTO newReportExportDTO) {
|
|
|
+ // 查询是否配置了模板
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+ int count = reportHandlerDeptRelationMapper.selectCount(Wrappers.<ReportHandlerDeptRelation>lambdaQuery()
|
|
|
+ .eq(ReportHandlerDeptRelation::getDetpId, deptId)
|
|
|
+ .eq(ReportHandlerDeptRelation::getReportType, ReportTypeEnum.NEW_EXCEL_COMMON.getType()));
|
|
|
+ if (count <= 0) {
|
|
|
+ return R.failed("该企业尚未配置新模版,请联系客服人员进行模版配置");
|
|
|
+ }
|
|
|
+
|
|
|
+ String key = String.format(CacheConstants.NEW_EXCEL_COMMON_REPORT_CACHE, newReportExportDTO.getId());
|
|
|
+
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(o) && WmReportOpt.WmReportOptStatus.GENERATING.name().equals(o)) {
|
|
|
+
|
|
|
+ return R.failed("已有在途生成记录,能耐心等待");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ BaseMap map = new BaseMap();
|
|
|
+ if (StrUtil.isBlank(newReportExportDTO.getTaskStatus())) {
|
|
|
+ newReportExportDTO.setTaskStatus("3");
|
|
|
+ }
|
|
|
+ newReportExportDTO.setDeptId(deptId);
|
|
|
+ map.put("requestBody", JSONUtil.toJsonStr(newReportExportDTO));
|
|
|
+
|
|
|
+ rabbitMqClient.sendMessage(MqConstants.DIRECT_MODE_NEW_EXCEL_COMMON_REPORT_EXPORT_QUEUE, map);
|
|
|
+
|
|
|
+ redisTemplate.opsForValue().set(key, WmReportOpt.WmReportOptStatus.GENERATING.name(),
|
|
|
+ CacheConstants.DEF_REPORT_CREATING_TTL, TimeUnit.MILLISECONDS);
|
|
|
+
|
|
|
+ return R.ok("开始导出,请耐心等待");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取新版报告导出状态
|
|
|
+ *
|
|
|
+ * @param reportType 报告类型
|
|
|
+ * @param packageId 积分包id
|
|
|
+ * @return {@link WmReportOpt} 结果
|
|
|
+ */
|
|
|
+ @GetMapping("/new-report-status")
|
|
|
+ public WmReportOpt getNewReportStatus(@RequestParam("reportType") ReportTypeEnum reportType,
|
|
|
+ @RequestParam("id") String packageId) {
|
|
|
+ WmReportOpt opt = new WmReportOpt();
|
|
|
+
|
|
|
+ String reportCacheKey = null;
|
|
|
+ switch (reportType) {
|
|
|
+ case NEW_DRUG_ENT:
|
|
|
+ reportCacheKey = CacheConstants.NEW_DRUG_ENT_REPORT_CACHE;
|
|
|
+ break;
|
|
|
+ case NEW_PERSONAL:
|
|
|
+ reportCacheKey = CacheConstants.NEW_PERSONAL_REPORT_CACHE;
|
|
|
+ break;
|
|
|
+ case NEW_EXCEL_COMMON:
|
|
|
+ reportCacheKey = CacheConstants.NEW_EXCEL_COMMON_REPORT_CACHE;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ reportCacheKey = CacheConstants.NEW_PERSONAL_REPORT_CACHE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取生成记录
|
|
|
+ String key = String.format(reportCacheKey, packageId);
|
|
|
+ String o = redisTemplate.opsForValue().get(key);
|
|
|
+
|
|
|
+ if (StrUtil.isNotEmpty(o)) {
|
|
|
+
|
|
|
+ if (StrUtil.contains(o, "https")) {
|
|
|
+ // 临时解决url 前出现的字符~
|
|
|
+ Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
+ opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
+ opt.setLatestUrl(o.substring(o.indexOf("https")));
|
|
|
+ } else if (StrUtil.contains(o, "ERROR")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
+ }
|
|
|
+ // 生成中的
|
|
|
+ else if ("GENERATING".equals(o)) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATING);
|
|
|
+ }
|
|
|
+ // 生成失败的
|
|
|
+ else if (o.startsWith("ERROR")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o.split(StrUtil.UNDERLINE)[1]);
|
|
|
+ }
|
|
|
+ // 生成失败的2
|
|
|
+ else if (!o.startsWith("http")) {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.ERROR);
|
|
|
+ opt.setErrorMsg(o);
|
|
|
+ }
|
|
|
+ // 成功的
|
|
|
+ else {
|
|
|
+ Long expire = redisTemplate.opsForValue().getOperations().getExpire(key, TimeUnit.SECONDS);
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.GENERATED);
|
|
|
+ opt.setTtl(LocalDateTime.now().plusSeconds(expire));
|
|
|
+ // o = "https://pre.yaoyi.net/admin/sys-file/wmkj/兼职学术信息沟通专员业绩报告(2249)-20211116191527.doc";
|
|
|
+ opt.setLatestUrl(o);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ opt.setStatus(WmReportOpt.WmReportOptStatus.NOT_GENERATE);
|
|
|
+ }
|
|
|
+
|
|
|
+ return opt;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有个人报告导出状态
|
|
|
+ *
|
|
|
+ * @param packageId 积分包id
|
|
|
+ * @return {@link WmReportOpt} 结果
|
|
|
+ */
|
|
|
+ @GetMapping("/all-personal-report-status")
|
|
|
+ public R<Map<String, WmReportOpt>> getAllPersonalReportStatus(@RequestParam("id") String packageId) {
|
|
|
+ Map<String, WmReportOpt> result = new HashMap<>();
|
|
|
+
|
|
|
+ WmScorePackage scorePackage = new WmScorePackage();
|
|
|
+ scorePackage.setId(packageId);
|
|
|
+ scorePackage.setReportMqName(CacheConstants.EXPORT_ZB_REPORT_CACHE);
|
|
|
+ wmScorePackageService.getReportOpt(scorePackage);
|
|
|
+ result.put("reportOpt", scorePackage.getReportOpt());
|
|
|
+
|
|
|
+ // 封装excel报告状态
|
|
|
+ wmScorePackageService.getExcelReportOpt(scorePackage, CacheConstants.EXCEL_EXPORT_ZB_REPORT_CACHE);
|
|
|
+ result.put("excelReportOpt", scorePackage.getExcelReportOpt());
|
|
|
+
|
|
|
+ // 封装新版报告状态
|
|
|
+ WmReportOpt newReportOpt = wmScorePackageService.getNewReportOpt(scorePackage, CacheConstants.NEW_PERSONAL_REPORT_CACHE);
|
|
|
+ result.put("newReportOpt", newReportOpt);
|
|
|
+
|
|
|
+ // 封装新版excel报告状态
|
|
|
+ WmReportOpt newExcelReportOpt = wmScorePackageService.getNewReportOpt(scorePackage, CacheConstants.NEW_EXCEL_COMMON_REPORT_CACHE);
|
|
|
+ result.put("newExcelReportOpt", newExcelReportOpt);
|
|
|
+
|
|
|
+ return R.ok(result);
|
|
|
+ }
|
|
|
}
|