@@ -8,9 +8,7 @@ import javax.validation.constraints.NotNull; | |||
import javax.validation.constraints.Size; | |||
import cn.com.taiji.common.entity.StringPropertyUUIDEntity; | |||
import cn.com.taiji.core.entity.dict.basic.CardType; | |||
import cn.com.taiji.core.entity.dict.basic.DeviceVersion; | |||
import cn.com.taiji.core.entity.dict.basic.SourceType; | |||
import cn.com.taiji.core.entity.dict.basic.*; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@@ -71,6 +69,12 @@ public class DeviceQueryRecord extends StringPropertyUUIDEntity { | |||
@NotBlank | |||
@Column(name = "BINDING_FINISH_STATUS") | |||
private String bindingFinishStatus;//卡签绑定完成状态; | |||
@Column(name = "CARD_STATUS") | |||
private CardStatus cardStatus; | |||
@Column(name = "CARD_TYPE") | |||
private CardType cardType; | |||
@Column(name = "CARD_BALANCE") | |||
private Long cardBalance; | |||
// 签信息 | |||
@NotBlank | |||
@Size(max = 16) | |||
@@ -124,5 +128,6 @@ public class DeviceQueryRecord extends StringPropertyUUIDEntity { | |||
@NotBlank | |||
@Column(name = "OBU_VERSION") | |||
private String obuVersion;// obu版本号; | |||
@Column(name = "OBU_STATUS") | |||
private ObuStatus obuStatus; | |||
} |
@@ -2,8 +2,10 @@ package cn.com.taiji.iaw.api.ass; | |||
import javax.validation.Valid; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRecordRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRecordResponseDTO; | |||
import cn.com.taiji.iaw.dto.ass.CardObuQueryRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.CardObuQueryResponseDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryResponseDTO; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
@@ -26,9 +28,16 @@ public class DeviceQueryController extends MyValidController { | |||
@ApiOperation(value = "新增查询记录") | |||
@PostMapping(value = "/saveRecord") | |||
public ApiResponse<DeviceQueryRecordResponseDTO> saveRecord(@Valid @RequestBody DeviceQueryRecordRequestDTO reqDto) throws ManagerException { | |||
DeviceQueryRecordResponseDTO resDto = manager.saveRecord(reqDto); | |||
public ApiResponse<DeviceQueryResponseDTO> saveRecord(@Valid @RequestBody DeviceQueryRequestDTO reqDto) throws ManagerException { | |||
DeviceQueryResponseDTO resDto = manager.saveRecord(reqDto); | |||
return ApiResponse.of(resDto).setMessage("添加成功"); | |||
} | |||
@ApiOperation(value = "卡签信息查询") | |||
@PostMapping("/cardObuQuery") | |||
public ApiResponse<CardObuQueryResponseDTO> cardObuQuery(@Valid @RequestBody CardObuQueryRequestDTO req) throws ManagerException { | |||
CardObuQueryResponseDTO resDto = manager.cardObuQuery(req); | |||
return ApiResponse.of(resDto).setMessage("查询成功"); | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
package cn.com.taiji.iaw.dto.ass; | |||
import cn.com.taiji.common.valid.ViolationValidator; | |||
import cn.com.taiji.core.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* @author shake | |||
* @projectName CardObuQueryRequest | |||
* @date 2024/10/15 10:01 | |||
* @description 卡签查询请求 | |||
*/ | |||
@ApiModel(description = "卡签查询请求") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class CardObuQueryRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "卡号", required = true) | |||
private String cardId; | |||
@ApiModelProperty(value = "签号", required = true) | |||
private String obuId; | |||
@Override | |||
protected void validate(ViolationValidator validator) { | |||
validator.validFieldNotBlank("cardId", cardId); | |||
validator.validFieldNotBlank("obuId", obuId); | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
package cn.com.taiji.iaw.dto.ass; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import cn.com.taiji.core.entity.dict.basic.CardStatus; | |||
import cn.com.taiji.core.entity.dict.basic.CardType; | |||
import cn.com.taiji.core.entity.dict.basic.ObuStatus; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* @author shake | |||
* @projectName CardObuQueryRequest | |||
* @date 2024/10/15 10:01 | |||
* @description 卡签查询返回 | |||
*/ | |||
@ApiModel(description = "卡签查询返回") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class CardObuQueryResponseDTO extends BaseModel { | |||
@ApiModelProperty(value = "卡状态") | |||
private CardStatus cardStatus; | |||
@ApiModelProperty(value = "卡类型") | |||
private CardType cardType; | |||
@ApiModelProperty(value = "OBU状态") | |||
private ObuStatus obuStatus; | |||
} |
@@ -4,6 +4,9 @@ import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import javax.validation.constraints.Size; | |||
import cn.com.taiji.core.entity.dict.basic.CardStatus; | |||
import cn.com.taiji.core.entity.dict.basic.CardType; | |||
import cn.com.taiji.core.entity.dict.basic.ObuStatus; | |||
import org.springframework.validation.annotation.Validated; | |||
import cn.com.taiji.core.dto.AbstractBizRequestDTO; | |||
@@ -13,14 +16,12 @@ import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
import java.time.LocalDateTime; | |||
@ApiModel(description = "设备查询记录新增") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
@Validated | |||
public class DeviceQueryRecordRequestDTO extends AbstractBizRequestDTO { | |||
public class DeviceQueryRequestDTO extends AbstractBizRequestDTO { | |||
// 卡信息 | |||
@NotBlank | |||
@Size(max = 20) | |||
@@ -56,6 +57,14 @@ public class DeviceQueryRecordRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank | |||
@ApiModelProperty(value = "卡签绑定完成状态") | |||
private String bindingFinishStatus;//卡签绑定完成状态; | |||
@NotNull | |||
@ApiModelProperty(value = "卡状态") | |||
private CardStatus cardStatus; | |||
@NotNull | |||
@ApiModelProperty(value = "卡类型") | |||
private CardType cardType; | |||
@ApiModelProperty(value = "卡余额") | |||
private Long cardBalance; | |||
// 签信息 | |||
@NotBlank | |||
@Size(max = 16) | |||
@@ -109,4 +118,7 @@ public class DeviceQueryRecordRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank | |||
@ApiModelProperty(value = "obu版本号") | |||
private String obuVersion;// obu版本号; | |||
@NotNull | |||
@ApiModelProperty(value = "OBU状态") | |||
private ObuStatus obuStatus; | |||
} |
@@ -11,7 +11,7 @@ import lombok.experimental.Accessors; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class DeviceQueryRecordResponseDTO extends BaseModel { | |||
public class DeviceQueryResponseDTO extends BaseModel { | |||
@ApiModelProperty(value = "id") | |||
private String id; | |||
@@ -1,9 +1,13 @@ | |||
package cn.com.taiji.iaw.manager.ass; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRecordRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRecordResponseDTO; | |||
import cn.com.taiji.iaw.dto.ass.CardObuQueryRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.CardObuQueryResponseDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryResponseDTO; | |||
public interface DeviceQueryRecordManager { | |||
DeviceQueryRecordResponseDTO saveRecord(DeviceQueryRecordRequestDTO requestDTO) throws ServiceHandleException; | |||
DeviceQueryResponseDTO saveRecord(DeviceQueryRequestDTO requestDTO) throws ServiceHandleException; | |||
CardObuQueryResponseDTO cardObuQuery(CardObuQueryRequestDTO req); | |||
} |
@@ -1,14 +1,21 @@ | |||
package cn.com.taiji.iaw.manager.ass; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.core.entity.basic.QtkCardInfo; | |||
import cn.com.taiji.core.entity.basic.QtkObuInfo; | |||
import cn.com.taiji.core.entity.dict.basic.CardType; | |||
import cn.com.taiji.core.entity.managew.DeviceQueryRecord; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkCardInfoRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkObuInfoRepo; | |||
import cn.com.taiji.iaw.dto.ass.CardObuQueryRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.CardObuQueryResponseDTO; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import cn.com.taiji.core.repo.jpa.managew.DeviceQueryRecordRepo; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRecordRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRecordResponseDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.DeviceQueryResponseDTO; | |||
import cn.com.taiji.iaw.manager.AbstractCommManager; | |||
import java.time.LocalDateTime; | |||
@@ -21,21 +28,47 @@ public class DeviceQueryRecordManagerImpl extends AbstractCommManager implements | |||
@Autowired | |||
private DeviceQueryRecordRepo recordRepo; | |||
@Autowired | |||
private QtkCardInfoRepo cardInfoRepo; | |||
@Autowired | |||
private QtkObuInfoRepo obuInfoRepo; | |||
/** | |||
* 设备查询记录记录 | |||
*/ | |||
@Override | |||
@Transactional(rollbackFor = Exception.class) | |||
public DeviceQueryRecordResponseDTO saveRecord(DeviceQueryRecordRequestDTO requestDTO) throws ServiceHandleException { | |||
public DeviceQueryResponseDTO saveRecord(DeviceQueryRequestDTO requestDTO) throws ServiceHandleException { | |||
DeviceQueryRecord record = copyProperties(requestDTO, new DeviceQueryRecord()); | |||
record.setOpenId(findOpenIdByToken(requestDTO.getAccessToken())); | |||
record.setSourceType(requestDTO.getOrderSource()); | |||
record.setQueryTime(LocalDateTime.now()); | |||
recordRepo.save(record); | |||
DeviceQueryRecordResponseDTO resDTO = new DeviceQueryRecordResponseDTO(); | |||
DeviceQueryResponseDTO resDTO = new DeviceQueryResponseDTO(); | |||
resDTO.setId(record.getId()); | |||
return resDTO; | |||
} | |||
@Override | |||
public CardObuQueryResponseDTO cardObuQuery(CardObuQueryRequestDTO requestDTO) { | |||
// 1. 创建返回对象 | |||
CardObuQueryResponseDTO response = new CardObuQueryResponseDTO(); | |||
// 2. 根据卡号查询卡信息 | |||
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(requestDTO.getCardId()); | |||
// 可能会存在卡不存在的情况,所以,如果卡不存在,不报错,卡存在,则返回卡数据 | |||
if (cardInfo != null) { | |||
response.setCardStatus(cardInfo.getCardStatus()); | |||
response.setCardType(CardType.fromCode(cardInfo.getCardType())); | |||
} | |||
// 3. 根据OBU号查询OBU信息 | |||
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(requestDTO.getObuId()); | |||
if (obuInfo != null) { | |||
response.setObuStatus(obuInfo.getObuStatus()); | |||
} | |||
return response; | |||
} | |||
} |