Commit 05c230dd authored by 刘凡's avatar 刘凡

修改:新增气瓶接口

parent da353308
...@@ -8,11 +8,20 @@ import com.yeejoin.amos.boot.module.cylinder.api.mapper.CylinderFillingMessageMa ...@@ -8,11 +8,20 @@ import com.yeejoin.amos.boot.module.cylinder.api.mapper.CylinderFillingMessageMa
import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderFillingMessageEntity; import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderFillingMessageEntity;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; 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.springframework.stereotype.Component; import org.springframework.stereotype.Component;
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.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator; import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@Component @Component
public class CylinderFillingMessageService extends BaseService<CylinderFillingMessageModel, CylinderFillingMessageEntity, CylinderFillingMessageMapper> { public class CylinderFillingMessageService extends BaseService<CylinderFillingMessageModel, CylinderFillingMessageEntity, CylinderFillingMessageMapper> {
public IPage<CylinderFillingMessageModel> getUploadCylinderLogs(PageParam pageParam, String regionCode) { public IPage<CylinderFillingMessageModel> getUploadCylinderLogs(PageParam pageParam, String regionCode) {
...@@ -24,4 +33,6 @@ public class CylinderFillingMessageService extends BaseService<CylinderFillingMe ...@@ -24,4 +33,6 @@ public class CylinderFillingMessageService extends BaseService<CylinderFillingMe
public IPage<CylinderFillingMessageModel> getUploadCylinderLogsByOrgCode( Page<CylinderFillingMessageModel> page, @Condition(Operator.likeRight) String orgCode) { public IPage<CylinderFillingMessageModel> getUploadCylinderLogsByOrgCode( Page<CylinderFillingMessageModel> page, @Condition(Operator.likeRight) String orgCode) {
return queryForPage(page, null, false, orgCode); return queryForPage(page, null, false, orgCode);
} }
} }
...@@ -1465,4 +1465,6 @@ public class CylinderInfoController extends BaseController { ...@@ -1465,4 +1465,6 @@ public class CylinderInfoController extends BaseController {
IPage<CylinderFillingMessageModel> result = cylinderFillingMessageService.getUploadCylinderLogs(pageParam, regionCode); IPage<CylinderFillingMessageModel> result = cylinderFillingMessageService.getUploadCylinderLogs(pageParam, regionCode);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
}; };
} }
package com.yeejoin.amos.boot.module.cylinder.flc.biz.controller; package com.yeejoin.amos.boot.module.cylinder.flc.biz.controller;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderAreaDataServiceImpl; import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderAreaDataServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -57,4 +60,18 @@ public class CylinderStatisticsController { ...@@ -57,4 +60,18 @@ public class CylinderStatisticsController {
public ResponseModel testSaveCylinderFillingRecord2ES(){ public ResponseModel testSaveCylinderFillingRecord2ES(){
return ResponseHelper.buildResponse(service.testSaveCylinderFillingRecord2ES()); return ResponseHelper.buildResponse(service.testSaveCylinderFillingRecord2ES());
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "区域安全指数")
@PostMapping(value = "/security-index")
public ResponseModel<Map<String, Object>> getsecurityIndex(@RequestBody Map<String, Object> map ) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
}
Map<String, Object> result = service.getsecurityIndex(regionCode.toString());
return ResponseHelper.buildResponse(result);
};
} }
package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl; package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.cylinder.api.dto.ESEquipmentCategoryDto; 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.KeyValueDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.TzBaseEnterpriseInfoDto; import com.yeejoin.amos.boot.module.cylinder.api.dto.TzBaseEnterpriseInfoDto;
...@@ -356,8 +358,11 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -356,8 +358,11 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
// 1.许可有效率 // 1.许可有效率
if (!ValidationUtil.isEmpty(companyModel)) { if (!ValidationUtil.isEmpty(companyModel)) {
String value = this.getLicenseEfficiencyByRegion(orgCode); String value = this.getLicenseEfficiencyByRegion(orgCode);
xuke.add(value); if (NO_DATA_STR.equals(value)) {
// isHavingUnitInRegion = this.setNoUnitDataStaticInfo(list, value); xuke.add("0");
} else {
xuke.add(String.format("%.4f", Double.parseDouble(value) / 100.0000 ));
}
} }
if (!ValidationUtil.isEmpty(orgCode) && !isHavingUnitInRegion) { if (!ValidationUtil.isEmpty(orgCode) && !isHavingUnitInRegion) {
shiyongdengji.add("0"); shiyongdengji.add("0");
...@@ -368,23 +373,23 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -368,23 +373,23 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
continue; continue;
} }
// 2.使用登记办理率 // 2.使用登记办理率
shiyongdengji.add("100"); shiyongdengji.add("1");
// 3.检验超期率 // 3.检验超期率
jianyanchaoqi.add(this.getBaseMapper().getInspectionExpiredRate(orgCode, null).get("expiredRate").toString()); jianyanchaoqi.add(String.format("%.4f", Double.parseDouble(this.getBaseMapper().getInspectionExpiredRate(orgCode, null).get("expiredRate").toString()) / 100.0000));
// 4.检验合格率 // 4.检验合格率
jianyanhege.add(this.getBaseMapper().getInspectionResultRate(orgCode, null).get("resultRate").toString()); jianyanhege.add(String.format("%.4f", Double.parseDouble(this.getBaseMapper().getInspectionResultRate(orgCode, null).get("resultRate").toString()) / 100.0000));
// 5.充装检查率 // 5.充装检查率
long totalAll = searchEsCount(false, false, orgCode, null); long totalAll = searchEsCount(false, false, orgCode, null);
long totalCheck = searchEsCount(true, false, orgCode, null); long totalCheck = searchEsCount(true, false, orgCode, null);
long totalResult = searchEsCount(false, true, orgCode, null); long totalResult = searchEsCount(false, true, orgCode, null);
if (totalAll != 0) { if (totalAll != 0) {
czjc.add(new DecimalFormat("#.00").format(((double) totalCheck / totalAll) * 100)); czjc.add(new DecimalFormat("#.0000").format(((double) totalCheck / totalAll)));
} else { } else {
czjc.add("0"); czjc.add("0");
} }
// 6.充装检查合格率 // 6.充装检查合格率
if (totalAll != 0) { if (totalAll != 0) {
czjchege.add(new DecimalFormat("#.00").format(((double) totalResult / totalAll) * 100)); czjchege.add(new DecimalFormat("#.0000").format(((double) totalResult / totalAll)));
} else { } else {
czjchege.add("0"); czjchege.add("0");
} }
...@@ -662,4 +667,96 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -662,4 +667,96 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
return list; return list;
} }
public Map<String, Object> getsecurityIndex(String regionCode) throws Exception {
List<RegionModel> regionModels = Systemctl.regionClient.queryByParentRegionCode(Integer.parseInt(regionCode)).getResult();
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));
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<>();
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);
if (NO_DATA_STR.equals(value)) {
value = "0";
} else {
xuke.add(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);
List<String> ydata = new ArrayList<>();
for (int i = 0; i < xdata.size(); i++) {
// 计算xuke的加权值
double xukeWeighted = Double.parseDouble(xuke.get(i)) * 0.10; // 10%
// 剩余权重平均分配给四个因素,每个因素大约22.5%(但为了简化,我们这里用25%的剩余权重)
double remainingWeightPerFactor = 0.90 / 4; // 简化为每个因素25%的剩余权重
// 计算其他四个因素的加权值
double jianyanchaoqiWeighted = Double.parseDouble(jianyanchaoqi.get(i)) * remainingWeightPerFactor;
double jianyanhegeWeighted = Double.parseDouble(jianyanhege.get(i)) * remainingWeightPerFactor;
double czjcWeighted = Double.parseDouble(czjc.get(i)) * remainingWeightPerFactor;
double czjchegeWeighted = Double.parseDouble(czjchege.get(i)) * remainingWeightPerFactor;
// 计算总指数
double totalIndex = xukeWeighted + jianyanchaoqiWeighted + jianyanhegeWeighted + czjcWeighted + czjchegeWeighted;
ydata.add(String.format("%.2f", totalIndex));
}
result.put("ydata", ydata);
return result;
}
} }
\ 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