Commit bf6c7f47 authored by 刘凡's avatar 刘凡

修改:新增气瓶接口

parent 1e855670
......@@ -2,9 +2,12 @@ package com.yeejoin.amos.api.openapi.controller;
import com.yeejoin.amos.api.common.restful.utils.ResponseHelper;
import com.yeejoin.amos.api.common.restful.utils.ResponseModel;
import com.yeejoin.amos.api.openapi.face.dto.CylinderFillingMessage;
import com.yeejoin.amos.api.openapi.constant.Constant;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessage;
import com.yeejoin.amos.api.openapi.face.model.*;
import com.yeejoin.amos.api.openapi.face.service.*;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.cylinder.api.service.CylinderFillingMessageService;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api;
......@@ -14,13 +17,16 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.event.RestEventTrigger;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -56,6 +62,8 @@ public class CylinderController {
CylinderFillingMessageService cylinderFillingMessageService;
@Autowired
private EmqKeeper emqKeeper;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private TmCylinderOffloadingService cylinderOffloadingService;
......@@ -104,14 +112,17 @@ public class CylinderController {
@PostMapping(value = "/filling")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> cylinderFillingInfo(@RequestBody String fillingData) throws Exception {
String token = RequestContext.getToken();
AgencyUserModel me = Privilege.agencyUserClient.getme().getResult();
String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, token);
BizTokenModel bizTokenModel = (BizTokenModel)this.redisTemplate.opsForValue().get(tokenKey);
JSONObject jsonobject = JSONObject.fromObject(fillingData);
CylinderFillingDataValidationResultModel validateResult = null;
CylinderFillingMessage cylinderFillingMessage = new CylinderFillingMessage();
cylinderFillingMessage.setTime(simpleDateFormat.format(new Date()));
cylinderFillingMessage.setFillingCompanyName(me.getCompanys().get(0).getCompanyName());
cylinderFillingMessage.setAppId(bizTokenModel.getAppId());
try {
validateResult = cylinderFillingDataValidationService.validateFilling(jsonobject);
} catch (Exception e) {
......@@ -157,13 +168,7 @@ public class CylinderController {
throw new BadRequest("数据校验失败!!!");
}
// Map<String, Class> classMap = new HashMap<>();
// classMap.put("fillingBefore", TmCylinderFillingModel.class);
// classMap.put("filling", TmCylinderFillingRecordModel.class);
// classMap.put("fillingAfter", TmCylinderFillingCheckModel.class);
TmCylinderFillingModelList cylinderFillingModelList = com.alibaba.fastjson.JSONObject.parseObject(fillingData, TmCylinderFillingModelList.class);
// TmCylinderFillingModelList cylinderFillingModelList = (TmCylinderFillingModelList) JSONObject.toBean(jsonobject,
// TmCylinderFillingModelList.class, classMap);
List<TmCylinderFillingModel> fillingBeforeList = cylinderFillingModelList.getFillingBefore();
List<TmCylinderFillingRecordModel> fillingList = cylinderFillingModelList.getFilling();
......@@ -175,9 +180,9 @@ public class CylinderController {
cylinderFillingRecordService.createCylinderFilling(fillingList);
cylinderFillingCheckService.createCylinderFillingAfter(fillingAfterList);
CylinderFillingMessageModel cylinderFillingMessageModel = new CylinderFillingMessageModel();
BeanUtils.copyProperties(cylinderFillingMessage, cylinderFillingMessageModel);
cylinderFillingMessageModel.setAppId(bizTokenModel.getAppId());
cylinderFillingMessageService.createWithModel(cylinderFillingMessageModel);
emqKeeper.getMqttClient().publish("openapi/cylinder/filling", JSONObject.fromObject(cylinderFillingMessage).toString().getBytes(), 2, false);
......@@ -191,7 +196,6 @@ public class CylinderController {
public ResponseModel<String> cylinderFillingAudit(@RequestBody List<TmCylinderFillingExamineModel> fillingAuditData) {
cylinderFillingDataValidationService.validateCylinderFillingExamineModel(fillingAuditData);
return ResponseHelper.buildResponse(cylinderFillingExamineService.createCylinderFillingExamine(fillingAuditData));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
......
package com.yeejoin.amos.api.openapi.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.api.common.restful.utils.ResponseHelper;
import com.yeejoin.amos.api.common.restful.utils.ResponseModel;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.api.openapi.face.model.CylinderTableModel;
import com.yeejoin.amos.api.openapi.face.model.CylinderUnitTree;
import com.yeejoin.amos.api.openapi.face.orm.entity.OpenapiBizToken;
import com.yeejoin.amos.boot.module.cylinder.api.dto.PageParam;
import com.yeejoin.amos.api.openapi.face.service.*;
import com.yeejoin.amos.boot.module.cylinder.api.service.CylinderFillingMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
......@@ -47,6 +51,8 @@ public class CylinderPageController {
private OpenapiBizTokenService openapiBizTokenService;
@Autowired
private CylinderDateInfoService cylinderDateInfoService;
@Autowired
CylinderFillingMessageService cylinderFillingMessageService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "服务商树")
......@@ -96,10 +102,11 @@ public class CylinderPageController {
};
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "同步气瓶数据")
@GetMapping(value = "/logs")
public ResponseModel<IPage<CylinderFillingMessageModel>> getUploadCylinderLogs(PageParam pageParam, String orgCode ) {
IPage<CylinderFillingMessageModel> result = cylinderFillingMessageService.getUploadCylinderLogs(pageParam, orgCode);
return ResponseHelper.buildResponse(result);
};
}
......@@ -14,7 +14,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.api.openapi.face.model.EquipmentModel;
import com.yeejoin.amos.api.openapi.face.orm.entity.PageParam;
import com.yeejoin.amos.boot.module.cylinder.api.dto.PageParam;
import com.yeejoin.amos.api.openapi.face.service.EquipmentService;
import io.swagger.annotations.Api;
......
package com.yeejoin.amos.api.openapi.face.service;
import com.yeejoin.amos.api.openapi.face.model.CylinderFillingMessageModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.CylinderFillingMessageMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.CylinderFillingMessageEntity;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Component
public class CylinderFillingMessageService extends BaseService<CylinderFillingMessageModel, CylinderFillingMessageEntity, CylinderFillingMessageMapper> {
}
......@@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.api.openapi.face.model.EquipmentModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.TmEquipmentMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.Equipment;
import com.yeejoin.amos.api.openapi.face.orm.entity.PageParam;
import com.yeejoin.amos.boot.module.cylinder.api.dto.PageParam;
@Service
public class EquipmentService extends AppBaseService<EquipmentModel, Equipment, TmEquipmentMapper> {
......
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.api.openapi.face.orm.dao.OpenapiBizTokenMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.OpenapiBizToken;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -53,6 +54,9 @@ public class OpenapiBizTokenService extends BaseService<OpenapiBizTokenModel, Op
HashMap<String, Object> authModel = responseModel.getResult();
String token = (String) authModel.get("token");
bizTokenModel.setToken(token);
RequestContext.setToken(token);
AgencyUserModel user = Privilege.agencyUserClient.getme().getResult();
bizTokenModel.setApiCompanyCode(user.getCompanys().get(0).getOrgCode());
String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, token);
this.redisTemplate.opsForValue().set(tokenKey, bizTokenModel);
return token;
......
......@@ -25,6 +25,11 @@
<artifactId>amos-component-rule</artifactId>
<groupId>com.yeejoin</groupId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.yeejoin.amos.api.openapi.face.dto;
package com.yeejoin.amos.boot.module.cylinder.api.dto;
import lombok.Data;
......@@ -8,4 +8,5 @@ public class CylinderFillingMessage {
private String fillingCompanyName;
private Integer cylinderNumber;
private String message;
private String appId;
}
package com.yeejoin.amos.api.openapi.face.model;
package com.yeejoin.amos.boot.module.cylinder.api.dto;
import lombok.Data;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
......@@ -9,4 +9,6 @@ public class CylinderFillingMessageModel extends BaseModel {
private String fillingCompanyName;
private Integer cylinderNumber;
private String message;
private String appId;
private String orgCode;
}
package com.yeejoin.amos.api.openapi.face.orm.entity;
package com.yeejoin.amos.boot.module.cylinder.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -18,4 +18,8 @@ public class CylinderFillingMessageEntity extends BaseEntity {
private Integer cylinderNumber;
@TableField("message")
private String message;
@TableField("app_id")
private String appId;
@TableField("org_code")
private String orgCode;
}
package com.yeejoin.amos.boot.module.cylinder.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum TagTypeEnums {
other("其他", "other"),
electronicLabelCodeNumber("电子标签", "electronicLabelCodeNumber"),
qrcodeNumber("二维码", "qrcodeNumber");
private String name;
private String key;
}
package com.yeejoin.amos.api.openapi.face.orm.dao;
package com.yeejoin.amos.boot.module.cylinder.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.CylinderFillingMessageEntity;
import com.yeejoin.amos.api.openapi.face.orm.entity.OpenapiLog;
import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderFillingMessageEntity;
public interface CylinderFillingMessageMapper extends BaseMapper<CylinderFillingMessageEntity> {
}
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.cylinder.api.dto.EquEnterDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.TzBaseEnterpriseInfo;
import org.apache.ibatis.annotations.Param;
/**
* 企业数据信息 Mapper 接口
......@@ -44,4 +45,6 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
IPage<TzBaseEnterpriseInfoDto> page(Page<TzBaseEnterpriseInfoDto> page, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto);
IPage<TzBaseEnterpriseInfoDto> pageList(Page<TzBaseEnterpriseInfoDto> page, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto, List orgCodeList);
List<TzBaseEnterpriseInfoDto> queryByUseCode(@Param("useCodes") List<String> useCode);
}
package com.yeejoin.amos.boot.module.cylinder.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.cylinder.api.dto.PageParam;
import com.yeejoin.amos.boot.module.cylinder.api.mapper.CylinderFillingMessageMapper;
import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderFillingMessageEntity;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Component
public class CylinderFillingMessageService extends BaseService<CylinderFillingMessageModel, CylinderFillingMessageEntity, CylinderFillingMessageMapper> {
public IPage<CylinderFillingMessageModel> getUploadCylinderLogs(PageParam pageParam, String regionCode) {
CompanyModel result = Privilege.companyClient.queryByCompanyCode(regionCode).getResult();
Page<CylinderFillingMessageModel> page = new Page<>(pageParam.getCurrent(), pageParam.getSize());
return getUploadCylinderLogsByOrgCode(page, result.getOrgCode());
}
public IPage<CylinderFillingMessageModel> getUploadCylinderLogsByOrgCode( Page<CylinderFillingMessageModel> page, @Condition(Operator.likeRight) String orgCode) {
return queryForPage(page, null, false, orgCode);
}
}
......@@ -44,4 +44,6 @@ public interface ITzBaseEnterpriseInfoService extends IService<TzBaseEnterpriseI
TzBaseEnterpriseInfoDto getInfoByUseCode(String useCode);
String setLabel(List<Long> enterpriseIds, List<String> enterpriseLabels);
List<TzBaseEnterpriseInfoDto> queryByUseCode(List<String> useCode);
}
package com.yeejoin.amos.boot.module.cylinder.flc.api.dto;
import lombok.Data;
@Data
public class CylinderFillingRecordStatisticsDto {
private String time;
private String fillingQuantity;
private String offloadingVolume;
}
package com.yeejoin.amos.boot.module.cylinder.flc.api.dto;
import lombok.Data;
@Data
public class CylinderInfoStatisticsDto {
private String unitName;
private String city;
private String province;
private String district;
private Double num;
}
......@@ -35,10 +35,12 @@ public class CylinderUnitDto extends BaseDto {
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "单位名称")
private String useUnit;
@ApiModelProperty(value = "统一社会信用代码")
private String creditCode;
@ApiModelProperty(value = "统一社会信用代码")
private String useCode;
@ApiModelProperty(value = "详细地址")
private String address;
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoStatisticsDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData;
import org.apache.ibatis.annotations.Param;
......@@ -38,4 +39,9 @@ public interface CylinderAreaDataMapper extends BaseMapper<CylinderAreaData> {
*/
List<KeyValueDto> queryLicenseEfficiencyOfRegion(@Param(value = "regionCode") String regionCode);
List<CylinderInfoStatisticsDto> getCylinderStatisticsData(@Param(value = "orgCode") String orgCode);
List<CylinderInfoStatisticsDto> getCylinderStatisticsDataByCity(String orgCode);
List<Map<String, Object>> getQiZhanStatisticsDataByCity(@Param(value = "orgCodes") List<String> orgCodes);
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderFillingRecordStatisticsDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInfo;
import org.apache.ibatis.annotations.Param;
......@@ -23,7 +24,7 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
* @param sequenceNbr
* @return
*/
Map<String, String> queryNumAndOutOfDateNum(@Param("sequenceNbr") Long sequenceNbr);
Map<String, String> queryNumAndOutOfDateNum(@Param("unitCode") String unitCode);
Integer getMonthInfoTotal(@Param("regionCode") String regionCode);
......@@ -121,5 +122,9 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
String getAttachmentByUnitCode (@Param("appId") String appId);
void updateCylinderInfoEsStatusBySeqCodes(String appId, List<String> seqCodeList);
List<CylinderFillingRecordStatisticsDto> queryFillingRecordByOrgCode(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
List<CylinderFillingRecordStatisticsDto> queryoffloadingByOrgCode(@Param("orgCode") String orgCode, @Param("startTime") String startTime);
}
......@@ -2,6 +2,10 @@ package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderTagsDataUnit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 气瓶及标签数量比表-企业 Mapper 接口
......@@ -11,4 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface CylinderTagsDataUnitMapper extends BaseMapper<CylinderTagsDataUnit> {
Map<String, Object> selectForTagsStatisticsData(@Param("orgCode") String orgCode);
}
......@@ -48,7 +48,7 @@ public interface CylinderUnitMapper extends BaseMapper<CylinderUnit> {
Integer getThisMonthUnitTotalByRegionCode(String regionCode);
List<CylinderUnitDto> getMessage(@Param("regionCode") String regionCode);
List<CylinderUnitDto> getMessage(@Param("orgCode") String orgCode);
/**
* 根据层级查气瓶信息
......
......@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -21,7 +23,7 @@ public interface ICylinderInfoService {
* @param unitId
* @return
*/
Map<String, String> queryNumAndOutOfDateNum(Long unitId);
Map<String, String> queryNumAndOutOfDateNum(String unitCode) throws IOException;
void synFillingUnloadData();
......
......@@ -27,12 +27,13 @@
THEN '正常'
when min(ul.expiry_date) is null then '未提供'
ELSE '已超期'
END AS licenseOk from tz_base_unit_licence ul where cu.credit_code = ul.unit_code) as strKey
END AS licenseOk from tz_base_unit_licence ul where cu.use_code = ul.unit_code) as strKey
FROM
tz_cylinder_unit cu
tz_base_enterprise_info cu
where
cu.unit_status = '1210'
and cu.region_code like concat('%', #{regionCode}, '%')
cu.data_sources = '陕西省内企业'
AND cu.unit_type LIKE '%充装单位%'
and cu.org_code like concat('%', #{regionCode}, '%')
GROUP BY strKey
</select>
......@@ -41,11 +42,12 @@
CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN ci.next_inspection_date <![CDATA[<=]]> now() THEN 1 END) * 100.0 / COUNT(*)), 2) END AS expiredRate
FROM
"tz_cylinder_inspection" ci
LEFT JOIN tz_cylinder_unit cu on ci.app_id = cu.app_id
LEFT JOIN tz_base_enterprise_info cu on ci.app_id = cu.app_id
<where>
cu.unit_status = '1210'
cu.data_sources = '陕西省内企业'
AND cu.unit_type LIKE '%充装单位%'
<if test="regionCode != null and regionCode != ''">
and cu.region_code like concat('%', #{regionCode}, '%')
and cu.org_code like concat(#{regionCode}, '%')
</if>
<if test="appId != null and appId != ''">
and cu.app_id = #{appId}
......@@ -58,15 +60,85 @@
CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN ci.inspection_result = '3123' THEN 1 END) * 100.0 / COUNT(*)), 2) END AS resultRate
FROM
"tz_cylinder_inspection" ci
LEFT JOIN tz_cylinder_unit cu on ci.app_id = cu.app_id
LEFT JOIN tz_base_enterprise_info cu on ci.app_id = cu.app_id
<where>
cu.unit_status = '1210'
cu.data_sources = '陕西省内企业'
AND cu.unit_type LIKE '%充装单位%'
<if test="regionCode != null and regionCode != ''">
and cu.region_code like concat('%', #{regionCode}, '%')
and cu.org_code like concat( #{regionCode}, '%')
</if>
<if test="appId != null and appId != ''">
and cu.app_id = #{appId}
</if>
</where>
</select>
<select id="getCylinderStatisticsData" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoStatisticsDto">
SELECT
t1.unit_name unitName,
i.city,
i.province,
i.district,
ROUND( COUNT ( t1.sequence_code ) / 10000.00, 2 ) num
FROM
tz_base_enterprise_info i
RIGHT JOIN tz_cylinder_info t1 ON t1.app_id = i.app_id
WHERE
i.data_sources = '陕西省内企业'
AND i.unit_type LIKE'%充装单位%'
AND i.industry_supervisor like concat(#{orgCode}, '%')
GROUP BY
t1.unit_name
ORDER BY
num DESC
</select>
<select id="getCylinderStatisticsDataByCity" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoStatisticsDto">
SELECT
i.city,
i.province
ROUND( COUNT ( t1.sequence_code ) / 10000.00, 2 ) num
FROM
tz_base_enterprise_info i
RIGHT JOIN tz_cylinder_info t1 ON t1.app_id = i.app_id
WHERE
i.data_sources = '陕西省内企业'
AND i.unit_type LIKE'%充装单位%'
AND i.industry_supervisor like concat(#{orgCode}, '%')
GROUP BY
i.city,
i.province
ORDER BY
num DESC
</select>
<select id="getQiZhanStatisticsDataByCity" resultType="Map">
select a.* from (
SELECT
case
<if test="orgCodes != null and orgCodes.size > 0">
<foreach collection="orgCodes" item="orgCode">
when i.supervise_org_code like concat ( #{orgCode}, '%' ) then
#{orgCode}
</foreach>
</if>
end orgCode,
COUNT ( i.use_unit ) unitCount
FROM
tz_base_enterprise_info i
WHERE
i.data_sources = '陕西省内企业'
AND i.unit_type LIKE'%充装单位%'
<if test="orgCodes != null and orgCodes.size > 0">
AND
<foreach collection="orgCodes" open="(" item="orgCode" close=")" separator=" or ">
(i.org_code like concat(#{orgCode}, '%') )
</foreach>
</if>
) a
where a.orgCode is not null
GROUP BY
a.orgCode
</select>
</mapper>
......@@ -4,16 +4,14 @@
<select id="queryNumAndOutOfDateNum" resultType="java.util.Map">
SELECT
count( t.sequence_nbr ) AS cylinderNum,
(select expiry_date from tz_base_unit_licence where unit_code = u.credit_code ORDER BY expiry_date desc limit 1) AS fillingPermitDate,
(select expiry_date from tz_base_unit_licence where unit_code = u.use_code ORDER BY expiry_date desc limit 1) AS fillingPermitDate,
count( CASE WHEN i.next_inspection_date <![CDATA[ < ]]> now() THEN 1 END ) AS outOfDateNum
FROM
tz_cylinder_unit U
LEFT JOIN tz_cylinder_info AS t ON t.app_id = u.app_id
LEFT JOIN tz_cylinder_inspection AS i ON i.sequence_code = t.sequence_code
tz_base_enterprise_info U
LEFT JOIN tz_cylinder_inspection AS i ON i.app_id = U.app_id
WHERE
u.sequence_nbr = #{sequenceNbr}
GROUP BY u.sequence_nbr
u.use_code = #{unitCode}
GROUP BY u.use_code
</select>
<sql id="selectAPPIdByRegionCode">
......@@ -614,4 +612,38 @@
#{seqCode}
</foreach>
</update>
<select id="queryFillingRecordByOrgCode" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderFillingRecordStatisticsDto">
SELECT
SUBSTR( f.filling_endtime, 0, 10 ) filling_time,
SUM ( f.filling_quantity ) filling_quantity
FROM
tz_cylinder_filling_record f ,
tz_base_enterprise_info i
WHERE
i.app_id = f.app_id
AND f.filling_endtime >= concat(#{startTime}, ' 00:00:00')
AND i.org_code like concat(#{orgCode}, '%')
GROUP BY
filling_time
ORDER BY
filling_time DESC
</select>
<select id="queryoffloadingByOrgCode" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderFillingRecordStatisticsDto">
SELECT
f.statistics_sync_date filling_time,
SUM ( f.offloading_volume ) filling_quantity
FROM
tz_cylinder_offloading f,
tz_base_enterprise_info i
WHERE
i.app_id = f.app_id
AND f.statistics_sync_date >= #{startTime}
AND i.org_code like concat(#{orgCode}, '%')
GROUP BY
filling_time
ORDER BY
filling_time DESC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!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.cylinder.flc.api.mapper.CylinderTagsDataUnitMapper">
<select id="selectForTagsStatisticsData" resultType="Map">
SELECT SUM
( A.qrcode ) qrcodeNumber,
SUM ( A.electronic_label_code ) electronicLabelCodeNumber,
SUM ( A.other ) other
FROM
(
SELECT
IF
( t.qrcode = NULL OR t.qrcode = '', 0, 1 ) qrcode,
IF
( t.electronic_label_code = NULL OR t.electronic_label_code = '', 0, 1 ) electronic_label_code,
IF
( ( ( t.electronic_label_code = NULL OR t.electronic_label_code = '' ) AND ( t.qrcode = NULL OR t.qrcode = '' ) ), 1, 0 ) other
FROM
tz_cylinder_tags t,
tz_base_enterprise_info e
where t.app_id = e.app_id
<if test="orgCode != null and orgCode != ''">
and e.industry_supervisor like concat(#{orgCode}, '%')
</if>
) A
</select>
</mapper>
......@@ -51,6 +51,8 @@
<select id="getMessage" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto">
SELECT tcu.*,
tcu.use_unit unitName,
tcu.use_code creditCode,
CASE
WHEN (SELECT COUNT(1)
FROM tz_cylinder_inspection ins
......@@ -58,12 +60,14 @@
and LENGTH(ins.next_inspection_date) >= 10
and TO_DAYS(ins.next_inspection_date) - TO_DAYS(NOW()) &lt;= 30) > 0 THEN
1
WHEN (SELECT COUNT(1) FROM view_unit_outofdate v WHERE v.credit_code = tcu.credit_code) > 0 THEN
WHEN (SELECT COUNT(1) FROM view_unit_outofdate v WHERE v.credit_code = tcu.use_code) > 0 THEN
1
ELSE 0
END AS outOfDate
FROM tz_cylinder_unit tcu
WHERE tcu.region_code like concat('%', #{regionCode}, '%')
FROM tz_base_enterprise_info tcu
WHERE tcu.org_code like concat( #{orgCode}, '%')
AND tcu.data_sources = '陕西省内企业'
AND tcu.unit_type LIKE'%充装单位%'
</select>
<select id="queryCylinderUnitOfPermissionExpire" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto">
SELECT
......
......@@ -155,4 +155,13 @@
select * from tz_base_enterprise_info where use_unit = #{useUnit}
</select>
<select id="queryByUseCode" resultType="com.yeejoin.amos.boot.module.cylinder.api.dto.TzBaseEnterpriseInfoDto">
select * from tz_base_enterprise_info where use_code in
<if test="useCodes != null">
<foreach collection="useCodes" item="useCode" open="(" close=")" separator=",">
#{useCode}
</foreach>
</if>
</select>
</mapper>
......@@ -26,6 +26,7 @@
<artifactId>amos-boot-module-common-biz</artifactId>
<version>${amos-boot-biz.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
......
......@@ -39,6 +39,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.ParseException;
......@@ -507,6 +509,11 @@ public class TzBaseEnterpriseInfoServiceImpl
return "success";
}
@Override
public List<TzBaseEnterpriseInfoDto> queryByUseCode(@Condition(Operator.in) List<String> useCode) {
return this.baseMapper.queryByUseCode(useCode);
}
private String checkLabel(List<String> enterpriseLabels, String result) {
List<String> strings = Arrays.asList(result.split(","));
ArrayList<String> res = new ArrayList<>(strings);
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.cylinder.flc.biz.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -14,7 +15,10 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.cylinder.api.dto.PageParam;
import com.yeejoin.amos.boot.module.cylinder.api.service.CylinderFillingMessageService;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.*;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.*;
import com.yeejoin.amos.boot.module.cylinder.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.BaseUnitLicence;
......@@ -24,9 +28,6 @@ import com.yeejoin.amos.boot.module.cylinder.api.entity.MsgLog;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.BaseUnitLicenceServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.ESCylinderServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.TzBaseEnterpriseInfoServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnit;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
......@@ -50,6 +51,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -104,6 +106,8 @@ public class CylinderInfoController extends BaseController {
@Autowired
private CylinderAreaDataServiceImpl cylinderAreaDataService;
@Autowired
CylinderFillingMessageService cylinderFillingMessageService;
/**
* 新增气瓶基本信息
*
......@@ -1370,6 +1374,53 @@ public class CylinderInfoController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getCylinderStatisticsData")
@ApiOperation(httpMethod = "GET", value = "获取气瓶统计数据-按照企业名称统计", notes = "获取气瓶统计数据-按照企业名称统计")
public ResponseModel<List<Map<String, Object>>> getCylinderStatisticsData(@RequestParam( value="regionCode") String regionCode) throws IOException {
List<Map<String, Object>> result = cylinderAreaDataService.getCylinderStatisticsData(regionCode);
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/getCylinderStatisticsDataByCity")
@ApiOperation(httpMethod = "POST", value = "获取气瓶统计数据-按照城市统计", notes = "获取气瓶统计数据-按照城市统计")
public ResponseModel<Map<String, Object>> getCylinderStatisticsDataByCity(@RequestBody Map<String, Object> map) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
}
Map<String, Object> result = cylinderAreaDataService.getCylinderStatisticsDataByCity(regionCode.toString());
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/getCylinderStatisticsDataByCityForTotal")
@ApiOperation(httpMethod = "POST", value = "获取气瓶统计数据-按照城市统计", notes = "获取气瓶统计数据-按照城市统计-地图统计")
public ResponseModel<Map<String, Object>> getCylinderStatisticsDataByCityForTotal(@RequestBody Map<String, Object> map) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
}
Map<String, Object> result = cylinderAreaDataService.getCylinderStatisticsDataByCityForTotal(regionCode.toString());
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/getCylinderStatisticsDataByCityForMap")
@ApiOperation(httpMethod = "POST", value = "获取气瓶统计数据-按照城市统计", notes = "获取气瓶统计数据-按照城市统计-地图")
public ResponseModel<List<Map<String, Object>>> getCylinderStatisticsDataByCityForMap(@RequestBody Map<String, Object> map) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
}
List<Map<String, Object>> result = cylinderAreaDataService.getCylinderStatisticsDataByCityForMap(regionCode.toString());
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "市级为维度,各市的充装次数和累计充装量,当前日期向前推31天的数据总和")
@GetMapping(value = "/countFillingTimesAndQuantityByCity")
public ResponseModel<Map<String, Object>> countFillingTimesAndQuantityByCity() {
......@@ -1377,6 +1428,13 @@ public class CylinderInfoController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "30天的充装量、卸液量数据")
@GetMapping(value = "/fillingTimesAndQuantity")
public ResponseModel<List<CylinderFillingRecordStatisticsDto> > fillingTimesAndQuantity(@RequestParam("regionCode") String reginCode) {
return ResponseHelper.buildResponse(cylinderInfoServiceImpl.fillingTimesAndQuantity(reginCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "资质附件,轮播图用")
@GetMapping(value = "/getAttachmentByUnitCode")
public ResponseModel<List<Map<String, Object>>> getAttachmentByUnitCode(@RequestParam(value = "companyId") String companyId) {
......@@ -1398,4 +1456,13 @@ public class CylinderInfoController extends BaseController {
}
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "同步气瓶数据日志")
@GetMapping(value = "/logs")
@DS("cyl")
public ResponseModel<IPage<CylinderFillingMessageModel>> getUploadCylinderLogs(PageParam pageParam, String regionCode ) {
IPage<CylinderFillingMessageModel> result = cylinderFillingMessageService.getUploadCylinderLogs(pageParam, regionCode);
return ResponseHelper.buildResponse(result);
};
}
......@@ -6,12 +6,14 @@ import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderAreaDa
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
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;
import java.util.Map;
@RestController
......@@ -33,6 +35,22 @@ public class CylinderStatisticsController {
return ResponseHelper.buildResponse(service.getEarlyWarningStatistics(regionCode, appId));
}
/**
* 预警预报统计
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/earlyWarning/child", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "预警预报")
public ResponseModel<Map<String, Object>> getChildEarlyWarning(@RequestBody Map<String, Object> map) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
}
return ResponseHelper.buildResponse(service.getChildEarlyWarning(regionCode.toString()));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/test/saveCylinderFillingRecord2ES", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "testSaveCylinderFillingRecord2ES")
......
......@@ -6,6 +6,8 @@ import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List;
import java.util.Map;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderTagsDataUnitServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -113,4 +115,16 @@ public class CylinderTagsDataUnitController extends BaseController {
public ResponseModel<List<CylinderTagsDataUnitDto>> selectForList() {
return ResponseHelper.buildResponse(cylinderTagsDataUnitServiceImpl.queryForCylinderTagsDataUnitList());
}
/**
* 依据机构获取便签统计数据
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET",value = "气瓶及标签数量比表-依据机构获取便签统计数据", notes = "气瓶及标签数量比表-依据机构获取便签统计数据")
@GetMapping(value = "/tagsStatisticsData")
public ResponseModel<List<Map<String, Object>>> selectForTagsStatisticsData(@RequestParam(value = "orgCode", required = false) String orgCode) {
return ResponseHelper.buildResponse(cylinderTagsDataUnitServiceImpl.selectForTagsStatisticsData(orgCode));
}
}
......@@ -2,13 +2,19 @@ package com.yeejoin.amos.boot.module.cylinder.flc.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.cylinder.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.TzBaseEnterpriseInfoServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CommonVideoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderInfoService;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderUnitVideoService;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderUnitServiceImpl;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -19,6 +25,8 @@ 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.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -40,8 +48,8 @@ public class CylinderUnitController extends BaseController {
ICylinderInfoService iCylinderInfoService;
@Autowired
ICylinderUnitVideoService icylinderUnitVideoService;
@Autowired
TzBaseEnterpriseInfoServiceImpl baseEnterpriseInfoService;
/**
* 通过regionCode查询气瓶企业
*
......@@ -51,7 +59,8 @@ public class CylinderUnitController extends BaseController {
@RequestMapping(value = "/queryCylinderUnitList", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "通过regionCode查询气瓶企业", notes = "通过regionCode查询气瓶企业")
public ResponseModel<List<CylinderUnitDto>> querySpecialEquipmentList(@RequestParam String regionCode) {
return ResponseHelper.buildResponse(cylinderUnitServiceImpl.getMessage(regionCode));
CompanyModel result = Privilege.companyClient.queryByCompanyCode(regionCode).getResult();
return ResponseHelper.buildResponse(cylinderUnitServiceImpl.getMessage(result.getOrgCode()));
// List<CylinderUnit> unitList = cylinderUnitServiceImpl
// .list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionCode));
//
......@@ -82,11 +91,17 @@ public class CylinderUnitController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getUnitInfo")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个气瓶企业信息", notes = "根据sequenceNbr查询单个气瓶企业信息")
public ResponseModel<CylinderUnitDto> selectOne(@RequestParam Long id) {
CylinderUnitDto unit = cylinderUnitServiceImpl.queryBySeq(id);
public ResponseModel<CylinderUnitDto> selectOne(@RequestParam("id") Long id) throws IOException {
TzBaseEnterpriseInfo tzBaseEnterpriseInfoDto = baseEnterpriseInfoService.getById(id);
CylinderUnitDto unit = new CylinderUnitDto();
BeanUtils.copyProperties(tzBaseEnterpriseInfoDto, unit);
unit.setAddress(tzBaseEnterpriseInfoDto.getAddress());
unit.setUnitName(tzBaseEnterpriseInfoDto.getUseUnit());
unit.setEvaluate("★★★★★");
unit.setCreditCode(tzBaseEnterpriseInfoDto.getUseCode());
// 查询气瓶数量以及过期数量
Map<String, String> cylinderInfo = iCylinderInfoService.queryNumAndOutOfDateNum(unit.getSequenceNbr());
Map<String, String> cylinderInfo = iCylinderInfoService.queryNumAndOutOfDateNum(tzBaseEnterpriseInfoDto.getUseCode());
int num = cylinderUnitServiceImpl.getWarnNumByAppId(unit.getAppId());
if (cylinderInfo != null) {
......
package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.module.cylinder.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.cylinder.api.service.ITzBaseEnterpriseInfoService;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESCylinderFillingRecordRepository;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderAreaDataDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoStatisticsDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import joptsimple.internal.Strings;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -28,8 +46,7 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -51,6 +68,8 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
@Autowired
ESCylinderFillingRecordRepository esCylinderFillingRecordRepository;
@Autowired
ITzBaseEnterpriseInfoService iTzBaseEnterpriseInfoService;
/**
* 分页查询
*/
......@@ -247,4 +266,400 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
esCylinderFillingRecordRepository.saveAll(dtoList);
return "success";
}
public List<Map<String, Object>> getCylinderStatisticsData(String regionCode) throws IOException {
// 构建搜索请求
CompanyModel result = Privilege.companyClient.queryByCompanyCode(regionCode).getResult();
String orgCode = result.getOrgCode();
SearchRequest searchRequest = new SearchRequest("idx_biz_view_jg_all"); // 替换为你的索引名
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
// 构建查询条件
searchSourceBuilder.query(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"))
.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_CODE", orgCode)) // 假设你只匹配以50开头的ORG_BRANCH_CODE
);
TermsAggregationBuilder aggregation = AggregationBuilders.terms("USE_UNIT_CREDIT_CODE").field("USE_UNIT_CREDIT_CODE.keyword").size(10); // 注意:.keyword后缀可能根据你的字段映射而有所不同
searchSourceBuilder.aggregation(aggregation);
searchRequest.source(searchSourceBuilder);
// 执行搜索并获取响应
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
// 处理聚合结果
// 这里只是打印出聚合的名称和桶的数量,你需要根据自己的需求来处理这些数据
Terms terms = searchResponse.getAggregations().get("USE_UNIT_CREDIT_CODE");
List<Map<String, Object>> dataList = new ArrayList<>();
List<String> keys = new ArrayList<>();
for (Terms.Bucket bucket : terms.getBuckets()) {
Map<String, Object> item = new HashMap<>();
item.put("count", bucket.getDocCount());
item.put("key", bucket.getKeyAsString());
dataList.add(item);
keys.add(bucket.getKeyAsString());
}
List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoDtos = iTzBaseEnterpriseInfoService.queryByUseCode(keys);
Map<String, TzBaseEnterpriseInfoDto> collect = tzBaseEnterpriseInfoDtos.stream().collect(Collectors.toMap(TzBaseEnterpriseInfoDto::getUseCode, f -> f));
for (Map<String, Object> item : dataList) {
Object key = item.get("key");
if (collect.containsKey(key)) {
item.put("name", collect.get(key).getUseUnit());
item.put("city", collect.get(key).getCity());
item.put("province", collect.get(key).getProvince());
item.put("district", collect.get(key).getDistrict());
}
}
return dataList;
}
public Map<String, Object> getChildEarlyWarning(String regionCode) throws Exception {
List<RegionModel> regionModels = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(regionCode)).getResult();
List<Map> list = new ArrayList<>();
List<String> collect = regionModels.stream().map(c -> c.getRegionCode().toString()).collect(Collectors.toList());
List<CompanyModel> companyModelList = Privilege.companyClient.queryListByCompanyCode(Strings.join(collect, ",")).getResult();
Map<String, CompanyModel> companyMap = companyModelList.stream().collect(Collectors.toMap(CompanyModel::getCompanyCode, c -> c));
Set<String> legendData = new HashSet<>();
List<String> xdata = new ArrayList<>();
List<String> xuke = new ArrayList<>();
List<String> shiyongdengji = new ArrayList<>();
List<String> jianyanchaoqi = new ArrayList<>();
List<String> jianyanhege = new ArrayList<>();
List<String> czjc = new ArrayList<>();
List<String> czjchege = new ArrayList<>();
// List<String> renyuan = new ArrayList<>();
legendData.add("许可有效率");
legendData.add("使用登记办理率");
legendData.add("检验超期率");
legendData.add("检验合格率");
legendData.add("充装检查率");
legendData.add("充装检查合格率");
for (RegionModel region : regionModels) {
CompanyModel companyModel = companyMap.get(region.getRegionCode().toString());
if (ObjectUtils.isEmpty(companyModel)) {
continue;
}
// 是否有充装企业在指定区域下
Boolean isHavingUnitInRegion = true;
String orgCode = companyModel.getOrgCode();
xdata.add(region.getRegionName());
// 1.许可有效率
if (!ValidationUtil.isEmpty(companyModel)) {
String value = this.getLicenseEfficiencyByRegion(orgCode);
xuke.add(value);
// isHavingUnitInRegion = this.setNoUnitDataStaticInfo(list, value);
}
if (!ValidationUtil.isEmpty(orgCode) && !isHavingUnitInRegion) {
shiyongdengji.add("0");
jianyanchaoqi.add("0");
jianyanhege.add("0");shiyongdengji.add("0");
czjc.add("0");
czjchege.add("0");
continue;
}
// 2.使用登记办理率
shiyongdengji.add("100");
// 3.检验超期率
jianyanchaoqi.add(this.getBaseMapper().getInspectionExpiredRate(orgCode, null).get("expiredRate").toString());
// 4.检验合格率
jianyanhege.add(this.getBaseMapper().getInspectionResultRate(orgCode, null).get("resultRate").toString());
// 5.充装检查率
long totalAll = searchEsCount(false, false, orgCode, null);
long totalCheck = searchEsCount(true, false, orgCode, null);
long totalResult = searchEsCount(false, true, orgCode, null);
if (totalAll != 0) {
czjc.add(new DecimalFormat("#.00").format(((double) totalCheck / totalAll) * 100));
} else {
czjc.add("0");
}
// 6.充装检查合格率
if (totalAll != 0) {
czjchege.add(new DecimalFormat("#.00").format(((double) totalResult / totalAll) * 100));
} else {
czjchege.add("0");
}
}
Map<String, Object> result = new HashMap<>();
result.put("xdata", xdata);
result.put("legendData", legendData);
result.put("xuke", xuke);
result.put("shiyongdengji", shiyongdengji);
result.put("jianyanchaoqi", jianyanchaoqi);
result.put("jianyanhege", jianyanhege);
result.put("czjc", czjc);
result.put("czjchege", czjchege);
return result;
}
public Map getChildWarning(String regionCode) {
Map<String, Object> result = Maps.newHashMap();
// 是否有充装企业在指定区域下
Boolean isHavingUnitInRegion = true;
List<Map<String, Object>> list = Lists.newArrayList();
Map<String, Object> result1 = Maps.newHashMap();
Map<String, Object> result2 = Maps.newHashMap();
// 1.许可有效率
if (!ValidationUtil.isEmpty(regionCode)) {
result1.put("name", "许可有效率(%)");
result1.put("value", this.getLicenseEfficiencyByRegion(regionCode));
isHavingUnitInRegion = this.setNoUnitDataStaticInfo(list, result1.get("value").toString());
}
if (!ValidationUtil.isEmpty(regionCode) && !isHavingUnitInRegion) {
list.add(result1);
result.put(regionCode, list);
return result;
}
// 2.使用登记办理率
result2.put("name", "使用登记办理率(%)");
result2.put("value", "100");
// 3.检验超期率
Map<String, Object> result3 = Maps.newHashMap();
result3.put("name", "检验超期率(%)");
result3.put("value", this.getBaseMapper().getInspectionExpiredRate(regionCode, null).get("expiredRate").toString());
// 4.检验合格率
Map<String, Object> result4 = Maps.newHashMap();
result4.put("name", "检验合格率(%)");
result4.put("value", this.getBaseMapper().getInspectionResultRate(regionCode, null).get("resultRate").toString());
// 5.充装检查率
Map<String, Object> result5 = Maps.newHashMap();
long totalAll = searchEsCount(false, false, regionCode, null);
long totalCheck = searchEsCount(true, false, regionCode, null);
long totalResult = searchEsCount(false, true, regionCode, null);
result5.put("name", "充装检查率(%)");
if (totalAll != 0) {
result5.put("value", new DecimalFormat("#.00").format(((double) totalCheck / totalAll) * 100));
} else {
result5.put("value", 0);
}
// 6.充装检查合格率
Map<String, Object> result6 = Maps.newHashMap();
result6.put("name", "充装检查合格率(%)");
if (totalAll != 0) {
result6.put("value", new DecimalFormat("#.00").format(((double) totalResult / totalAll) * 100));
} else {
result6.put("value", 0);
}
// list中按以下固定顺序返回给前端
list.add(result1);
list.add(result3);
list.add(result5);
list.add(result2);
list.add(result4);
list.add(result6);
result.put(regionCode, list);
return result;
}
public Map<String, Object> getCylinderStatisticsDataByCity(String regionCode) throws Exception {
// 构建搜索请求
List<RegionModel> regionList = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(regionCode)).getResult();
List<String> companyCode = regionList.stream().map(r -> r.getRegionCode().toString()).collect(Collectors.toList());
List<CompanyModel> companyList = Privilege.companyClient.queryListByCompanyCode(String.join(",", companyCode)).getResult();
Map<String, RegionModel> regionMap = regionList.stream().collect(Collectors.toMap(r ->r.getRegionCode().toString(), r -> r));
List<Map<String, Object>> legendData = new ArrayList<>();
List<String> xdata = new ArrayList<>();
List<String> qiping = new ArrayList<>();
List<String> qizhan = new ArrayList<>();
long maxValue = 0;
for (CompanyModel comapany : companyList) {
String orgCode = comapany.getOrgCode();
xdata.add(regionMap.get(comapany.getCompanyCode()).getRegionName());
SearchRequest searchRequest = new SearchRequest("idx_biz_view_jg_all"); // 替换为你的索引名
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
// 构建查询条件
searchSourceBuilder.query(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"))
.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_CODE", orgCode)) // 假设你只匹配以50开头的ORG_BRANCH_CODE
);
TermsAggregationBuilder aggregation = AggregationBuilders.terms("ORG_BRANCH_CODE").field("ORG_BRANCH_CODE.keyword").size(10); // 注意:.keyword后缀可能根据你的字段映射而有所不同
searchSourceBuilder.aggregation(aggregation);
searchRequest.source(searchSourceBuilder);
// 执行搜索并获取响应
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
// 处理聚合结果
// 这里只是打印出聚合的名称和桶的数量,你需要根据自己的需求来处理这些数据
Terms terms = searchResponse.getAggregations().get("ORG_BRANCH_CODE");
if (!ObjectUtils.isEmpty(terms.getBuckets())) {
if (terms.getBuckets().get(0).getDocCount() > maxValue) {
maxValue = terms.getBuckets().get(0).getDocCount();
}
qiping.add( terms.getBuckets().get(0).getDocCount() + "");
} else {
qiping.add( "0");
}
}
if (maxValue > 100000) {
for (int i = 0; i < qiping.size(); i++) {
qiping.set(i, String.format("%.4f", Long.parseLong(qiping.get(i)) / 10000.0000) + "");
}
}
List<String> orgCodes = companyList.stream().map(c -> c.getOrgCode()).collect(Collectors.toList());
List<Map<String, Object>> qizhanMap = this.baseMapper.getQiZhanStatisticsDataByCity(orgCodes);
Map<Object, Object> collect = qizhanMap.stream().collect(Collectors.toMap(m -> ((Map) m).get("orgCode"), m -> ((Map) m).get("unitCount")));
for (CompanyModel comapany : companyList) {
String orgCode = comapany.getOrgCode();
if (collect.containsKey(orgCode)) {
qizhan.add(collect.get(orgCode).toString());
} else {
qizhan.add("0");
}
}
Map<String, Object> qiLegend = new HashMap<>();
if (maxValue > 100000) {
qiLegend.put("value", "气瓶数量(万)");
qiLegend.put("dataKey", "qiping");
} else {
qiLegend.put("value", "气瓶数量");
qiLegend.put("dataKey", "qiping");
}
Map<String, Object> zhanLegend = new HashMap<>();
zhanLegend.put("value", "气站数量");
zhanLegend.put("dataKey", "qizhan");
legendData.add(qiLegend);
legendData.add(zhanLegend);
Map<String, Object> result = new HashMap<>();
result.put("qizhan", qizhan);
result.put("qiping", qiping);
result.put("xdata", xdata);
result.put("legendData", legendData);
return result;
}
public Map<String, Object> getCylinderStatisticsDataByCityForTotal(String regionCode) throws IOException {
// 构建搜索请求
CompanyModel comapany = Privilege.companyClient.queryByCompanyCode(regionCode).getResult();
String orgCode = comapany.getOrgCode();
SearchRequest searchRequest = new SearchRequest("idx_biz_view_jg_all"); // 替换为你的索引名
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
long qiping = 0;
// 构建查询条件
searchSourceBuilder.query(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"))
.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_CODE", orgCode)) // 假设你只匹配以50开头的ORG_BRANCH_CODE
);
TermsAggregationBuilder aggregation = AggregationBuilders.terms("ORG_BRANCH_CODE").field("ORG_BRANCH_CODE.keyword").size(10); // 注意:.keyword后缀可能根据你的字段映射而有所不同
searchSourceBuilder.aggregation(aggregation);
searchRequest.source(searchSourceBuilder);
// 执行搜索并获取响应
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
// 处理聚合结果
// 这里只是打印出聚合的名称和桶的数量,你需要根据自己的需求来处理这些数据
Terms terms = searchResponse.getAggregations().get("ORG_BRANCH_CODE");
if (!ObjectUtils.isEmpty(terms.getBuckets())) {
qiping = terms.getBuckets().get(0).getDocCount() ;
} else {
qiping = 0;
}
List<String> orgCodes = new ArrayList<>();
orgCodes.add(orgCode);
List<Map<String, Object>> qizhanMap = this.baseMapper.getQiZhanStatisticsDataByCity(orgCodes);
String unitNumber = "0";
if (!ObjectUtils.isEmpty(qizhanMap)) {
unitNumber = qizhanMap.get(0).get("unitCount").toString();
}
Map<String, Object> result = new HashMap<>();
result.put("cylindersCount", qiping);
result.put("stationCount", unitNumber);
result.put("operatorCount", 0);
return result;
}
public List<Map<String, Object>> getCylinderStatisticsDataByCityForMap(String regionCode) throws Exception {
// 构建搜索请求
List<RegionModel> regionList = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(regionCode)).getResult();
List<String> companyCode = regionList.stream().map(r -> r.getRegionCode().toString()).collect(Collectors.toList());
List<CompanyModel> companyList = Privilege.companyClient.queryListByCompanyCode(String.join(",", companyCode)).getResult();
Map<String, RegionModel> regionMap = regionList.stream().collect(Collectors.toMap(r ->r.getRegionCode().toString(), r -> r));
List<Map<String, Object>> list = new ArrayList<>();
if (ObjectUtils.isEmpty(companyList)) {
return new ArrayList<>();
}
List<String> orgCodes = companyList.stream().map(CompanyModel::getOrgCode).collect(Collectors.toList());
List<Map<String, Object>> qizhanMap = this.baseMapper.getQiZhanStatisticsDataByCity(orgCodes);
Map<Object, Object> collect = qizhanMap.stream().collect(Collectors.toMap(m -> ((Map) m).get("orgCode"), m -> ((Map) m).get("unitCount")));
for (CompanyModel company : companyList) {
String orgCode = company.getOrgCode();
SearchRequest searchRequest = new SearchRequest("idx_biz_view_jg_all"); // 替换为你的索引名
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
long qiping = 0;
// 构建查询条件
searchSourceBuilder.query(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"))
.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_CODE", orgCode)) // 假设你只匹配以50开头的ORG_BRANCH_CODE
);
TermsAggregationBuilder aggregation = AggregationBuilders.terms("ORG_BRANCH_CODE").field("ORG_BRANCH_CODE.keyword").size(10); // 注意:.keyword后缀可能根据你的字段映射而有所不同
searchSourceBuilder.aggregation(aggregation);
searchRequest.source(searchSourceBuilder);
// 执行搜索并获取响应
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
// 处理聚合结果
// 这里只是打印出聚合的名称和桶的数量,你需要根据自己的需求来处理这些数据
Terms terms = searchResponse.getAggregations().get("ORG_BRANCH_CODE");
if (!ObjectUtils.isEmpty(terms.getBuckets())) {
qiping = terms.getBuckets().get(0).getDocCount() ;
} else {
qiping = 0;
}
String unitNumber = "0";
if (!ObjectUtils.isEmpty(collect) && collect.containsKey("orgCode")) {
unitNumber = collect.get("orgCode").toString();
}
Map<String, Object> result = new HashMap<>();
RegionModel region = regionMap.get(company.getCompanyCode());
result.put("regionAddress", company.getAddress());
result.put("regionCode", company.getCompanyCode());
result.put("regionName", region.getRegionName());
result.put("longitude", company.getLongitude());
result.put("latitude", company.getLatitude());
result.put("stationCount", unitNumber);
result.put("cylindersCount", qiping);
result.put("operatorCount", 0);
list.add(result);
}
return list;
}
}
\ No newline at end of file
......@@ -28,6 +28,8 @@ import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnit;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderInfoMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderInfoService;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
......@@ -40,8 +42,10 @@ import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.ParsedCardinality;
import org.elasticsearch.search.aggregations.metrics.Sum;
import org.elasticsearch.search.builder.SearchSourceBuilder;
......@@ -49,6 +53,8 @@ import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -89,6 +95,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
public static final String SEQUENCE_NBR = "sequenceNbr";
public static final String TOTAL_FILLING_QUANTITY = "total_filling_quantity";
private static final String INDEX_NAME = "cylinder_filling";
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
......@@ -236,8 +245,28 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
public Map<String, String> queryNumAndOutOfDateNum(String unitCode) throws IOException {
SearchRequest searchRequest = new SearchRequest("idx_biz_view_jg_all"); // 替换为你的索引名
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
// 构建查询条件
searchSourceBuilder.query(
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", "2300"))
.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE ", unitCode)) // 假设你只匹配以50开头的ORG_BRANCH_CODE
);
searchSourceBuilder.size(1000);
searchRequest.source(searchSourceBuilder);
// 执行搜索并获取响应
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
SearchHits hits = searchResponse.getHits();
int cylinderNum = hits.getHits().length;
Map<String, String> result = baseMapper.queryNumAndOutOfDateNum(unitCode);
result.put("cylinderNum", cylinderNum + "");
return result;
}
/**
......@@ -1464,4 +1493,36 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
}
public List<CylinderFillingRecordStatisticsDto> fillingTimesAndQuantity(String reginCode) {
String orgCode = null;
CompanyModel result = Privilege.companyClient.queryByCompanyCode(reginCode).getResult();
orgCode = result.getOrgCode();
List<String> times = new ArrayList<>();
Date currentDate = new Date();
for (int i =0; i < 30; i++) {
Date date = new Date(currentDate.getTime() - i * 24 * 60 * 60 * 1000);
times.add(sdf.format(date));
}
Date date = new Date(currentDate.getTime() - 29 * 24 * 60 * 60 * 1000);
List<CylinderFillingRecordStatisticsDto> fillingRecord = baseMapper.queryFillingRecordByOrgCode(orgCode, sdf.format(date));
List<CylinderFillingRecordStatisticsDto> offloading = baseMapper.queryoffloadingByOrgCode(orgCode, sdf.format(date));
if (fillingRecord == null) {
fillingRecord = new ArrayList<>(0);
}
if (offloading == null) {
offloading = new ArrayList<>(0);
}
Map<String, String> fillingRecordMap = fillingRecord.stream().collect(Collectors.toMap(CylinderFillingRecordStatisticsDto::getTime, f -> f.getFillingQuantity()));
Map<String, String> offloadingMap = offloading.stream().collect(Collectors.toMap(CylinderFillingRecordStatisticsDto::getTime, f -> f.getOffloadingVolume()));
List<CylinderFillingRecordStatisticsDto> data = new ArrayList<>();
for (String key : times) {
CylinderFillingRecordStatisticsDto dayData = new CylinderFillingRecordStatisticsDto();
dayData.setTime(key);
dayData.setFillingQuantity(fillingRecordMap.getOrDefault(key, "0"));
dayData.setOffloadingVolume(offloadingMap.getOrDefault(key, "0"));
data.add(dayData);
}
return data;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import com.yeejoin.amos.boot.module.cylinder.api.enums.TagTypeEnums;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderTagsDataUnit;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderTagsDataUnitMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderTagsDataUnitService;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderTagsDataUnitDto;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 气瓶及标签数量比表-企业服务实现类
......@@ -30,4 +38,29 @@ public class CylinderTagsDataUnitServiceImpl extends BaseService<CylinderTagsDat
public List<CylinderTagsDataUnitDto> queryForCylinderTagsDataUnitList() {
return this.queryForList("" , false);
}
public List<Map<String, Object>> selectForTagsStatisticsData(String regionCode) {
List<Map<String, Object>> result = new ArrayList<>();
if (ObjectUtils.isEmpty(regionCode)) {
Map<String, Object> stringObjectMap = this.getBaseMapper().selectForTagsStatisticsData(null);
return getTagTypeMaps(result, stringObjectMap);
}
CompanyModel company = Privilege.companyClient.queryByCompanyCode(regionCode).getResult();
if (ObjectUtils.isEmpty(company)) {
return null;
}
Map<String, Object> stringObjectMap = this.getBaseMapper().selectForTagsStatisticsData(company.getOrgCode());
return getTagTypeMaps(result, stringObjectMap);
}
private List<Map<String, Object>> getTagTypeMaps(List<Map<String, Object>> result, Map<String, Object> stringObjectMap) {
for (TagTypeEnums enums : TagTypeEnums.values()) {
Map<String, Object> item = new HashMap<>();
item.put("name", enums.getName());
item.put("value", stringObjectMap.get(enums.getKey()));
result.add(item);
}
return result;
}
}
\ No newline at end of file
......@@ -156,7 +156,7 @@ public class CylinderUnitServiceImpl extends BaseService<CylinderUnitDto, Cylind
}
public List<CylinderUnitDto> getMessage(String regionCode){
return baseMapper.getMessage(regionCode);
public List<CylinderUnitDto> getMessage(String orgCode){
return baseMapper.getMessage(orgCode);
}
}
\ No newline at end of file
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