Commit 653e2c84 authored by wujiang's avatar wujiang

修改特种设备bug

parent 7f0787ce
......@@ -123,4 +123,5 @@ public class RegUnitInfoDto extends BaseDto {
@ApiModelProperty(value = "平台用户id,平台创建用户后更新")
private String adminUserId;
}
......@@ -17,4 +17,26 @@ public interface ICylinderInfoService {
* @return
*/
Map<String, String> queryNumAndOutOfDateNum(Long unitId);
void synFillingUnloadData();
void synAreaData();
void addIntegrityData();
void getCylinderUnitInfo();
void getCylinderInfo();
void synUnitCylinderInfoData();
void synUnitCylinderFillingData();
void synUnitCylinderTagsData();
void synUnitIntegrityData();
void synUnitFillingCheckData();
void synFillingUnloadUnitData();
}
......@@ -15,7 +15,7 @@
WHERE
t.sequence_nbr IN ( SELECT max( tt.sequence_nbr ) FROM tz_cylinder_info tt GROUP BY tt.sequence_code )
AND u.sequence_nbr = #{sequenceNbr}
GROUP BY t.sequence_nbr
GROUP BY u.sequence_nbr
</select>
<sql id="selectAPPIdByRegionCode">
......
......@@ -5,18 +5,16 @@
<select id="getInfoByUseUnit"
resultType="com.yeejoin.amos.boot.module.tzs.api.dto.EquEnterDto">
SELECT
RI.sequence_nbr,
RI.use_org_code,
RI.equ_category,
RI.product_name,
UI.address
FROM
tz_jg_registration_info AS RI
LEFT JOIN tz_jg_use_info UI ON RI.sequence_code = UI.sequence_code
LEFT JOIN tz_base_enterprise_info EI ON EI.use_unit = #{useUnit}
WHERE
EI.use_code = RI.organization_code
SELECT
RI.sequence_nbr,
RI.use_org_code,
RI.equ_category,
RI.product_name,
UI.address
FROM tz_jg_registration_info RI
LEFT JOIN tz_jg_use_info UI ON RI.sequence_code = UI.sequence_code
LEFT JOIN tz_base_enterprise_info EI ON EI.use_code = UI.use_unit_credit_code
WHERE EI.use_unit =#{useUnit}
</select>
<select id="getInfo"
......
......@@ -30,6 +30,7 @@ import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.amos.boot.module.tzs.biz.listener.BaseEnterpriseMqTtlListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.CarcylUnitInspectMqTtlListener;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService;
/**
* <pre>
......@@ -71,6 +72,9 @@ public class AmosTzsApplication {
@Autowired
private PrivilegeCompanyDeleteListener privilegeCompanyDeleteListener;
@Autowired
ICylinderInfoService cylinderInfoServiceImpl;
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmosTzsApplication.class, args);
Environment env = context.getEnvironment();
......@@ -92,14 +96,30 @@ public class AmosTzsApplication {
public void initMqtt() throws MqttException {
emqKeeper.getMqttClient().subscribe("/idx/idx_biz_carcyl_unit_inspect", 1, carcylUnitInspectMqTtlListener);
emqKeeper.getMqttClient().subscribe("/tm/tz_base_enterprise_info", 1, baseEnterpriseMqTtlListener);
emqKeeper.getMqttClient().subscribe("/tz/privilege_company_add_update",1, privilegeCompanyUpdateAddListener);
emqKeeper.getMqttClient().subscribe("/tz/privilege_company_delete",1, privilegeCompanyDeleteListener);
emqKeeper.getMqttClient().subscribe("/tz/privilege_company_add_update", 1, privilegeCompanyUpdateAddListener);
emqKeeper.getMqttClient().subscribe("/tz/privilege_company_delete", 1, privilegeCompanyDeleteListener);
// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam", 1, examMqTtlListener);
// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam_record", 1, examMqTtRecordListener);
}
@Bean
public void initToken() {
new Thread(new Runnable() {
@Override
public void run() {
cylinderInfoServiceImpl.synFillingUnloadData();
cylinderInfoServiceImpl.synAreaData();
cylinderInfoServiceImpl.addIntegrityData();
cylinderInfoServiceImpl.getCylinderUnitInfo();
cylinderInfoServiceImpl.getCylinderInfo();
cylinderInfoServiceImpl.synUnitCylinderInfoData();
cylinderInfoServiceImpl.synUnitCylinderFillingData();
cylinderInfoServiceImpl.synUnitCylinderTagsData();
cylinderInfoServiceImpl.synUnitIntegrityData();
cylinderInfoServiceImpl.synUnitFillingCheckData();
cylinderInfoServiceImpl.synFillingUnloadUnitData();
}
}).start();
startPlatformTokenService.getToken();
}
}
......@@ -129,7 +129,8 @@ public class TzBaseEnterpriseInfoController {
});
IPage<TzBaseEnterpriseInfo> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
pageBean = new Page<>(0, Integer.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
......
......@@ -105,6 +105,7 @@ public class TzsAuthController extends BaseController {
map.put("regulator",company.getCompanyName());
}
map.put("company", company.getCompanyName());
map.put("companyId", company.getParentId()!=0L?company.getParentId():company.getSequenceNbr());
}
map.put("userName", result.getResult().getRealName());
}
......
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.yeejoin.amos.boot.module.tzs.biz.utils.DesUtil;
import com.yeejoin.amos.boot.module.tzs.biz.utils.RedisUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel;
import com.yeejoin.amos.component.robot.AmosRequestContext;
@Service
public class StartPlatformTokenService {
......@@ -34,17 +29,14 @@ public class StartPlatformTokenService {
@Autowired
RedisUtil redisUtil;
@Autowired
AmosRequestContext amosRequestContext;
public void getToken() {
RequestContext.setProduct(product);
RequestContext.setAppKey(appkey);
IdPasswordAuthModel authModel = new IdPasswordAuthModel();
authModel.setLoginId(user);
authModel.setPassword(DesUtil.encode(password, secretKey));
System.out.println("user:" + user);
System.out.println("secretKey:" + secretKey);
FeignClientResult<Map<String, String>> authResult = Privilege.authClient.idpassword(authModel);
String token = authResult.getResult().get("token");
String token = amosRequestContext.getToken();
System.out.println("token:" + token);
RequestContext.setToken(token);
redisUtil.set("platform_token", token);
......
......@@ -97,8 +97,19 @@ public class RegUnitInfoController extends BaseController {
if (ValidationUtil.isEmpty(unitCode)) {
throw new BadRequest("单位编码不能为空");
}
RegUnitInfoDto regUnitInfoDto = iRegUnitInfoService.unitCheck(unitCode, unitType,companyName);
return ResponseHelper.buildResponse(regUnitInfoDto);
try {
RegUnitInfoDto regUnitInfoDto = iRegUnitInfoService.unitCheck(unitCode, unitType,companyName);
return ResponseHelper.buildResponse(regUnitInfoDto);
}catch (Exception e) {
ResponseModel<RegUnitInfoDto> response = new ResponseModel<>();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
response.setResult(null);
response.setDevMessage(e.getMessage());
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.setTraceId(RequestContext.getTraceId());
response.setPath(request.getServletPath());
return response;
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
......
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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 com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -10,29 +32,40 @@ import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog;
import com.yeejoin.amos.boot.module.tzs.api.enums.EarlyWarningLevelEnum;
import com.yeejoin.amos.boot.module.tzs.api.mapper.ScheduleMapper;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.MsgLogServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzsAuthServiceImpl;
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.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.CylinderInfoDto;
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.CylinderInfoDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderIntegrityData;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderIntegrityDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderTags;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderTagsDataUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderUnitData;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderInfoMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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 java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
import lombok.extern.slf4j.Slf4j;
/**
* 气瓶基本信息服务实现类
......@@ -110,6 +143,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Autowired
StartPlatformTokenService startPlatformTokenService;
/**
* 分页查询
......@@ -218,28 +254,37 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionModel));
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>().like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println("====================regioncode: "+regionModel.getRegionCode()+"============================");
unitlist.forEach(t -> {
System.out.println("====================appId: "+t.getAppId()+"============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty=unitIntegirty==null?0d:unitIntegirty;
//tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
//tz_cylinder_info
tagIntegirty=tagIntegirty==null?0d:tagIntegirty;
//tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty=infoIntegirty==null?0d:infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
//tz_cylinder_filling 30天内
recordIntegirty=recordIntegirty==null?0d:recordIntegirty;
//tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty=fillingIntegirty==null?0d:fillingIntegirty;
//tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty=checkIntegirty==null?0d:checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty + checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
......@@ -258,9 +303,12 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: "+t.getUnitName()+"============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
......@@ -287,6 +335,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
......@@ -574,6 +623,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
......
......@@ -228,7 +228,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
FeignClientResult<CompanyModel> result =Privilege.companyClient.queryByCompanyName(companyName);
if(result.getResult()!=null)
{
throw new BadRequest("重复的公司名称");
throw new RuntimeException("重复的公司名称");
}
}
......
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