From f59a0ee86c01d974364c9b193f3be2c89bafb7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Tue, 11 Apr 2023 09:41:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=B4=E7=94=B5=E7=94=9F=E4=BA=A7=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=E6=8D=AE=20=E6=93=8D=E4=BD=9C=E7=A5=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=88=97=E8=A1=A8=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../areamonthly/feign/TicketFeignClient.java | 32 + .../fallback/StandardTicketInfoFeignClient.java | 30 + .../hzims/ticket/areamonthly/vo/AreaMonthlyVo.java | 28 + .../ticket/areamonthly/vo/StandardTicketVo.java | 71 ++ .../hzims/middle/mybatisplus/CodeGenerator.java | 208 ++--- .../middle/systemlog/config/SysLogConfig.java | 11 +- .../hzims/middle/systemlog/entity/Statistics.java | 2 + .../middle/systemlog/mapper/StatisticsMapper.xml | 5 + .../middle/systemlog/mapper/SysLogMapper.java | 10 + .../hzims/middle/systemlog/mapper/SysLogMapper.xml | 13 + .../systemlog/mapper/xml/StatisticsMapper.xml | 5 - .../systemlog/service/StatisticsService.java | 9 + .../middle/systemlog/service/SysLogService.java | 8 + .../service/impl/StatisticsServiceImpl.java | 47 +- .../systemlog/service/impl/SysLogServiceImpl.java | 12 + .../middle/systemlog/task/SyslogTimerTask.java | 5 +- .../middle/systemlog/vo/SysLogStatisticsVo.java | 36 + .../src/main/resources/application.yml | 4 +- .../src/main/resources/mapper/SysLogMapper.xml | 5 - .../hzims/operational/OperationApplication.java | 1 + .../operational/main/config/IPageDeserializer.java | 33 + .../main/config/WebDataConvertConfig.java | 52 ++ .../web/AreaMonthlyDetailsController.java | 52 ++ .../main/service/AreaMonthlyDetailsService.java | 24 + .../impl/AreaMonthlyDetailsServiceImpl.java | 48 + .../src/main/resources/application-dev.yml | 2 + hzims-service/ticket/pom.xml | 4 - .../hzims/ticket/processflow/CodeGenerator.java | 208 ++--- .../constant/TicketProcessConstant.java | 3 +- .../consumer/StandardWorkTicketConsumer.java | 14 +- .../processflow/entity/WorkflowOperationLog.java | 10 +- .../serviceimpl/MakeProcessServiceImpl.java | 2 +- .../controller/StandardTicketInfoController.java | 140 +-- .../service/IStandardTicketInfoService.java | 16 +- .../impl/StandardTicketInfoServiceImpl.java | 965 +++++++++++---------- .../service/impl/TicketProcessServiceImpl.java | 22 +- .../ticket/workTicket/feign/TicketInfoClient.java | 365 ++++---- 37 files changed, 1550 insertions(+), 952 deletions(-) create mode 100644 hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/TicketFeignClient.java create mode 100644 hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/fallback/StandardTicketInfoFeignClient.java create mode 100644 hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/AreaMonthlyVo.java create mode 100644 hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/StandardTicketVo.java create mode 100644 hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.xml create mode 100644 hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.xml delete mode 100644 hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml create mode 100644 hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogStatisticsVo.java delete mode 100644 hzims-service/hzims-middle/src/main/resources/mapper/SysLogMapper.xml create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/IPageDeserializer.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/WebDataConvertConfig.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/TicketFeignClient.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/TicketFeignClient.java new file mode 100644 index 0000000..fa7bc87 --- /dev/null +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/TicketFeignClient.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.ticket.areamonthly.feign; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.feign.fallback.StandardTicketInfoFeignClient; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.SpringQueryMap; +import org.springframework.web.bind.annotation.*; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 13:39 + */ + +@FeignClient(value = "hzims-ticket", fallback = StandardTicketInfoFeignClient.class) +public interface TicketFeignClient { + + /** + * 根据月份,区域 获取操作详情数据 + * + * @return + */ + @GetMapping("/standard/ticket/areaMonthlyWithOperation/{page}/{size}") + R> areaMonthlyWithOperation(@PathVariable("page") Long page, + @PathVariable("size") Long size, + @SpringQueryMap AreaMonthlyVo areaMonthlyV); +} diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/fallback/StandardTicketInfoFeignClient.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/fallback/StandardTicketInfoFeignClient.java new file mode 100644 index 0000000..4c42a82 --- /dev/null +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/feign/fallback/StandardTicketInfoFeignClient.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.ticket.areamonthly.feign.fallback; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.feign.TicketFeignClient; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 17:24 + */ +@Service +public class StandardTicketInfoFeignClient implements TicketFeignClient { + /** + * 根据月份,区域 获取操作详情数据 + * + * @param page + * @param size + * @return + */ + @Override + public R> areaMonthlyWithOperation(Long page, Long size, AreaMonthlyVo areaMonthlyV) { + + return R.fail("远程调用失败"); + } +} diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/AreaMonthlyVo.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/AreaMonthlyVo.java new file mode 100644 index 0000000..62eb588 --- /dev/null +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/AreaMonthlyVo.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.ticket.areamonthly.vo; + +import lombok.Data; + +import java.time.YearMonth; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 11:28 + */ +@Data +public class AreaMonthlyVo { + + + /** + * 区域编号 + */ + private String areaId; + + + /** + * 月份 + */ + private YearMonth YearMonth; + +} diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/StandardTicketVo.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/StandardTicketVo.java new file mode 100644 index 0000000..888e12b --- /dev/null +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/areamonthly/vo/StandardTicketVo.java @@ -0,0 +1,71 @@ +package com.hnac.hzims.ticket.areamonthly; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 17:06 + */ +@EqualsAndHashCode +@Data +public class StandardTicketVo implements Serializable { + + private static final long serialVersionUID = -8870464581684939369L; + + + /** + * 开票种类 + */ + private String ticketType; + + /** + * 单位 + */ + private String company; + /** + * 编号 + */ + private String code; + /** + * 开票来源 + */ + private String taskType; + /** + * 开票任务来源 + */ + private String taskName; + + /** + * 发令人 + */ + private Long issueOrderPerson; + + /** + * 受令人 + */ + private Long accessOrderPerson; + /** + * 监护人 + */ + private String guardian; + + /** + * 值班负责人 + */ + private Long principal; + /** + * 开票时间 + */ + private Date createTime; +} + diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java index 50f2d36..8d8bfd6 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/mybatisplus/CodeGenerator.java @@ -1,104 +1,104 @@ -package com.hnac.hzims.middle.mybatisplus; - -import com.baomidou.mybatisplus.generator.AutoGenerator; -import com.baomidou.mybatisplus.generator.InjectionConfig; -import com.baomidou.mybatisplus.generator.config.*; -import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; - -import java.util.ArrayList; -import java.util.List; - -/** - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/4/4 9:07 - */ -public class CodeGenerator { - - - public static void main(String[] args) { - // 代码生成器 - AutoGenerator mpg = new AutoGenerator(); - - // 全局配置 - GlobalConfig gc = new GlobalConfig(); - String projectPath = System.getProperty("user.dir") + "/hzims-service/hzims-middle"; - gc.setOutputDir(projectPath + "/src/main/java"); - gc.setAuthor("dfy"); - gc.setOpen(false); - // gc.setSwagger2(true); 实体属性 Swagger2 注解 - mpg.setGlobalConfig(gc); - - // 数据源配置 - DataSourceConfig dsc = new DataSourceConfig(); - dsc.setUrl("jdbc:mysql://192.168.1.20:3576/dev_hzims_middle?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true"); - // dsc.setSchemaName("public"); - dsc.setDriverName("com.mysql.cj.jdbc.Driver"); - dsc.setUsername("root"); - dsc.setPassword("123"); - mpg.setDataSource(dsc); - - // 包配置 - PackageConfig pc = new PackageConfig(); - pc.setModuleName("systemlog"); - pc.setParent("com.hnac.hzims.middle"); - mpg.setPackageInfo(pc); - - // 自定义配置 - InjectionConfig cfg = new InjectionConfig() { - @Override - public void initMap() { - // to do nothing - } - }; - - // 如果模板引擎是 freemarker - String templatePath = "/templates/mapper.xml.ftl"; - // 如果模板引擎是 velocity - // String templatePath = "/templates/mapper.xml.vm"; - - // 自定义输出配置 - List focList = new ArrayList<>(); - cfg.setFileOutConfigList(focList); - mpg.setCfg(cfg); - - // 配置模板 - TemplateConfig templateConfig = new TemplateConfig(); - - // 配置自定义输出模板 - //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别 - // templateConfig.setEntity("templates/entity2.java"); - // templateConfig.setService(); - // templateConfig.setController(); - - // templateConfig.setXml(null); - mpg.setTemplate(templateConfig); - - // 策略配置 - StrategyConfig strategy = new StrategyConfig(); - strategy.setNaming(NamingStrategy.underline_to_camel); - strategy.setColumnNaming(NamingStrategy.underline_to_camel); - // strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!"); - strategy.setEntityLombokModel(true); - strategy.setRestControllerStyle(true); - strategy.setEntityBooleanColumnRemoveIsPrefix(true); - strategy.setEntityLombokModel(true); - strategy.setEntitySerialVersionUID(true); - strategy.setChainModel(true); - strategy.setEntityTableFieldAnnotationEnable(true); - // strategy.setFieldPrefix("hzims_"); - // 公共父类 - // strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!"); - // 写于父类中的公共字段 - // strategy.setSuperEntityColumns("id"); - strategy.setInclude("hzims_statistics"); - strategy.setControllerMappingHyphenStyle(true); - strategy.setTablePrefix("hzims_"); - mpg.setStrategy(strategy); - // mpg.setTemplateEngine(new FreemarkerTemplateEngine()); - mpg.execute(); - } - -} - +// package com.hnac.hzims.middle.mybatisplus; +// +// import com.baomidou.mybatisplus.generator.AutoGenerator; +// import com.baomidou.mybatisplus.generator.InjectionConfig; +// import com.baomidou.mybatisplus.generator.config.*; +// import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; +// +// import java.util.ArrayList; +// import java.util.List; +// +// /** +// * @Author WL +// * @Version v1.0 +// * @Serial 1.0 +// * @Date 2023/4/4 9:07 +// */ +// public class CodeGenerator { +// +// +// public static void main(String[] args) { +// // 代码生成器 +// AutoGenerator mpg = new AutoGenerator(); +// +// // 全局配置 +// GlobalConfig gc = new GlobalConfig(); +// String projectPath = System.getProperty("user.dir") + "/hzims-service/hzims-middle"; +// gc.setOutputDir(projectPath + "/src/main/java"); +// gc.setAuthor("dfy"); +// gc.setOpen(false); +// // gc.setSwagger2(true); 实体属性 Swagger2 注解 +// mpg.setGlobalConfig(gc); +// +// // 数据源配置 +// DataSourceConfig dsc = new DataSourceConfig(); +// dsc.setUrl("jdbc:mysql://192.168.1.20:3576/dev_hzims_middle?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true"); +// // dsc.setSchemaName("public"); +// dsc.setDriverName("com.mysql.cj.jdbc.Driver"); +// dsc.setUsername("root"); +// dsc.setPassword("123"); +// mpg.setDataSource(dsc); +// +// // 包配置 +// PackageConfig pc = new PackageConfig(); +// pc.setModuleName("systemlog"); +// pc.setParent("com.hnac.hzims.middle"); +// mpg.setPackageInfo(pc); +// +// // 自定义配置 +// InjectionConfig cfg = new InjectionConfig() { +// @Override +// public void initMap() { +// // to do nothing +// } +// }; +// +// // 如果模板引擎是 freemarker +// String templatePath = "/templates/mapper.xml.ftl"; +// // 如果模板引擎是 velocity +// // String templatePath = "/templates/mapper.xml.vm"; +// +// // 自定义输出配置 +// List focList = new ArrayList<>(); +// cfg.setFileOutConfigList(focList); +// mpg.setCfg(cfg); +// +// // 配置模板 +// TemplateConfig templateConfig = new TemplateConfig(); +// +// // 配置自定义输出模板 +// //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别 +// // templateConfig.setEntity("templates/entity2.java"); +// // templateConfig.setService(); +// // templateConfig.setController(); +// +// // templateConfig.setXml(null); +// mpg.setTemplate(templateConfig); +// +// // 策略配置 +// StrategyConfig strategy = new StrategyConfig(); +// strategy.setNaming(NamingStrategy.underline_to_camel); +// strategy.setColumnNaming(NamingStrategy.underline_to_camel); +// // strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!"); +// strategy.setEntityLombokModel(true); +// strategy.setRestControllerStyle(true); +// strategy.setEntityBooleanColumnRemoveIsPrefix(true); +// strategy.setEntityLombokModel(true); +// strategy.setEntitySerialVersionUID(true); +// strategy.setChainModel(true); +// strategy.setEntityTableFieldAnnotationEnable(true); +// // strategy.setFieldPrefix("hzims_"); +// // 公共父类 +// // strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!"); +// // 写于父类中的公共字段 +// // strategy.setSuperEntityColumns("id"); +// strategy.setInclude("hzims_statistics"); +// strategy.setControllerMappingHyphenStyle(true); +// strategy.setTablePrefix("hzims_"); +// mpg.setStrategy(strategy); +// // mpg.setTemplateEngine(new FreemarkerTemplateEngine()); +// mpg.execute(); +// } +// +// } +// diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/SysLogConfig.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/SysLogConfig.java index 006d3aa..6a409ff 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/SysLogConfig.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/config/SysLogConfig.java @@ -1,6 +1,8 @@ package com.hnac.hzims.middle.systemlog.config; +import com.hnac.hzims.middle.systemlog.service.StatisticsService; import com.hnac.hzims.middle.systemlog.task.SyslogTimerTask; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -15,15 +17,18 @@ import java.util.Timer; @Configuration public class SysLogConfig { + @Autowired + private StatisticsService statisticsService; + @Bean public void syslogTimer() { //1.创建一个timer实例 Timer timer = new Timer(); //2.创建一个SyslogTimerTask实例 - SyslogTimerTask myTimeTask = new SyslogTimerTask(); + SyslogTimerTask myTimeTask = new SyslogTimerTask(statisticsService); //3.通过timer定时定频率调用SyslogTimerTask的业务逻辑 - // 即 第一次执行是在当前时间的两秒之后,之后每隔30秒钟执行一次 - timer.schedule(myTimeTask,2000L,30000L); + // 即 第一次执行是在当前时间的两秒之后,之后每隔3秒钟执行一次 + timer.schedule(myTimeTask,2000L,10000L); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java index 09bde87..5348ce9 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/entity/Statistics.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; +import java.time.YearMonth; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.xml b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.xml new file mode 100644 index 0000000..093a8d3 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/StatisticsMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java index 009f3a1..4d6d268 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.java @@ -2,6 +2,9 @@ package com.hnac.hzims.middle.systemlog.mapper; import com.hnac.hzims.middle.systemlog.entity.SysLog; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; + +import java.util.List; /** *

@@ -13,4 +16,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface SysLogMapper extends BaseMapper { + /** + * 查询统计的数据 + * @return + */ + List countStatistics(); + + } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.xml b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.xml new file mode 100644 index 0000000..c2f6ff0 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/SysLogMapper.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml deleted file mode 100644 index 093a8d3..0000000 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/mapper/xml/StatisticsMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java index a04f72c..32abe97 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/StatisticsService.java @@ -3,6 +3,8 @@ package com.hnac.hzims.middle.systemlog.service; import com.hnac.hzims.middle.systemlog.entity.Statistics; import com.baomidou.mybatisplus.extension.service.IService; +import java.time.YearMonth; + /** *

* 操作日志统计数据 服务类 @@ -17,4 +19,11 @@ public interface StatisticsService extends IService { * 保存统计的数据 */ void saveCountStatistics(); + + /** + * 根据时间查询数据 + * @param operationTime + * @return + */ + Statistics getStatisticsBydateCalculated(String operationTime); } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java index e409a1e..224eceb 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java @@ -2,6 +2,9 @@ package com.hnac.hzims.middle.systemlog.service; import com.hnac.hzims.middle.systemlog.entity.SysLog; import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; + +import java.util.List; /** *

@@ -13,4 +16,9 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface SysLogService extends IService { + /** + * 查询统计的数据 + * @return + */ + List countStatistics(); } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java index b1f5c97..b4209ec 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java @@ -1,13 +1,18 @@ package com.hnac.hzims.middle.systemlog.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.hnac.hzims.middle.systemlog.entity.Statistics; import com.hnac.hzims.middle.systemlog.mapper.StatisticsMapper; import com.hnac.hzims.middle.systemlog.service.StatisticsService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.middle.systemlog.service.SysLogService; +import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.YearMonth; +import java.util.List; + /** *

* 操作日志统计数据 服务实现类 @@ -22,13 +27,53 @@ public class StatisticsServiceImpl extends ServiceImpl sysLogStatisticsVoList = sysLogService.countStatistics(); + System.out.println(sysLogStatisticsVoList); + //2. 保存数据 + if (sysLogStatisticsVoList == null) { + return; + } + + for (SysLogStatisticsVo sysLogStatisticsVo : sysLogStatisticsVoList) { + //查询数据 + Statistics statistics = statisticsService.getStatisticsBydateCalculated(sysLogStatisticsVo.getOperationTime()); + //如果为空保存数据,如果不为空更新数据 + if (statistics == null) { + statistics = new Statistics(); + statistics.setDateCalculated(sysLogStatisticsVo.getOperationTime()); + statistics.setModuleNameNum(sysLogStatisticsVo.getModuleNameCount()); + statistics.setTitleNum(sysLogStatisticsVo.getTitleCount()); + statistics.setPathNum(sysLogStatisticsVo.getPathCount()); + statisticsService.save(statistics); + }else { + statistics.setModuleNameNum(sysLogStatisticsVo.getModuleNameCount()); + statistics.setTitleNum(sysLogStatisticsVo.getTitleCount()); + statistics.setPathNum(sysLogStatisticsVo.getPathCount()); + statisticsService.updateById(statistics); + } + } + } + /** + * 根据时间查询数据 + * + * @param operationTime + * @return + */ + @Override + public Statistics getStatisticsBydateCalculated(String operationTime) { + QueryWrapper statisticsQueryWrapper = new QueryWrapper<>(); + statisticsQueryWrapper.eq("date_calculated", operationTime); + return baseMapper.selectOne(statisticsQueryWrapper); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java index a889cce..e1b242b 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java @@ -4,8 +4,11 @@ import com.hnac.hzims.middle.systemlog.entity.SysLog; import com.hnac.hzims.middle.systemlog.mapper.SysLogMapper; import com.hnac.hzims.middle.systemlog.service.SysLogService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 服务实现类 @@ -17,4 +20,13 @@ import org.springframework.stereotype.Service; @Service public class SysLogServiceImpl extends ServiceImpl implements SysLogService { + /** + * 查询统计的数据 + * + * @return + */ + @Override + public List countStatistics() { + return baseMapper.countStatistics(); + } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java index 99a09d0..12b2d50 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/task/SyslogTimerTask.java @@ -2,6 +2,7 @@ package com.hnac.hzims.middle.systemlog.task; import com.hnac.hzims.middle.systemlog.service.StatisticsService; import com.hnac.hzims.middle.systemlog.service.SysLogService; +import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -13,11 +14,10 @@ import java.util.TimerTask; * @Serial 1.0 * @Date 2023/4/8 14:13 */ -@Component +@AllArgsConstructor public class SyslogTimerTask extends TimerTask { - @Autowired private StatisticsService statisticsService; /** @@ -26,6 +26,7 @@ public class SyslogTimerTask extends TimerTask { @Override public void run() { //保存统计的数据 + System.out.println("保存统计的数据"); statisticsService.saveCountStatistics(); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogStatisticsVo.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogStatisticsVo.java new file mode 100644 index 0000000..5a6e712 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogStatisticsVo.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.middle.systemlog.vo; + +import lombok.Data; + +import java.time.YearMonth; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 9:03 + */ +@Data +public class SysLogStatisticsVo { + + /** + * 操作时间 + */ + private String operationTime; + + /** + * 操作模块统计 + */ + private Integer titleCount; + + + /** + * 操作类型统计 + */ + private Integer moduleNameCount; + + /** + * 根据路径统计 + */ + private Integer pathCount; +} diff --git a/hzims-service/hzims-middle/src/main/resources/application.yml b/hzims-service/hzims-middle/src/main/resources/application.yml index 6e69e09..6428635 100644 --- a/hzims-service/hzims-middle/src/main/resources/application.yml +++ b/hzims-service/hzims-middle/src/main/resources/application.yml @@ -15,9 +15,7 @@ spring: #mybatis-plus配置 mybatis-plus: - mapper-locations: - - classpath:com/hnac/hzims/**/mapper/*Mapper.xml - - classpath:/mapper/*Mapper.xml + mapper-locations: classpath:com/hnac/hzims/**/mapper/*Mapper.xml #实体扫描,多个package用逗号或者分号分隔 typeAliasesPackage: com.hnac.hzims.**.entity diff --git a/hzims-service/hzims-middle/src/main/resources/mapper/SysLogMapper.xml b/hzims-service/hzims-middle/src/main/resources/mapper/SysLogMapper.xml deleted file mode 100644 index 698fb08..0000000 --- a/hzims-service/hzims-middle/src/main/resources/mapper/SysLogMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java index b5472b2..e8cca7f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java @@ -22,6 +22,7 @@ import org.springblade.core.launch.BladeApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cloud.client.SpringCloudApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/IPageDeserializer.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/IPageDeserializer.java new file mode 100644 index 0000000..9f7bfc9 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/IPageDeserializer.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.operational.main.config; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +import java.io.IOException; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 16:12 + */ +public class IPageDeserializer extends StdDeserializer { + protected IPageDeserializer(Class vc) { + super(vc); + } + + @Override + public IPage deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException { + JsonNode node = jsonParser.getCodec().readTree(jsonParser); + String s = node.toString(); + ObjectMapper om = new ObjectMapper(); + Page page = om.readValue(s,Page.class); + return page; + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/WebDataConvertConfig.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/WebDataConvertConfig.java new file mode 100644 index 0000000..c6caf24 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/config/WebDataConvertConfig.java @@ -0,0 +1,52 @@ +package com.hnac.hzims.operational.main.config; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; + +import java.util.Arrays; +import java.util.List; + +/** + * + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 16:11 + */ +@Configuration +public class WebDataConvertConfig extends WebMvcConfigurationSupport { + + + @Override + public void configureMessageConverters(List> converters) { + converters.add(mappingJackson2HttpMessageConverter()); + super.configureMessageConverters(converters); + } + + @Bean + public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + SimpleModule module = new SimpleModule(); + module.addDeserializer(IPage.class, new IPageDeserializer(IPage.class)); + mapper.registerModule(module); + + converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON,MediaType.APPLICATION_JSON_UTF8,MediaType.APPLICATION_OCTET_STREAM)); + converter.setObjectMapper(mapper); + + return converter; + } + + +} + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java new file mode 100644 index 0000000..c7b8f89 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java @@ -0,0 +1,52 @@ +package com.hnac.hzims.operational.main.controller.web; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.main.service.AreaMonthlyDetailsService; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 水电生成报告详情数据 + * + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 11:21 + */ +@Slf4j +@RequiredArgsConstructor +@RestController +@RequestMapping("/areaMonthlyDetails") +public class AreaMonthlyDetailsController { + + + private final AreaMonthlyDetailsService areaMonthlyDetailsService; + + + /** + * 操作票 根据月份,区域 获取操作详情数据 + * + * @return + */ + @GetMapping("/areaMonthlyWithOperation/{page}/{size}") + public R areaMonthlyWithOperation(@PathVariable("page") Long page, + @PathVariable("size") Long size, + AreaMonthlyVo areaMonthly) { + IPage standardTicketInfoVoIPage = + areaMonthlyDetailsService.areaMonthlyWithOperation(page,size, areaMonthly); + return R.data(standardTicketInfoVoIPage); + } + + + + + + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java new file mode 100644 index 0000000..6ce6fa6 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.main.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; + +/** + * + * 水电生产运行数据 + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 13:46 + */ +public interface AreaMonthlyDetailsService { + /** + * 根据月份,区域 获取操作详情数据 + * @param page + * @param size + * @param areaMonthly + * @return + */ + IPage areaMonthlyWithOperation(Long page, Long size, AreaMonthlyVo areaMonthly); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java new file mode 100644 index 0000000..2ae6bcb --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.operational.main.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.feign.TicketFeignClient; +import com.hnac.hzims.operational.main.service.AreaMonthlyDetailsService; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +/** + * 水电生产运行数据 + * + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/10 13:46 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class AreaMonthlyDetailsServiceImpl implements AreaMonthlyDetailsService { + + private final TicketFeignClient ticketFeignClient; + + + /** + * 根据月份,区域 获取操作详情数据 + * + * @param page + * @param size + * @param areaMonthly + * @return + */ + @Override + public IPage areaMonthlyWithOperation(Long page, Long size, AreaMonthlyVo areaMonthly) { + R> pageR = + ticketFeignClient.areaMonthlyWithOperation(page, size,areaMonthly); + if (pageR.isSuccess()) { + log.info("获取操作详情数据成功"); + return pageR.getData(); + } + System.out.println(pageR.getMsg()); + return null; + } +} diff --git a/hzims-service/operational/src/main/resources/application-dev.yml b/hzims-service/operational/src/main/resources/application-dev.yml index 18f9e7d..712302b 100644 --- a/hzims-service/operational/src/main/resources/application-dev.yml +++ b/hzims-service/operational/src/main/resources/application-dev.yml @@ -4,6 +4,8 @@ server: #数据源配置 spring: + main: + allow-bean-definition-overriding: true profiles: active: dev #排除DruidDataSourceAutoConfigure diff --git a/hzims-service/ticket/pom.xml b/hzims-service/ticket/pom.xml index 5c335a1..0685ea8 100644 --- a/hzims-service/ticket/pom.xml +++ b/hzims-service/ticket/pom.xml @@ -168,10 +168,6 @@ provided - org.springframework.boot - spring-boot-configuration-processor - - org.springblade blade-dict-api diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/CodeGenerator.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/CodeGenerator.java index facbe23..7693224 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/CodeGenerator.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/CodeGenerator.java @@ -1,104 +1,104 @@ -package com.hnac.hzims.ticket.processflow; - -import com.baomidou.mybatisplus.generator.AutoGenerator; -import com.baomidou.mybatisplus.generator.InjectionConfig; -import com.baomidou.mybatisplus.generator.config.*; -import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; - -import java.util.ArrayList; -import java.util.List; - -/** - * 代码生成器 - * @Author dfy - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/3/29 8:59 - */ -public class CodeGenerator { - - - public static void main(String[] args) { - // 代码生成器 - AutoGenerator mpg = new AutoGenerator(); - - // 全局配置 - GlobalConfig gc = new GlobalConfig(); - String projectPath = System.getProperty("user.dir") + "/hzims-service/ticket"; - gc.setOutputDir(projectPath + "/src/main/java"); - gc.setAuthor("dfy"); - gc.setOpen(false); - // gc.setSwagger2(true); 实体属性 Swagger2 注解 - mpg.setGlobalConfig(gc); - - // 数据源配置 - DataSourceConfig dsc = new DataSourceConfig(); - dsc.setUrl("jdbc:mysql://192.168.1.20:3576/dev_hzims_ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true"); - // dsc.setSchemaName("public"); - dsc.setDriverName("com.mysql.cj.jdbc.Driver"); - dsc.setUsername("root"); - dsc.setPassword("123"); - mpg.setDataSource(dsc); - - // 包配置 - PackageConfig pc = new PackageConfig(); - pc.setModuleName("processflow"); - pc.setParent("com.hnac.hzims.ticket"); - mpg.setPackageInfo(pc); - - // 自定义配置 - InjectionConfig cfg = new InjectionConfig() { - @Override - public void initMap() { - // to do nothing - } - }; - - // 如果模板引擎是 freemarker - String templatePath = "/templates/mapper.xml.ftl"; - // 如果模板引擎是 velocity - // String templatePath = "/templates/mapper.xml.vm"; - - // 自定义输出配置 - List focList = new ArrayList<>(); - cfg.setFileOutConfigList(focList); - mpg.setCfg(cfg); - - // 配置模板 - TemplateConfig templateConfig = new TemplateConfig(); - - // 配置自定义输出模板 - //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别 - // templateConfig.setEntity("templates/entity2.java"); - // templateConfig.setService(); - // templateConfig.setController(); - - // templateConfig.setXml(null); - mpg.setTemplate(templateConfig); - - // 策略配置 - StrategyConfig strategy = new StrategyConfig(); - strategy.setNaming(NamingStrategy.underline_to_camel); - strategy.setColumnNaming(NamingStrategy.underline_to_camel); - // strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!"); - strategy.setEntityLombokModel(true); - strategy.setRestControllerStyle(true); - strategy.setEntityBooleanColumnRemoveIsPrefix(true); - strategy.setEntityLombokModel(true); - strategy.setEntitySerialVersionUID(true); - strategy.setChainModel(true); - strategy.setEntityTableFieldAnnotationEnable(true); - // strategy.setFieldPrefix("hzims_"); - // 公共父类 - // strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!"); - // 写于父类中的公共字段 - // strategy.setSuperEntityColumns("id"); - strategy.setInclude("hzims_process_type"); - strategy.setControllerMappingHyphenStyle(true); - strategy.setTablePrefix("hzims_"); - mpg.setStrategy(strategy); - // mpg.setTemplateEngine(new FreemarkerTemplateEngine()); - mpg.execute(); - } - -} +// package com.hnac.hzims.ticket.processflow; +// +// import com.baomidou.mybatisplus.generator.AutoGenerator; +// import com.baomidou.mybatisplus.generator.InjectionConfig; +// import com.baomidou.mybatisplus.generator.config.*; +// import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; +// +// import java.util.ArrayList; +// import java.util.List; +// +// /** +// * 代码生成器 +// * @Author dfy +// * @Version v1.0 +// * @Serial 1.0 +// * @Date 2023/3/29 8:59 +// */ +// public class CodeGenerator { +// +// +// public static void main(String[] args) { +// // 代码生成器 +// AutoGenerator mpg = new AutoGenerator(); +// +// // 全局配置 +// GlobalConfig gc = new GlobalConfig(); +// String projectPath = System.getProperty("user.dir") + "/hzims-service/ticket"; +// gc.setOutputDir(projectPath + "/src/main/java"); +// gc.setAuthor("dfy"); +// gc.setOpen(false); +// // gc.setSwagger2(true); 实体属性 Swagger2 注解 +// mpg.setGlobalConfig(gc); +// +// // 数据源配置 +// DataSourceConfig dsc = new DataSourceConfig(); +// dsc.setUrl("jdbc:mysql://192.168.1.20:3576/dev_hzims_ticket?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true"); +// // dsc.setSchemaName("public"); +// dsc.setDriverName("com.mysql.cj.jdbc.Driver"); +// dsc.setUsername("root"); +// dsc.setPassword("123"); +// mpg.setDataSource(dsc); +// +// // 包配置 +// PackageConfig pc = new PackageConfig(); +// pc.setModuleName("processflow"); +// pc.setParent("com.hnac.hzims.ticket"); +// mpg.setPackageInfo(pc); +// +// // 自定义配置 +// InjectionConfig cfg = new InjectionConfig() { +// @Override +// public void initMap() { +// // to do nothing +// } +// }; +// +// // 如果模板引擎是 freemarker +// String templatePath = "/templates/mapper.xml.ftl"; +// // 如果模板引擎是 velocity +// // String templatePath = "/templates/mapper.xml.vm"; +// +// // 自定义输出配置 +// List focList = new ArrayList<>(); +// cfg.setFileOutConfigList(focList); +// mpg.setCfg(cfg); +// +// // 配置模板 +// TemplateConfig templateConfig = new TemplateConfig(); +// +// // 配置自定义输出模板 +// //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别 +// // templateConfig.setEntity("templates/entity2.java"); +// // templateConfig.setService(); +// // templateConfig.setController(); +// +// // templateConfig.setXml(null); +// mpg.setTemplate(templateConfig); +// +// // 策略配置 +// StrategyConfig strategy = new StrategyConfig(); +// strategy.setNaming(NamingStrategy.underline_to_camel); +// strategy.setColumnNaming(NamingStrategy.underline_to_camel); +// // strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!"); +// strategy.setEntityLombokModel(true); +// strategy.setRestControllerStyle(true); +// strategy.setEntityBooleanColumnRemoveIsPrefix(true); +// strategy.setEntityLombokModel(true); +// strategy.setEntitySerialVersionUID(true); +// strategy.setChainModel(true); +// strategy.setEntityTableFieldAnnotationEnable(true); +// // strategy.setFieldPrefix("hzims_"); +// // 公共父类 +// // strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!"); +// // 写于父类中的公共字段 +// // strategy.setSuperEntityColumns("id"); +// strategy.setInclude("hzims_process_type"); +// strategy.setControllerMappingHyphenStyle(true); +// strategy.setTablePrefix("hzims_"); +// mpg.setStrategy(strategy); +// // mpg.setTemplateEngine(new FreemarkerTemplateEngine()); +// mpg.execute(); +// } +// +// } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java index 4d0471b..7b9706f 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java @@ -10,5 +10,6 @@ package com.hnac.hzims.ticket.processflow.constant; */ public class TicketProcessConstant { - public final static String STARTEVENT = "startEvent1"; + // public final static String STARTEVENT = "startEvent1"; + public final static String STARTEVENT = "newFirstWorkTicket"; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java index b03730f..15fb42e 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java @@ -44,19 +44,21 @@ public class StandardWorkTicketConsumer implements IQueueConsume { WorkflowQueue ticker = new WorkflowQueue(); ticker.setProcessDefinitionKey(taskDefinitionKey); //判断执行具体的实现类 - ProcessService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)) - .findFirst().orElse(null); + ProcessService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); if (ObjectUtils.isNotEmpty(ticketService)) { //执行业务方法 try { ticketService.calculate(response); } catch (Exception e) { //todo 业务出错误 做补偿 - log.error("业务出错,StandardWorkTicketConsumer: ", e); - log.info("正在保存到hzims_workflow_operation_log...."); + log.error("业务出错,StandardWorkTicketConsumer: {}", e.getMessage()); + log.error("业务出错,StandardWorkTicketConsumer: {} ", response); WorkflowOperationLog workflowOperationLog = new WorkflowOperationLog(); - BeanUtils.copyProperties(response, workflowOperationLog); - workflowOperationLogService.save(workflowOperationLog); + BeanUtils.copyProperties(response,workflowOperationLog); + if (ObjectUtils.isNotEmpty(workflowOperationLog)) { + log.info("正在保存到hzims_workflow_operation_log.... :{}", workflowOperationLog); + workflowOperationLogService.save(workflowOperationLog); + } } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/entity/WorkflowOperationLog.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/entity/WorkflowOperationLog.java index b0b521c..a40e262 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/entity/WorkflowOperationLog.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/entity/WorkflowOperationLog.java @@ -1,10 +1,8 @@ package com.hnac.hzims.ticket.processflow.entity; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; @@ -44,8 +42,8 @@ public class WorkflowOperationLog implements Serializable { /** * 当前环节流程ID */ - @TableField("task_definition_key") - private String taskDefinitionKey; + @TableField("process_definition_key") + private String processDefinitionKey; /** * 实例key diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeProcessServiceImpl.java index ea3f3e0..cf40c11 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeProcessServiceImpl.java @@ -43,7 +43,7 @@ public class MakeProcessServiceImpl extends ProcessAbstractService { log.info("已执行开工作票流程环节操作~~~~"); return true; } - log.info("未是否执行开工作票流程环节操作,请联系管理员~~~~"); + log.error("未是否执行开工作票流程环节操作,请联系管理员~~~~"); return false; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java index 430d32b..b28d1a1 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java @@ -2,11 +2,15 @@ package com.hnac.hzims.ticket.standardTicket.controller; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketInfoDto; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; import io.swagger.annotations.Api; @@ -20,6 +24,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.vo.ComleteTask; +import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; @@ -30,76 +35,93 @@ import java.util.Map; /** * @author hx */ -@Api(value = "标准票管理",tags = "标准票管理") +@Api(value = "标准票管理", tags = "标准票管理") @RestController @RequestMapping("/standard/ticket") @AllArgsConstructor @Slf4j public class StandardTicketInfoController extends BladeController { - private final IStandardTicketInfoService standardTicketInfoService; + private final IStandardTicketInfoService standardTicketInfoService; - @PostMapping("/remove") - @ApiOperationSupport(order = 10) - @ApiOperation(value = "逻辑删除") - public R remove(@RequestParam Long id,@RequestParam String comment) { - return standardTicketInfoService.remove(id,comment); - } + @PostMapping("/remove") + @ApiOperationSupport(order = 10) + @ApiOperation(value = "逻辑删除") + public R remove(@RequestParam Long id, @RequestParam String comment) { + return standardTicketInfoService.remove(id, comment); + } - @PostMapping("/save") - @ApiOperationSupport(order = 20) - @ApiOperation(value = "新增") - public R save(@Valid @RequestBody StandardTicketInfoDto req) { - return standardTicketInfoService.doSave(req); - } + @PostMapping("/save") + @ApiOperationSupport(order = 20) + @ApiOperation(value = "新增") + public R save(@Valid @RequestBody StandardTicketInfoDto req) { + return standardTicketInfoService.doSave(req); + } - @PostMapping("/update") - @ApiOperationSupport(order = 30) - @ApiOperation(value = "修改") - public R update(@Valid @RequestBody StandardTicketInfoDto req) { - return R.status(standardTicketInfoService.updateById(req)); - } + @PostMapping("/update") + @ApiOperationSupport(order = 30) + @ApiOperation(value = "修改") + public R update(@Valid @RequestBody StandardTicketInfoDto req) { + return R.status(standardTicketInfoService.updateById(req)); + } - @GetMapping("/detail") - @ApiOperationSupport(order = 40) - @ApiOperation(value = "详情") - public R detail(@RequestParam Long id) { - return standardTicketInfoService.detail(id); - } + @GetMapping("/detail") + @ApiOperationSupport(order = 40) + @ApiOperation(value = "详情") + public R detail(@RequestParam Long id) { + return standardTicketInfoService.detail(id); + } - @ApiLog - @PostMapping("/queryList") - @ApiOperationSupport(order = 50) - @ApiOperation(value = "分页") - @OperationAnnotation(moduleName = "两票管理",title = "操作票",operatorType = OperatorType.MOBILE,businessType = - BusinessType.GENCODE, - action = "分页") - public R> queryList(StandardTicketInfoDto req, Query query) { - return standardTicketInfoService.queryList(req, query); - } + @ApiLog + @PostMapping("/queryList") + @ApiOperationSupport(order = 50) + @ApiOperation(value = "分页") + @OperationAnnotation(moduleName = "两票管理", title = "操作票", operatorType = OperatorType.MOBILE, businessType = + BusinessType.GENCODE, + action = "分页") + public R> queryList(StandardTicketInfoDto req, Query query) { + return standardTicketInfoService.queryList(req, query); + } - @PostMapping("/list") - @ApiOperationSupport(order = 60) - @ApiOperation(value = "分页") - public R> list(@RequestBody StandardTicketInfoDto req){ - return R.data(standardTicketInfoService.list(req)); - } + @PostMapping("/list") + @ApiOperationSupport(order = 60) + @ApiOperation(value = "分页") + public R> list(@RequestBody StandardTicketInfoDto req) { + return R.data(standardTicketInfoService.list(req)); + } - @GetMapping("/completeTask") - @ApiOperationSupport(order = 70) - @ApiOperation(value = "操作票完成工作流") - public R completeTask(@RequestBody Map params){ - if(CollectionUtil.isEmpty(params) || ObjectUtil.isEmpty(params.get("info")) || ObjectUtil.isEmpty(params.get("flow"))){ - return R.fail(400,"传参错误"); - } - StandardTicketInfoDto infoDto = JSONObject.parseObject(JSONObject.toJSONString(params.get("info")),StandardTicketInfoDto.class); - ComleteTask comleteTask = JSONObject.parseObject(JSONObject.toJSONString(params.get("flow")),ComleteTask.class); - return standardTicketInfoService.completeTask(infoDto,comleteTask); - } + @GetMapping("/completeTask") + @ApiOperationSupport(order = 70) + @ApiOperation(value = "操作票完成工作流") + public R completeTask(@RequestBody Map params) { + if (CollectionUtil.isEmpty(params) || ObjectUtil.isEmpty(params.get("info")) || ObjectUtil.isEmpty(params.get("flow"))) { + return R.fail(400, "传参错误"); + } + StandardTicketInfoDto infoDto = JSONObject.parseObject(JSONObject.toJSONString(params.get("info")), StandardTicketInfoDto.class); + ComleteTask comleteTask = JSONObject.parseObject(JSONObject.toJSONString(params.get("flow")), ComleteTask.class); + return standardTicketInfoService.completeTask(infoDto, comleteTask); + } - @GetMapping("/exportTicketPdf") - @ApiOperationSupport(order = 80) - @ApiOperation(value = "导出操作票") - public void exportTicketPdf(@RequestParam Long id, HttpServletResponse response){ - standardTicketInfoService.exportTicketPdf(id,response); - } + @GetMapping("/exportTicketPdf") + @ApiOperationSupport(order = 80) + @ApiOperation(value = "导出操作票") + public void exportTicketPdf(@RequestParam Long id, HttpServletResponse response) { + standardTicketInfoService.exportTicketPdf(id, response); + } + + + /** + * 根据月份,区域 获取操作详情数据 + * + * @return + */ + @GetMapping("/areaMonthlyWithOperation/{page}/{size}") + public R> areaMonthlyWithOperation( + @PathVariable("page") Long page, + @PathVariable("size") Long size, + @SpringQueryMap AreaMonthlyVo areaMonthlyVo) { + Page searchPage = new Page<>(page, size); + IPage standardTicketInfoEntity = + standardTicketInfoService.areaMonthlyWithOperation(areaMonthlyVo, searchPage); + return R.data(standardTicketInfoEntity); + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java index 911b140..abae5de 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java @@ -1,8 +1,11 @@ package com.hnac.hzims.ticket.standardTicket.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketInfoDto; import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; @@ -11,13 +14,10 @@ import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.flow.core.vo.ComleteTask; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; import java.util.List; -import java.util.Map; /** * @author hx @@ -97,4 +97,14 @@ public interface IStandardTicketInfoService extends BaseService getOperateWorkStatistic(LocalDateTime firstDateTime,LocalDateTime endDateTime,List list); + + + /** + * 根据区域Id 分页查询 + * @param areaMonthly + * @param searchPage + * @return + */ + Page areaMonthlyWithOperation(AreaMonthlyVo areaMonthly, Page searchPage); + } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java index aa45bac..a4d8a3d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java @@ -2,14 +2,17 @@ package com.hnac.hzims.ticket.standardTicket.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; import com.hnac.hzims.ticket.allTicket.vo.DoublePassVO; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; +import com.hnac.hzims.ticket.areamonthly.StandardTicketVo; +import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketInfoDto; import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketMeasureDto; @@ -33,7 +36,6 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; -import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; @@ -41,6 +43,7 @@ import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.vo.ComleteTask; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,9 +51,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.math.RoundingMode; -import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; @@ -69,485 +70,523 @@ import java.util.stream.Collectors; @Slf4j public class StandardTicketInfoServiceImpl extends BaseServiceImpl implements IStandardTicketInfoService { - private final IStandardTicketMeasureService standardTicketMeasureService; - private final IFlowClient flowClient; - private final IStandardTicketMeasureService measureService; - private final IWorkTicketInfoService iWorkTicketInfoService; - private final TicketInfoEvaluateService ticketInfoEvaluateService; + private final IStandardTicketMeasureService standardTicketMeasureService; + private final IFlowClient flowClient; + private final IStandardTicketMeasureService measureService; + private final IWorkTicketInfoService iWorkTicketInfoService; + private final TicketInfoEvaluateService ticketInfoEvaluateService; - @Value("${hzims.ticket.path.xlsx.savePath}") - private String xlsSavePath; + @Value("${hzims.ticket.path.xlsx.savePath}") + private String xlsSavePath; - @Value("${hzims.ticket.path.pdf.savePath}") - private String pdfSavePath; + @Value("${hzims.ticket.path.pdf.savePath}") + private String pdfSavePath; - @Value("${hzims.ticket.standard-flow-key}") - private String standardFlowKey; + @Value("${hzims.ticket.standard-flow-key}") + private String standardFlowKey; - @Override - public R detail(Long id) { - StandardTicketInfoEntity standardTicketInfoEntity = this.getById(id); - if(ObjectUtil.isEmpty(standardTicketInfoEntity)){ - return R.fail(400,"未查询到相关记录"); - } - StandardTicketInfoVO standardTicketInfoVO = StandardTicketInfoWrapper.build().entityVO(standardTicketInfoEntity); - /**完善安全措施执行情况列表**/ - StandardTicketMeasureDto req = new StandardTicketMeasureDto(); - req.setTicketId(id); - List measureVOList = standardTicketMeasureService.list(req); - standardTicketInfoVO.setStandardTicketMeasureVOList(measureVOList); - return R.data(standardTicketInfoVO); - } + @Override + public R detail(Long id) { + StandardTicketInfoEntity standardTicketInfoEntity = this.getById(id); + if (ObjectUtil.isEmpty(standardTicketInfoEntity)) { + return R.fail(400, "未查询到相关记录"); + } + StandardTicketInfoVO standardTicketInfoVO = StandardTicketInfoWrapper.build().entityVO(standardTicketInfoEntity); + /**完善安全措施执行情况列表**/ + StandardTicketMeasureDto req = new StandardTicketMeasureDto(); + req.setTicketId(id); + List measureVOList = standardTicketMeasureService.list(req); + standardTicketInfoVO.setStandardTicketMeasureVOList(measureVOList); + return R.data(standardTicketInfoVO); + } - @Override - public R> queryList(StandardTicketInfoDto req, Query query) { - LambdaQueryWrapper queryWrapper = this.getQueryWrapper(req); - queryWrapper.orderByDesc(StandardTicketInfoEntity::getCreateTime); - IPage pages = super.page(Condition.getPage(query),queryWrapper); - return R.data(pages.setRecords(StandardTicketInfoWrapper.build().listVO(pages.getRecords()))); - } + @Override + public R> queryList(StandardTicketInfoDto req, Query query) { + LambdaQueryWrapper queryWrapper = this.getQueryWrapper(req); + queryWrapper.orderByDesc(StandardTicketInfoEntity::getCreateTime); + IPage pages = super.page(Condition.getPage(query), queryWrapper); + return R.data(pages.setRecords(StandardTicketInfoWrapper.build().listVO(pages.getRecords()))); + } - @Override - public List list(StandardTicketInfoDto req) { - List standardTicketInfoEntityList = this.list(this.getQueryWrapper(req)); - return StandardTicketInfoWrapper.build().listVO(standardTicketInfoEntityList); - } + @Override + public List list(StandardTicketInfoDto req) { + List standardTicketInfoEntityList = this.list(this.getQueryWrapper(req)); + return StandardTicketInfoWrapper.build().listVO(standardTicketInfoEntityList); + } - @Override - @Transactional - public R doSave(StandardTicketInfoDto req) { - if(CollectionUtil.isEmpty(req.getWorkTicketSafetyMeasureDtoList())){ - return R.fail("请选择对应的安全措施"); - } - req.setCode(this.getOperateTicketCode()); - req.setIssueOrderTime(LocalDateTime.now()); - req.setStatus(TicketConstants.StandardTicketStatusEnum.GUARDIAN_CONFIRM.getStatus()); - boolean flag = this.save(req); - if(!flag){ - return R.fail("保存标准票失败!"); - } - req.getWorkTicketSafetyMeasureDtoList().forEach(standardTicketMeasureEntity -> { - standardTicketMeasureEntity.setTicketId(req.getId()); - }); - boolean measureFlag = measureService.saveOrUpdateBatch(req.getWorkTicketSafetyMeasureDtoList()); - if(!measureFlag){ - return R.fail(400,"保存安全措施失败"); - } - /*开启工作流*/ - String processInstanceId = this.startProcessInstance(standardFlowKey,req); - return R.status(this.update( - Wrappers.lambdaUpdate() - .set(StandardTicketInfoEntity::getProcessInstanceId,processInstanceId) - .eq(StandardTicketInfoEntity::getId,req.getId()) - )); - } + @Override + @Transactional + public R doSave(StandardTicketInfoDto req) { + if (CollectionUtil.isEmpty(req.getWorkTicketSafetyMeasureDtoList())) { + return R.fail("请选择对应的安全措施"); + } + req.setCode(this.getOperateTicketCode()); + req.setIssueOrderTime(LocalDateTime.now()); + req.setStatus(TicketConstants.StandardTicketStatusEnum.GUARDIAN_CONFIRM.getStatus()); + boolean flag = this.save(req); + if (!flag) { + return R.fail("保存标准票失败!"); + } + req.getWorkTicketSafetyMeasureDtoList().forEach(standardTicketMeasureEntity -> { + standardTicketMeasureEntity.setTicketId(req.getId()); + }); + boolean measureFlag = measureService.saveOrUpdateBatch(req.getWorkTicketSafetyMeasureDtoList()); + if (!measureFlag) { + return R.fail(400, "保存安全措施失败"); + } + /*开启工作流*/ + String processInstanceId = this.startProcessInstance(standardFlowKey, req); + return R.status(this.update( + Wrappers.lambdaUpdate() + .set(StandardTicketInfoEntity::getProcessInstanceId, processInstanceId) + .eq(StandardTicketInfoEntity::getId, req.getId()) + )); + } - @Override - public R completeTask(StandardTicketInfoDto infoDto, ComleteTask comleteTask) { - /**若完成待监护人确认则设置监护人确认时间**/ - if(TicketConstants.StandardTicketStatusEnum.PRINCIPAL_CONFIRM.getStatus().equals(infoDto.getStatus())){ - infoDto.setGuardianshipTime(LocalDateTime.now()); - infoDto.setPrincipalTime(LocalDateTime.now()); - this.updateById(infoDto); - } - /**若完成工作负责人确认则设置工作负责人确认时间**/ - else if(TicketConstants.StandardTicketStatusEnum.END.getStatus().equals(infoDto.getStatus())){ - infoDto.setPrincipalTime(LocalDateTime.now()); - this.updateById(infoDto); - //操作票设置默认为合格 - TicketInfoEvaluateEntity evaluateEntity = new TicketInfoEvaluateEntity(); - evaluateEntity.setTicketId(infoDto.getId()); - ticketInfoEvaluateService.save(evaluateEntity); - } - R completeR = flowClient.completeTask(comleteTask); - if(completeR.isSuccess()){ - throw new ServiceException(completeR.getMsg()); - } - return R.success("操作成功!"); - } + @Override + public R completeTask(StandardTicketInfoDto infoDto, ComleteTask comleteTask) { + /**若完成待监护人确认则设置监护人确认时间**/ + if (TicketConstants.StandardTicketStatusEnum.PRINCIPAL_CONFIRM.getStatus().equals(infoDto.getStatus())) { + infoDto.setGuardianshipTime(LocalDateTime.now()); + infoDto.setPrincipalTime(LocalDateTime.now()); + this.updateById(infoDto); + } + /**若完成工作负责人确认则设置工作负责人确认时间**/ + else if (TicketConstants.StandardTicketStatusEnum.END.getStatus().equals(infoDto.getStatus())) { + infoDto.setPrincipalTime(LocalDateTime.now()); + this.updateById(infoDto); + //操作票设置默认为合格 + TicketInfoEvaluateEntity evaluateEntity = new TicketInfoEvaluateEntity(); + evaluateEntity.setTicketId(infoDto.getId()); + ticketInfoEvaluateService.save(evaluateEntity); + } + R completeR = flowClient.completeTask(comleteTask); + if (completeR.isSuccess()) { + throw new ServiceException(completeR.getMsg()); + } + return R.success("操作成功!"); + } - @Override - public void exportTicketPdf(Long id, HttpServletResponse response){ - R voR = this.detail(id); - if(!voR.isSuccess()){ - throw new ServiceException(voR.getMsg()); - } - StandardTicketInfoVO infoVO = voR.getData(); - Map ticketInfoMap = new HashMap<>(); - try { - ticketInfoMap = PdfUtils.objectToMap(infoVO); - } - catch (Exception e) { - log.info("转换对象失败!"); - } - /**格式化时间**/ - ticketInfoMap.put("startTime",DateUtil.format(infoVO.getStartTime(),TicketConstants.TICKET_DATE_PATTERN)); - ticketInfoMap.put("endTime",DateUtil.format(infoVO.getEndTime(),TicketConstants.TICKET_DATE_PATTERN)); - ticketInfoMap.put("issueOrderTime",DateUtil.format(infoVO.getIssueOrderTime(),TicketConstants.TICKET_DATE_PATTERN)); - List measureVOList = infoVO.getStandardTicketMeasureVOList(); - AtomicInteger index = new AtomicInteger(1); - if(CollectionUtil.isNotEmpty(measureVOList)){ - List> measureMapList = measureVOList.stream().map(measure->{ - try { - Map map = PdfUtils.objectToMap(measure); - map.put("index",index.get()); - map.put("status",TicketConstants.MATTER_FINISH_STATUS.equals(measure.getStatus()) ? "√" : ""); - index.getAndIncrement(); - return map; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - }).collect(Collectors.toList()); - ticketInfoMap.put("measureMapList",measureMapList); - } - //ticketInfoMap.put("stamp_image",stampImageUrl); - String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(infoVO.getTicketType()) + PdfUtils.XLSX_SUFFIX; - TemplateExportParams templateExportParams = new TemplateExportParams("template/" + fileName, true); - Workbook workbook = null; - try { - workbook = ExcelUtil.getWorkbook(templateExportParams,ticketInfoMap); - } catch (Exception e) { - e.printStackTrace(); - } - //上传xlsx至服务器 - try { - ExcelUtil.upload(workbook,xlsSavePath,infoVO.getTitle()+PdfUtils.XLSX_SUFFIX); - } catch (Exception e) { - e.printStackTrace(); - } - //将xlsx文件转换为pdf并保存 - String pdfFileName = infoVO.getTitle() + PdfUtils.PDF_SUFFIX; - String xlsFileName = infoVO.getTitle()+PdfUtils.XLSX_SUFFIX; - PdfUtils.convertPdf(xlsSavePath, xlsFileName, pdfSavePath, pdfFileName); - String savePath = pdfSavePath + pdfFileName; - // 设置response参数,可以打开下载页面 - PdfUtils.readPdf(response,savePath); - //WordUtils.exportWord(wordTemplatePath, ticketInfoMap,"大隆水电站倒闸操作票模板",response); - } + @Override + public void exportTicketPdf(Long id, HttpServletResponse response) { + R voR = this.detail(id); + if (!voR.isSuccess()) { + throw new ServiceException(voR.getMsg()); + } + StandardTicketInfoVO infoVO = voR.getData(); + Map ticketInfoMap = new HashMap<>(); + try { + ticketInfoMap = PdfUtils.objectToMap(infoVO); + } catch (Exception e) { + log.info("转换对象失败!"); + } + /**格式化时间**/ + ticketInfoMap.put("startTime", DateUtil.format(infoVO.getStartTime(), TicketConstants.TICKET_DATE_PATTERN)); + ticketInfoMap.put("endTime", DateUtil.format(infoVO.getEndTime(), TicketConstants.TICKET_DATE_PATTERN)); + ticketInfoMap.put("issueOrderTime", DateUtil.format(infoVO.getIssueOrderTime(), TicketConstants.TICKET_DATE_PATTERN)); + List measureVOList = infoVO.getStandardTicketMeasureVOList(); + AtomicInteger index = new AtomicInteger(1); + if (CollectionUtil.isNotEmpty(measureVOList)) { + List> measureMapList = measureVOList.stream().map(measure -> { + try { + Map map = PdfUtils.objectToMap(measure); + map.put("index", index.get()); + map.put("status", TicketConstants.MATTER_FINISH_STATUS.equals(measure.getStatus()) ? "√" : ""); + index.getAndIncrement(); + return map; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + }).collect(Collectors.toList()); + ticketInfoMap.put("measureMapList", measureMapList); + } + //ticketInfoMap.put("stamp_image",stampImageUrl); + String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(infoVO.getTicketType()) + PdfUtils.XLSX_SUFFIX; + TemplateExportParams templateExportParams = new TemplateExportParams("template/" + fileName, true); + Workbook workbook = null; + try { + workbook = ExcelUtil.getWorkbook(templateExportParams, ticketInfoMap); + } catch (Exception e) { + e.printStackTrace(); + } + //上传xlsx至服务器 + try { + ExcelUtil.upload(workbook, xlsSavePath, infoVO.getTitle() + PdfUtils.XLSX_SUFFIX); + } catch (Exception e) { + e.printStackTrace(); + } + //将xlsx文件转换为pdf并保存 + String pdfFileName = infoVO.getTitle() + PdfUtils.PDF_SUFFIX; + String xlsFileName = infoVO.getTitle() + PdfUtils.XLSX_SUFFIX; + PdfUtils.convertPdf(xlsSavePath, xlsFileName, pdfSavePath, pdfFileName); + String savePath = pdfSavePath + pdfFileName; + // 设置response参数,可以打开下载页面 + PdfUtils.readPdf(response, savePath); + //WordUtils.exportWord(wordTemplatePath, ticketInfoMap,"大隆水电站倒闸操作票模板",response); + } - @Override - @Transactional - public R remove(Long id, String comment) { - StandardTicketInfoEntity ticketInfoEntity = this.getById(id); - if(ObjectUtil.isEmpty(ticketInfoEntity)){ - return R.fail(400,"未查找到该记录对应的操作票"); - } - if(Func.isEmpty(ticketInfoEntity.getProcessInstanceId())){ - return R.fail("该操作票未开启工作流"); - } - this.update(Wrappers.lambdaUpdate() - .set(StandardTicketInfoEntity::getStatus,TicketConstants.StandardTicketStatusEnum.TERMINATION.getStatus()) - .eq(StandardTicketInfoEntity::getId,id)); - /**删除工作流**/ - R r = flowClient.delProcessInstanceById(ticketInfoEntity.getProcessInstanceId(),comment); - if(!r.isSuccess()){ - throw new ServiceException(r.getMsg()); - } - return R.success("删除成功!"); - } + @Override + @Transactional + public R remove(Long id, String comment) { + StandardTicketInfoEntity ticketInfoEntity = this.getById(id); + if (ObjectUtil.isEmpty(ticketInfoEntity)) { + return R.fail(400, "未查找到该记录对应的操作票"); + } + if (Func.isEmpty(ticketInfoEntity.getProcessInstanceId())) { + return R.fail("该操作票未开启工作流"); + } + this.update(Wrappers.lambdaUpdate() + .set(StandardTicketInfoEntity::getStatus, TicketConstants.StandardTicketStatusEnum.TERMINATION.getStatus()) + .eq(StandardTicketInfoEntity::getId, id)); + /**删除工作流**/ + R r = flowClient.delProcessInstanceById(ticketInfoEntity.getProcessInstanceId(), comment); + if (!r.isSuccess()) { + throw new ServiceException(r.getMsg()); + } + return R.success("删除成功!"); + } - /** - * 获取双票合格率 - * @param depatList - * @param firstDateTime - * @param now - * @return - */ - @Override - public DoublePassRateVO getDoublePassRate(List depatList, LocalDateTime firstDateTime, LocalDateTime now) { - DoublePassRateVO doublePassRateVO = new DoublePassRateVO(); - // 查询操作票 - List standardList = this.list(new LambdaQueryWrapper(){{ - ge(StandardTicketInfoEntity::getCreateTime,firstDateTime); - le(StandardTicketInfoEntity::getCreateTime,now); - in(StandardTicketInfoEntity::getCreateDept,depatList); - }}); - // 查询工作票 - List workList = iWorkTicketInfoService.list(new LambdaQueryWrapper(){{ - ge(WorkTicketInfoEntity::getCreateTime,firstDateTime); - le(WorkTicketInfoEntity::getCreateTime,now); - in(WorkTicketInfoEntity::getCreateDept,depatList); - }}); - if(CollectionUtil.isEmpty(standardList) && CollectionUtil.isEmpty(workList)){ - doublePassRateVO.setDoubleTicketCount(0); - doublePassRateVO.setDoubleTicketPassCount(0); - doublePassRateVO.setDoublePassRate("0"); - return doublePassRateVO; - } - List standardIdList = new ArrayList<>(); - standardIdList.addAll(standardList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList())); - standardIdList.addAll(workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList())); - doublePassRateVO.setDoubleTicketCount(standardIdList.size()); - // 查询合格评价 - List evaluateList = ticketInfoEvaluateService.list(new LambdaQueryWrapper(){{ - ge(TicketInfoEvaluateEntity::getCreateTime,firstDateTime); - le(TicketInfoEvaluateEntity::getCreateTime,now); - in(TicketInfoEvaluateEntity::getTicketId,standardIdList); - eq(TicketInfoEvaluateEntity::getStatus,TicketConstants.TicketQualifiedEnum.Qualified.getCode()); - }}); - if(CollectionUtil.isEmpty(evaluateList)){ - doublePassRateVO.setDoubleTicketPassCount(0); - doublePassRateVO.setDoublePassRate("0"); - return doublePassRateVO; - } - double doublePassRate = new BigDecimal(evaluateList.size() / (double) standardIdList.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - doublePassRateVO.setDoubleTicketPassCount(evaluateList.size()); - doublePassRateVO.setDoublePassRate(String.valueOf(doublePassRate)); - return doublePassRateVO; - } + /** + * 获取双票合格率 + * + * @param depatList + * @param firstDateTime + * @param now + * @return + */ + @Override + public DoublePassRateVO getDoublePassRate(List depatList, LocalDateTime firstDateTime, LocalDateTime now) { + DoublePassRateVO doublePassRateVO = new DoublePassRateVO(); + // 查询操作票 + List standardList = this.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getCreateTime, firstDateTime); + le(StandardTicketInfoEntity::getCreateTime, now); + in(StandardTicketInfoEntity::getCreateDept, depatList); + }}); + // 查询工作票 + List workList = iWorkTicketInfoService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getCreateTime, firstDateTime); + le(WorkTicketInfoEntity::getCreateTime, now); + in(WorkTicketInfoEntity::getCreateDept, depatList); + }}); + if (CollectionUtil.isEmpty(standardList) && CollectionUtil.isEmpty(workList)) { + doublePassRateVO.setDoubleTicketCount(0); + doublePassRateVO.setDoubleTicketPassCount(0); + doublePassRateVO.setDoublePassRate("0"); + return doublePassRateVO; + } + List standardIdList = new ArrayList<>(); + standardIdList.addAll(standardList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList())); + standardIdList.addAll(workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList())); + doublePassRateVO.setDoubleTicketCount(standardIdList.size()); + // 查询合格评价 + List evaluateList = ticketInfoEvaluateService.list(new LambdaQueryWrapper() {{ + ge(TicketInfoEvaluateEntity::getCreateTime, firstDateTime); + le(TicketInfoEvaluateEntity::getCreateTime, now); + in(TicketInfoEvaluateEntity::getTicketId, standardIdList); + eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); + }}); + if (CollectionUtil.isEmpty(evaluateList)) { + doublePassRateVO.setDoubleTicketPassCount(0); + doublePassRateVO.setDoublePassRate("0"); + return doublePassRateVO; + } + double doublePassRate = new BigDecimal(evaluateList.size() / (double) standardIdList.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + doublePassRateVO.setDoubleTicketPassCount(evaluateList.size()); + doublePassRateVO.setDoublePassRate(String.valueOf(doublePassRate)); + return doublePassRateVO; + } - /** - * 获取首页区域当月操作票/工作票 - * @param list - * @return - */ - @Override - public R getOperateWorkStatistic(LocalDateTime firstDateTime,LocalDateTime endDateTime,List list) { - TicketMonthVO ticketMonthVO = new TicketMonthVO(); - // 查询操作票 - getOperateMoth(firstDateTime,endDateTime,list,ticketMonthVO); - // 查询工作票 - getWorkMoth(firstDateTime,endDateTime,list,ticketMonthVO); - return R.data(ticketMonthVO); - } + /** + * 获取首页区域当月操作票/工作票 + * + * @param list + * @return + */ + @Override + public R getOperateWorkStatistic(LocalDateTime firstDateTime, LocalDateTime endDateTime, List list) { + TicketMonthVO ticketMonthVO = new TicketMonthVO(); + // 查询操作票 + getOperateMoth(firstDateTime, endDateTime, list, ticketMonthVO); + // 查询工作票 + getWorkMoth(firstDateTime, endDateTime, list, ticketMonthVO); + return R.data(ticketMonthVO); + } - /** - * 首页-当月操作票获取 - * @param firstDateTime - * @param endDateTime - * @param list - * @param ticketMonthVO - */ - private void getOperateMoth(LocalDateTime firstDateTime, LocalDateTime endDateTime, List list, TicketMonthVO ticketMonthVO) { - List operateList = this.list(new LambdaQueryWrapper(){{ - ge(StandardTicketInfoEntity::getCreateTime,firstDateTime); - le(StandardTicketInfoEntity::getCreateTime,endDateTime); - in(StandardTicketInfoEntity::getCreateDept,list); - }}); - if(CollectionUtil.isEmpty(operateList)){ - ticketMonthVO.setOperate(0); - ticketMonthVO.setOperateQualify(0); - return; - } - ticketMonthVO.setOperate(operateList.size()); - List operateIdList = operateList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList()); - // 查询合格评价 - List operateQualifyList = ticketInfoEvaluateService.list(new LambdaQueryWrapper(){{ - in(TicketInfoEvaluateEntity::getTicketId,operateIdList); - eq(TicketInfoEvaluateEntity::getStatus,TicketConstants.TicketQualifiedEnum.Qualified.getCode()); - }}); - if(CollectionUtil.isEmpty(operateQualifyList)){ - ticketMonthVO.setOperateQualify(0); - return; - } - ticketMonthVO.setOperateQualify(operateQualifyList.size()); - } + /** + * 根据区域Id 分页查询 + * + * @param areaMonthly + * @param searchPage + * @return + */ + @Override + public Page areaMonthlyWithOperation(AreaMonthlyVo areaMonthly, Page searchPage) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("CREATE_DEPT", areaMonthly.getAreaId()); + queryWrapper.eq(areaMonthly.getYearMonth() != null, + "date_format(create_time,'%Y-%m')", areaMonthly.getYearMonth()); + Page standardTicketInfoEntityPage = baseMapper.selectPage(searchPage, queryWrapper); + //数据转换StandardTicketInfoEntity ==> StandardTicketVo + List standardTicketInfoVOList = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(standardTicketInfoEntityPage.getRecords())) { + standardTicketInfoVOList = standardTicketInfoEntityPage.getRecords().stream().map(item -> { + StandardTicketVo standardTicketVo = new StandardTicketVo(); + BeanUtils.copyProperties(item, standardTicketVo); + return standardTicketVo; + }).collect(Collectors.toList()); + } + Page page = new Page<>(); + page.setSize(standardTicketInfoEntityPage.getSize()); + page.setCurrent(standardTicketInfoEntityPage.getCurrent()); + page.setTotal(standardTicketInfoEntityPage.getTotal()); + page.setRecords(standardTicketInfoVOList); + return page; + } - /** - * 首页-当月工作票获取 - * @param list - * @param ticketMonthVO - */ - private void getWorkMoth(LocalDateTime firstDateTime,LocalDateTime endDateTime,List list, TicketMonthVO ticketMonthVO) { - List workList = iWorkTicketInfoService.list(new LambdaQueryWrapper(){{ - ge(WorkTicketInfoEntity::getCreateTime,firstDateTime); - le(WorkTicketInfoEntity::getCreateTime,endDateTime); - in(WorkTicketInfoEntity::getCreateDept,list); - }}); - if(CollectionUtil.isEmpty(workList)){ - ticketMonthVO.setWork(0); - ticketMonthVO.setWorkQualify(0); - return; - } - ticketMonthVO.setWork(workList.size()); - List workIdList = workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); - // 查询合格评价 - List operateQualifyList = ticketInfoEvaluateService.list(new LambdaQueryWrapper(){{ - in(TicketInfoEvaluateEntity::getTicketId,workIdList); - eq(TicketInfoEvaluateEntity::getStatus,TicketConstants.TicketQualifiedEnum.Qualified.getCode()); - }}); - if(CollectionUtil.isEmpty(operateQualifyList)){ - ticketMonthVO.setOperateQualify(0); - return; - } - ticketMonthVO.setWorkQualify(operateQualifyList.size()); - } + /** + * 首页-当月操作票获取 + * + * @param firstDateTime + * @param endDateTime + * @param list + * @param ticketMonthVO + */ + private void getOperateMoth(LocalDateTime firstDateTime, LocalDateTime endDateTime, List list, TicketMonthVO ticketMonthVO) { + List operateList = this.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getCreateTime, firstDateTime); + le(StandardTicketInfoEntity::getCreateTime, endDateTime); + in(StandardTicketInfoEntity::getCreateDept, list); + }}); + if (CollectionUtil.isEmpty(operateList)) { + ticketMonthVO.setOperate(0); + ticketMonthVO.setOperateQualify(0); + return; + } + ticketMonthVO.setOperate(operateList.size()); + List operateIdList = operateList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList()); + // 查询合格评价 + List operateQualifyList = ticketInfoEvaluateService.list(new LambdaQueryWrapper() {{ + in(TicketInfoEvaluateEntity::getTicketId, operateIdList); + eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); + }}); + if (CollectionUtil.isEmpty(operateQualifyList)) { + ticketMonthVO.setOperateQualify(0); + return; + } + ticketMonthVO.setOperateQualify(operateQualifyList.size()); + } - /** - * 获取StandardTicketInfoEntity - LambdaQueryWrapper - * @param req - * @return - */ - private LambdaQueryWrapper getQueryWrapper(StandardTicketInfoDto req){ - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - if(Func.isNotEmpty(req.getCompany())){ - queryWrapper.like(StandardTicketInfoEntity::getCompany,"%".concat(req.getCompany()).concat("%")); - } - if(Func.isNotEmpty(req.getStatus())){ - queryWrapper.eq(StandardTicketInfoEntity::getStatus,req.getStatus()); - } - if(Func.isNotEmpty(req.getTicketType())){ - queryWrapper.eq(StandardTicketInfoEntity::getTicketType,req.getTicketType()); - } - if(Func.isNotEmpty(req.getTaskType())){ - queryWrapper.eq(StandardTicketInfoEntity::getTaskType,req.getTaskType()); - } - if(Func.isNotEmpty(req.getCode())){ - queryWrapper.like(StandardTicketInfoEntity::getCode,req.getCode()); - } - if(Func.isNotEmpty(req.getIssueOrderPerson())){ - queryWrapper.eq(StandardTicketInfoEntity::getIssueOrderPerson,req.getIssueOrderPerson()); - } - if(Func.isNotEmpty(req.getAccessOrderPerson())){ - queryWrapper.eq(StandardTicketInfoEntity::getAccessOrderPerson,req.getAccessOrderPerson()); - } - if(Func.isNotEmpty(req.getAccessOrderPerson())){ - queryWrapper.eq(StandardTicketInfoEntity::getAccessOrderPerson,req.getAccessOrderPerson()); - } - if(Func.isNotEmpty(req.getTitle())){ - queryWrapper.like(StandardTicketInfoEntity::getTitle,"%".concat(req.getTitle()).concat("%")); - } - if(Func.isNotEmpty(req.getStartTime())){ - queryWrapper.ge(StandardTicketInfoEntity::getCreateTime,req.getStartTime()); - } - if(Func.isNotEmpty(req.getEndTime())){ - queryWrapper.le(StandardTicketInfoEntity::getCreateTime,req.getEndTime()); - } - if(!CollectionUtil.isEmpty(req.getDeptIds())){ - queryWrapper.in(StandardTicketInfoEntity::getCreateDept,req.getDeptIds()); - } - return queryWrapper; - } + /** + * 首页-当月工作票获取 + * + * @param list + * @param ticketMonthVO + */ + private void getWorkMoth(LocalDateTime firstDateTime, LocalDateTime endDateTime, List list, TicketMonthVO ticketMonthVO) { + List workList = iWorkTicketInfoService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getCreateTime, firstDateTime); + le(WorkTicketInfoEntity::getCreateTime, endDateTime); + in(WorkTicketInfoEntity::getCreateDept, list); + }}); + if (CollectionUtil.isEmpty(workList)) { + ticketMonthVO.setWork(0); + ticketMonthVO.setWorkQualify(0); + return; + } + ticketMonthVO.setWork(workList.size()); + List workIdList = workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); + // 查询合格评价 + List operateQualifyList = ticketInfoEvaluateService.list(new LambdaQueryWrapper() {{ + in(TicketInfoEvaluateEntity::getTicketId, workIdList); + eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); + }}); + if (CollectionUtil.isEmpty(operateQualifyList)) { + ticketMonthVO.setOperateQualify(0); + return; + } + ticketMonthVO.setWorkQualify(operateQualifyList.size()); + } - /** - * 开启标准票流程 - * @param processDefinitionKey 标准票流程key - * @param entity - * @return - */ - private String startProcessInstance(String processDefinitionKey, StandardTicketInfoEntity entity) { - Map params = new HashMap(2) {{ - put("taskId", entity.getId()); - put("guardianUserIds", "taskUser_".concat(entity.getGuardian().toString())); - }}; + /** + * 获取StandardTicketInfoEntity - LambdaQueryWrapper + * + * @param req + * @return + */ + private LambdaQueryWrapper getQueryWrapper(StandardTicketInfoDto req) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + if (Func.isNotEmpty(req.getCompany())) { + queryWrapper.like(StandardTicketInfoEntity::getCompany, "%".concat(req.getCompany()).concat("%")); + } + if (Func.isNotEmpty(req.getStatus())) { + queryWrapper.eq(StandardTicketInfoEntity::getStatus, req.getStatus()); + } + if (Func.isNotEmpty(req.getTicketType())) { + queryWrapper.eq(StandardTicketInfoEntity::getTicketType, req.getTicketType()); + } + if (Func.isNotEmpty(req.getTaskType())) { + queryWrapper.eq(StandardTicketInfoEntity::getTaskType, req.getTaskType()); + } + if (Func.isNotEmpty(req.getCode())) { + queryWrapper.like(StandardTicketInfoEntity::getCode, req.getCode()); + } + if (Func.isNotEmpty(req.getIssueOrderPerson())) { + queryWrapper.eq(StandardTicketInfoEntity::getIssueOrderPerson, req.getIssueOrderPerson()); + } + if (Func.isNotEmpty(req.getAccessOrderPerson())) { + queryWrapper.eq(StandardTicketInfoEntity::getAccessOrderPerson, req.getAccessOrderPerson()); + } + if (Func.isNotEmpty(req.getAccessOrderPerson())) { + queryWrapper.eq(StandardTicketInfoEntity::getAccessOrderPerson, req.getAccessOrderPerson()); + } + if (Func.isNotEmpty(req.getTitle())) { + queryWrapper.like(StandardTicketInfoEntity::getTitle, "%".concat(req.getTitle()).concat("%")); + } + if (Func.isNotEmpty(req.getStartTime())) { + queryWrapper.ge(StandardTicketInfoEntity::getCreateTime, req.getStartTime()); + } + if (Func.isNotEmpty(req.getEndTime())) { + queryWrapper.le(StandardTicketInfoEntity::getCreateTime, req.getEndTime()); + } + if (!CollectionUtil.isEmpty(req.getDeptIds())) { + queryWrapper.in(StandardTicketInfoEntity::getCreateDept, req.getDeptIds()); + } + return queryWrapper; + } - return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey,"standardTicket:task:" + entity.getId(),entity.getTitle(), params) - .getData() - .getProcessInstanceId(); - } + /** + * 开启标准票流程 + * + * @param processDefinitionKey 标准票流程key + * @param entity + * @return + */ + private String startProcessInstance(String processDefinitionKey, StandardTicketInfoEntity entity) { + Map params = new HashMap(2) {{ + put("taskId", entity.getId()); + put("guardianUserIds", "taskUser_".concat(entity.getGuardian().toString())); + }}; - /*** - * 获取标准票编号 - * @return - */ - private String getOperateTicketCode(){ - /**获取当前时间**/ - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM"); - YearMonth yearMonth = YearMonth.now(); - String tym = yearMonth.format(formatter); - LocalDateTime date = LocalDateTime.now(); - LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0); - LocalDateTime lastDay = date.with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59); - log.info("当月第一天:{};当月最后一天{}",firstDay,lastDay); - /**获取当月工作票总条数**/ - List infoEntityList = this.list(new LambdaQueryWrapper(){{ - ge(StandardTicketInfoEntity::getCreateTime,firstDay); - le(StandardTicketInfoEntity::getCreateTime,lastDay); - }}); - if(CollectionUtil.isEmpty(infoEntityList)){ - return TicketConstants.TicketCodePreEnum.DQ_OPERATE.getPrefix().concat("-").concat(tym).concat("-001"); - } - return TicketConstants.TicketCodePreEnum.DQ_OPERATE.getPrefix().concat("-").concat(tym).concat("-").concat(String.format("%03d", infoEntityList.size())); - } + return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, "standardTicket:task:" + entity.getId(), entity.getTitle(), params) + .getData() + .getProcessInstanceId(); + } - /** - * 根据站点获取双票数量 - * @param stationMap - * @param firstDateTime - * @param now - * @return - */ - public List getDoublePassQuantity(Map stationMap, LocalDateTime firstDateTime, LocalDateTime now) { - List doublePassVOList = new ArrayList<>(); - // 站点遍历 - stationMap.forEach((key,value)->{ - DoublePassVO doublePassVO = new DoublePassVO(); - doublePassVO.setStationId(Long.valueOf(key)); - // 查询操作票 - List standardList = this.list(new LambdaQueryWrapper(){{ - ge(StandardTicketInfoEntity::getCreateTime,firstDateTime); - le(StandardTicketInfoEntity::getCreateTime,now); - eq(StandardTicketInfoEntity::getCreateDept,value); - }}); - List standardIdList = standardList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList()); - // 查询工作票 - List workList = iWorkTicketInfoService.list(new LambdaQueryWrapper(){{ - ge(WorkTicketInfoEntity::getCreateTime,firstDateTime); - le(WorkTicketInfoEntity::getCreateTime,now); - eq(WorkTicketInfoEntity::getCreateDept,value); - }}); - List workIdList = workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(standardIdList) && CollectionUtil.isEmpty(workIdList)){ - doublePassVO.setDoubleTicketCount(0); - doublePassVO.setQualifiedCount(0); - doublePassVOList.add(doublePassVO); - return; - } - // 双票 = 查询操作票 + 查询工作票 - standardIdList.addAll(workIdList); - // 查询合格评价 - List evaluateList = ticketInfoEvaluateService.list(new LambdaQueryWrapper(){{ - ge(TicketInfoEvaluateEntity::getCreateTime,firstDateTime); - le(TicketInfoEvaluateEntity::getCreateTime,now); - in(TicketInfoEvaluateEntity::getTicketId,standardIdList); - eq(TicketInfoEvaluateEntity::getStatus,TicketConstants.TicketQualifiedEnum.Qualified.getCode()); - }}); - if(CollectionUtil.isEmpty(evaluateList)){ - doublePassVO.setDoubleTicketCount(standardIdList.size()); - doublePassVO.setQualifiedCount(0); - doublePassVOList.add(doublePassVO); - return; - } - doublePassVO.setDoubleTicketCount(standardIdList.size()); - doublePassVO.setQualifiedCount(evaluateList.size()); - doublePassVOList.add(doublePassVO); - }); - return doublePassVOList; - } + /*** + * 获取标准票编号 + * @return + */ + private String getOperateTicketCode() { + /**获取当前时间**/ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM"); + YearMonth yearMonth = YearMonth.now(); + String tym = yearMonth.format(formatter); + LocalDateTime date = LocalDateTime.now(); + LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0); + LocalDateTime lastDay = date.with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59); + log.info("当月第一天:{};当月最后一天{}", firstDay, lastDay); + /**获取当月工作票总条数**/ + List infoEntityList = this.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getCreateTime, firstDay); + le(StandardTicketInfoEntity::getCreateTime, lastDay); + }}); + if (CollectionUtil.isEmpty(infoEntityList)) { + return TicketConstants.TicketCodePreEnum.DQ_OPERATE.getPrefix().concat("-").concat(tym).concat("-001"); + } + return TicketConstants.TicketCodePreEnum.DQ_OPERATE.getPrefix().concat("-").concat(tym).concat("-").concat(String.format("%03d", infoEntityList.size())); + } - /** - * 站点统计月报 - 操作票统计 - * @param startDate 开始时间 - * @param endDate 结束时间 - * @param deptIdList 机构ID - * @return - */ - @Override - public TicketInfoStatisticVO operateTicketReportStatistic(String startDate, String endDate, List deptIdList) { - TicketInfoStatisticVO result = new TicketInfoStatisticVO(); - result.setTicketInfoType("操作票"); - List operateTicketReportStatistic = this.baseMapper.getOperateTicketReportStatistic(startDate, endDate, deptIdList); - if(CollectionUtil.isNotEmpty(operateTicketReportStatistic)) { - //已完成数量 - int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(ticket -> TicketConstants.StandardTicketStatusEnum.END.getStatus().equals(ticket.getStatus())) - .collect(Collectors.toList()).size(); - //合格数量 - int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size(); - //计算合格率 - double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double)operateTicketReportStatistic.size() *100) - .setScale(2, RoundingMode.HALF_DOWN).doubleValue(); - result = TicketInfoStatisticVO.builder() - .ticketInfoType("操作票") - .ticketInfoNumber(operateTicketReportStatistic.size()) - .ticketInfoCompleteNum(ticketInfoCompleteNum) - .ticketInfoQualifiedNum(ticketInfoQualifiedNum) - .ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum) - .ticketInfoProportion(ticketInfoProportion) - .build(); - } - return result; - } + /** + * 根据站点获取双票数量 + * + * @param stationMap + * @param firstDateTime + * @param now + * @return + */ + public List getDoublePassQuantity(Map stationMap, LocalDateTime firstDateTime, LocalDateTime now) { + List doublePassVOList = new ArrayList<>(); + // 站点遍历 + stationMap.forEach((key, value) -> { + DoublePassVO doublePassVO = new DoublePassVO(); + doublePassVO.setStationId(Long.valueOf(key)); + // 查询操作票 + List standardList = this.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getCreateTime, firstDateTime); + le(StandardTicketInfoEntity::getCreateTime, now); + eq(StandardTicketInfoEntity::getCreateDept, value); + }}); + List standardIdList = standardList.stream().map(StandardTicketInfoEntity::getId).collect(Collectors.toList()); + // 查询工作票 + List workList = iWorkTicketInfoService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getCreateTime, firstDateTime); + le(WorkTicketInfoEntity::getCreateTime, now); + eq(WorkTicketInfoEntity::getCreateDept, value); + }}); + List workIdList = workList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(standardIdList) && CollectionUtil.isEmpty(workIdList)) { + doublePassVO.setDoubleTicketCount(0); + doublePassVO.setQualifiedCount(0); + doublePassVOList.add(doublePassVO); + return; + } + // 双票 = 查询操作票 + 查询工作票 + standardIdList.addAll(workIdList); + // 查询合格评价 + List evaluateList = ticketInfoEvaluateService.list(new LambdaQueryWrapper() {{ + ge(TicketInfoEvaluateEntity::getCreateTime, firstDateTime); + le(TicketInfoEvaluateEntity::getCreateTime, now); + in(TicketInfoEvaluateEntity::getTicketId, standardIdList); + eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); + }}); + if (CollectionUtil.isEmpty(evaluateList)) { + doublePassVO.setDoubleTicketCount(standardIdList.size()); + doublePassVO.setQualifiedCount(0); + doublePassVOList.add(doublePassVO); + return; + } + doublePassVO.setDoubleTicketCount(standardIdList.size()); + doublePassVO.setQualifiedCount(evaluateList.size()); + doublePassVOList.add(doublePassVO); + }); + return doublePassVOList; + } + + /** + * 站点统计月报 - 操作票统计 + * + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param deptIdList 机构ID + * @return + */ + @Override + public TicketInfoStatisticVO operateTicketReportStatistic(String startDate, String endDate, List deptIdList) { + TicketInfoStatisticVO result = new TicketInfoStatisticVO(); + result.setTicketInfoType("操作票"); + List operateTicketReportStatistic = this.baseMapper.getOperateTicketReportStatistic(startDate, endDate, deptIdList); + if (CollectionUtil.isNotEmpty(operateTicketReportStatistic)) { + //已完成数量 + int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(ticket -> TicketConstants.StandardTicketStatusEnum.END.getStatus().equals(ticket.getStatus())) + .collect(Collectors.toList()).size(); + //合格数量 + int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size(); + //计算合格率 + double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100) + .setScale(2, RoundingMode.HALF_DOWN).doubleValue(); + result = TicketInfoStatisticVO.builder() + .ticketInfoType("操作票") + .ticketInfoNumber(operateTicketReportStatistic.size()) + .ticketInfoCompleteNum(ticketInfoCompleteNum) + .ticketInfoQualifiedNum(ticketInfoQualifiedNum) + .ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum) + .ticketInfoProportion(ticketInfoProportion) + .build(); + } + return result; + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 3ed5371..94c55ef 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -5,10 +5,14 @@ import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.flow.core.vo.TaskList; import org.springframework.stereotype.Service; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -49,7 +53,23 @@ public class TicketProcessServiceImpl implements TicketProcessService { // variables.put("task_id", taskId); // variables.put("signUserIds", formData); - // flowClient.startProcessInstanceContainNameByKey(processDefinitionKey,"workTicket:task:"+1,) + + Map params = new HashMap(2) {{ + put("taskId", "1644624168666353665"); + put("signUserIds", AuthUtil.getUserId()); + }}; + + flowClient.startProcessInstanceContainNameByKey( + processDefinitionKey,"workTicket:task:"+1, + "开启工作的任务", + params); + + R> listR = flowClient.todoList(processDefinitionKey); + listR.getData().forEach(taskList -> { + System.out.println("任务名称:"+taskList); + System.out.println(taskList.getTaskName()); + System.out.println(taskList.getStatus()); + }); } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java index 5c8a9ac..a2113fa 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java @@ -14,7 +14,6 @@ import com.hnac.hzims.ticket.workTicket.service.IWorkTicketDelayService; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketPrincipalChangeService; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; -import com.hnac.hzims.ticket.workTicket.vo.WorkTicketReportStatisticVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; import lombok.AllArgsConstructor; @@ -47,192 +46,196 @@ import java.util.stream.Collectors; @RequestMapping("/feign/workTicket/info") public class TicketInfoClient implements ITicketInfoClient { - private final IWorkTicketInfoService infoService; - private final IStandardTicketInfoService standardService; - private final IWorkTicketPrincipalChangeService transferService; - private final IFlowClient flowClient; - private final IWorkTicketDelayService delayService; + private final IWorkTicketInfoService infoService; + private final IStandardTicketInfoService standardService; + private final IWorkTicketPrincipalChangeService transferService; + private final IFlowClient flowClient; + private final IWorkTicketDelayService delayService; - @Override - @GetMapping("/updateUndoneStatus") - @Transactional(rollbackFor = Exception.class) - public R updateUndoneStatus(@RequestParam Long ticketId) { - log.info("--开始处理逾期完成的票据--"); - WorkTicketInfoEntity entity = infoService.getById(ticketId); - synchronized (entity) { - entity.setId(ticketId); - entity.setStatus(TicketConstants.FirstWorkTicketFlowStatusEnum.UNDONE.getStatus()); - Boolean flag = infoService.updateById(entity); - //修改票据状态后需要终止工作流任务 - if(StringUtil.isNotBlank(entity.getProcessInstanceId())){ - R result = flowClient.delProcessInstanceById(entity.getProcessInstanceId(),"检修任务已逾期,暂停两票工作流任务"); - if(!result.isSuccess()){ - throw new ServiceException(result.getMsg()); - } - } - return R.status(flag); - } - } + @Override + @GetMapping("/updateUndoneStatus") + @Transactional(rollbackFor = Exception.class) + public R updateUndoneStatus(@RequestParam Long ticketId) { + log.info("--开始处理逾期完成的票据--"); + WorkTicketInfoEntity entity = infoService.getById(ticketId); + synchronized (entity) { + entity.setId(ticketId); + entity.setStatus(TicketConstants.FirstWorkTicketFlowStatusEnum.UNDONE.getStatus()); + Boolean flag = infoService.updateById(entity); + //修改票据状态后需要终止工作流任务 + if (StringUtil.isNotBlank(entity.getProcessInstanceId())) { + R result = flowClient.delProcessInstanceById(entity.getProcessInstanceId(), "检修任务已逾期,暂停两票工作流任务"); + if (!result.isSuccess()) { + throw new ServiceException(result.getMsg()); + } + } + return R.status(flag); + } + } - @Override - @GetMapping("/getWorkTicketByTime") - public R> getWorkTicketByTime(@RequestParam String startDate, @RequestParam String endDate) { - List infoList = infoService.list(new LambdaQueryWrapper(){{ - ge(WorkTicketInfoEntity::getPlanStartTime,startDate); - le(WorkTicketInfoEntity::getPlanStartTime,endDate); - }}); - return R.data(infoList); - } + @Override + @GetMapping("/getWorkTicketByTime") + public R> getWorkTicketByTime(@RequestParam String startDate, @RequestParam String endDate) { + List infoList = infoService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getPlanStartTime, startDate); + le(WorkTicketInfoEntity::getPlanStartTime, endDate); + }}); + return R.data(infoList); + } - @Override - @GetMapping("/getOperateTicketByTime") - public R> getOperateTicketByTime(@RequestParam String startDate, @RequestParam String endDate) { - List infoList = standardService.list(new LambdaQueryWrapper(){{ - ge(StandardTicketInfoEntity::getStartTime,startDate); - le(StandardTicketInfoEntity::getStartTime,endDate); - }}); - return R.data(infoList); - } + @Override + @GetMapping("/getOperateTicketByTime") + public R> getOperateTicketByTime(@RequestParam String startDate, @RequestParam String endDate) { + List infoList = standardService.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getStartTime, startDate); + le(StandardTicketInfoEntity::getStartTime, endDate); + }}); + return R.data(infoList); + } - @Override - @GetMapping("/getWorkTicketTransfer") - public R> getWorkTicketTransfer(@RequestParam String startDate, @RequestParam String endDate) { - List infoList = infoService.list(new LambdaQueryWrapper(){{ - ge(WorkTicketInfoEntity::getPlanStartTime,startDate); - le(WorkTicketInfoEntity::getPlanStartTime,endDate); - }}); - if(CollectionUtil.isEmpty(infoList)){ - return R.data(Lists.newArrayList()); - } - List infoIdList = infoList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); - List moveList = transferService.list(new LambdaQueryWrapper(){{ - in(WorkTicketPrincipalChangeEntity::getTicketId,infoIdList); - }}); - return R.data(moveList); - } + @Override + @GetMapping("/getWorkTicketTransfer") + public R> getWorkTicketTransfer(@RequestParam String startDate, @RequestParam String endDate) { + List infoList = infoService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getPlanStartTime, startDate); + le(WorkTicketInfoEntity::getPlanStartTime, endDate); + }}); + if (CollectionUtil.isEmpty(infoList)) { + return R.data(Lists.newArrayList()); + } + List infoIdList = infoList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); + List moveList = transferService.list(new LambdaQueryWrapper() {{ + in(WorkTicketPrincipalChangeEntity::getTicketId, infoIdList); + }}); + return R.data(moveList); + } - @Override - @PostMapping("/getWorkTicketStatistic") - public R getWorkTicketStatistic(@RequestBody Map params) { - String startDate = (String) params.get("startDate"); - String endDate = (String) params.get("endDate"); - List deptList = (List) params.get("deptList"); - log.info("开始main方法"); - WorkTicketStatisticVO workTicketStatisticVO = new WorkTicketStatisticVO(); - List infoList = infoService.list(new LambdaQueryWrapper(){{ - ge(WorkTicketInfoEntity::getPlanStartTime,startDate); - le(WorkTicketInfoEntity::getPlanStartTime,endDate); - in(WorkTicketInfoEntity::getCreateDept,deptList); - }}); - if(CollectionUtil.isNotEmpty(infoList)){ - List infoIdList = infoList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); - workTicketStatisticVO.setTotal(infoList.size()); - //工作票作废 - List invalidList = infoList.stream().filter(w-> TicketConstants.FirstWorkTicketFlowStatusEnum.INVALID.getStatus().equals(w.getStatus())) - .collect(Collectors.toList()); - workTicketStatisticVO.setInvalid(CollectionUtil.isNotEmpty(invalidList) ? invalidList.size() : 0); - // 工作票完成数 - List completeList = infoList.stream().filter(w-> TicketConstants.FirstWorkTicketFlowStatusEnum.FINISH.getStatus().equals(w.getStatus())) - .collect(Collectors.toList()); - workTicketStatisticVO.setComplete(CollectionUtil.isNotEmpty(completeList) ? completeList.size() : 0); - //工作票移交 - FutureTask transferTask = new FutureTask(()->{ - log.info("开始工作票移交"); - List moveList = transferService.list(new LambdaQueryWrapper(){{ - in(WorkTicketPrincipalChangeEntity::getTicketId,infoIdList); - }}); - return CollectionUtil.isNotEmpty(moveList) ? moveList.size() : 0; - }); - new Thread(transferTask,"工作票移交Thread").start(); - //工作票延期 - FutureTask delayTask = new FutureTask(()->{ - log.info("开始工作票延期"); - List delayEntityList = delayService.list(Wrappers.lambdaQuery() - .in(WorkTicketDelayEntity::getTicketId,infoIdList) - ); - return CollectionUtil.isNotEmpty(delayEntityList) ? delayEntityList.size() : 0; - }); - new Thread(delayTask,"工作票延期Thread").start(); - try { - workTicketStatisticVO.setDelay((Integer) delayTask.get()); - workTicketStatisticVO.setTransfer((Integer) transferTask.get()); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - Thread.currentThread().interrupt(); - } - } - return R.data(workTicketStatisticVO); - } + @Override + @PostMapping("/getWorkTicketStatistic") + public R getWorkTicketStatistic(@RequestBody Map params) { + String startDate = (String) params.get("startDate"); + String endDate = (String) params.get("endDate"); + List deptList = (List) params.get("deptList"); + log.info("开始main方法"); + WorkTicketStatisticVO workTicketStatisticVO = new WorkTicketStatisticVO(); + List infoList = infoService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getPlanStartTime, startDate); + le(WorkTicketInfoEntity::getPlanStartTime, endDate); + in(WorkTicketInfoEntity::getCreateDept, deptList); + }}); + if (CollectionUtil.isNotEmpty(infoList)) { + List infoIdList = infoList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); + workTicketStatisticVO.setTotal(infoList.size()); + //工作票作废 + List invalidList = infoList.stream().filter(w -> TicketConstants.FirstWorkTicketFlowStatusEnum.INVALID.getStatus().equals(w.getStatus())) + .collect(Collectors.toList()); + workTicketStatisticVO.setInvalid(CollectionUtil.isNotEmpty(invalidList) ? invalidList.size() : 0); + // 工作票完成数 + List completeList = infoList.stream().filter(w -> TicketConstants.FirstWorkTicketFlowStatusEnum.FINISH.getStatus().equals(w.getStatus())) + .collect(Collectors.toList()); + workTicketStatisticVO.setComplete(CollectionUtil.isNotEmpty(completeList) ? completeList.size() : 0); + //工作票移交 + FutureTask transferTask = new FutureTask(() -> { + log.info("开始工作票移交"); + List moveList = transferService.list(new LambdaQueryWrapper() {{ + in(WorkTicketPrincipalChangeEntity::getTicketId, infoIdList); + }}); + return CollectionUtil.isNotEmpty(moveList) ? moveList.size() : 0; + }); + new Thread(transferTask, "工作票移交Thread").start(); + //工作票延期 + FutureTask delayTask = new FutureTask(() -> { + log.info("开始工作票延期"); + List delayEntityList = delayService.list(Wrappers.lambdaQuery() + .in(WorkTicketDelayEntity::getTicketId, infoIdList) + ); + return CollectionUtil.isNotEmpty(delayEntityList) ? delayEntityList.size() : 0; + }); + new Thread(delayTask, "工作票延期Thread").start(); + try { + workTicketStatisticVO.setDelay((Integer) delayTask.get()); + workTicketStatisticVO.setTransfer((Integer) transferTask.get()); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + } + return R.data(workTicketStatisticVO); + } - /** - * 获取首页操作票统计结果 - * @param params - * @return - */ - @Override - @PostMapping("/getOperateTicketStatistic") - public R getOperateTicketStatistic(@RequestBody Map params) { - String startDate = (String) params.get("startDate"); - String endDate = (String) params.get("endDate"); - List deptList = (List) params.get("deptList"); - List standardTicketList = standardService.list(new LambdaQueryWrapper(){{ - ge(StandardTicketInfoEntity::getStartTime,startDate); - le(StandardTicketInfoEntity::getStartTime,endDate); - in(StandardTicketInfoEntity::getCreateDept,deptList); - }}); - if(CollectionUtil.isEmpty(standardTicketList)){ - return R.data(0); - } - return R.data(standardTicketList.size()); - } + /** + * 获取首页操作票统计结果 + * + * @param params + * @return + */ + @Override + @PostMapping("/getOperateTicketStatistic") + public R getOperateTicketStatistic(@RequestBody Map params) { + String startDate = (String) params.get("startDate"); + String endDate = (String) params.get("endDate"); + List deptList = (List) params.get("deptList"); + List standardTicketList = standardService.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getStartTime, startDate); + le(StandardTicketInfoEntity::getStartTime, endDate); + in(StandardTicketInfoEntity::getCreateDept, deptList); + }}); + if (CollectionUtil.isEmpty(standardTicketList)) { + return R.data(0); + } + return R.data(standardTicketList.size()); + } - /** - * 获取首页月工作票,操作票统计结果 - * @param params - * @return - */ - @Override - @PostMapping("/getOperateWorkStatistic") - public R getOperateWorkStatistic(@RequestBody Map params) { - try{ - SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); - Date startDate = sdf.parse((String) params.get("startDate")); - Date endDate = sdf.parse((String) params.get("endDate")); - DateTimeFormatter df = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); - LocalDateTime firstDateTime = LocalDateTime.parse(DateUtil.format(startDate,DateUtil.PATTERN_DATETIME),df); - LocalDateTime endDateTime = LocalDateTime.parse(DateUtil.format(endDate,DateUtil.PATTERN_DATETIME),df); - List list = (List) params.get("deptList"); - return standardService.getOperateWorkStatistic(firstDateTime,endDateTime,list); - }catch (ParseException e){ - return R.fail("获取失败"); - } - } + /** + * 获取首页月工作票,操作票统计结果 + * + * @param params + * @return + */ + @Override + @PostMapping("/getOperateWorkStatistic") + public R getOperateWorkStatistic(@RequestBody Map params) { + try { + SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); + Date startDate = sdf.parse((String) params.get("startDate")); + Date endDate = sdf.parse((String) params.get("endDate")); + DateTimeFormatter df = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); + LocalDateTime firstDateTime = LocalDateTime.parse(DateUtil.format(startDate, DateUtil.PATTERN_DATETIME), df); + LocalDateTime endDateTime = LocalDateTime.parse(DateUtil.format(endDate, DateUtil.PATTERN_DATETIME), df); + List list = (List) params.get("deptList"); + return standardService.getOperateWorkStatistic(firstDateTime, endDateTime, list); + } catch (ParseException e) { + return R.fail("获取失败"); + } + } + + /** + * 安全检查工作票事项统计 + * + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param dept 机构ID + * @return WorkTicketStatisticVO统计对象 + */ + @Override + @GetMapping("/getWorkTicketCheck") + public R getWorkTicketCheck(@RequestParam(value = "startDate") String startDate, + @RequestParam(value = "endDate") String endDate, + @RequestParam(value = "dept") Long dept) { + SafeCheckStatisticVO vo = infoService.getWorkTicketStatistic(startDate, endDate, dept); + if (vo == null) { + vo = new SafeCheckStatisticVO(); + } + vo.setProjectType(Constants.SafeCheckProjectEnum.WORK_TICKET.getType()); + vo.setProjectTypeName(Constants.SafeCheckProjectEnum.WORK_TICKET.getName()); + //计算合格率 + if (ObjectUtil.isNotEmpty(vo.getTotal()) && vo.getTotal() != 0) { + double qualifiedRate = new BigDecimal( + vo.getQualified() / (double) vo.getTotal() * 100 + ).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + vo.setQualifiedRate(qualifiedRate); + } + return R.data(vo); + } - /** - * 安全检查工作票事项统计 - * @param startDate 开始时间 - * @param endDate 结束时间 - * @param dept 机构ID - * @return WorkTicketStatisticVO统计对象 - */ - @Override - @GetMapping("/getWorkTicketCheck") - public R getWorkTicketCheck(@RequestParam(value = "startDate") String startDate, - @RequestParam(value = "endDate") String endDate, - @RequestParam(value = "dept") Long dept){ - SafeCheckStatisticVO vo = infoService.getWorkTicketStatistic(startDate,endDate,dept); - if(vo == null){ - vo = new SafeCheckStatisticVO(); - } - vo.setProjectType(Constants.SafeCheckProjectEnum.WORK_TICKET.getType()); - vo.setProjectTypeName(Constants.SafeCheckProjectEnum.WORK_TICKET.getName()); - //计算合格率 - if(ObjectUtil.isNotEmpty(vo.getTotal()) && vo.getTotal() != 0){ - double qualifiedRate = new BigDecimal( - vo.getQualified() / (double) vo.getTotal() * 100 - ).setScale(2 , BigDecimal.ROUND_HALF_UP).doubleValue(); - vo.setQualifiedRate(qualifiedRate); - } - return R.data(vo); - } }