Commit 6999bdf0 authored by helinlin's avatar helinlin

修改气瓶系统bug

parent f8f5705c
......@@ -125,8 +125,8 @@ public class MetaHandler implements MetaObjectHandler {
*/
@Override
public void updateFill(MetaObject metaObject) {
Class clazz = metaObject.getOriginalObject().getClass();
FillCommonUserField annotation = (FillCommonUserField) clazz.getAnnotation(FillCommonUserField.class);
Class<?> clazz = metaObject.getOriginalObject().getClass();
FillCommonUserField annotation = clazz.getAnnotation(FillCommonUserField.class);
if (annotation == null || annotation.isAutoFill()) {
String userId = RequestContext.getExeUserId();
ReginParams reginParams =
......
package com.yeejoin.amos.boot.biz.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
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 org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
......@@ -30,18 +32,16 @@ public class MyBatisPlusConfig {
public Sequence sequence() {
return new Sequence();
}
/**
* plus分页插件支持
*/
// @Bean
// public PaginationInterceptor paginationInterceptor() {
// PaginationInterceptor page = new PaginationInterceptor();
// //设置方言类型
// page.setDialectType("mysql");
// //不限制
// page.setLimit(-1);
// return page;
// }
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return mybatisPlusInterceptor;
}
/**
* pageHelper插件支持
......@@ -50,15 +50,10 @@ public class MyBatisPlusConfig {
*/
@Bean
ConfigurationCustomizer mybatisConfigurationCustomizer() {
return new ConfigurationCustomizer() {
@Override
public void customize(MybatisConfiguration configuration) {
configuration.addInterceptor(new com.github.pagehelper.PageInterceptor());
}
};
return 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
public PermissionInterceptor permissionInterceptor() {
return new PermissionInterceptor();
......
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
......@@ -15,10 +16,10 @@ import java.util.Date;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="CylinderFillingRecordDto", description="液化气体气瓶充装信息-充装记录")
public class CylinderFillingRecordDto extends BaseDto {
@ApiModel(value = "CylinderFillingRecordDto", description = "液化气体气瓶充装信息-充装记录")
public class CylinderFillingRecordDto extends BaseDto {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "充装记录Id")
......@@ -69,12 +70,11 @@ public class CylinderFillingRecordDto extends BaseDto {
@ApiModelProperty(value = "异常情况")
private String abnormalStr;
@ApiModelProperty(value = "充装前检查时间")
private String inspectionDate;
@ApiModelProperty(value = "充装前检查结果")
private String fillingResult;
@ApiModelProperty(value = "充装前检查结果")
private String fillingResult;
@ApiModelProperty(value = "充装前检查人员")
private String inspectorUser;
......@@ -98,42 +98,40 @@ public class CylinderFillingRecordDto extends BaseDto {
@ApiModelProperty(value = "对接公司编码")
private String appId;
@ApiModelProperty(value = "是否在检验有效期以内")
private String isValid;
@ApiModelProperty(value = "是否在检验有效期以内")
private String isValid;
@ApiModelProperty(value = "警示标签上印有的瓶装气体的名称及化学分子式应与气瓶钢印标志是否一致")
private Integer same;
@ApiModelProperty(value = "气瓶外表面的颜色标志是否符合规定")
private Integer isRegulations;
@ApiModelProperty(value = "警示标签上印有的瓶装气体的名称及化学分子式应与气瓶钢印标志是否一致")
private Integer same;
@ApiModelProperty(value = "气瓶瓶阀的出气口螺纹型式是否符合GB/T15383")
private Integer isComplianceWithgbt;
@ApiModelProperty(value = "气瓶外表面的颜色标志是否符合规定")
private Integer isRegulations;
@ApiModelProperty(value = "气瓶内有无剩余压力")
private Integer haveStillPressure;
@ApiModelProperty(value = "气瓶瓶阀的出气口螺纹型式是否符合GB/T15383")
private Integer isComplianceWithgbt;
@ApiModelProperty(value = "气瓶外表面有无裂纹、严重腐蚀、明显变形及其他严重外部损伤缺陷")
private Integer isComplete;
@ApiModelProperty(value = "气瓶内有无剩余压力")
private Integer haveStillPressure;
@ApiModelProperty(value = "气瓶的安全附件齐全并符合安全要求")
private Integer haveSecurityDocuments;
@ApiModelProperty(value = "气瓶外表面有无裂纹、严重腐蚀、明显变形及其他严重外部损伤缺陷")
private Integer isComplete;
@ApiModelProperty(value = "充装量在规定范围内")
private Integer withinScope;
@ApiModelProperty(value = "气瓶的安全附件齐全并符合安全要求")
private Integer haveSecurityDocuments;
@ApiModelProperty(value = "瓶阀及其与瓶口连接的密封良好")
private Integer sealedState;
@ApiModelProperty(value = "充装量在规定范围内")
private Integer withinScope;
@ApiModelProperty(value = "瓶体未出现鼓包变形或泄露等严重缺陷")
private Integer defective;
@ApiModelProperty(value = "瓶阀及其与瓶口连接的密封良好")
private Integer sealedState;
@ApiModelProperty(value = "瓶体温度没有异常升高的迹象")
private Integer abnormalTemperature;
@ApiModelProperty(value = "瓶体未出现鼓包变形或泄露等严重缺陷")
private Integer defective;
@ApiModelProperty(value = "气瓶粘贴警示标签和充装标签")
private Integer warningSign;
@ApiModelProperty(value = "瓶体温度没有异常升高的迹象")
private Integer abnormalTemperature;
@ApiModelProperty(value = "气瓶粘贴警示标签和充装标签")
private Integer warningSign;
}
......@@ -23,7 +23,7 @@ public class CylinderFillingDataUnit extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 月充装量
* 月充装量
*/
@TableField("total_sum")
private Double totalSum;
......
......@@ -14,7 +14,7 @@
</select>
<select id="queryListByQueryDto" resultType="java.util.Map">
<select id="queryListByQueryDto">
SELECT
r.sequence_nbr AS sequenceNbr,
r.filling_unit_name AS fillingUnitName,
......
......@@ -2,7 +2,6 @@
<!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">
<select id="queryNumAndOutOfDateNum" resultType="java.util.Map">
SELECT
count( sequence_nbr ) AS cylinderNum,
......@@ -21,22 +20,22 @@
)
</select>
<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 (
<sql id="selectAPPIdByRegionCode">
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 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 u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
)
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 (<include refid="selectAPPIdByRegionCode"/>)
</select>
<select id="getInfoTotalByRegionCode" resultType="java.lang.Integer">
select count(sequence_nbr) from tz_cylinder_info where app_id in (
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
)
select count(sequence_nbr) from tz_cylinder_info where app_id in (<include refid="selectAPPIdByRegionCode"/>)
</select>
<select id="queryIntegirtyByAppId" resultType="java.lang.Double">
......@@ -44,9 +43,7 @@
</select>
<select id="getWarnNum" resultType="java.lang.Integer">
select count(1) from view_cylider_outofdate v where v.app_id in (
select u.app_id from tz_cylinder_unit u where u.region_code like CONCAT('%',#{regionCode},'%')
)
select count(1) from view_cylider_outofdate v where v.app_id in (<include refid="selectAPPIdByRegionCode"/>)
</select>
<select id="getLastMonthInfoTotalUnit" resultType="java.lang.Integer">
......
......@@ -2,14 +2,11 @@ package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON;
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.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
......@@ -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();
}
@Override
public Boolean videoOnEquipmentSpecific(VideoOnEquipmentSpecificVo videoOnEquipmentSpecificVo) {
Long equipmentSpecificId = videoOnEquipmentSpecificVo.getEquipmentSpecificId();
List<Long> videoIdList = videoOnEquipmentSpecificVo.getVideoIdList();
......
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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 org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
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.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 {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{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));
}
......
......@@ -5,11 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.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.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderInfoDto;
......@@ -26,15 +22,8 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -42,12 +31,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 气瓶基本信息
......@@ -60,16 +44,16 @@ import java.util.Map;
@RequestMapping(value = "/cylinder-info")
public class CylinderInfoController extends BaseController {
@Autowired
CylinderInfoServiceImpl cylinderInfoServiceImpl;
@Autowired
CylinderInfoServiceImpl cylinderInfoServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
private Map<Integer, String> regionMap;
private Map<Integer, String> regionMap;
/**
......@@ -78,28 +62,28 @@ public class CylinderInfoController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增气瓶基本信息", notes = "新增气瓶基本信息")
public ResponseModel<CylinderInfoDto> save(@RequestBody CylinderInfoDto model) {
model = cylinderInfoServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增气瓶基本信息", notes = "新增气瓶基本信息")
public ResponseModel<CylinderInfoDto> save(@RequestBody CylinderInfoDto model) {
model = cylinderInfoServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新气瓶基本信息", notes = "根据sequenceNbr更新气瓶基本信息")
public ResponseModel<CylinderInfoDto> updateBySequenceNbrCylinderInfo(@RequestBody CylinderInfoDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.updateWithModel(model));
}
/**
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新气瓶基本信息", notes = "根据sequenceNbr更新气瓶基本信息")
public ResponseModel<CylinderInfoDto> updateBySequenceNbrCylinderInfo(@RequestBody CylinderInfoDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
......@@ -108,52 +92,52 @@ public class CylinderInfoController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{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));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个气瓶基本信息", notes = "根据sequenceNbr查询单个气瓶基本信息")
public ResponseModel<CylinderInfoDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryBySeq(sequenceNbr));
}
/**
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个气瓶基本信息", notes = "根据sequenceNbr查询单个气瓶基本信息")
public ResponseModel<CylinderInfoDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "气瓶基本信息分页查询", notes = "气瓶基本信息分页查询")
public ResponseModel<Page<CylinderInfoDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size) {
Page<CylinderInfoDto> page = new Page<CylinderInfoDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoPage(page));
}
/**
* 列表全部数据查询
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息分页查询", notes = "气瓶基本信息分页查询")
public ResponseModel<Page<CylinderInfoDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) {
Page<CylinderInfoDto> page = new Page<CylinderInfoDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoPage(page));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "气瓶基本信息列表全部数据查询", notes = "气瓶基本信息列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<CylinderInfoDto>> selectForList() {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoList());
}
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息列表全部数据查询", notes = "气瓶基本信息列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<CylinderInfoDto>> selectForList() {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.queryForCylinderInfoList());
}
// /**
......@@ -206,32 +190,31 @@ public class CylinderInfoController extends BaseController {
// return ResponseHelper.buildResponse(result);
// }
/**
* 获取气瓶增加减少总量及环比
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderInfo")
@ApiOperation(httpMethod = "GET", value = "获取气瓶增加减少总量及环比", notes = "获取气瓶增加减少总量及环比")
public ResponseModel<Boolean> getCylinderInfo1() {
Boolean flag = cylinderInfoServiceImpl.getCylinderInfo();
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 = "/getCylinderInfo")
@ApiOperation(httpMethod = "GET", value = "获取气瓶增加减少总量及环比", notes = "获取气瓶增加减少总量及环比")
public ResponseModel<Boolean> getCylinderInfo1() {
Boolean flag = cylinderInfoServiceImpl.getCylinderInfo();
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 {
// return ResponseHelper.buildResponse(true);
// }
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/addIntegrityData")
@ApiOperation(httpMethod = "GET", value = "数据完整性同步", notes = "数据完整性同步")
public ResponseModel<Boolean> addIntegrityData() {
Boolean flag = cylinderInfoServiceImpl.addIntegrityData();
return ResponseHelper.buildResponse(flag);
}
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synAreaData")
@ApiOperation(httpMethod = "GET", value = "同步区域数据", notes = "同步区域数据")
public ResponseModel<Boolean> synAreaData() {
Boolean flag = cylinderInfoServiceImpl.synAreaData();
return ResponseHelper.buildResponse(flag);
}
/**
* 装卸液体数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadData")
@ApiOperation(httpMethod = "GET", value = "装卸液体数据同步", notes = "装卸液体数据同步")
public ResponseModel<Boolean> synFillingUnloadData() {
Boolean flag = cylinderInfoServiceImpl.synFillingUnloadData();
return ResponseHelper.buildResponse(flag);
}
/**
* 列表分页查询
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderRecordList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装信息", notes = "获取登陆人所在气瓶充装信息")
public ResponseModel<IPage<CylinderFillingRecordDto>> cyinderRecordList(@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize, String sort, CylinderFillingRecordDto cylinderFillingRecordDto) {
Page<CylinderFillingRecordDto> page = new Page<CylinderFillingRecordDto>();
page.setCurrent(pageNum);
page.setSize(pageSize);
String sortParam = "";
String sortRule = "";
if(sort!=null) { // 排序失效
String[] date= sort.split(",");
if(date[1].equals("ascend")) {
sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "asc";
}else {
sortParam ="r." + RedisKey.humpToLine(date[0]);
sortRule = "desc";
}
}else {
sortParam = "r.sync_date";
sortRule = "desc";
}
if(StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) {
cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF");
}
Page<CylinderFillingRecordDto> pageBean = cylinderFillingRecordServiceImpl.queryListByQueryDto(page,cylinderFillingRecordDto, sortParam, sortRule);
Page<CylinderFillingRecordDto> result = new Page<CylinderFillingRecordDto>(pageNum,pageSize);
long totle = pageBean.getTotal();
result.setRecords(pageBean.getRecords());
result.setTotal(totle);
return ResponseHelper.buildResponse(result);
}
/**
* 气瓶基本信息
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfoList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶基本信息", notes = "获取登陆人所在气瓶基本信息")
public ResponseModel<IPage<CylinderInfoDto>> cyinderInfoList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderInfoDto cylinderInfoDto) {
Page<CylinderInfo> pageBean;
IPage<CylinderInfo> page;
QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>();
if(StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) {
List<String> appids = new ArrayList<>();
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode,cylinderInfoDto.getRegionCode()));
unitList.stream().forEach(u -> {
appids.add(u.getAppId());
});
if (appids.size() == 0) {
appids.add("-1");
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/addIntegrityData")
@ApiOperation(httpMethod = "GET", value = "数据完整性同步", notes = "数据完整性同步")
public ResponseModel<Boolean> addIntegrityData() {
Boolean flag = cylinderInfoServiceImpl.addIntegrityData();
return ResponseHelper.buildResponse(flag);
}
/**
* 数据完整性同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synAreaData")
@ApiOperation(httpMethod = "GET", value = "同步区域数据", notes = "同步区域数据")
public ResponseModel<Boolean> synAreaData() {
Boolean flag = cylinderInfoServiceImpl.synAreaData();
return ResponseHelper.buildResponse(flag);
}
/**
* 装卸液体数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadData")
@ApiOperation(httpMethod = "GET", value = "装卸液体数据同步", notes = "装卸液体数据同步")
public ResponseModel<Boolean> synFillingUnloadData() {
Boolean flag = cylinderInfoServiceImpl.synFillingUnloadData();
return ResponseHelper.buildResponse(flag);
}
/**
* 列表分页查询
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderRecordList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶充装信息", notes = "获取登陆人所在气瓶充装信息")
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.setCurrent(pageNum);
page.setSize(pageSize);
String sortParam = "";
String sortRule = "";
if (sort != null) { // 排序失效
String[] date = sort.split(",");
if (date[1].equals("ascend")) {
sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "asc";
} else {
sortParam = "r." + RedisKey.humpToLine(date[0]);
sortRule = "desc";
}
} else {
sortParam = "r.sync_date";
sortRule = "desc";
}
if (StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) {
cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF");
}
Page<CylinderFillingRecordDto> pageBean = cylinderFillingRecordServiceImpl.queryListByQueryDto(page, cylinderFillingRecordDto, sortParam, sortRule);
Page<CylinderFillingRecordDto> result = new Page<>(pageNum, pageSize);
long totle = pageBean.getTotal();
result.setRecords(pageBean.getRecords());
result.setTotal(totle);
return ResponseHelper.buildResponse(result);
}
/**
* 气瓶基本信息
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfoList")
@ApiOperation(httpMethod = "GET", value = "获取登陆人所在气瓶基本信息", notes = "获取登陆人所在气瓶基本信息")
public ResponseModel<IPage<CylinderInfoDto>> cyinderInfoList(@RequestParam(value = "pageNum") String pageNum, @RequestParam(value = "pageSize") String pageSize, String sort, CylinderInfoDto cylinderInfoDto) {
QueryWrapper<CylinderInfo> cylinderInfoQueryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(cylinderInfoDto.getRegionCode())) {
List<String> appids = new ArrayList<>();
List<CylinderUnit> unitList = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, cylinderInfoDto.getRegionCode()));
unitList.forEach(u -> {
appids.add(u.getAppId());
});
if (appids.size() == 0) {
appids.add("-1");
}
cylinderInfoDto.setAppIds(appids);
}
setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, sort);
Page<CylinderInfo> pageBean;
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);
}
setQueryWrapper(cylinderInfoQueryWrapper, cylinderInfoDto, 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 = 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());
} else {
}
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(cylinderInfo.getInspectionDateStart())) {
queryWrapper.ge("inspection_date",cylinderInfo.getInspectionDateStart());
}
if(!ValidationUtil.isEmpty(cylinderInfo.getAppId())) {
queryWrapper.eq("app_id",cylinderInfo.getAppId());
}
if(!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateEnd())) {
queryWrapper.le("inspection_date",cylinderInfo.getInspectionDateEnd());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位
queryWrapper.like("unit_name",cylinderInfo.getUnitName());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号
queryWrapper.eq("factory_num", cylinderInfo.getFactoryNum());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种
queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getQrCode())) {// 二维码编号
queryWrapper.like("qrCode",cylinderInfo.getQrCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getElectronicLabelCode())) {// 电子标签编号
queryWrapper.like("electronic_label_code",cylinderInfo.getElectronicLabelCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码
queryWrapper.like("sequence_code",cylinderInfo.getSequenceCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号
queryWrapper.like("unit_inner_code",cylinderInfo.getUnitInnerCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态
queryWrapper.eq("cylinder_status",cylinderInfo.getCylinderStatus());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位
queryWrapper.like("manufacturing_unit",cylinderInfo.getManufacturingUnit());
}
return queryWrapper;
}
/**
* 获取气瓶详细信息
* @param sequenceNbr
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfo/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "获取气瓶详细信息", notes = "获取气瓶详细信息")
public ResponseModel<CylinderInfoDto> cyinderInfoList(@PathVariable Long sequenceNbr) {
CylinderInfo cylinderInfo = cylinderInfoServiceImpl.getById(sequenceNbr);
CylinderInfoDto target = new CylinderInfoDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderInfo, target);
if(0 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("在用");
} else if(1 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("停用");
} else if(2 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("注销");
} else if(3 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("报废");
} else {
target.setCylinderStatusStr("");
}
if(1 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("无缝气瓶");
} else if(2 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("焊接气瓶");
} else if(3 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("缠绕气瓶");
} else if(4 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("绝热气瓶");
} else if(5 ==cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("内装填料气瓶");
} else {
target.setCylinderVarietyStr("");
}
Date nextDate = target.getNextInspectionDate();
long dates = nextDate.getTime() - System.currentTimeMillis();
if(dates >= 1000 * 60 * 60 * 24 * 30 ) {
target.setInspectionStatas(1);
} else if(0< dates && dates < 1000 * 60 * 60 * 24 * 30) {
target.setInspectionStatas(2);
} else {
target.setInspectionStatas(0);
}
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);
}
} else {
queryWrapper.orderByDesc("sync_date");
}
if (!ValidationUtil.isEmpty(cylinderInfo.getAppId())) {
queryWrapper.eq("app_id", cylinderInfo.getAppId());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateStart())) {
queryWrapper.ge("inspection_date", cylinderInfo.getInspectionDateStart());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getInspectionDateEnd())) {
queryWrapper.le("inspection_date", cylinderInfo.getInspectionDateEnd());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitName())) { // 产权单位
queryWrapper.like("unit_name", cylinderInfo.getUnitName());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getFactoryNum())) {// 出厂编号
queryWrapper.like("factory_num", cylinderInfo.getFactoryNum());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderVariety())) {// 气瓶品种
queryWrapper.eq("cylinder_variety", cylinderInfo.getCylinderVariety());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getQrCode())) {// 二维码编号
queryWrapper.like("qrCode", cylinderInfo.getQrCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getElectronicLabelCode())) {// 电子标签编号
queryWrapper.like("electronic_label_code", cylinderInfo.getElectronicLabelCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getSequenceCode())) {// 气瓶唯一标识码
queryWrapper.like("sequence_code", cylinderInfo.getSequenceCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getUnitInnerCode())) {// 单位内部编号
queryWrapper.like("unit_inner_code", cylinderInfo.getUnitInnerCode());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getCylinderStatus())) {// 气瓶状态
queryWrapper.eq("cylinder_status", cylinderInfo.getCylinderStatus());
}
if (!ValidationUtil.isEmpty(cylinderInfo.getManufacturingUnit())) {// 制造单位
queryWrapper.like("manufacturing_unit", cylinderInfo.getManufacturingUnit());
}
return queryWrapper;
}
/**
* 获取气瓶详细信息
*
* @param sequenceNbr
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/cyinderInfo/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "获取气瓶详细信息", notes = "获取气瓶详细信息")
public ResponseModel<CylinderInfoDto> cyinderInfoList(@PathVariable Long sequenceNbr) {
CylinderInfo cylinderInfo = cylinderInfoServiceImpl.getById(sequenceNbr);
CylinderInfoDto target = new CylinderInfoDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderInfo, target);
if (0 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("在用");
} else if (1 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("停用");
} else if (2 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("注销");
} else if (3 == cylinderInfo.getCylinderStatus()) {
target.setCylinderStatusStr("报废");
} else {
target.setCylinderStatusStr("");
}
if (1 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("无缝气瓶");
} else if (2 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("焊接气瓶");
} else if (3 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("缠绕气瓶");
} else if (4 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("绝热气瓶");
} else if (5 == cylinderInfo.getCylinderVariety()) {
target.setCylinderVarietyStr("内装填料气瓶");
} else {
target.setCylinderVarietyStr("");
}
Date nextDate = target.getNextInspectionDate();
long dates = nextDate.getTime() - System.currentTimeMillis();
if (dates >= 1000 * 60 * 60 * 24 * 30) {
target.setInspectionStatas(1);
} else if (0 < dates && dates < 1000 * 60 * 60 * 24 * 30) {
target.setInspectionStatas(2);
} else {
target.setInspectionStatas(0);
}
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
* @return
*/
......@@ -648,167 +620,163 @@ public class CylinderInfoController extends BaseController {
@GetMapping(value = "/cylinderUnit/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "获取气瓶充装单位详情", notes = "获取气瓶充装单位详情")
public ResponseModel<CylinderUnitDto> cyinderUnitList(@PathVariable Long sequenceNbr) {
CylinderUnit cylinderUnit = cylinderUnitServiceImpl.getById(sequenceNbr);
if(this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap,t);
});
}
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderUnit, target);
String regionCode = cylinderUnit.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 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶充装单位");
} else if(2 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶检验单位");
} else if(3 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶生产单位");
} else {
target.setUnitTypeStr("");
}
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())));
Date nextDate = target.getFillingPermitDate();
long dates = nextDate.getTime() - System.currentTimeMillis();
if(dates >= 1000 * 60 * 60 * 24 * 200 ) {
target.setLicenseStatus(1);
} else if(0< dates && dates < 1000 * 60 * 60 * 24 * 200) {
target.setLicenseStatus(2);
} else {
target.setLicenseStatus(0);
}
CylinderUnit cylinderUnit = cylinderUnitServiceImpl.getById(sequenceNbr);
if (this.regionMap == null) {
this.regionMap = new HashMap<>();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.stream().forEach(t -> {
this.addRegionsMap(regionMap, t);
});
}
CylinderUnitDto target = new CylinderUnitDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(cylinderUnit, target);
String regionCode = cylinderUnit.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 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶充装单位");
} else if (2 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶检验单位");
} else if (3 == cylinderUnit.getUnitType()) {
target.setUnitTypeStr("液化石油气瓶生产单位");
} else {
target.setUnitTypeStr("");
}
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())));
Date nextDate = target.getFillingPermitDate();
long dates = nextDate.getTime() - System.currentTimeMillis();
if (dates >= 1000 * 60 * 60 * 24 * 200) {
target.setLicenseStatus(1);
} else if (0 < dates && dates < 1000 * 60 * 60 * 24 * 200) {
target.setLicenseStatus(2);
} else {
target.setLicenseStatus(0);
}
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")) {
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);
});
}
}
/**
* 企业气瓶总量数据同步
*
* @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);
}
/**
* 企业气瓶总量数据同步
*
* @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 {
@ApiOperation(httpMethod = "GET", value = "企业气瓶充装数据同步", notes = "企业气瓶充装数据同步")
public ResponseModel<Boolean> synUnitCylinderFillingData() {
Boolean flag = cylinderInfoServiceImpl.synUnitCylinderFillingData();
return ResponseHelper.buildResponse(flag);
}
......@@ -837,18 +804,18 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(flag);
}
/**
* 企业数据完整度同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitIntegrityData")
@ApiOperation(httpMethod = "GET", value = "企业数据完整度同步", notes = "企业数据完整度同步")
public ResponseModel<Boolean> synUnitIntegrityData() {
Boolean flag = cylinderInfoServiceImpl.synUnitIntegrityData();
return ResponseHelper.buildResponse(flag);
}
/**
* 企业数据完整度同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synUnitIntegrityData")
@ApiOperation(httpMethod = "GET", value = "企业数据完整度同步", notes = "企业数据完整度同步")
public ResponseModel<Boolean> synUnitIntegrityData() {
Boolean flag = cylinderInfoServiceImpl.synUnitIntegrityData();
return ResponseHelper.buildResponse(flag);
}
/**
* 气瓶充装检查情况同步
......@@ -863,19 +830,18 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(flag);
}
/**
* 装卸液体企业数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadUnitData")
@ApiOperation(httpMethod = "GET", value = "装卸液体企业数据同步", notes = "装卸液体企业数据同步")
public ResponseModel<Boolean> synFillingUnloadUnitData() {
Boolean flag = cylinderInfoServiceImpl.synFillingUnloadUnitData();
return ResponseHelper.buildResponse(flag);
}
/**
* 装卸液体企业数据同步
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/synFillingUnloadUnitData")
@ApiOperation(httpMethod = "GET", value = "装卸液体企业数据同步", notes = "装卸液体企业数据同步")
public ResponseModel<Boolean> synFillingUnloadUnitData() {
Boolean flag = cylinderInfoServiceImpl.synFillingUnloadUnitData();
return ResponseHelper.buildResponse(flag);
}
}
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
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.mapper.CylinderFillingRecordMapper;
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
import java.util.List;
......@@ -20,19 +19,19 @@ import java.util.List;
* @date 2022-03-04
*/
@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);
}
/**
* 列表查询 示例
*/
public List<CylinderFillingRecordDto> queryForCylinderFillingRecordList() {
return this.queryForList("" , false);
public List<CylinderFillingRecordDto> queryForCylinderFillingRecordList() {
return this.queryForList("", false);
}
public Double queryIntegirtyByAppId(String appId) {
......@@ -40,31 +39,42 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
}
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) {
Page<List<CylinderFillingRecordDto>>list = this.baseMapper.queryListByQueryDto(page,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<List<CylinderFillingRecordDto>> list = this.baseMapper.queryListByQueryDto(
page,
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<>();
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.setSize(page.getSize());
page1.setTotal(list.getTotal());
page1.setRecords(resultDtoList);
return page1;
return page1;
}
public Double getFillingSumByMonth(String appId, Date time) {
return baseMapper.getFillingSumByMonth(appId,time);
return baseMapper.getFillingSumByMonth(appId, 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) {
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;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderAreaDataDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingCheckDataUnitDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderFillingDataUnitDto;
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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.*;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.*;
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.dto.CylinderInfoDto;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Consumer;
/**
* 气瓶基本信息服务实现类
......@@ -56,7 +26,7 @@ import java.util.Map;
* @date 2021-12-14
*/
@Service
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,CylinderInfo,CylinderInfoMapper> implements ICylinderInfoService {
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper> implements ICylinderInfoService {
@Autowired
......@@ -111,15 +81,15 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return this.queryForPage(page, null, false);
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return this.queryForList("" , false);
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
......@@ -127,10 +97,8 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
* @return
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
......@@ -138,7 +106,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
/**
* 获取上上个月气瓶总量
* @return
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
......@@ -156,105 +123,75 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
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>());
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
List<String> regionCodes = new ArrayList<String>();
regions.stream().forEach(t -> {
this.addRegionsList(regionCodes,t);
});
regionCodes.stream().forEach(r -> {
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(int i = 0 ; i < 30 ; i ++) {
now.add(Calendar.DATE,-1);
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSum(r,now.getTime());
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(r);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
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 -> {
addRegionsList(regionList, c);
});
}
}
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() {
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
List<RegionModel> regionCodes = new ArrayList<RegionModel>();
regions.stream().forEach(t -> {
this.addRegionsList1(regionCodes,t);
});
regionCodes.stream().forEach(r -> {
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(r.getRegionName());
String code = r.getRegionCode() +"";
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
Integer warmTotal = cylinderUnitWarn + cylinderInfoWarn;
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if("610000".equals(code)) {
if ("610000".equals(code)) {
parentCode = "-1";
} else if(!"00".equals(code.substring(4,6))) {
parentCode = code.substring(0,4) + "00";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(r.getRegionCode()+"");
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum(Long.valueOf(warmTotal));
temp.setWarnNum((long) warmTotal);
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>());
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
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));
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionModel));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
unitlist.stream().forEach(t -> {
unitlist.forEach(t -> {
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
......@@ -270,348 +207,340 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto,Cylinde
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
//tz_cylinder_filling_check 30天内
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);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(u);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if(tempList.size() == 5) {
if(tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0,temp);
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
Collections.sort(tempList, new Comparator<CylinderIntegrityDataDto>() {
@Override
public int compare(CylinderIntegrityDataDto o1, CylinderIntegrityDataDto o2) {
//升序
return o1.getIntegrity().compareTo(o2.getIntegrity());
}
});
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.stream().forEach(t -> {
tempList.forEach(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>());
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
List<String> regionCodes = new ArrayList<String>();
regions.stream().forEach(t -> {
this.addRegionsList(regionCodes,t);
});
regionCodes.stream().forEach(u -> {
String regionCode = u;
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
Double percent = 0d;
if(monthUnitLastInfo != 0) {
percent = (lastUnitTotal - monthUnitLastInfo) / monthUnitLastInfo;
double changeNum = lastUnitTotal - monthUnitLastInfo;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = changeNum / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) (lastUnitTotal - monthUnitLastInfo));
temp.setChangePercent( (int )(percent*100) + "");
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
cylinderUnitDataServiceImpl.createWithModel(temp);
});
return true;
}
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行
public Boolean getCylinderInfo() {
// 每日清空再重新获取数据
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoData>());
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
List<String> regionCodes = new ArrayList<String>();
regions.stream().forEach(t -> {
this.addRegionsList(regionCodes,t);
});
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
regionCodes.stream().forEach(u -> {
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = u;
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));
Double percent = 0d;
if(monthBeforeLastInfo != 0) {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);//当前总数
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));//上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));//上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (lastInfoTotal - monthBeforeLastInfo));
temp.setChangePercent((int )(percent*100)+"");
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
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>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(u.getAppId());
Integer count = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,u.getAppId()));
temp.setAppId(cylinderUnit.getAppId());
int count = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));//当前总数
temp.setTotalSum((long) count);
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(u.getAppId()));
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(u.getAppId()));
Double percent = 0d;
if(lastmonth != 0) {
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));//上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));//上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (thismonth - lastmonth));
temp.setChangePercent((int )(percent*100)+"");
temp.setChangePercent((int) (percent * 100) + "");
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>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
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();
String year = c.get(Calendar.YEAR)+"";
int month = c.get(Calendar.MONTH)+1 ;
String monthStr = month < 10 ? "0"+month : month +"";
temp.setFillingMonth(monthStr);
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
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);
// 获取上月数据
c.add(Calendar.MONTH, -1);
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(u.getAppId(),c.getTime());
Double percent = 0d;
if(lastMonth != 0) {
calendar.add(Calendar.MONTH, -1);
//上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(), calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int )(percent*100)+"");
temp.setAppId(u.getAppId());
temp.setChangeSum(thisMonth-lastMonth);
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
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>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(u.getAppId());
int cylinder = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,u.getAppId()));
int tags = cylinderTagsServiceImpl.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId,u.getAppId()));
Double percent = 0d;
if(tags != 0) {
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
double percent = 0d;
if (tags != 0) {
percent = (double) cylinder / (double) tags;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent*100);
temp.setTagPercent(percent * 100);
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>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(u.getAppId());
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = u.getIntegrity();
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(u.getAppId());
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(u.getAppId());
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(u.getAppId());
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(u.getAppId());
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(u.getAppId());
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(u.getAppId());
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(u.getAppId());
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(u.getAppId());
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(u.getAppId());
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(u.getAppId());
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(u.getAppId());
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
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>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for(int i = 0 ; i < 12 ; i++) {
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
String year = c.get(Calendar.YEAR)+"";
int month = c.get(Calendar.MONTH)+1 ;
String monthStr = month < 10 ? "0"+month : month +"";
String year = c.get(Calendar.YEAR) + "";
int month = c.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingMonth(monthStr);
temp.setFillingYear(year);
Integer thisMonth = cylinderFillingRecordServiceImpl.getFillingCountByMonth(u.getAppId(),c.getTime());
Integer thisMonth = cylinderFillingRecordServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
temp.setTotalSum((long) thisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(u.getAppId(),c.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl.getFillingCountByMonth(u.getAppId(),c.getTime());
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(), c.getTime());
// 充装前检查率:充装前检查次数/充装次数
Double before = 0d;
if(thisMonth != 0) {
before = (double)(fillingCount) / (double) thisMonth;
double before = 0d;
if (thisMonth != 0) {
before = (double) (fillingCount) / (double) thisMonth;
}
temp.setFillingPercent(before * 100);
temp.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
Double after = 0d;
if(thisMonth != 0) {
after = (double)(fillingCheckCount) / (double) thisMonth;
double after = 0d;
if (thisMonth != 0) {
after = (double) (fillingCheckCount) / (double) thisMonth;
}
temp.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/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());
if(thisMonth != 0) {
passed = ( (double) (fillingPassedCount) + (double) fillingCheckPassedCount ) / (double) (2 * thisMonth);
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl.getFillingPassedCountByMonth(cylinderUnit.getAppId(), c.getTime());
if (thisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount) / (double) (2 * thisMonth);
}
temp.setFillingPassedPercent(passed * 100);
temp.setAppId(u.getAppId());
temp.setFillingPassedPercent(passed * 100);
temp.setAppId(cylinderUnit.getAppId());
c.add(Calendar.MONTH, -1);
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>());
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.stream().forEach(u -> {
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for(int i = 0 ; i < 30 ; i ++) {
now.add(Calendar.DATE,-1);
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(u.getAppId(),now.getTime());
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(u.getAppId());
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
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 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.2.0</version>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<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>
<groupId>cn.jpush.api</groupId>
......@@ -271,28 +277,37 @@
</dependencies>
</dependencyManagement>
<repositories>
<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>
<id>Releases</id>
<name>Releases</name>
<url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>Snapshots</id>
<name>Snapshots</name>
<url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<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>
</repositories>
<modules>
<module>amos-boot-module</module>
<module>amos-boot-biz-common</module>
<module>amos-boot-system-avic</module>
<module>amos-boot-system-tzs</module>
<module>amos-boot-system-jcs</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