Commit 594559b9 authored by 刘凡's avatar 刘凡

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register_to_0715

parents 7de04d0c 05c230dd
......@@ -4,4 +4,5 @@ public class Constant {
public static final String TOKEN_PREFIX = "OPENAPI_";
public static final String SECRETKEY = "tzs";
public static final String PASSWORD_ENCODE_KEY = "qaz";
}
......@@ -2,27 +2,38 @@ 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.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;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
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;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@RequestMapping(value = "/cylinder")
......@@ -47,6 +58,17 @@ public class CylinderController {
private TmCylinderTagsService cylinderTagsService;
@Autowired
private CylinderFillingDataValidationService cylinderFillingDataValidationService;
@Autowired
CylinderFillingMessageService cylinderFillingMessageService;
@Autowired
private EmqKeeper emqKeeper;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private TmCylinderOffloadingService cylinderOffloadingService;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "气瓶企业信息")
......@@ -90,17 +112,63 @@ 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) {
e.printStackTrace();
logger.error("液化气体气瓶充装信息上报,数据校验失败");
cylinderFillingMessage.setMessage(e.getMessage());
}
if (!ObjectUtils.isEmpty(validateResult)) {
cylinderFillingMessage.setCylinderNumber(validateResult.getCylinderNumber());
List<String> message = new ArrayList<>();
Integer errorNumber = 0;
JSONObject error = new JSONObject();
if (!ObjectUtils.isEmpty(validateResult.getBeforeErrorData())) {
errorNumber += validateResult.getBeforeErrorData().size();
error.put("充装前检查错误数据:", validateResult.getBeforeErrorData());
message.add("充装前检查数据异常气瓶数:" + validateResult.getBeforeErrorCylinderNumber());
}
if (!ObjectUtils.isEmpty(validateResult.getRecordErrorData())) {
errorNumber += validateResult.getRecordErrorData().size();
error.put("填充错误数据:", validateResult.getRecordErrorData());
message.add("充装记录数据异常气瓶数:" + validateResult.getRecordErrorCylinderNumber());
}
if (!ObjectUtils.isEmpty(validateResult.getAfterErrorData())) {
errorNumber += validateResult.getAfterErrorData().size();
error.put("充装后错误数据:", validateResult.getAfterErrorData());
message.add("充装后复查数据异常气瓶数:" + validateResult.getAfterErrorCylinderNumber());
}
if (errorNumber <= 0) {
message.add("液化气体气瓶充装信息成功数:" + validateResult.getSuccessCylinderNumber() + "条");
} else {
cylinderFillingMessage.setMessage(String.join("条; ", message));
CylinderFillingMessageModel cylinderFillingMessageModel = new CylinderFillingMessageModel();
BeanUtils.copyProperties(cylinderFillingMessage, cylinderFillingMessageModel);
cylinderFillingMessageService.createWithModel(cylinderFillingMessageModel);
emqKeeper.getMqttClient().publish("openapi/cylinder/filling", JSONObject.fromObject(cylinderFillingMessage).toString().getBytes(), 2, false);
cylinderFillingDataValidationService.validateFilling(jsonobject);
throw new BadRequest(error.toString());
}
} else {
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 = (TmCylinderFillingModelList) JSONObject.toBean(jsonobject,
TmCylinderFillingModelList.class, classMap);
TmCylinderFillingModelList cylinderFillingModelList = com.alibaba.fastjson.JSONObject.parseObject(fillingData, TmCylinderFillingModelList.class);
List<TmCylinderFillingModel> fillingBeforeList = cylinderFillingModelList.getFillingBefore();
List<TmCylinderFillingRecordModel> fillingList = cylinderFillingModelList.getFilling();
......@@ -111,6 +179,13 @@ public class CylinderController {
cylinderFillingService.createCylinderFillingBefore(fillingBeforeList);
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);
return ResponseHelper.buildResponse("OK");
}
......@@ -121,6 +196,14 @@ 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)
@ApiOperation(value = "气站卸液量记录数据")
@PostMapping(value = "/offloading")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> createCylinderOffloading(@RequestBody List<TmCylinderOffloadingModel> offloadingData) {
cylinderFillingDataValidationService.validateCylinderOffloadingData(offloadingData);
return ResponseHelper.buildResponse(cylinderOffloadingService.createCylinderOffloading(offloadingData));
}
}
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.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@AllArgsConstructor
@Getter
public enum CylinderOffloadingFieldEnum {
offloadingVolume(true, false),
creditCode(true, true),
syncDate(true, true),
syncState(true, false);
private final boolean isRequire;
private final boolean isUnique;
public static List<String> getAllRequireKeys() {
return Arrays.stream(values()).filter(e -> e.isRequire).map(Enum::name).collect(Collectors.toList());
}
public static List<String> getAllUniqueKeys() {
return Arrays.stream(values()).filter(e -> e.isUnique).map(Enum::name).collect(Collectors.toList());
}
}
......@@ -52,5 +52,10 @@ public class UniqueFieldsQueryBuilder implements QueryConditionBuilder{
queryWrapper.in("app_id", fillingBeforeList.stream().map(AbstractBaseEntity::getAppId).collect(Collectors.toList()));
queryWrapper.in("sequence_code", fillingBeforeList.stream().map(TmCylinderFillingCheck::getSequenceCode).collect(Collectors.toList()));
}
if (entity instanceof TmCylinderOffloading) {
List<TmCylinderOffloading> tmCylinderOffloadingList = (List<TmCylinderOffloading>) entityList;
queryWrapper.in("credit_code", tmCylinderOffloadingList.stream().map(TmCylinderOffloading::getCreditCode).collect(Collectors.toList()));
queryWrapper.in("statistics_sync_date", tmCylinderOffloadingList.stream().map(TmCylinderOffloading::getStatisticsSyncDate).collect(Collectors.toList()));
}
}
}
package com.yeejoin.amos.api.openapi.face.model;
import java.util.Date;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@Data
public abstract class AbstractBaseModel extends BaseModel{
......
package com.yeejoin.amos.api.openapi.face.model;
import java.io.Serializable;
import lombok.Data;
import java.io.Serializable;
@Data
public class BizTokenModel implements Serializable{
......@@ -18,15 +18,15 @@ public class BizTokenModel implements Serializable{
/**
* 应用编号
*/
private String appKey;
private String appKey = "AMOS_ADMIN";
/**
* 客户端标识
*/
private String product;
private String product = "AMOS-WEB-ADMIN";
/**
* 所属机构
*/
private String agencyCode;
private String agencyCode = "tzs";
/**
* 应用用户票据,唯一标识
*/
......
......@@ -6,6 +6,12 @@ import java.util.List;
@Data
public class CylinderFillingDataValidationResultModel {
private Integer cylinderNumber;
private Integer beforeErrorCylinderNumber;
private Integer recordErrorCylinderNumber;
private Integer afterErrorCylinderNumber;
private Integer successCylinderNumber;
private List<String> beforeErrorData;
private List<String> recordErrorData;
private List<String> afterErrorData;
......
package com.yeejoin.amos.api.openapi.face.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -19,7 +20,8 @@ public class TmCylinderFillingModel extends AbstractBaseModel{
private String isValid; //是否在检验有效期以内,严禁充装超期未检气瓶、非法改装或翻新及报废气瓶
private int same; //警示标签上印有的瓶装气体的名称及化学分子式应与气瓶钢印标志是否一致*
private int isRegulations; //气瓶外表面的颜色标志是否符合规定*
private int isComplianceWithGBT; //气瓶瓶阀的出气口螺纹型式是否符合GB/T15383的规定,即可燃气体用的瓶阀,出口螺纹应是内螺纹(左旋)*
@JSONField(name = "isComplianceWithGBT")
private int isComplianceWithgbt; //气瓶瓶阀的出气口螺纹型式是否符合GB/T15383的规定,即可燃气体用的瓶阀,出口螺纹应是内螺纹(左旋)*
private int haveStillPressure; //气瓶内有无剩余压力*
private int isComplete; //气瓶外表面有无裂纹、严重腐蚀、明显变形及其他严重外部损伤缺陷*
private int haveSecurityDocuments; //气瓶的安全附件齐全并符合安全要求
......
package com.yeejoin.amos.api.openapi.face.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
/**
* 气站卸液量记录表
* @author tb
*
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class TmCylinderOffloadingModel extends AbstractBaseModel {
private static final long serialVersionUID = 1L;
private String offloadingVolume; //卸液量(单位吨)
private String creditCode; //对接单位统一信用代码
protected String version = "v1"; //对接接口版本
@ApiModelProperty(value = "统计同步时间 yyyy-MM-dd")
private LocalDate statisticsSyncDate;
}
package com.yeejoin.amos.api.openapi.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.TmCylinderOffloading;
/**
*
* <pre>
* 气站卸液量记录表 Mapper 接口
* </pre>
*
* @author gwb
* @version $Id: TmCylinderOffloadingMapper.java, v 0.1 2024年7月5日 下午3:28:31 tb Exp $
*/
public interface TmCylinderOffloadingMapper extends BaseMapper<TmCylinderOffloading>
{
}
\ No newline at end of file
package com.yeejoin.amos.api.openapi.face.orm.entity;
import java.util.Date;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@Data
public abstract class AbstractBaseEntity extends BaseEntity{
......@@ -17,9 +15,9 @@ public abstract class AbstractBaseEntity extends BaseEntity{
*/
private static final long serialVersionUID = 1L;
@TableField("sync_date")
protected Date SyncDate;//同步时间 yyyy-MM-dd HH24:mi:ss
protected Date syncDate;//同步时间 yyyy-MM-dd HH24:mi:ss
@TableField("sync_state")
protected int SyncState;//同步状态(0-新增 1-更新 2-删除)
protected int syncState;//同步状态(0-新增 1-更新 2-删除)
/**
* 对接公司编码
*/
......
package com.yeejoin.amos.api.openapi.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
/**
* 气站卸液量记录表
* @author kinky
*
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("tm_cylinder_offloading")
public class TmCylinderOffloading extends AbstractBaseEntity{
private static final long serialVersionUID = 1L;
@TableField("offloading_volume")
private String offloadingVolume; //卸液量(单位吨)
@TableField("credit_code")
private String creditCode; //对接单位统一信用代码
@ApiModelProperty(value = "对接接口版本")
protected String version = "v1";
@ApiModelProperty(value = "统计同步时间 yyyy-MM-dd")
private LocalDate statisticsSyncDate;
}
......@@ -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> {
......
package com.yeejoin.amos.api.openapi.face.service;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.yeejoin.amos.api.openapi.constant.Constant;
import com.yeejoin.amos.api.openapi.face.model.BizTokenModel;
import com.yeejoin.amos.api.openapi.face.model.OpenapiBizTokenModel;
......@@ -18,7 +8,18 @@ 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;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.HashMap;
import java.util.List;
/**
......@@ -35,31 +36,29 @@ public class OpenapiBizTokenService extends BaseService<OpenapiBizTokenModel, Op
@Autowired
private RedisTemplate redisTemplate;
public static final String DEFAULT_PASSWORD = "a1234560";
public List<String> getServiceList() {
return baseMapper.getServiceList();
}
public String getByAppId(String appId) {
// TODO Auto-generated method stub
OpenapiBizToken openapiBizToken = baseMapper.getByAppId(appId);
IdPasswordAuthModel idPasswordAuthModel = new IdPasswordAuthModel();
idPasswordAuthModel.setLoginId(openapiBizToken.getUserName());
idPasswordAuthModel.setPassword(openapiBizToken.getPassWord());
idPasswordAuthModel.setLoginId(appId);
idPasswordAuthModel.setPassword(DesUtil.encode(DEFAULT_PASSWORD, Constant.PASSWORD_ENCODE_KEY));
BizTokenModel bizTokenModel = new BizTokenModel();
bizTokenModel.setAppKey(openapiBizToken.getAppKey());
bizTokenModel.setProduct(openapiBizToken.getProduct());
bizTokenModel.setAgencyCode(openapiBizToken.getAgencyCode());
bizTokenModel.setAppId(openapiBizToken.getAppId());
bizTokenModel.setApiCompanyCode(openapiBizToken.getApiCompanyCode());
RequestContext.setProduct(openapiBizToken.getProduct());
RequestContext.setAppKey(openapiBizToken.getAppKey());
bizTokenModel.setAppId(appId);
RequestContext.setProduct(bizTokenModel.getProduct());
RequestContext.setAppKey(bizTokenModel.getAppKey());
FeignClientResult<HashMap<String, Object>> responseModel = Privilege.authClient.idpassword(idPasswordAuthModel);
HashMap<String, Object> authModel = responseModel.getResult();
String token = (String) authModel.get("token");
bizTokenModel.setToken(token);
String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX,token);
this.redisTemplate.opsForValue().set(tokenKey,bizTokenModel);
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;
}
......
......@@ -81,6 +81,9 @@ public class SyncCylinderDataService {
@Autowired
TmCylinderInfoService tmCylinderInfoService;
@Autowired
CylinderOffloadingMapper cylinderOffloadingMapper;
@Value("${cylinder.filling.insert.topic:cylinder/filling/insert/topic}")
private String insertTopic;
......@@ -167,6 +170,7 @@ public class SyncCylinderDataService {
}
@DS("tzs")
public void createCylinderFillingRecord(List<ESCylinderFillingRecordDto> cylinderFillingRecord) {
if (!ObjectUtils.isEmpty(cylinderFillingRecord)) {
List<String> appIds = cylinderFillingRecord.stream().map(ESCylinderFillingRecordDto::getAppId).collect(Collectors.toList());
......@@ -260,4 +264,8 @@ public class SyncCylinderDataService {
}
}
public void syncCylinderOffloading(List<TmCylinderOffloadingModel> tmCylinderOffloadingList) {
List<CylinderOffloading> cylinderOffloadingList = Bean.toModels(tmCylinderOffloadingList, CylinderOffloading.class);
cylinderOffloadingMapper.saveOrUpdateBatch(cylinderOffloadingList);
}
}
......@@ -33,7 +33,6 @@ public class TmCylinderFillingCheckService extends MyBaseServiceImpl<TmCylinderF
private SyncCylinderDataService syncCylinderDataService;
@DSTransactional
@Transactional
public void createCylinderFillingAfter(List<TmCylinderFillingCheckModel> model) {
String appId = getAppId();
Date now = new Date();
......
......@@ -47,7 +47,6 @@ public class TmCylinderFillingRecordService extends MyBaseServiceImpl<TmCylinder
private SyncCylinderDataService syncCylinderDataService;
@DSTransactional
@Transactional(rollbackFor = Exception.class)
public void createCylinderFilling(List<TmCylinderFillingRecordModel> model) {
Date now = new Date();
String appId = getAppId();
......@@ -74,7 +73,7 @@ public class TmCylinderFillingRecordService extends MyBaseServiceImpl<TmCylinder
}
@DS("tzs")
private void syncCylinderFilling(List<TmCylinderFillingRecordModel> model) {
public void syncCylinderFilling(List<TmCylinderFillingRecordModel> model) {
syncCylinderDataService.syncCylinderFillingRecord(model);
ArrayList<ESCylinderFillingRecordDto> models = Bean.toModels(model, ESCylinderFillingRecordDto.class);
......
......@@ -33,7 +33,6 @@ public class TmCylinderFillingService extends MyBaseServiceImpl<TmCylinderFillin
private SyncCylinderDataService syncCylinderDataService;
@DSTransactional
@Transactional(rollbackFor = {java.lang.Exception.class})
public void createCylinderFillingBefore(List<TmCylinderFillingModel> model) {
Date now = new Date();
String appId = getAppId();
......
package com.yeejoin.amos.api.openapi.face.service;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.api.openapi.face.model.TmCylinderOffloadingModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.TmCylinderOffloadingMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.TmCylinderOffloading;
import com.yeejoin.amos.api.openapi.service.MyBaseServiceImpl;
import com.yeejoin.amos.api.openapi.util.MultiFieldKey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
/**
* <pre>
* 气站卸液量记录表 服务类
* </pre>
*
* @author gwb
* @version $Id: TmCylinderOffloadingService.java, v 0.1 2024年7月5日 下午3:28:55 tb Exp $
*/
@Component
@Slf4j
public class TmCylinderOffloadingService extends MyBaseServiceImpl<TmCylinderOffloadingModel, TmCylinderOffloading, TmCylinderOffloadingMapper> {
@Autowired
private SyncCylinderDataService syncCylinderDataService;
@DSTransactional
public String createCylinderOffloading(List<TmCylinderOffloadingModel> model) {
if (ValidationUtil.isEmpty(model))
throw new BadRequest("气站卸液量信息数据为空.");
String appId = getAppId();
Date now = new Date();
for (TmCylinderOffloadingModel tmCylinderOffloadingModel : model) {
tmCylinderOffloadingModel.setSequenceNbr(null);
tmCylinderOffloadingModel.setRecDate(now);
tmCylinderOffloadingModel.setAppId(appId);
LocalDate localDate = tmCylinderOffloadingModel.getSyncDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
tmCylinderOffloadingModel.setStatisticsSyncDate(localDate);
}
// 同步到业务库
syncCylinderOffloadingModel(model);
List<TmCylinderOffloading> tmCylinderOffloadingList = Bean.toModels(model, TmCylinderOffloading.class);
this.saveOrUpdateBatchByUniqueFields(
tmCylinderOffloadingList,
tmCylinderOffloading -> new LambdaQueryWrapper<TmCylinderOffloading>()
.eq(TmCylinderOffloading::getCreditCode, tmCylinderOffloading.getCreditCode())
.eq(TmCylinderOffloading::getStatisticsSyncDate, tmCylinderOffloading.getStatisticsSyncDate()),
entity -> new MultiFieldKey(entity.getCreditCode(), entity.getStatisticsSyncDate()),
"creditCode", "statisticsSyncDate");
return "OK";
}
/**
* 同步气站信息至气瓶服务
* @param model
*/
private void syncCylinderOffloadingModel(List<TmCylinderOffloadingModel> model) {
syncCylinderDataService.syncCylinderOffloading(model);
}
}
spring.profiles.active=vb
server.compression.enabled=true
spring.jackson.dateFormat=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=Asia/Shanghai
logging.config=classpath:logback-${spring.profiles.active}.xml
#设置文件上传的大小限制
......@@ -13,3 +14,8 @@ mybatis-plus.mapper-locations=classpath*:mapper/*Mapper.xml
mybatis-plus.type-aliases-super-type=org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity
mybatis-plus.global-config.db-config.id-type=ID_WORKER
spring.main.allow-bean-definition-overriding=true
amos.system.user.user-name=jg_admin
amos.system.user.password=a1234560
amos.system.user.product=AMOS_STUDIO_WEB
amos.system.user.app-key=AMOS_STUDIO
\ No newline at end of file
......@@ -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.boot.module.cylinder.api.dto;
import lombok.Data;
@Data
public class CylinderFillingMessage {
private String time;
private String fillingCompanyName;
private Integer cylinderNumber;
private String message;
private String appId;
}
package com.yeejoin.amos.boot.module.cylinder.api.dto;
import lombok.Data;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
@Data
public class CylinderFillingMessageModel extends BaseModel {
private String time;
private String fillingCompanyName;
private Integer cylinderNumber;
private String message;
private String appId;
private String orgCode;
}
package com.yeejoin.amos.boot.module.cylinder.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("iot_cylinder_filling_logs")
public class CylinderFillingMessageEntity extends BaseEntity {
@TableField("filling_date")
private String time;
@TableField("filling_company_name")
private String fillingCompanyName;
@TableField("cylinder_number")
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.boot.module.cylinder.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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 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.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.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@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;
......
......@@ -25,6 +25,9 @@ public class CylinderFillingCheck extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "气瓶唯一标识码")
private String sequenceCode;
@ApiModelProperty(value = "充装后复查ID")
private String fillingCheckId;
......
package com.yeejoin.amos.boot.module.cylinder.flc.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.time.LocalDate;
import java.util.Date;
/**
* 气站卸液量记录表
* @author kinky
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tz_cylinder_offloading")
public class CylinderOffloading extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableField("offloading_volume")
private String offloadingVolume; //卸液量(单位吨)
@TableField("credit_code")
private String creditCode; //对接单位统一信用代码
@ApiModelProperty(value = "对接接口版本")
protected String version = "v1";
@ApiModelProperty(value = "对接公司编码")
@TableField("app_id")
private String appId;
@ApiModelProperty(value = "同步时间 yyyy-MM-dd HH24:mi:ss")
private Date syncDate;
@ApiModelProperty(value = "统计同步时间 yyyy-MM-dd")
private LocalDate statisticsSyncDate;
@ApiModelProperty(value = "0-新增")
private Integer syncState;
}
......@@ -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);
}
package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderOffloading;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <pre>
* 气站卸液量记录表 Mapper 接口
* </pre>
*
* @author gwb
* @version $Id: TmCylinderOffloadingMapper.java, v 0.1 2024年7月5日 下午3:28:31 tb Exp $
*/
public interface CylinderOffloadingMapper extends BaseMapper<CylinderOffloading> {
void saveOrUpdateBatch(@Param("list") List<CylinderOffloading> cylinderOffloadingList);
}
\ No newline at end of file
......@@ -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.CylinderOffloadingMapper">
<insert id="saveOrUpdateBatch" parameterType="com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderOffloading">
INSERT INTO "tz_cylinder_offloading"(
sequence_nbr,
app_id,
offloading_volume,
rec_date,
rec_user_id,
sync_date,
sync_state,
version,
credit_code,
statistics_sync_date)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.sequenceNbr},
#{item.appId},
#{item.offloadingVolume},
#{item.recDate},
#{item.recUserId},
#{item.syncDate},
#{item.syncState},
#{item.version},
#{item.creditCode},
#{item.statisticsSyncDate})
</foreach>
on conflict (credit_code,statistics_sync_date) do update set
"app_id" = EXCLUDED."app_id",
"offloading_volume" = EXCLUDED."offloading_volume",
"rec_date" = EXCLUDED."rec_date",
"rec_user_id" = EXCLUDED."rec_user_id",
"sync_date" = EXCLUDED."sync_date",
"sync_state" = EXCLUDED."sync_state",
"version" = EXCLUDED."version",
"credit_code" = EXCLUDED."credit_code",
"statistics_sync_date" = EXCLUDED."statistics_sync_date"
</insert>
</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.org_code 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,15 @@ 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);
};
}
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.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderAreaDataServiceImpl;
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,10 +38,40 @@ 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")
public ResponseModel 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);
};
}
......@@ -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 regionCode) {
return ResponseHelper.buildResponse(cylinderTagsDataUnitServiceImpl.selectForTagsStatisticsData(regionCode));
}
}
......@@ -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) {
......
......@@ -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
......@@ -145,4 +145,9 @@ public class RegUnitInfoDto extends BaseDto {
@ApiModelProperty(value = "单位所在地是否为全国")
private String isNationwide;
/**
* 气站对接appId
*/
private String appId;
}
......@@ -204,4 +204,13 @@ public class RegUnitInfo extends BaseEntity {
*/
private String adminIdCardPhoto;
/**
* 单位是省内或省外。1省外
*/
private String isNationwide;
/**
* 气站对接appId
*/
private String appId;
}
......@@ -44,6 +44,7 @@ import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.commons.lang3.ObjectUtils;
......@@ -154,6 +155,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
*/
private static String PERSON_REGISTER_TYPE = "PERSON_REGISTER_TYPE";
public static final String SECRETKEY = "tzs";
public static final String FILLING_UNIT_TYPE = "1231";
public static final String DEFAULT_PASSWORD = "a1234560";
@Value("${org.filter.group.seq}")
private Long groupSeq;
......@@ -214,7 +219,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
model.getRegUnitIc().setUnitName(model.getName());
Bean.copyExistPropertis(model.getRegUnitIc(), regUnitIc);
regUnitIcService.saveOrUpdate(regUnitIc);
// 5.创建企业信息
// 5.创建企业信息:tz_base_enterprise_info
model.setAppId(regUnitInfo.getAppId());
this.createBaseEnterpriseInfo(model, EnterpriseEnums.QY_DW.getType());
if (!ObjectUtils.isEmpty(regUnitInfo.getAdminName())) {
regUnitInfo.setContactPerson(regUnitInfo.getAdminName());
......@@ -430,6 +436,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
baseEnterpriseInfo.setSyncDate(new Date());
baseEnterpriseInfo.setSyncState(0);
baseEnterpriseInfo.setAppId(regUnitInfo.getAppId());
LambdaQueryWrapper<TzBaseEnterpriseInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TzBaseEnterpriseInfo::getUseCode, regUnitInfo.getUnitCode());
tzBaseEnterpriseInfoService.saveOrUpdate(baseEnterpriseInfo, wrapper);
......@@ -911,7 +918,22 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
// tzsUserInfo.setAmosUserName(regUnitInfo.getAdminLoginName());
// tzsUserInfoService.save(tzsUserInfo);
// }
regUnitInfo.setAdminUserId(userResult.getResult().getUserId());
// 生成用户id
String adminUserId = userResult.getResult().getUserId();
// 省内充装单位1231:生成对接数据账号
if (Arrays.asList(units).contains(FILLING_UNIT_TYPE) && (ValidationUtil.isEmpty(regUnitInfo.getIsNationwide()) || "0".equals(regUnitInfo.getIsNationwide()))) {
AgencyUserModel shadowUser = new AgencyUserModel();
shadowUser.setUserId(adminUserId);
String appId = DesUtil.encode(adminUserId, SECRETKEY);
shadowUser.setUserName(appId);
shadowUser.setPassword(DEFAULT_PASSWORD);
Privilege.agencyUserClient.createLoginInfoAppId(shadowUser);
regUnitInfo.setAppId(appId);
}
regUnitInfo.setAdminUserId(adminUserId);
regUnitInfo.setAmosCompanySeq(companyInfo.getSequenceNbr().toString());
// 3.3 org_user 创建组织机构
OrgUsr org = new OrgUsr();
......@@ -919,8 +941,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
org.setBizOrgType(CommonConstant.BIZ_ORG_TYPE_COMPANY);
org.setBizOrgName(regUnitInfo.getName());
org.setRecDate(new Date());
org.setRecUserId(userResult.getResult().getUserId());
org.setRecUserName(userResult.getResult().getRealName());
org.setRecUserId(adminUserId);
org.setRecUserName(adminUserName);
org.setAmosOrgId(companyInfo.getSequenceNbr() + "");
org.setAmosOrgCode(companyInfo.getOrgCode());
iOrgUsrService.save(org);
......
......@@ -27,7 +27,7 @@
<springcloud.version>Hoxton.SR8</springcloud.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<tyboot-version>1.1.23-SNAPSHOT</tyboot-version>
<amos.version>1.10.8</amos.version>
<amos.version>1.10.8-TZS</amos.version>
<itext.version>7.1.1</itext.version>
<elasticsearch.version>7.15.2</elasticsearch.version>
</properties>
......
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