Commit 6999bdf0 authored by helinlin's avatar helinlin

修改气瓶系统bug

parent f8f5705c
...@@ -125,8 +125,8 @@ public class MetaHandler implements MetaObjectHandler { ...@@ -125,8 +125,8 @@ public class MetaHandler implements MetaObjectHandler {
*/ */
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
Class clazz = metaObject.getOriginalObject().getClass(); Class<?> clazz = metaObject.getOriginalObject().getClass();
FillCommonUserField annotation = (FillCommonUserField) clazz.getAnnotation(FillCommonUserField.class); FillCommonUserField annotation = clazz.getAnnotation(FillCommonUserField.class);
if (annotation == null || annotation.isAutoFill()) { if (annotation == null || annotation.isAutoFill()) {
String userId = RequestContext.getExeUserId(); String userId = RequestContext.getExeUserId();
ReginParams reginParams = ReginParams reginParams =
......
package com.yeejoin.amos.boot.biz.config; package com.yeejoin.amos.boot.biz.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.config.GlobalConfig; import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.yeejoin.amos.boot.biz.common.interceptors.PermissionInterceptor; import com.yeejoin.amos.boot.biz.common.interceptors.PermissionInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -30,18 +32,16 @@ public class MyBatisPlusConfig { ...@@ -30,18 +32,16 @@ public class MyBatisPlusConfig {
public Sequence sequence() { public Sequence sequence() {
return new Sequence(); return new Sequence();
} }
/** /**
* plus分页插件支持 * plus分页插件支持
*/ */
// @Bean @Bean
// public PaginationInterceptor paginationInterceptor() { public MybatisPlusInterceptor mybatisPlusInterceptor() {
// PaginationInterceptor page = new PaginationInterceptor(); MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
// //设置方言类型 mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// page.setDialectType("mysql"); return mybatisPlusInterceptor;
// //不限制 }
// page.setLimit(-1);
// return page;
// }
/** /**
* pageHelper插件支持 * pageHelper插件支持
...@@ -50,15 +50,10 @@ public class MyBatisPlusConfig { ...@@ -50,15 +50,10 @@ public class MyBatisPlusConfig {
*/ */
@Bean @Bean
ConfigurationCustomizer mybatisConfigurationCustomizer() { ConfigurationCustomizer mybatisConfigurationCustomizer() {
return new ConfigurationCustomizer() { return configuration -> configuration.addInterceptor(new com.github.pagehelper.PageInterceptor());
@Override
public void customize(MybatisConfiguration configuration) {
configuration.addInterceptor(new com.github.pagehelper.PageInterceptor());
}
};
} }
@ConditionalOnProperty(name = "mybatis.interceptor.enabled",havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(name = "mybatis.interceptor.enabled", havingValue = "true", matchIfMissing = true)
@Bean @Bean
public PermissionInterceptor permissionInterceptor() { public PermissionInterceptor permissionInterceptor() {
return new PermissionInterceptor(); return new PermissionInterceptor();
......
...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto; import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
/** /**
...@@ -15,7 +16,7 @@ import java.util.Date; ...@@ -15,7 +16,7 @@ import java.util.Date;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value="CylinderFillingRecordDto", description="液化气体气瓶充装信息-充装记录") @ApiModel(value = "CylinderFillingRecordDto", description = "液化气体气瓶充装信息-充装记录")
public class CylinderFillingRecordDto extends BaseDto { public class CylinderFillingRecordDto extends BaseDto {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -69,7 +70,6 @@ public class CylinderFillingRecordDto extends BaseDto { ...@@ -69,7 +70,6 @@ public class CylinderFillingRecordDto extends BaseDto {
@ApiModelProperty(value = "异常情况") @ApiModelProperty(value = "异常情况")
private String abnormalStr; private String abnormalStr;
@ApiModelProperty(value = "充装前检查时间") @ApiModelProperty(value = "充装前检查时间")
private String inspectionDate; private String inspectionDate;
...@@ -98,7 +98,6 @@ public class CylinderFillingRecordDto extends BaseDto { ...@@ -98,7 +98,6 @@ public class CylinderFillingRecordDto extends BaseDto {
@ApiModelProperty(value = "对接公司编码") @ApiModelProperty(value = "对接公司编码")
private String appId; private String appId;
@ApiModelProperty(value = "是否在检验有效期以内") @ApiModelProperty(value = "是否在检验有效期以内")
private String isValid; private String isValid;
...@@ -135,5 +134,4 @@ public class CylinderFillingRecordDto extends BaseDto { ...@@ -135,5 +134,4 @@ public class CylinderFillingRecordDto extends BaseDto {
@ApiModelProperty(value = "气瓶粘贴警示标签和充装标签") @ApiModelProperty(value = "气瓶粘贴警示标签和充装标签")
private Integer warningSign; private Integer warningSign;
} }
...@@ -23,7 +23,7 @@ public class CylinderFillingDataUnit extends BaseEntity { ...@@ -23,7 +23,7 @@ public class CylinderFillingDataUnit extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 月充装量 * 月充装量
*/ */
@TableField("total_sum") @TableField("total_sum")
private Double totalSum; private Double totalSum;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</select> </select>
<select id="queryListByQueryDto" resultType="java.util.Map"> <select id="queryListByQueryDto">
SELECT SELECT
r.sequence_nbr AS sequenceNbr, r.sequence_nbr AS sequenceNbr,
r.filling_unit_name AS fillingUnitName, r.filling_unit_name AS fillingUnitName,
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInfoMapper"> <mapper namespace="com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInfoMapper">
<select id="queryNumAndOutOfDateNum" resultType="java.util.Map"> <select id="queryNumAndOutOfDateNum" resultType="java.util.Map">
SELECT SELECT
count( sequence_nbr ) AS cylinderNum, count( sequence_nbr ) AS cylinderNum,
...@@ -21,22 +20,22 @@ ...@@ -21,22 +20,22 @@
) )
</select> </select>
<select id="getLastMonthInfoTotal" resultType="java.lang.Integer"> <sql id="selectAPPIdByRegionCode">
select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( sync_date, '%Y%m' ) ) =1 AND app_id in (
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%') select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
) </sql>
<select id="getLastMonthInfoTotal" resultType="java.lang.Integer">
select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) ,
date_format( sync_date, '%Y%m' ) ) =1 AND app_id in (<include refid="selectAPPIdByRegionCode"/>)
</select> </select>
<select id="getMonthBeforeLastInfoTotal" resultType="java.lang.Integer"> <select id="getMonthBeforeLastInfoTotal" resultType="java.lang.Integer">
select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( sync_date, '%Y%m' ) ) =2 AND app_id in ( select IFNULL(count(sequence_nbr), 0) from tz_cylinder_info where PERIOD_DIFF( date_format( now( ) , '%Y%m' ) ,
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%') date_format( sync_date, '%Y%m' ) ) =2 AND app_id in (<include refid="selectAPPIdByRegionCode"/>)
)
</select> </select>
<select id="getInfoTotalByRegionCode" resultType="java.lang.Integer"> <select id="getInfoTotalByRegionCode" resultType="java.lang.Integer">
select count(sequence_nbr) from tz_cylinder_info where app_id in ( select count(sequence_nbr) from tz_cylinder_info where app_id in (<include refid="selectAPPIdByRegionCode"/>)
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
)
</select> </select>
<select id="queryIntegirtyByAppId" resultType="java.lang.Double"> <select id="queryIntegirtyByAppId" resultType="java.lang.Double">
...@@ -44,9 +43,7 @@ ...@@ -44,9 +43,7 @@
</select> </select>
<select id="getWarnNum" resultType="java.lang.Integer"> <select id="getWarnNum" resultType="java.lang.Integer">
select count(1) from view_cylider_outofdate v where v.app_id in ( select count(1) from view_cylider_outofdate v where v.app_id in (<include refid="selectAPPIdByRegionCode"/>)
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
)
</select> </select>
<select id="getLastMonthInfoTotalUnit" resultType="java.lang.Integer"> <select id="getLastMonthInfoTotalUnit" resultType="java.lang.Integer">
......
...@@ -2,14 +2,11 @@ package com.yeejoin.equipmanage.service.impl; ...@@ -2,14 +2,11 @@ package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -1671,6 +1668,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1671,6 +1668,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
return SourcesStatisticsImpl.PREFIX_CATEGORY_COUNT + row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.EQUIPMENT.getCode() + "_" + row.get("categoryCode").toString(); return SourcesStatisticsImpl.PREFIX_CATEGORY_COUNT + row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.EQUIPMENT.getCode() + "_" + row.get("categoryCode").toString();
} }
@Override
public Boolean videoOnEquipmentSpecific(VideoOnEquipmentSpecificVo videoOnEquipmentSpecificVo) { public Boolean videoOnEquipmentSpecific(VideoOnEquipmentSpecificVo videoOnEquipmentSpecificVo) {
Long equipmentSpecificId = videoOnEquipmentSpecificVo.getEquipmentSpecificId(); Long equipmentSpecificId = videoOnEquipmentSpecificVo.getEquipmentSpecificId();
List<Long> videoIdList = videoOnEquipmentSpecificVo.getVideoIdList(); List<Long> videoIdList = videoOnEquipmentSpecificVo.getVideoIdList();
......
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller; package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List; import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderAreaDataDto;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderAreaDataServiceImpl; import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderAreaDataServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import io.swagger.annotations.Api;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderAreaDataDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
/** /**
* 气瓶区域统计表 * 气瓶区域统计表
...@@ -67,7 +65,7 @@ public class CylinderAreaDataController extends BaseController { ...@@ -67,7 +65,7 @@ public class CylinderAreaDataController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}") @DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除气瓶区域统计表", notes = "根据sequenceNbr删除气瓶区域统计表") @ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除气瓶区域统计表", notes = "根据sequenceNbr删除气瓶区域统计表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){ public ResponseModel<Boolean> deleteBySequenceNbr(@PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(cylinderAreaDataServiceImpl.removeById(sequenceNbr)); return ResponseHelper.buildResponse(cylinderAreaDataServiceImpl.removeById(sequenceNbr));
} }
......
...@@ -5,11 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -5,11 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.biz.utils.AlertBeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils; import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingRecordDto; import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto; import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto;
...@@ -26,15 +22,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -26,15 +22,8 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...@@ -42,12 +31,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -42,12 +31,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 气瓶基本信息 * 气瓶基本信息
...@@ -94,7 +78,7 @@ public class CylinderInfoController extends BaseController { ...@@ -94,7 +78,7 @@ public class CylinderInfoController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}") @PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新气瓶基本信息", notes = "根据sequenceNbr更新气瓶基本信息") @ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新气瓶基本信息", notes = "根据sequenceNbr更新气瓶基本信息")
public ResponseModel<CylinderInfoDto> updateBySequenceNbrCylinderInfo(@RequestBody CylinderInfoDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) { public ResponseModel<CylinderInfoDto> updateBySequenceNbrCylinderInfo(@RequestBody CylinderInfoDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.updateWithModel(model)); return ResponseHelper.buildResponse(cylinderInfoServiceImpl.updateWithModel(model));
} }
...@@ -108,7 +92,7 @@ public class CylinderInfoController extends BaseController { ...@@ -108,7 +92,7 @@ public class CylinderInfoController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}") @DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除气瓶基本信息", notes = "根据sequenceNbr删除气瓶基本信息") @ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除气瓶基本信息", notes = "根据sequenceNbr删除气瓶基本信息")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){ public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.removeById(sequenceNbr)); return ResponseHelper.buildResponse(cylinderInfoServiceImpl.removeById(sequenceNbr));
} }
...@@ -120,7 +104,7 @@ public class CylinderInfoController extends BaseController { ...@@ -120,7 +104,7 @@ public class CylinderInfoController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}") @GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个气瓶基本信息", notes = "根据sequenceNbr查询单个气瓶基本信息") @ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个气瓶基本信息", notes = "根据sequenceNbr查询单个气瓶基本信息")
public ResponseModel<CylinderInfoDto> selectOne(@PathVariable Long sequenceNbr) { public ResponseModel<CylinderInfoDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryBySeq(sequenceNbr)); return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryBySeq(sequenceNbr));
} }
...@@ -134,8 +118,8 @@ public class CylinderInfoController extends BaseController { ...@@ -134,8 +118,8 @@ public class CylinderInfoController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "气瓶基本信息分页查询", notes = "气瓶基本信息分页查询") @ApiOperation(httpMethod = "GET", value = "气瓶基本信息分页查询", notes = "气瓶基本信息分页查询")
public ResponseModel<Page<CylinderInfoDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam public ResponseModel<Page<CylinderInfoDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) { (value = "size") int size) {
Page<CylinderInfoDto> page = new Page<CylinderInfoDto>(); Page<CylinderInfoDto> page = new Page<CylinderInfoDto>();
page.setCurrent(current); page.setCurrent(current);
...@@ -149,7 +133,7 @@ public class CylinderInfoController extends BaseController { ...@@ -149,7 +133,7 @@ public class CylinderInfoController extends BaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "气瓶基本信息列表全部数据查询", notes = "气瓶基本信息列表全部数据查询") @ApiOperation(httpMethod = "GET", value = "气瓶基本信息列表全部数据查询", notes = "气瓶基本信息列表全部数据查询")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public ResponseModel<List<CylinderInfoDto>> selectForList() { public ResponseModel<List<CylinderInfoDto>> selectForList() {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoList()); return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoList());
...@@ -233,7 +217,6 @@ public class CylinderInfoController extends BaseController { ...@@ -233,7 +217,6 @@ public class CylinderInfoController extends BaseController {
} }
// // 数据完整性计算 气瓶企业信息 气瓶基本信息 标签 检验 充装 充装审核 // // 数据完整性计算 气瓶企业信息 气瓶基本信息 标签 检验 充装 充装审核
// /** // /**
// * 数据完整性计算 // * 数据完整性计算
...@@ -398,7 +381,6 @@ public class CylinderInfoController extends BaseController { ...@@ -398,7 +381,6 @@ public class CylinderInfoController extends BaseController {
} }
/** /**
* 装卸液体数据同步 * 装卸液体数据同步
* *
...@@ -424,29 +406,29 @@ public class CylinderInfoController extends BaseController { ...@@ -424,29 +406,29 @@ public class CylinderInfoController extends BaseController {
@GetMapping(value = "/cyinderRecordList") @GetMapping(value = "/cyinderRecordList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装信息", notes = "获取登陆人所在气瓶充装信息") @ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装信息", notes = "获取登陆人所在气瓶充装信息")
public ResponseModel<IPage<CylinderFillingRecordDto>> cyinderRecordList(@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize, String sort, CylinderFillingRecordDto cylinderFillingRecordDto) { public ResponseModel<IPage<CylinderFillingRecordDto>> cyinderRecordList(@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize, String sort, CylinderFillingRecordDto cylinderFillingRecordDto) {
Page<CylinderFillingRecordDto> page = new Page<CylinderFillingRecordDto>(); Page<CylinderFillingRecordDto> page = new Page<>();
page.setCurrent(pageNum); page.setCurrent(pageNum);
page.setSize(pageSize); page.setSize(pageSize);
String sortParam = ""; String sortParam = "";
String sortRule = ""; String sortRule = "";
if(sort!=null) { // 排序失效 if (sort != null) { // 排序失效
String[] date= sort.split(","); String[] date = sort.split(",");
if(date[1].equals("ascend")) { if (date[1].equals("ascend")) {
sortParam = "r." + RedisKey.humpToLine(date[0]); sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "asc"; sortRule = "asc";
}else { } else {
sortParam ="r." + RedisKey.humpToLine(date[0]); sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "desc"; sortRule = "desc";
} }
}else { } else {
sortParam = "r.sync_date"; sortParam = "r.sync_date";
sortRule = "desc"; sortRule = "desc";
} }
if(StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) { if (StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) {
cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF"); cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF");
} }
Page<CylinderFillingRecordDto> pageBean = cylinderFillingRecordServiceImpl.queryListByQueryDto(page,cylinderFillingRecordDto, sortParam, sortRule); Page<CylinderFillingRecordDto> pageBean = cylinderFillingRecordServiceImpl.queryListByQueryDto(page, cylinderFillingRecordDto, sortParam, sortRule);
Page<CylinderFillingRecordDto> result = new Page<CylinderFillingRecordDto>(pageNum,pageSize); Page<CylinderFillingRecordDto> result = new Page<>(pageNum, pageSize);
long totle = pageBean.getTotal(); long totle = pageBean.getTotal();
result.setRecords(pageBean.getRecords()); result.setRecords(pageBean.getRecords());
result.setTotal(totle); result.setTotal(totle);
...@@ -465,16 +447,11 @@ public class CylinderInfoController extends BaseController { ...@@ -465,16 +447,11 @@ public class CylinderInfoController extends BaseController {
@GetMapping(value = "/cyinderInfoList") @GetMapping(value = "/cyinderInfoList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶基本信息", notes = "获取登陆人所在气瓶基本信息") @ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶基本信息", notes = "获取登陆人所在气瓶基本信息")
public ResponseModel<IPage<CylinderInfoDto>> cyinderInfoList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderInfoDto cylinderInfoDto) { public ResponseModel<IPage<CylinderInfoDto>> cyinderInfoList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderInfoDto cylinderInfoDto) {
Page<CylinderInfo> pageBean;
IPage<CylinderInfo> page;
QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>(); QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) {
if(StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) {
List<String> appids = new ArrayList<>(); List<String> appids = new ArrayList<>();
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, cylinderInfoDto.getRegionCode()));
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode,cylinderInfoDto.getRegionCode())); unitList.forEach(u -> {
unitList.stream().forEach(u -> {
appids.add(u.getAppId()); appids.add(u.getAppId());
}); });
if (appids.size() == 0) { if (appids.size() == 0) {
...@@ -483,74 +460,68 @@ public class CylinderInfoController extends BaseController { ...@@ -483,74 +460,68 @@ public class CylinderInfoController extends BaseController {
cylinderInfoDto.setAppIds(appids); cylinderInfoDto.setAppIds(appids);
} }
setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, sort); setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, sort);
Page<CylinderInfo> pageBean;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) { if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE); pageBean = new Page<>(0, Long.MAX_VALUE);
} else { } else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize)); pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
} }
page = cylinderInfoServiceImpl.page(pageBean, cylinderInfoQueryWrapper); IPage<CylinderInfo> page = cylinderInfoServiceImpl.page(pageBean, cylinderInfoQueryWrapper);
int num= cylinderInfoServiceImpl.count(cylinderInfoQueryWrapper); int num = cylinderInfoServiceImpl.count(cylinderInfoQueryWrapper);
pageBean.setTotal(num); pageBean.setTotal(num);
IPage<CylinderInfoDto> result = BeanDtoVoUtils.cyinderInfoIPageDto(page); IPage<CylinderInfoDto> result = BeanDtoVoUtils.cyinderInfoIPageDto(page);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
private QueryWrapper<CylinderInfo> setQueryWrapper(QueryWrapper<CylinderInfo> queryWrapper, CylinderInfoDto cylinderInfo, String sort) { private QueryWrapper<CylinderInfo> setQueryWrapper(QueryWrapper<CylinderInfo> queryWrapper, CylinderInfoDto cylinderInfo, String sort) {
if(cylinderInfo.getAppIds() != null && cylinderInfo.getAppIds().size() >0) { if (cylinderInfo.getAppIds() != null && cylinderInfo.getAppIds().size() > 0) {
queryWrapper.in("app_id", cylinderInfo.getAppIds()); queryWrapper.in("app_id", cylinderInfo.getAppIds());
} else {
} }
if(sort!=null) { // 排序失效 if (sort != null) { // 排序失效
String[] date= sort.split(","); String[] date = sort.split(",");
if(date[1].equals("ascend")) { if ("ascend".equals(date[1])) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0])); queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
}else { } else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0])); queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
} }
}else { } else {
queryWrapper.orderByDesc("sync_date"); queryWrapper.orderByDesc("sync_date");
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getAppId())) {
if(!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateStart())) { queryWrapper.eq("app_id", cylinderInfo.getAppId());
queryWrapper.ge("inspection_date",cylinderInfo.getInspectionDateStart());
} }
if(!ValidationUtil.isEmpty(cylinderInfo.getAppId())) { if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateStart())) {
queryWrapper.eq("app_id",cylinderInfo.getAppId()); queryWrapper.ge("inspection_date", cylinderInfo.getInspectionDateStart());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateEnd())) {
if(!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateEnd())) { queryWrapper.le("inspection_date", cylinderInfo.getInspectionDateEnd());
queryWrapper.le("inspection_date",cylinderInfo.getInspectionDateEnd());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位 if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位
queryWrapper.like("unit_name",cylinderInfo.getUnitName()); queryWrapper.like("unit_name", cylinderInfo.getUnitName());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号 if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号
queryWrapper.eq("factory_num", cylinderInfo.getFactoryNum()); queryWrapper.like("factory_num", cylinderInfo.getFactoryNum());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种 if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种
queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety()); queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getQrCode())) {// 二维码编号 if (!ValidationUtil.isEmpty(cylinderInfo.getQrCode())) {// 二维码编号
queryWrapper.like("qrCode",cylinderInfo.getQrCode()); queryWrapper.like("qrCode", cylinderInfo.getQrCode());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getElectronicLabelCode())) {// 电子标签编号 if (!ValidationUtil.isEmpty(cylinderInfo.getElectronicLabelCode())) {// 电子标签编号
queryWrapper.like("electronic_label_code",cylinderInfo.getElectronicLabelCode()); queryWrapper.like("electronic_label_code", cylinderInfo.getElectronicLabelCode());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码 if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码
queryWrapper.like("sequence_code",cylinderInfo.getSequenceCode()); queryWrapper.like("sequence_code", cylinderInfo.getSequenceCode());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号 if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号
queryWrapper.like("unit_inner_code",cylinderInfo.getUnitInnerCode()); queryWrapper.like("unit_inner_code", cylinderInfo.getUnitInnerCode());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态 if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态
queryWrapper.eq("cylinder_status",cylinderInfo.getCylinderStatus()); queryWrapper.eq("cylinder_status", cylinderInfo.getCylinderStatus());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位 if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位
queryWrapper.like("manufacturing_unit",cylinderInfo.getManufacturingUnit()); queryWrapper.like("manufacturing_unit", cylinderInfo.getManufacturingUnit());
} }
return queryWrapper; return queryWrapper;
} }
...@@ -558,6 +529,7 @@ public class CylinderInfoController extends BaseController { ...@@ -558,6 +529,7 @@ public class CylinderInfoController extends BaseController {
/** /**
* 获取气瓶详细信息 * 获取气瓶详细信息
*
* @param sequenceNbr * @param sequenceNbr
* @return * @return
*/ */
...@@ -569,43 +541,42 @@ public class CylinderInfoController extends BaseController { ...@@ -569,43 +541,42 @@ public class CylinderInfoController extends BaseController {
CylinderInfoDto target = new CylinderInfoDto(); CylinderInfoDto target = new CylinderInfoDto();
// 把原对象数据拷贝到新对象 // 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderInfo, target); BeanUtils.copyProperties(cylinderInfo, target);
if(0 == cylinderInfo.getCylinderStatus()) { if (0 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("在用"); target.setCylinderStatusStr("在用");
} else if(1 == cylinderInfo.getCylinderStatus()) { } else if (1 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("停用"); target.setCylinderStatusStr("停用");
} else if(2 == cylinderInfo.getCylinderStatus()) { } else if (2 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("注销"); target.setCylinderStatusStr("注销");
} else if(3 == cylinderInfo.getCylinderStatus()) { } else if (3 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("报废"); target.setCylinderStatusStr("报废");
} else { } else {
target.setCylinderStatusStr(""); target.setCylinderStatusStr("");
} }
if(1 == cylinderInfo.getCylinderVariety()) { if (1 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("无缝气瓶"); target.setCylinderVarietyStr("无缝气瓶");
} else if(2 == cylinderInfo.getCylinderVariety()) { } else if (2 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("焊接气瓶"); target.setCylinderVarietyStr("焊接气瓶");
} else if(3 == cylinderInfo.getCylinderVariety()) { } else if (3 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("缠绕气瓶"); target.setCylinderVarietyStr("缠绕气瓶");
} else if(4 == cylinderInfo.getCylinderVariety()) { } else if (4 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("绝热气瓶"); target.setCylinderVarietyStr("绝热气瓶");
} else if(5 ==cylinderInfo.getCylinderVariety()) { } else if (5 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("内装填料气瓶"); target.setCylinderVarietyStr("内装填料气瓶");
} else { } else {
target.setCylinderVarietyStr(""); target.setCylinderVarietyStr("");
} }
Date nextDate = target.getNextInspectionDate(); Date nextDate = target.getNextInspectionDate();
long dates = nextDate.getTime() - System.currentTimeMillis(); long dates = nextDate.getTime() - System.currentTimeMillis();
if(dates >= 1000 * 60 * 60 * 24 * 30 ) { if (dates >= 1000 * 60 * 60 * 24 * 30) {
target.setInspectionStatas(1); target.setInspectionStatas(1);
} else if(0< dates && dates < 1000 * 60 * 60 * 24 * 30) { } else if (0 < dates && dates < 1000 * 60 * 60 * 24 * 30) {
target.setInspectionStatas(2); target.setInspectionStatas(2);
} else { } else {
target.setInspectionStatas(0); target.setInspectionStatas(0);
} }
return ResponseHelper.buildResponse(target); return ResponseHelper.buildResponse(target);
} }
...@@ -632,7 +603,7 @@ public class CylinderInfoController extends BaseController { ...@@ -632,7 +603,7 @@ public class CylinderInfoController extends BaseController {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize)); pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
} }
page = cylinderUnitServiceImpl.page(pageBean, cylinderUnitQueryWrapper); page = cylinderUnitServiceImpl.page(pageBean, cylinderUnitQueryWrapper);
int num= cylinderUnitServiceImpl.count(cylinderUnitQueryWrapper); int num = cylinderUnitServiceImpl.count(cylinderUnitQueryWrapper);
pageBean.setTotal(num); pageBean.setTotal(num);
IPage<CylinderUnitDto> result = this.cyinderInfoIPageDto(page); IPage<CylinderUnitDto> result = this.cyinderInfoIPageDto(page);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
...@@ -641,6 +612,7 @@ public class CylinderInfoController extends BaseController { ...@@ -641,6 +612,7 @@ public class CylinderInfoController extends BaseController {
/** /**
* 获取气瓶充装单位详情 * 获取气瓶充装单位详情
*
* @param sequenceNbr * @param sequenceNbr
* @return * @return
*/ */
...@@ -649,11 +621,11 @@ public class CylinderInfoController extends BaseController { ...@@ -649,11 +621,11 @@ public class CylinderInfoController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "获取气瓶充装单位详情", notes = "获取气瓶充装单位详情") @ApiOperation(httpMethod = "GET", value = "获取气瓶充装单位详情", notes = "获取气瓶充装单位详情")
public ResponseModel<CylinderUnitDto> cyinderUnitList(@PathVariable Long sequenceNbr) { public ResponseModel<CylinderUnitDto> cyinderUnitList(@PathVariable Long sequenceNbr) {
CylinderUnit cylinderUnit = cylinderUnitServiceImpl.getById(sequenceNbr); CylinderUnit cylinderUnit = cylinderUnitServiceImpl.getById(sequenceNbr);
if(this.regionMap == null) { if (this.regionMap == null) {
this.regionMap = new HashMap<>(); this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult(); Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> { regions.stream().forEach(t -> {
this.addRegionsMap(regionMap,t); this.addRegionsMap(regionMap, t);
}); });
} }
CylinderUnitDto target = new CylinderUnitDto(); CylinderUnitDto target = new CylinderUnitDto();
...@@ -662,26 +634,26 @@ public class CylinderInfoController extends BaseController { ...@@ -662,26 +634,26 @@ public class CylinderInfoController extends BaseController {
String regionCode = cylinderUnit.getRegionCode(); String regionCode = cylinderUnit.getRegionCode();
String[] regionCodes = regionCode.split("#"); String[] regionCodes = regionCode.split("#");
regionCode = ""; regionCode = "";
for(int i =0 ; i < regionCodes.length ; i ++) { for (int i = 0; i < regionCodes.length; i++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i])); regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
} }
target.setRegionCode(regionCode); target.setRegionCode(regionCode);
if(1 == cylinderUnit.getUnitType()) { if (1 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶充装单位"); target.setUnitTypeStr("液化石油气瓶充装单位");
} else if(2 == cylinderUnit.getUnitType()) { } else if (2 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶检验单位"); target.setUnitTypeStr("液化石油气瓶检验单位");
} else if(3 == cylinderUnit.getUnitType()) { } else if (3 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶生产单位"); target.setUnitTypeStr("液化石油气瓶生产单位");
} else { } else {
target.setUnitTypeStr(""); target.setUnitTypeStr("");
} }
target.setCylinderNumber((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,target.getAppId()))); target.setCylinderNumber((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId())));
target.setCylinderOutOfDate((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,target.getAppId()).le(CylinderInfo::getNextInspectionDate,new Date()))); target.setCylinderOutOfDate((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId()).le(CylinderInfo::getNextInspectionDate, new Date())));
Date nextDate = target.getFillingPermitDate(); Date nextDate = target.getFillingPermitDate();
long dates = nextDate.getTime() - System.currentTimeMillis(); long dates = nextDate.getTime() - System.currentTimeMillis();
if(dates >= 1000 * 60 * 60 * 24 * 200 ) { if (dates >= 1000 * 60 * 60 * 24 * 200) {
target.setLicenseStatus(1); target.setLicenseStatus(1);
} else if(0< dates && dates < 1000 * 60 * 60 * 24 * 200) { } else if (0 < dates && dates < 1000 * 60 * 60 * 24 * 200) {
target.setLicenseStatus(2); target.setLicenseStatus(2);
} else { } else {
target.setLicenseStatus(0); target.setLicenseStatus(0);
...@@ -691,30 +663,28 @@ public class CylinderInfoController extends BaseController { ...@@ -691,30 +663,28 @@ public class CylinderInfoController extends BaseController {
} }
private QueryWrapper<CylinderUnit> setQueryWrapper(QueryWrapper<CylinderUnit> queryWrapper, CylinderUnitDto cylinderUnitDto, String sort) { private QueryWrapper<CylinderUnit> setQueryWrapper(QueryWrapper<CylinderUnit> queryWrapper, CylinderUnitDto cylinderUnitDto, String sort) {
if(sort!=null) { // 排序失效 if (sort != null) { // 排序失效
String[] date= sort.split(","); String[] date = sort.split(",");
if(date[1].equals("ascend")) { if (date[1].equals("ascend")) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0])); queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
}else { } else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0])); queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
} }
}else { } else {
queryWrapper.orderByDesc("sync_date"); queryWrapper.orderByDesc("sync_date");
} }
if(!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateStart())) { // 许可有效期 if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateStart())) { // 许可有效期
queryWrapper.ge("filling_permit_date",cylinderUnitDto.getFillingPermitDateStart()); queryWrapper.ge("filling_permit_date", cylinderUnitDto.getFillingPermitDateStart());
} }
if(!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateEnd())) { if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateEnd())) {
queryWrapper.le("filling_permit_date",cylinderUnitDto.getFillingPermitDateEnd()); queryWrapper.le("filling_permit_date", cylinderUnitDto.getFillingPermitDateEnd());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitName())) { // 企业名称 if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitName())) { // 企业名称
queryWrapper.like("unit_name",cylinderUnitDto.getUnitName()); queryWrapper.like("unit_name", cylinderUnitDto.getUnitName());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitType())) {// 企业类型 if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitType())) {// 企业类型
...@@ -722,36 +692,36 @@ public class CylinderInfoController extends BaseController { ...@@ -722,36 +692,36 @@ public class CylinderInfoController extends BaseController {
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getCreditCode())) {// 统一社会信用代码 if (!ValidationUtil.isEmpty(cylinderUnitDto.getCreditCode())) {// 统一社会信用代码
queryWrapper.like("credit_code",cylinderUnitDto.getCreditCode()); queryWrapper.like("credit_code", cylinderUnitDto.getCreditCode());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getAddress())) {// 详细地址 if (!ValidationUtil.isEmpty(cylinderUnitDto.getAddress())) {// 详细地址
queryWrapper.like("address",cylinderUnitDto.getAddress()); queryWrapper.like("address", cylinderUnitDto.getAddress());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitPerson())) {// 企业负责人 if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitPerson())) {// 企业负责人
queryWrapper.like("unit_person",cylinderUnitDto.getUnitPerson()); queryWrapper.like("unit_person", cylinderUnitDto.getUnitPerson());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getPersonMobilePhone())) {// 负责人手机 if (!ValidationUtil.isEmpty(cylinderUnitDto.getPersonMobilePhone())) {// 负责人手机
queryWrapper.like("person_mobile_phone",cylinderUnitDto.getPersonMobilePhone()); queryWrapper.like("person_mobile_phone", cylinderUnitDto.getPersonMobilePhone());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingLicense())) {// 许可证号 if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingLicense())) {// 许可证号
queryWrapper.like("filling_license",cylinderUnitDto.getFillingLicense()); queryWrapper.like("filling_license", cylinderUnitDto.getFillingLicense());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermScope())) {// 许可范围 if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermScope())) {// 许可范围
queryWrapper.like("filling_perm_scope",cylinderUnitDto.getFillingPermScope()); queryWrapper.like("filling_perm_scope", cylinderUnitDto.getFillingPermScope());
} }
if (!ValidationUtil.isEmpty(cylinderUnitDto.getRegionCode())) {// 所属区域 if (!ValidationUtil.isEmpty(cylinderUnitDto.getRegionCode())) {// 所属区域
queryWrapper.like("region_code",cylinderUnitDto.getRegionCode()); queryWrapper.like("region_code", cylinderUnitDto.getRegionCode());
} }
return queryWrapper; return queryWrapper;
} }
private IPage<CylinderUnitDto> cyinderInfoIPageDto(IPage<CylinderUnit> page) { private IPage<CylinderUnitDto> cyinderInfoIPageDto(IPage<CylinderUnit> page) {
if(this.regionMap == null) { if (this.regionMap == null) {
this.regionMap = new HashMap<>(); this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult(); Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> { regions.stream().forEach(t -> {
this.addRegionsMap(regionMap,t); this.addRegionsMap(regionMap, t);
}); });
} }
...@@ -764,20 +734,20 @@ public class CylinderInfoController extends BaseController { ...@@ -764,20 +734,20 @@ public class CylinderInfoController extends BaseController {
String regionCode = item.getRegionCode(); String regionCode = item.getRegionCode();
String[] regionCodes = regionCode.split("#"); String[] regionCodes = regionCode.split("#");
regionCode = ""; regionCode = "";
for(int i =0 ; i < regionCodes.length ; i ++) { for (int i = 0; i < regionCodes.length; i++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i])); regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
} }
target.setRegionCode(regionCode); target.setRegionCode(regionCode);
if(1 == item.getUnitType()) { if (1 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶充装单位"); target.setUnitTypeStr("液化石油气瓶充装单位");
} else if(2 == item.getUnitType()) { } else if (2 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶检验单位"); target.setUnitTypeStr("液化石油气瓶检验单位");
} else if(3 == item.getUnitType()) { } else if (3 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶生产单位"); target.setUnitTypeStr("液化石油气瓶生产单位");
} else { } else {
target.setUnitTypeStr(""); target.setUnitTypeStr("");
} }
target.setCylinderNumber((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,target.getAppId()))); target.setCylinderNumber((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId())));
return target; return target;
} catch (Exception e) { } catch (Exception e) {
return null; return null;
...@@ -785,8 +755,8 @@ public class CylinderInfoController extends BaseController { ...@@ -785,8 +755,8 @@ public class CylinderInfoController extends BaseController {
}); });
} }
private void addRegionsMap(Map<Integer,String> regionMap, RegionModel region) { private void addRegionsMap(Map<Integer, String> regionMap, RegionModel region) {
regionMap.put(region.getRegionCode(),region.getRegionName()); regionMap.put(region.getRegionCode(), region.getRegionName());
if (region.getChildren() != null) { if (region.getChildren() != null) {
region.getChildren().stream().forEach(c -> { region.getChildren().stream().forEach(c -> {
addRegionsMap(regionMap, c); addRegionsMap(regionMap, c);
...@@ -795,7 +765,6 @@ public class CylinderInfoController extends BaseController { ...@@ -795,7 +765,6 @@ public class CylinderInfoController extends BaseController {
} }
/** /**
* 企业气瓶总量数据同步 * 企业气瓶总量数据同步
* *
...@@ -806,7 +775,6 @@ public class CylinderInfoController extends BaseController { ...@@ -806,7 +775,6 @@ public class CylinderInfoController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "企业气瓶总量数据同步", notes = "企业气瓶总量数据同步") @ApiOperation(httpMethod = "GET", value = "企业气瓶总量数据同步", notes = "企业气瓶总量数据同步")
public ResponseModel<Boolean> synUnitCylinderInfoData() { public ResponseModel<Boolean> synUnitCylinderInfoData() {
Boolean flag = cylinderInfoServiceImpl.synUnitCylinderInfoData(); Boolean flag = cylinderInfoServiceImpl.synUnitCylinderInfoData();
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
...@@ -820,7 +788,6 @@ public class CylinderInfoController extends BaseController { ...@@ -820,7 +788,6 @@ public class CylinderInfoController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "企业气瓶充装数据同步", notes = "企业气瓶充装数据同步") @ApiOperation(httpMethod = "GET", value = "企业气瓶充装数据同步", notes = "企业气瓶充装数据同步")
public ResponseModel<Boolean> synUnitCylinderFillingData() { public ResponseModel<Boolean> synUnitCylinderFillingData() {
Boolean flag = cylinderInfoServiceImpl.synUnitCylinderFillingData(); Boolean flag = cylinderInfoServiceImpl.synUnitCylinderFillingData();
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
...@@ -873,7 +840,6 @@ public class CylinderInfoController extends BaseController { ...@@ -873,7 +840,6 @@ public class CylinderInfoController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "装卸液体企业数据同步", notes = "装卸液体企业数据同步") @ApiOperation(httpMethod = "GET", value = "装卸液体企业数据同步", notes = "装卸液体企业数据同步")
public ResponseModel<Boolean> synFillingUnloadUnitData() { public ResponseModel<Boolean> synFillingUnloadUnitData() {
Boolean flag = cylinderInfoServiceImpl.synFillingUnloadUnitData(); Boolean flag = cylinderInfoServiceImpl.synFillingUnloadUnitData();
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
......
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl; package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderFillingRecord; import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderFillingRecord;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderFillingRecordMapper; import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderFillingRecordMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderFillingRecordService; import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderFillingRecordService;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingRecordDto;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -20,7 +19,7 @@ import java.util.List; ...@@ -20,7 +19,7 @@ import java.util.List;
* @date 2022-03-04 * @date 2022-03-04
*/ */
@Service @Service
public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillingRecordDto,CylinderFillingRecord,CylinderFillingRecordMapper> implements ICylinderFillingRecordService { public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillingRecordDto, CylinderFillingRecord, CylinderFillingRecordMapper> implements ICylinderFillingRecordService {
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -32,7 +31,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -32,7 +31,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
* 列表查询 示例 * 列表查询 示例
*/ */
public List<CylinderFillingRecordDto> queryForCylinderFillingRecordList() { public List<CylinderFillingRecordDto> queryForCylinderFillingRecordList() {
return this.queryForList("" , false); return this.queryForList("", false);
} }
public Double queryIntegirtyByAppId(String appId) { public Double queryIntegirtyByAppId(String appId) {
...@@ -40,15 +39,26 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -40,15 +39,26 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
} }
public Double getFillingSum(String r, Date time) { public Double getFillingSum(String r, Date time) {
return this.baseMapper.getFillingSum(r,time); return this.baseMapper.getFillingSum(r, time);
} }
public Page<CylinderFillingRecordDto> queryListByQueryDto(Page<CylinderFillingRecordDto> page, CylinderFillingRecordDto cylinderFillingRecordDto, String sortParam, String sortRule) { public Page<CylinderFillingRecordDto> queryListByQueryDto(Page<CylinderFillingRecordDto> page, CylinderFillingRecordDto cylinderFillingRecordDto, String sortParam, String sortRule) {
Page<List<CylinderFillingRecordDto>>list = this.baseMapper.queryListByQueryDto(page,cylinderFillingRecordDto.getFillingUnitName(),cylinderFillingRecordDto.getPropertyUnit(),cylinderFillingRecordDto.getFactoryNum(), Page<List<CylinderFillingRecordDto>> list = this.baseMapper.queryListByQueryDto(
cylinderFillingRecordDto.getCylinderVariety(), cylinderFillingRecordDto.getQrCode(), cylinderFillingRecordDto.getElectronicLabelCode(),cylinderFillingRecordDto.getSequenceCode(),cylinderFillingRecordDto.getUnitInnerCode(), page,
cylinderFillingRecordDto.getFillingStarttime(), cylinderFillingRecordDto.getFillingEndtime(), sortParam,sortRule,cylinderFillingRecordDto.getAppId()); cylinderFillingRecordDto.getFillingUnitName(),
cylinderFillingRecordDto.getPropertyUnit(),
cylinderFillingRecordDto.getFactoryNum(),
cylinderFillingRecordDto.getCylinderVariety(),
cylinderFillingRecordDto.getQrCode(),
cylinderFillingRecordDto.getElectronicLabelCode(),
cylinderFillingRecordDto.getSequenceCode(),
cylinderFillingRecordDto.getUnitInnerCode(),
cylinderFillingRecordDto.getFillingStarttime(),
cylinderFillingRecordDto.getFillingEndtime(),
sortParam, sortRule, cylinderFillingRecordDto.getAppId()
);
Page<CylinderFillingRecordDto> page1 = new Page<>(); Page<CylinderFillingRecordDto> page1 = new Page<>();
List<CylinderFillingRecordDto> resultDtoList = JSONArray.parseArray(JSONArray.toJSONString(list.getRecords()),CylinderFillingRecordDto.class); List<CylinderFillingRecordDto> resultDtoList = JSONArray.parseArray(JSONArray.toJSONString(list.getRecords()), CylinderFillingRecordDto.class);
page1.setCurrent(page.getCurrent()); page1.setCurrent(page.getCurrent());
page1.setSize(page.getSize()); page1.setSize(page.getSize());
page1.setTotal(list.getTotal()); page1.setTotal(list.getTotal());
...@@ -57,14 +67,14 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -57,14 +67,14 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
} }
public Double getFillingSumByMonth(String appId, Date time) { public Double getFillingSumByMonth(String appId, Date time) {
return baseMapper.getFillingSumByMonth(appId,time); return baseMapper.getFillingSumByMonth(appId, time);
} }
public Integer getFillingCountByMonth(String appId, Date time) { public Integer getFillingCountByMonth(String appId, Date time) {
return baseMapper.getFillingCountByMonth(appId,time); return baseMapper.getFillingCountByMonth(appId, time);
} }
public Double getFillingSumByDate(String appId, Date time) { public Double getFillingSumByDate(String appId, Date time) {
return baseMapper.getFillingSumByDate(appId,time); return baseMapper.getFillingSumByDate(appId, time);
} }
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl; package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderAreaDataDto; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingCheckDataUnitDto; import com.yeejoin.amos.boot.module.tzs.flc.api.dto.*;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingDataUnitDto; import com.yeejoin.amos.boot.module.tzs.flc.api.entity.*;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingUnloadDataDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingUnloadDataUnitDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDataDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDataUnitDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderIntegrityDataDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderIntegrityDataUnitDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderTagsDataUnitDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderUnitDataDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderAreaData;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderFillingCheckDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderFillingDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderFillingUnloadData;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderFillingUnloadDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfoData;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderInfoDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderIntegrityData;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderIntegrityDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderTags;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderTagsDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderUnitData;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInfoMapper; import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInfoMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService; import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel; import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar; import java.util.function.Consumer;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/** /**
* 气瓶基本信息服务实现类 * 气瓶基本信息服务实现类
...@@ -56,7 +26,7 @@ import java.util.Map; ...@@ -56,7 +26,7 @@ import java.util.Map;
* @date 2021-12-14 * @date 2021-12-14
*/ */
@Service @Service
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,CylinderInfo,CylinderInfoMapper> implements ICylinderInfoService { public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper> implements ICylinderInfoService {
@Autowired @Autowired
...@@ -112,14 +82,14 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde ...@@ -112,14 +82,14 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
* 分页查询 * 分页查询
*/ */
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) { public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return this.queryForPage(page, null, false); return queryForPage(page, null, false);
} }
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
public List<CylinderInfoDto> queryForCylinderInfoList() { public List<CylinderInfoDto> queryForCylinderInfoList() {
return this.queryForList("" , false); return queryForList("", false);
} }
@Override @Override
...@@ -127,10 +97,8 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde ...@@ -127,10 +97,8 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
return baseMapper.queryNumAndOutOfDateNum(unitId); return baseMapper.queryNumAndOutOfDateNum(unitId);
} }
/** /**
* 获取上个月气瓶总量 * 获取上个月气瓶总量
* @return
*/ */
public Integer getLastMonthInfoTotal(String regionCode) { public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode); return baseMapper.getLastMonthInfoTotal(regionCode);
...@@ -138,7 +106,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde ...@@ -138,7 +106,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
/** /**
* 获取上上个月气瓶总量 * 获取上上个月气瓶总量
* @return
*/ */
public Integer getMonthBeforeLastInfoTotal(String regionCode) { public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode); return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
...@@ -156,105 +123,75 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde ...@@ -156,105 +123,75 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
return baseMapper.getWarnNum(code); return baseMapper.getWarnNum(code);
} }
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 /**
public Boolean synFillingUnloadData() { * 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>()); cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult(); countByRegion(regionModel -> {
List<String> regionCodes = new ArrayList<String>();
regions.stream().forEach(t -> {
this.addRegionsList(regionCodes,t);
});
regionCodes.stream().forEach(r -> {
Calendar now = Calendar.getInstance(); Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(int i = 0 ; i < 30 ; i ++) { for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE,-1); now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto(); CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSum(r,now.getTime()); Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d; Double unloadSum = 0d;
temp.setFillingSum(fillingSum); temp.setFillingSum(fillingSum);
temp.setRegionCode(r); temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime()); temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime())); temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum); temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp); cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
} }
}); });
return true;
} }
private void addRegionsList(List<String> regionList, RegionModel region) { /**
regionList.add(region.getRegionCode() + ""); * 按区域统计
if (region.getChildren() != null) { */
region.getChildren().stream().forEach(c -> { @Transactional(rollbackFor = Exception.class)
addRegionsList(regionList, c); @Scheduled(cron = "0 0 2 * * ?")
}); public void synAreaData() {
}
}
private void addRegionsList1(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if(region.getChildren() != null) {
region.getChildren().stream().forEach(c -> {
addRegionsList1(regionList,c);
});
}
}
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行
public Boolean synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>()); cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult(); countByRegion(regionModel -> {
List<RegionModel> regionCodes = new ArrayList<RegionModel>();
regions.stream().forEach(t -> {
this.addRegionsList1(regionCodes,t);
});
regionCodes.stream().forEach(r -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto(); CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(r.getRegionName()); temp.setAreaName(regionModel.getRegionName());
String code = r.getRegionCode() +""; String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code); Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code); Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code); Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code); Integer cylinderInfoWarn = this.getWarnNum(code);
Integer warmTotal = cylinderUnitWarn + cylinderInfoWarn; int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = ""; String parentCode = "";
if("610000".equals(code)) { if ("610000".equals(code)) {
parentCode = "-1"; parentCode = "-1";
} else if(!"00".equals(code.substring(4,6))) { } else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0,4) + "00"; parentCode = code.substring(0, 4) + "00";
} else { } else {
parentCode = "610000"; parentCode = "610000";
} }
temp.setCylinderNum(Long.valueOf(cylinderTotal)); temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode); temp.setParentRegionCode(parentCode);
temp.setRegionCode(r.getRegionCode()+""); temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal)); temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum(Long.valueOf(warmTotal)); temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp); cylinderAreaDataServiceImpl.createWithModel(temp);
}); });
return true;
} }
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 /**
public Boolean addIntegrityData() { * 按区域统计
// 每日清空再重新获取数据 */
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void addIntegrityData() {
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>()); cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult(); List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionModel));
List<String> regionCodes = new ArrayList<String>();
regions.stream().forEach(t -> {
this.addRegionsList(regionCodes,t);
});
regionCodes.stream().forEach(u -> {
String regionCode = u;
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode,u));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>(); List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
unitlist.forEach(t -> {
unitlist.stream().forEach(t -> {
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto(); CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId(); String appId = t.getAppId();
Double totalIntegirty = 0d; Double totalIntegirty = 0d;
...@@ -270,348 +207,340 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde ...@@ -270,348 +207,340 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId); Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
//tz_cylinder_filling_check 30天内 //tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId); Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
totalIntegirty = (unitIntegirty + tagIntegirty+infoIntegirty+recordIntegirty+fillingIntegirty+checkIntegirty) / 6; totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty + checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty); BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100; totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId); temp.setAppId(appId);
temp.setRegionCode(u); temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty); temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName()); temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换 // 判断list 是否达到5个,如果达到则对比最后一个进行替换
if(tempList.size() == 5) { if (tempList.size() == 5) {
if(tempList.get(0).getIntegrity() < totalIntegirty) { if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0,temp); tempList.set(0, temp);
} }
} else { } else {
tempList.add(temp); tempList.add(temp);
} }
Collections.sort(tempList, new Comparator<CylinderIntegrityDataDto>() { tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
@Override
public int compare(CylinderIntegrityDataDto o1, CylinderIntegrityDataDto o2) {
//升序
return o1.getIntegrity().compareTo(o2.getIntegrity());
}
});
}); });
tempList.stream().forEach(t -> { tempList.forEach(t -> {
cylinderIntegrityDataServiceImpl.createWithModel(t); cylinderIntegrityDataServiceImpl.createWithModel(t);
}); });
}); });
return true;
} }
/**
* 企业总量按区域统计
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 */
public Boolean getCylinderUnitInfo() { @Transactional(rollbackFor = Exception.class)
// 每日清空再重新获取数据 @Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>()); cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult(); String regionCode = String.valueOf(regionModel.getRegionCode());
List<String> regionCodes = new ArrayList<String>();
regions.stream().forEach(t -> {
this.addRegionsList(regionCodes,t);
});
regionCodes.stream().forEach(u -> {
String regionCode = u;
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode); Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode)); Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode)); Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
Double percent = 0d; double changeNum = lastUnitTotal - monthUnitLastInfo;
if(monthUnitLastInfo != 0) { double percent = 0d;
percent = (lastUnitTotal - monthUnitLastInfo) / monthUnitLastInfo; if (monthUnitLastInfo != 0) {
percent = changeNum / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent); BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} }
CylinderUnitDataDto temp = new CylinderUnitDataDto(); CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) (lastUnitTotal - monthUnitLastInfo)); temp.setChangeSum((long) changeNum);
temp.setChangePercent( (int )(percent*100) + ""); temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode); temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal); temp.setTotalSum((long) cylinderUnitTotal);
cylinderUnitDataServiceImpl.createWithModel(temp); cylinderUnitDataServiceImpl.createWithModel(temp);
}); });
return true;
} }
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 /**
public Boolean getCylinderInfo() { * 气瓶总量按区域统计
// 每日清空再重新获取数据 */
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoData>()); @Transactional(rollbackFor = Exception.class)
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult(); @Scheduled(cron = "0 0 2 * * ?")
List<String> regionCodes = new ArrayList<String>(); public void getCylinderInfo() {
regions.stream().forEach(t -> { cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
this.addRegionsList(regionCodes,t); countByRegion(regionModel -> {
});
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
regionCodes.stream().forEach(u -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto(); CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = u; String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode); Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);//当前总数
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode)); Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));//上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode)); Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));//上上月总数
Double percent = 0d; double percent = 0d;
if(monthBeforeLastInfo != 0) { if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo; percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent); BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} }
temp.setChangeSum((long) (lastInfoTotal - monthBeforeLastInfo)); temp.setChangeSum((long) (lastInfoTotal - monthBeforeLastInfo));
temp.setChangePercent((int )(percent*100)+""); temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode); temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal); temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp); cylinderInfoDataServiceImpl.createWithModel(temp);
}); });
return true;
} }
/**
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 * 按单位统计
public Boolean synUnitCylinderInfoData() { */
// 每日清空再重新获取数据 @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>()); cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list(); countByUnit(cylinderUnit -> {
units.stream().forEach(u -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto(); CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(u.getAppId()); temp.setAppId(cylinderUnit.getAppId());
Integer count = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,u.getAppId())); int count = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));//当前总数
temp.setTotalSum((long) count); temp.setTotalSum((long) count);
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(u.getAppId())); Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));//上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(u.getAppId())); Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));//上上月总数
double percent = 0d;
Double percent = 0d; if (lastmonth != 0) {
if(lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth; percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent); BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} }
temp.setChangeSum((long) (thismonth - lastmonth)); temp.setChangeSum((long) (thismonth - lastmonth));
temp.setChangePercent((int )(percent*100)+""); temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp); cylinderInfoDataUnitServiceImpl.createWithModel(temp);
}); });
return true;
} }
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 /**
public Boolean synUnitCylinderFillingData() { * 充装量按单位和月统计
// 每日清空再重新获取数据 */
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>()); cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
// 按照月份 获取数据 取一年数据 // 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
// 按月份获取充装量 // 按月份获取充装量
// 当月与上月 对比获取数据 // 当月与上月 对比获取数据
for(int i = 0 ; i < 12 ; i++) { for (int i = 0; i < 12; i++) {
// 获取当月数据 // 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto(); CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = c.get(Calendar.YEAR)+""; String year = calendar.get(Calendar.YEAR) + "";
int month = c.get(Calendar.MONTH)+1 ; int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0"+month : month +""; String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingMonth(monthStr);
temp.setFillingYear(year); temp.setFillingYear(year);
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(u.getAppId(),c.getTime()); temp.setFillingMonth(monthStr);
//本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(), calendar.getTime());
temp.setTotalSum(thisMonth); temp.setTotalSum(thisMonth);
// 获取上月数据 calendar.add(Calendar.MONTH, -1);
c.add(Calendar.MONTH, -1); //上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(u.getAppId(),c.getTime()); Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(), calendar.getTime());
Double percent = 0d; double percent = 0d;
if(lastMonth != 0) { if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth; percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent); BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} }
temp.setChangePercent((int )(percent*100)+""); temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(u.getAppId()); temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth-lastMonth); temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp); cylinderFillingDataUnitServiceImpl.createWithModel(temp);
} }
}); });
return true;
} }
/**
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 * 按单位统计
public Boolean synUnitCylinderTagsData() { */
// 每日清空再重新获取数据 @Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>()); cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list(); countByUnit(cylinderUnit -> {
units.stream().forEach(u -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto(); CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(u.getAppId()); temp.setAppId(cylinderUnit.getAppId());
int cylinder = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,u.getAppId())); int cylinder = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId,u.getAppId())); int tags = cylinderTagsServiceImpl.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
double percent = 0d;
Double percent = 0d; if (tags != 0) {
if(tags != 0) {
percent = (double) cylinder / (double) tags; percent = (double) cylinder / (double) tags;
BigDecimal bg = new BigDecimal(percent); BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} }
temp.setCylinderSum((long) cylinder); temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags); temp.setTagsSum((long) tags);
temp.setTagPercent(percent*100); temp.setTagPercent(percent * 100);
cylinderTagsDataUnitServiceImpl.createWithModel(temp); cylinderTagsDataUnitServiceImpl.createWithModel(temp);
}); });
return true;
} }
@Transactional /**
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 * 按单位统计
public Boolean synUnitIntegrityData() { */
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>()); cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
// 企业信息 // 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto(); CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(u.getAppId()); uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息"); uninInfo.setDataType("企业信息");
Double unitIntegirty = u.getIntegrity(); Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty); uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo); cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息 // 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto(); CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(u.getAppId()); cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息"); cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(u.getAppId()); Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty); cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo); cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息 // 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto(); CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(u.getAppId()); cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息"); cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(u.getAppId()); Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty); cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag); cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息 // 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto(); CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(u.getAppId()); cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息"); cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d); cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection); cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查 // 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto(); CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(u.getAppId()); cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查"); cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(u.getAppId()); Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty); cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling); cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息 // 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto(); CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(u.getAppId()); cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息"); cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(u.getAppId()); Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty); cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord); cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查 // 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto(); CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(u.getAppId()); cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查"); cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(u.getAppId()); Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty); cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck); cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
}); });
return true;
} }
@Transactional /**
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 * 冲装详情按单位统计
public Boolean synUnitFillingCheckData() { */
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>()); cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list(); countByUnit(cylinderUnit -> {
units.stream().forEach(u -> {
// 按照月份 获取数据 取一年数据 // 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
// 按月份获取充装量 // 按月份获取充装量
// 当月与上月 对比获取数据 // 当月与上月 对比获取数据
for(int i = 0 ; i < 12 ; i++) { for (int i = 0; i < 12; i++) {
// 获取当月数据 // 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto(); CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
String year = c.get(Calendar.YEAR)+""; String year = c.get(Calendar.YEAR) + "";
int month = c.get(Calendar.MONTH)+1 ; int month = c.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0"+month : month +""; String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingMonth(monthStr); temp.setFillingMonth(monthStr);
temp.setFillingYear(year); temp.setFillingYear(year);
Integer thisMonth = cylinderFillingRecordServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
Integer thisMonth = cylinderFillingRecordServiceImpl.getFillingCountByMonth(u.getAppId(),c.getTime());
temp.setTotalSum((long) thisMonth); temp.setTotalSum((long) thisMonth);
// 获取本月数据 // 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(u.getAppId(),c.getTime()); Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl.getFillingCountByMonth(u.getAppId(),c.getTime()); Integer fillingCheckCount = cylinderFillingCheckServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
// 充装前检查率:充装前检查次数/充装次数 // 充装前检查率:充装前检查次数/充装次数
Double before = 0d; double before = 0d;
if(thisMonth != 0) { if (thisMonth != 0) {
before = (double)(fillingCount) / (double) thisMonth; before = (double) (fillingCount) / (double) thisMonth;
} }
temp.setFillingPercent(before * 100); temp.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数 // 充装后检查率:充装后检查次数/充装次数
Double after = 0d; double after = 0d;
if(thisMonth != 0) { if (thisMonth != 0) {
after = (double)(fillingCheckCount) / (double) thisMonth; after = (double) (fillingCheckCount) / (double) thisMonth;
} }
temp.setFillingCheckPercent(after * 100); temp.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数 // 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
Double passed = 0d; double passed = 0d;
// 充装前检查合格次数 // 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl.getFillingPassedCountByMonth(u.getAppId(),c.getTime()); Integer fillingPassedCount = cylinderFillingServiceImpl.getFillingPassedCountByMonth(cylinderUnit.getAppId(), c.getTime());
// 充装后检查合格次数 // 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl.getFillingPassedCountByMonth(u.getAppId(),c.getTime()); Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl.getFillingPassedCountByMonth(cylinderUnit.getAppId(), c.getTime());
if(thisMonth != 0) { if (thisMonth != 0) {
passed = ( (double) (fillingPassedCount) + (double) fillingCheckPassedCount ) / (double) (2 * thisMonth); passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount) / (double) (2 * thisMonth);
} }
temp.setFillingPassedPercent(passed * 100); temp.setFillingPassedPercent(passed * 100);
temp.setAppId(u.getAppId()); temp.setAppId(cylinderUnit.getAppId());
c.add(Calendar.MONTH, -1); c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp); cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
} }
}); });
return true;
} }
@Transactional /**
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 * 卸液量按单位统计
public Boolean synFillingUnloadUnitData() { */
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>()); cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list(); countByUnit(cylinderUnit -> {
units.stream().forEach(u -> {
Calendar now = Calendar.getInstance(); Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(int i = 0 ; i < 30 ; i ++) { for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE,-1); now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto(); CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(u.getAppId(),now.getTime()); Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(), now.getTime());
Double unloadSum = 0d; Double unloadSum = 0d;
temp.setFillingSum(fillingSum); temp.setFillingSum(fillingSum);
temp.setAppId(u.getAppId()); temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime()); temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime())); temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum); temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp); cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
} }
}); });
return true; }
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
} }
} }
\ No newline at end of file
...@@ -241,17 +241,23 @@ ...@@ -241,17 +241,23 @@
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId> <artifactId>mybatis-plus-generator</artifactId>
<version>3.2.0</version> <version>3.4.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version> <version>3.4.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version> <version>2.1.2</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.jpush.api</groupId> <groupId>cn.jpush.api</groupId>
...@@ -271,28 +277,37 @@ ...@@ -271,28 +277,37 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<repositories> <repositories>
<repository> <!--<repository>
<id>Releases</id> <id>Releases</id>
<name>Releases</name> <name>Releases</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/releases/</url> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/releases/</url>
</repository> </repository>
<repository> <repository>
<id>Snapshots</id> <id>Snapshots</id>
<name>Snapshots</name> <name>Snapshots</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/snapshots/</url> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository> <repository>
<id>com.e-iceblue</id> <id>com.e-iceblue</id>
<name>e-iceblue</name> <name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url> <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>-->
<repository>
<id>Releases</id>
<name>Releases</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>Snapshots</id>
<name>Snapshots</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/snapshots/</url>
</repository> </repository>
</repositories> </repositories>
<modules> <modules>
<module>amos-boot-module</module> <module>amos-boot-module</module>
<module>amos-boot-biz-common</module> <module>amos-boot-biz-common</module>
<module>amos-boot-system-avic</module>
<module>amos-boot-system-tzs</module> <module>amos-boot-system-tzs</module>
<module>amos-boot-system-jcs</module> <module>amos-boot-system-jcs</module>
<module>amos-boot-system-knowledgebase</module> <module>amos-boot-system-knowledgebase</module>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment