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,10 +16,10 @@ import java.util.Date; ...@@ -15,10 +16,10 @@ 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;
@ApiModelProperty(value = "充装记录Id") @ApiModelProperty(value = "充装记录Id")
...@@ -69,12 +70,11 @@ public class CylinderFillingRecordDto extends BaseDto { ...@@ -69,12 +70,11 @@ 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;
@ApiModelProperty(value = "充装前检查结果") @ApiModelProperty(value = "充装前检查结果")
private String fillingResult; private String fillingResult;
@ApiModelProperty(value = "充装前检查人员") @ApiModelProperty(value = "充装前检查人员")
private String inspectorUser; private String inspectorUser;
...@@ -98,42 +98,40 @@ public class CylinderFillingRecordDto extends BaseDto { ...@@ -98,42 +98,40 @@ public class CylinderFillingRecordDto extends BaseDto {
@ApiModelProperty(value = "对接公司编码") @ApiModelProperty(value = "对接公司编码")
private String appId; private String appId;
@ApiModelProperty(value = "是否在检验有效期以内")
private String isValid;
@ApiModelProperty(value = "是否在检验有效期以内") @ApiModelProperty(value = "警示标签上印有的瓶装气体的名称及化学分子式应与气瓶钢印标志是否一致")
private String isValid; private Integer same;
@ApiModelProperty(value = "警示标签上印有的瓶装气体的名称及化学分子式应与气瓶钢印标志是否一致")
private Integer same;
@ApiModelProperty(value = "气瓶外表面的颜色标志是否符合规定")
private Integer isRegulations;
@ApiModelProperty(value = "气瓶瓶阀的出气口螺纹型式是否符合GB/T15383") @ApiModelProperty(value = "气瓶外表面的颜色标志是否符合规定")
private Integer isComplianceWithgbt; private Integer isRegulations;
@ApiModelProperty(value = "气瓶内有无剩余压力") @ApiModelProperty(value = "气瓶瓶阀的出气口螺纹型式是否符合GB/T15383")
private Integer haveStillPressure; private Integer isComplianceWithgbt;
@ApiModelProperty(value = "气瓶外表面有无裂纹、严重腐蚀、明显变形及其他严重外部损伤缺陷") @ApiModelProperty(value = "气瓶内有无剩余压力")
private Integer isComplete; private Integer haveStillPressure;
@ApiModelProperty(value = "气瓶的安全附件齐全并符合安全要求") @ApiModelProperty(value = "气瓶外表面有无裂纹、严重腐蚀、明显变形及其他严重外部损伤缺陷")
private Integer haveSecurityDocuments; private Integer isComplete;
@ApiModelProperty(value = "充装量在规定范围内") @ApiModelProperty(value = "气瓶的安全附件齐全并符合安全要求")
private Integer withinScope; private Integer haveSecurityDocuments;
@ApiModelProperty(value = "瓶阀及其与瓶口连接的密封良好") @ApiModelProperty(value = "充装量在规定范围内")
private Integer sealedState; private Integer withinScope;
@ApiModelProperty(value = "瓶体未出现鼓包变形或泄露等严重缺陷") @ApiModelProperty(value = "瓶阀及其与瓶口连接的密封良好")
private Integer defective; private Integer sealedState;
@ApiModelProperty(value = "瓶体温度没有异常升高的迹象") @ApiModelProperty(value = "瓶体未出现鼓包变形或泄露等严重缺陷")
private Integer abnormalTemperature; private Integer defective;
@ApiModelProperty(value = "气瓶粘贴警示标签和充装标签") @ApiModelProperty(value = "瓶体温度没有异常升高的迹象")
private Integer warningSign; private Integer abnormalTemperature;
@ApiModelProperty(value = "气瓶粘贴警示标签和充装标签")
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;
/** /**
* 气瓶基本信息 * 气瓶基本信息
...@@ -60,16 +44,16 @@ import java.util.Map; ...@@ -60,16 +44,16 @@ import java.util.Map;
@RequestMapping(value = "/cylinder-info") @RequestMapping(value = "/cylinder-info")
public class CylinderInfoController extends BaseController { public class CylinderInfoController extends BaseController {
@Autowired @Autowired
CylinderInfoServiceImpl cylinderInfoServiceImpl; CylinderInfoServiceImpl cylinderInfoServiceImpl;
@Autowired @Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl; CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired @Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl; CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
private Map<Integer, String> regionMap; private Map<Integer, String> regionMap;
/** /**
...@@ -78,28 +62,28 @@ public class CylinderInfoController extends BaseController { ...@@ -78,28 +62,28 @@ public class CylinderInfoController extends BaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增气瓶基本信息", notes = "新增气瓶基本信息") @ApiOperation(httpMethod = "POST", value = "新增气瓶基本信息", notes = "新增气瓶基本信息")
public ResponseModel<CylinderInfoDto> save(@RequestBody CylinderInfoDto model) { public ResponseModel<CylinderInfoDto> save(@RequestBody CylinderInfoDto model) {
model = cylinderInfoServiceImpl.createWithModel(model); model = cylinderInfoServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model); return ResponseHelper.buildResponse(model);
} }
/** /**
* 根据sequenceNbr更新 * 根据sequenceNbr更新
* *
* @param sequenceNbr 主键 * @param sequenceNbr 主键
* @return * @return
*/ */
@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));
} }
/** /**
* 根据sequenceNbr删除 * 根据sequenceNbr删除
* *
* @param sequenceNbr 主键 * @param sequenceNbr 主键
...@@ -108,52 +92,52 @@ public class CylinderInfoController extends BaseController { ...@@ -108,52 +92,52 @@ 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));
} }
/** /**
* 根据sequenceNbr查询 * 根据sequenceNbr查询
* *
* @param sequenceNbr 主键 * @param sequenceNbr 主键
* @return * @return
*/ */
@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));
} }
/** /**
* 列表分页查询 * 列表分页查询
* *
* @param current 当前页 * @param current 当前页
* @param current 每页大小 * @param current 每页大小
* @return * @return
*/ */
@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);
page.setSize(size); page.setSize(size);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoPage(page)); return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoPage(page));
} }
/** /**
* 列表全部数据查询 * 列表全部数据查询
* *
* @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());
} }
// /** // /**
...@@ -206,32 +190,31 @@ public class CylinderInfoController extends BaseController { ...@@ -206,32 +190,31 @@ public class CylinderInfoController extends BaseController {
// return ResponseHelper.buildResponse(result); // return ResponseHelper.buildResponse(result);
// } // }
/** /**
* 获取气瓶增加减少总量及环比 * 获取气瓶增加减少总量及环比
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderInfo") @GetMapping(value = "/getCylinderInfo")
@ApiOperation(httpMethod = "GET", value = "获取气瓶增加减少总量及环比", notes = "获取气瓶增加减少总量及环比") @ApiOperation(httpMethod = "GET", value = "获取气瓶增加减少总量及环比", notes = "获取气瓶增加减少总量及环比")
public ResponseModel<Boolean> getCylinderInfo1() { public ResponseModel<Boolean> getCylinderInfo1() {
Boolean flag = cylinderInfoServiceImpl.getCylinderInfo(); Boolean flag = cylinderInfoServiceImpl.getCylinderInfo();
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
/**
* 获取企业增加减少总量及环比
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderUnitInfo")
@ApiOperation(httpMethod = "GET", value = "获取企业增加减少总量及环比", notes = "获取企业增加减少总量及环比")
public ResponseModel<Boolean> getCylinderUnitInfo() {
Boolean flag = cylinderInfoServiceImpl.getCylinderUnitInfo();
return ResponseHelper.buildResponse(flag);
}
/**
* 获取企业增加减少总量及环比
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderUnitInfo")
@ApiOperation(httpMethod = "GET", value = "获取企业增加减少总量及环比", notes = "获取企业增加减少总量及环比")
public ResponseModel<Boolean> getCylinderUnitInfo() {
Boolean flag = cylinderInfoServiceImpl.getCylinderUnitInfo();
return ResponseHelper.buildResponse(flag);
}
// // 数据完整性计算 气瓶企业信息 气瓶基本信息 标签 检验 充装 充装审核 // // 数据完整性计算 气瓶企业信息 气瓶基本信息 标签 检验 充装 充装审核
...@@ -370,277 +353,266 @@ public class CylinderInfoController extends BaseController { ...@@ -370,277 +353,266 @@ public class CylinderInfoController extends BaseController {
// return ResponseHelper.buildResponse(true); // return ResponseHelper.buildResponse(true);
// } // }
/** /**
* 数据完整性同步 * 数据完整性同步
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/addIntegrityData") @GetMapping(value = "/addIntegrityData")
@ApiOperation(httpMethod = "GET", value = "数据完整性同步", notes = "数据完整性同步") @ApiOperation(httpMethod = "GET", value = "数据完整性同步", notes = "数据完整性同步")
public ResponseModel<Boolean> addIntegrityData() { public ResponseModel<Boolean> addIntegrityData() {
Boolean flag = cylinderInfoServiceImpl.addIntegrityData(); Boolean flag = cylinderInfoServiceImpl.addIntegrityData();
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
/** /**
* 数据完整性同步 * 数据完整性同步
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synAreaData") @GetMapping(value = "/synAreaData")
@ApiOperation(httpMethod = "GET", value = "同步区域数据", notes = "同步区域数据") @ApiOperation(httpMethod = "GET", value = "同步区域数据", notes = "同步区域数据")
public ResponseModel<Boolean> synAreaData() { public ResponseModel<Boolean> synAreaData() {
Boolean flag = cylinderInfoServiceImpl.synAreaData(); Boolean flag = cylinderInfoServiceImpl.synAreaData();
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
/**
/** * 装卸液体数据同步
* 装卸液体数据同步 *
* * @return
* @return */
*/ @TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY) @GetMapping(value = "/synFillingUnloadData")
@GetMapping(value = "/synFillingUnloadData") @ApiOperation(httpMethod = "GET", value = "装卸液体数据同步", notes = "装卸液体数据同步")
@ApiOperation(httpMethod = "GET", value = "装卸液体数据同步", notes = "装卸液体数据同步") public ResponseModel<Boolean> synFillingUnloadData() {
public ResponseModel<Boolean> synFillingUnloadData() { Boolean flag = cylinderInfoServiceImpl.synFillingUnloadData();
Boolean flag = cylinderInfoServiceImpl.synFillingUnloadData();
return ResponseHelper.buildResponse(flag);
return ResponseHelper.buildResponse(flag); }
}
/**
/** * 列表分页查询
* 列表分页查询 *
* * @param pageNum 当前页
* @param pageNum 当前页 * @param pageSize 每页大小
* @param pageSize 每页大小 * @return
* @return */
*/ @TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY) @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<>();
Page<CylinderFillingRecordDto> page = new Page<CylinderFillingRecordDto>(); 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<>(pageNum, pageSize);
Page<CylinderFillingRecordDto> result = new Page<CylinderFillingRecordDto>(pageNum,pageSize); long totle = pageBean.getTotal();
long totle = pageBean.getTotal(); result.setRecords(pageBean.getRecords());
result.setRecords(pageBean.getRecords()); result.setTotal(totle);
result.setTotal(totle); return ResponseHelper.buildResponse(result);
return ResponseHelper.buildResponse(result); }
}
/**
/** * 气瓶基本信息
* 气瓶基本信息 *
* * @param pageNum 当前页
* @param pageNum 当前页 * @param pageSize 每页大小
* @param pageSize 每页大小 * @return
* @return */
*/ @TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY) @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) { QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>();
Page<CylinderInfo> pageBean; if (StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) {
IPage<CylinderInfo> page; List<String> appids = new ArrayList<>();
QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>(); List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, cylinderInfoDto.getRegionCode()));
unitList.forEach(u -> {
appids.add(u.getAppId());
if(StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) { });
List<String> appids = new ArrayList<>(); if (appids.size() == 0) {
appids.add("-1");
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode,cylinderInfoDto.getRegionCode())); }
unitList.stream().forEach(u -> { cylinderInfoDto.setAppIds(appids);
appids.add(u.getAppId()); }
}); setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, sort);
if (appids.size() == 0) { Page<CylinderInfo> pageBean;
appids.add("-1"); if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
IPage<CylinderInfo> page = cylinderInfoServiceImpl.page(pageBean, cylinderInfoQueryWrapper);
int num = cylinderInfoServiceImpl.count(cylinderInfoQueryWrapper);
pageBean.setTotal(num);
IPage<CylinderInfoDto> result = BeanDtoVoUtils.cyinderInfoIPageDto(page);
return ResponseHelper.buildResponse(result);
}
private QueryWrapper<CylinderInfo> setQueryWrapper(QueryWrapper<CylinderInfo> queryWrapper, CylinderInfoDto cylinderInfo, String sort) {
if (cylinderInfo.getAppIds() != null && cylinderInfo.getAppIds().size() > 0) {
queryWrapper.in("app_id", cylinderInfo.getAppIds());
}
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if ("ascend".equals(date[1])) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
} else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
} }
cylinderInfoDto.setAppIds(appids); } else {
} queryWrapper.orderByDesc("sync_date");
setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, sort); }
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) { if (!ValidationUtil.isEmpty(cylinderInfo.getAppId())) {
pageBean = new Page<>(0, Long.MAX_VALUE); queryWrapper.eq("app_id", cylinderInfo.getAppId());
} else { }
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize)); if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateStart())) {
} queryWrapper.ge("inspection_date", cylinderInfo.getInspectionDateStart());
page = cylinderInfoServiceImpl.page(pageBean, cylinderInfoQueryWrapper); }
int num= cylinderInfoServiceImpl.count(cylinderInfoQueryWrapper); if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateEnd())) {
pageBean.setTotal(num); queryWrapper.le("inspection_date", cylinderInfo.getInspectionDateEnd());
IPage<CylinderInfoDto> result = BeanDtoVoUtils.cyinderInfoIPageDto(page); }
return ResponseHelper.buildResponse(result); if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位
} queryWrapper.like("unit_name", cylinderInfo.getUnitName());
}
private QueryWrapper<CylinderInfo> setQueryWrapper(QueryWrapper<CylinderInfo> queryWrapper, CylinderInfoDto cylinderInfo, String sort) { if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号
if(cylinderInfo.getAppIds() != null && cylinderInfo.getAppIds().size() >0) { queryWrapper.like("factory_num", cylinderInfo.getFactoryNum());
queryWrapper.in("app_id", cylinderInfo.getAppIds()); }
} else { if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种
} queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety());
if(sort!=null) { // 排序失效 }
String[] date= sort.split(","); if (!ValidationUtil.isEmpty(cylinderInfo.getQrCode())) {// 二维码编号
if(date[1].equals("ascend")) { queryWrapper.like("qrCode", cylinderInfo.getQrCode());
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0])); }
}else { if (!ValidationUtil.isEmpty(cylinderInfo.getElectronicLabelCode())) {// 电子标签编号
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0])); queryWrapper.like("electronic_label_code", cylinderInfo.getElectronicLabelCode());
} }
}else { if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码
queryWrapper.orderByDesc("sync_date"); queryWrapper.like("sequence_code", cylinderInfo.getSequenceCode());
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号
if(!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateStart())) { queryWrapper.like("unit_inner_code", cylinderInfo.getUnitInnerCode());
queryWrapper.ge("inspection_date",cylinderInfo.getInspectionDateStart()); }
} if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态
if(!ValidationUtil.isEmpty(cylinderInfo.getAppId())) { queryWrapper.eq("cylinder_status", cylinderInfo.getCylinderStatus());
queryWrapper.eq("app_id",cylinderInfo.getAppId()); }
} if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位
queryWrapper.like("manufacturing_unit", cylinderInfo.getManufacturingUnit());
if(!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateEnd())) { }
queryWrapper.le("inspection_date",cylinderInfo.getInspectionDateEnd()); return queryWrapper;
} }
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位
queryWrapper.like("unit_name",cylinderInfo.getUnitName()); /**
} * 获取气瓶详细信息
*
if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号 * @param sequenceNbr
queryWrapper.eq("factory_num", cylinderInfo.getFactoryNum()); * @return
} */
@TycloudOperation(ApiLevel = UserType.AGENCY)
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种 @GetMapping(value = "/cyinderInfo/{sequenceNbr}")
queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety()); @ApiOperation(httpMethod = "GET", value = "获取气瓶详细信息", notes = "获取气瓶详细信息")
} public ResponseModel<CylinderInfoDto> cyinderInfoList(@PathVariable Long sequenceNbr) {
CylinderInfo cylinderInfo = cylinderInfoServiceImpl.getById(sequenceNbr);
if (!ValidationUtil.isEmpty(cylinderInfo.getQrCode())) {// 二维码编号 CylinderInfoDto target = new CylinderInfoDto();
queryWrapper.like("qrCode",cylinderInfo.getQrCode()); // 把原对象数据拷贝到新对象
} BeanUtils.copyProperties(cylinderInfo, target);
if (!ValidationUtil.isEmpty(cylinderInfo.getElectronicLabelCode())) {// 电子标签编号 if (0 == cylinderInfo.getCylinderStatus()) {
queryWrapper.like("electronic_label_code",cylinderInfo.getElectronicLabelCode()); target.setCylinderStatusStr("在用");
} } else if (1 == cylinderInfo.getCylinderStatus()) {
if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码 target.setCylinderStatusStr("停用");
queryWrapper.like("sequence_code",cylinderInfo.getSequenceCode()); } else if (2 == cylinderInfo.getCylinderStatus()) {
} target.setCylinderStatusStr("注销");
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号 } else if (3 == cylinderInfo.getCylinderStatus()) {
queryWrapper.like("unit_inner_code",cylinderInfo.getUnitInnerCode()); target.setCylinderStatusStr("报废");
} } else {
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态 target.setCylinderStatusStr("");
queryWrapper.eq("cylinder_status",cylinderInfo.getCylinderStatus()); }
}
if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位 if (1 == cylinderInfo.getCylinderVariety()) {
queryWrapper.like("manufacturing_unit",cylinderInfo.getManufacturingUnit()); target.setCylinderVarietyStr("无缝气瓶");
} } else if (2 == cylinderInfo.getCylinderVariety()) {
return queryWrapper; target.setCylinderVarietyStr("焊接气瓶");
} } else if (3 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("缠绕气瓶");
} else if (4 == cylinderInfo.getCylinderVariety()) {
/** target.setCylinderVarietyStr("绝热气瓶");
* 获取气瓶详细信息 } else if (5 == cylinderInfo.getCylinderVariety()) {
* @param sequenceNbr target.setCylinderVarietyStr("内装填料气瓶");
* @return } else {
*/ target.setCylinderVarietyStr("");
@TycloudOperation(ApiLevel = UserType.AGENCY) }
@GetMapping(value = "/cyinderInfo/{sequenceNbr}") Date nextDate = target.getNextInspectionDate();
@ApiOperation(httpMethod = "GET", value = "获取气瓶详细信息", notes = "获取气瓶详细信息") long dates = nextDate.getTime() - System.currentTimeMillis();
public ResponseModel<CylinderInfoDto> cyinderInfoList(@PathVariable Long sequenceNbr) { if (dates >= 1000 * 60 * 60 * 24 * 30) {
CylinderInfo cylinderInfo = cylinderInfoServiceImpl.getById(sequenceNbr); target.setInspectionStatas(1);
CylinderInfoDto target = new CylinderInfoDto(); } else if (0 < dates && dates < 1000 * 60 * 60 * 24 * 30) {
// 把原对象数据拷贝到新对象 target.setInspectionStatas(2);
BeanUtils.copyProperties(cylinderInfo, target); } else {
if(0 == cylinderInfo.getCylinderStatus()) { target.setInspectionStatas(0);
target.setCylinderStatusStr("在用"); }
} else if(1 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("停用");
} else if(2 == cylinderInfo.getCylinderStatus()) { return ResponseHelper.buildResponse(target);
target.setCylinderStatusStr("注销"); }
} else if(3 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("报废");
} else { /**
target.setCylinderStatusStr(""); * 获取登陆人所在气瓶充装单位信息
} *
* @param pageNum 当前页
if(1 == cylinderInfo.getCylinderVariety()) { * @param pageSize 每页大小
target.setCylinderVarietyStr("无缝气瓶"); * @return
} else if(2 == cylinderInfo.getCylinderVariety()) { */
target.setCylinderVarietyStr("焊接气瓶"); @TycloudOperation(ApiLevel = UserType.AGENCY)
} else if(3 == cylinderInfo.getCylinderVariety()) { @GetMapping(value = "/cyinderUnitList")
target.setCylinderVarietyStr("缠绕气瓶"); @ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装单位信息", notes = "获取登陆人所在气瓶充装单位信息")
} else if(4 == cylinderInfo.getCylinderVariety()) { public ResponseModel<IPage<CylinderUnitDto>> cyinderUnitList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderUnitDto cylinderUnitDto) {
target.setCylinderVarietyStr("绝热气瓶"); Page<CylinderUnit> pageBean;
} else if(5 ==cylinderInfo.getCylinderVariety()) { IPage<CylinderUnit> page;
target.setCylinderVarietyStr("内装填料气瓶"); QueryWrapper<CylinderUnit> cylinderUnitQueryWrapper = new QueryWrapper<>();
} else {
target.setCylinderVarietyStr(""); setQueryWrapper(cylinderUnitQueryWrapper, cylinderUnitDto, sort);
} if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
Date nextDate = target.getNextInspectionDate(); pageBean = new Page<>(0, Long.MAX_VALUE);
long dates = nextDate.getTime() - System.currentTimeMillis(); } else {
if(dates >= 1000 * 60 * 60 * 24 * 30 ) { pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
target.setInspectionStatas(1); }
} else if(0< dates && dates < 1000 * 60 * 60 * 24 * 30) { page = cylinderUnitServiceImpl.page(pageBean, cylinderUnitQueryWrapper);
target.setInspectionStatas(2); int num = cylinderUnitServiceImpl.count(cylinderUnitQueryWrapper);
} else { pageBean.setTotal(num);
target.setInspectionStatas(0); IPage<CylinderUnitDto> result = this.cyinderInfoIPageDto(page);
} return ResponseHelper.buildResponse(result);
}
return ResponseHelper.buildResponse(target);
}
/**
* 获取登陆人所在气瓶充装单位信息
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderUnitList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装单位信息", notes = "获取登陆人所在气瓶充装单位信息")
public ResponseModel<IPage<CylinderUnitDto>> cyinderUnitList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderUnitDto cylinderUnitDto) {
Page<CylinderUnit> pageBean;
IPage<CylinderUnit> page;
QueryWrapper<CylinderUnit> cylinderUnitQueryWrapper = new QueryWrapper<>();
setQueryWrapper(cylinderUnitQueryWrapper, cylinderUnitDto, sort);
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = cylinderUnitServiceImpl.page(pageBean, cylinderUnitQueryWrapper);
int num= cylinderUnitServiceImpl.count(cylinderUnitQueryWrapper);
pageBean.setTotal(num);
IPage<CylinderUnitDto> result = this.cyinderInfoIPageDto(page);
return ResponseHelper.buildResponse(result);
}
/** /**
* 获取气瓶充装单位详情 * 获取气瓶充装单位详情
*
* @param sequenceNbr * @param sequenceNbr
* @return * @return
*/ */
...@@ -648,167 +620,163 @@ public class CylinderInfoController extends BaseController { ...@@ -648,167 +620,163 @@ public class CylinderInfoController extends BaseController {
@GetMapping(value = "/cylinderUnit/{sequenceNbr}") @GetMapping(value = "/cylinderUnit/{sequenceNbr}")
@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();
// 把原对象数据拷贝到新对象 // 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderUnit, target); BeanUtils.copyProperties(cylinderUnit, target);
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);
} }
return ResponseHelper.buildResponse(target); return ResponseHelper.buildResponse(target);
} }
private QueryWrapper<CylinderUnit> setQueryWrapper(QueryWrapper<CylinderUnit> queryWrapper, CylinderUnitDto cylinderUnitDto, String sort) {
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if (date[1].equals("ascend")) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
} else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
}
} else {
queryWrapper.orderByDesc("sync_date");
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateStart())) { // 许可有效期
queryWrapper.ge("filling_permit_date", cylinderUnitDto.getFillingPermitDateStart());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateEnd())) {
queryWrapper.le("filling_permit_date", cylinderUnitDto.getFillingPermitDateEnd());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitName())) { // 企业名称
queryWrapper.like("unit_name", cylinderUnitDto.getUnitName());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitType())) {// 企业类型
queryWrapper.eq("unit_type", cylinderUnitDto.getUnitType());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getCreditCode())) {// 统一社会信用代码
queryWrapper.like("credit_code", cylinderUnitDto.getCreditCode());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getAddress())) {// 详细地址
queryWrapper.like("address", cylinderUnitDto.getAddress());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitPerson())) {// 企业负责人
queryWrapper.like("unit_person", cylinderUnitDto.getUnitPerson());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getPersonMobilePhone())) {// 负责人手机
queryWrapper.like("person_mobile_phone", cylinderUnitDto.getPersonMobilePhone());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingLicense())) {// 许可证号
queryWrapper.like("filling_license", cylinderUnitDto.getFillingLicense());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermScope())) {// 许可范围
queryWrapper.like("filling_perm_scope", cylinderUnitDto.getFillingPermScope());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getRegionCode())) {// 所属区域
queryWrapper.like("region_code", cylinderUnitDto.getRegionCode());
}
return queryWrapper;
}
private IPage<CylinderUnitDto> cyinderInfoIPageDto(IPage<CylinderUnit> page) {
if (this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap, t);
});
}
return page.convert(item -> {
try {
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(item, target);
String regionCode = item.getRegionCode();
String[] regionCodes = regionCode.split("#");
regionCode = "";
for (int i = 0; i < regionCodes.length; i++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
}
target.setRegionCode(regionCode);
if (1 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶充装单位");
} else if (2 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶检验单位");
} else if (3 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶生产单位");
} else {
target.setUnitTypeStr("");
}
target.setCylinderNumber((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, target.getAppId())));
return target;
} catch (Exception e) {
return null;
}
});
}
private void addRegionsMap(Map<Integer, String> regionMap, RegionModel region) {
regionMap.put(region.getRegionCode(), region.getRegionName());
if (region.getChildren() != null) {
region.getChildren().stream().forEach(c -> {
addRegionsMap(regionMap, c);
});
}
}
private QueryWrapper<CylinderUnit> setQueryWrapper(QueryWrapper<CylinderUnit> queryWrapper, CylinderUnitDto cylinderUnitDto, String sort) { /**
if(sort!=null) { // 排序失效 * 企业气瓶总量数据同步
String[] date= sort.split(","); *
if(date[1].equals("ascend")) { * @return
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0])); */
}else { @TycloudOperation(ApiLevel = UserType.AGENCY)
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0])); @GetMapping(value = "/synUnitCylinderInfoData")
} @ApiOperation(httpMethod = "GET", value = "企业气瓶总量数据同步", notes = "企业气瓶总量数据同步")
}else { public ResponseModel<Boolean> synUnitCylinderInfoData() {
queryWrapper.orderByDesc("sync_date"); Boolean flag = cylinderInfoServiceImpl.synUnitCylinderInfoData();
} return ResponseHelper.buildResponse(flag);
}
if(!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateStart())) { // 许可有效期
queryWrapper.ge("filling_permit_date",cylinderUnitDto.getFillingPermitDateStart());
}
if(!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermitDateEnd())) {
queryWrapper.le("filling_permit_date",cylinderUnitDto.getFillingPermitDateEnd());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitName())) { // 企业名称
queryWrapper.like("unit_name",cylinderUnitDto.getUnitName());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitType())) {// 企业类型
queryWrapper.eq("unit_type", cylinderUnitDto.getUnitType());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getCreditCode())) {// 统一社会信用代码
queryWrapper.like("credit_code",cylinderUnitDto.getCreditCode());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getAddress())) {// 详细地址
queryWrapper.like("address",cylinderUnitDto.getAddress());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getUnitPerson())) {// 企业负责人
queryWrapper.like("unit_person",cylinderUnitDto.getUnitPerson());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getPersonMobilePhone())) {// 负责人手机
queryWrapper.like("person_mobile_phone",cylinderUnitDto.getPersonMobilePhone());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingLicense())) {// 许可证号
queryWrapper.like("filling_license",cylinderUnitDto.getFillingLicense());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getFillingPermScope())) {// 许可范围
queryWrapper.like("filling_perm_scope",cylinderUnitDto.getFillingPermScope());
}
if (!ValidationUtil.isEmpty(cylinderUnitDto.getRegionCode())) {// 所属区域
queryWrapper.like("region_code",cylinderUnitDto.getRegionCode());
}
return queryWrapper;
}
private IPage<CylinderUnitDto> cyinderInfoIPageDto(IPage<CylinderUnit> page) {
if(this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap,t);
});
}
return page.convert(item -> {
try {
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(item, target);
String regionCode = item.getRegionCode();
String[] regionCodes = regionCode.split("#");
regionCode = "";
for(int i =0 ; i < regionCodes.length ; i ++) {
regionCode += this.regionMap.get(Integer.parseInt(regionCodes[i]));
}
target.setRegionCode(regionCode);
if(1 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶充装单位");
} else if(2 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶检验单位");
} else if(3 == item.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶生产单位");
} else {
target.setUnitTypeStr("");
}
target.setCylinderNumber((long) cylinderInfoServiceImpl.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,target.getAppId())));
return target;
} catch (Exception e) {
return null;
}
});
}
private void addRegionsMap(Map<Integer,String> regionMap, RegionModel region) {
regionMap.put(region.getRegionCode(),region.getRegionName());
if (region.getChildren() != null) {
region.getChildren().stream().forEach(c -> {
addRegionsMap(regionMap, c);
});
}
}
/**
* 企业气瓶总量数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitCylinderInfoData")
@ApiOperation(httpMethod = "GET", value = "企业气瓶总量数据同步", notes = "企业气瓶总量数据同步")
public ResponseModel<Boolean> synUnitCylinderInfoData() {
Boolean flag = cylinderInfoServiceImpl.synUnitCylinderInfoData();
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);
} }
...@@ -837,18 +804,18 @@ public class CylinderInfoController extends BaseController { ...@@ -837,18 +804,18 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
/** /**
* 企业数据完整度同步 * 企业数据完整度同步
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitIntegrityData") @GetMapping(value = "/synUnitIntegrityData")
@ApiOperation(httpMethod = "GET", value = "企业数据完整度同步", notes = "企业数据完整度同步") @ApiOperation(httpMethod = "GET", value = "企业数据完整度同步", notes = "企业数据完整度同步")
public ResponseModel<Boolean> synUnitIntegrityData() { public ResponseModel<Boolean> synUnitIntegrityData() {
Boolean flag = cylinderInfoServiceImpl.synUnitIntegrityData(); Boolean flag = cylinderInfoServiceImpl.synUnitIntegrityData();
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
/** /**
* 气瓶充装检查情况同步 * 气瓶充装检查情况同步
...@@ -863,19 +830,18 @@ public class CylinderInfoController extends BaseController { ...@@ -863,19 +830,18 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(flag); return ResponseHelper.buildResponse(flag);
} }
/** /**
* 装卸液体企业数据同步 * 装卸液体企业数据同步
* *
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadUnitData") @GetMapping(value = "/synFillingUnloadUnitData")
@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,19 +19,19 @@ import java.util.List; ...@@ -20,19 +19,19 @@ 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 {
/** /**
* 分页查询 * 分页查询
*/ */
public Page<CylinderFillingRecordDto> queryForCylinderFillingRecordPage(Page<CylinderFillingRecordDto> page) { public Page<CylinderFillingRecordDto> queryForCylinderFillingRecordPage(Page<CylinderFillingRecordDto> page) {
return this.queryForPage(page, null, false); return this.queryForPage(page, null, false);
} }
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
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,31 +39,42 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -40,31 +39,42 @@ 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());
page1.setRecords(resultDtoList); page1.setRecords(resultDtoList);
return page1; return page1;
} }
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
...@@ -111,15 +81,15 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde ...@@ -111,15 +81,15 @@ 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://4v059425e3.zicp.vip:13535/nexus/content/repositories/snapshots/</url>
<url>http://36.46.149.14:8081/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