import javax.validation.constraints.Size; | import javax.validation.constraints.Size; | ||||
import cn.com.taiji.common.entity.StringPropertyUUIDEntity; | 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.Getter; | ||||
import lombok.Setter; | import lombok.Setter; | ||||
@NotBlank | @NotBlank | ||||
@Column(name = "BINDING_FINISH_STATUS") | @Column(name = "BINDING_FINISH_STATUS") | ||||
private String bindingFinishStatus;//卡签绑定完成状态; | 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 | @NotBlank | ||||
@Size(max = 16) | @Size(max = 16) | ||||
@NotBlank | @NotBlank | ||||
@Column(name = "OBU_VERSION") | @Column(name = "OBU_VERSION") | ||||
private String obuVersion;// obu版本号; | private String obuVersion;// obu版本号; | ||||
@Column(name = "OBU_STATUS") | |||||
private ObuStatus obuStatus; | |||||
} | } |
import javax.validation.Valid; | 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.beans.factory.annotation.Autowired; | ||||
import org.springframework.web.bind.annotation.PostMapping; | import org.springframework.web.bind.annotation.PostMapping; | ||||
import org.springframework.web.bind.annotation.RequestBody; | import org.springframework.web.bind.annotation.RequestBody; | ||||
@ApiOperation(value = "新增查询记录") | @ApiOperation(value = "新增查询记录") | ||||
@PostMapping(value = "/saveRecord") | @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("添加成功"); | 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("查询成功"); | |||||
} | |||||
} | } |
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); | |||||
} | |||||
} |
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; | |||||
} |
import javax.validation.constraints.NotNull; | import javax.validation.constraints.NotNull; | ||||
import javax.validation.constraints.Size; | 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 org.springframework.validation.annotation.Validated; | ||||
import cn.com.taiji.core.dto.AbstractBizRequestDTO; | import cn.com.taiji.core.dto.AbstractBizRequestDTO; | ||||
import lombok.Setter; | import lombok.Setter; | ||||
import lombok.experimental.Accessors; | import lombok.experimental.Accessors; | ||||
import java.time.LocalDateTime; | |||||
@ApiModel(description = "设备查询记录新增") | @ApiModel(description = "设备查询记录新增") | ||||
@Getter | @Getter | ||||
@Setter | @Setter | ||||
@Accessors(chain = true) | @Accessors(chain = true) | ||||
@Validated | @Validated | ||||
public class DeviceQueryRecordRequestDTO extends AbstractBizRequestDTO { | |||||
public class DeviceQueryRequestDTO extends AbstractBizRequestDTO { | |||||
// 卡信息 | // 卡信息 | ||||
@NotBlank | @NotBlank | ||||
@Size(max = 20) | @Size(max = 20) | ||||
@NotBlank | @NotBlank | ||||
@ApiModelProperty(value = "卡签绑定完成状态") | @ApiModelProperty(value = "卡签绑定完成状态") | ||||
private String bindingFinishStatus;//卡签绑定完成状态; | private String bindingFinishStatus;//卡签绑定完成状态; | ||||
@NotNull | |||||
@ApiModelProperty(value = "卡状态") | |||||
private CardStatus cardStatus; | |||||
@NotNull | |||||
@ApiModelProperty(value = "卡类型") | |||||
private CardType cardType; | |||||
@ApiModelProperty(value = "卡余额") | |||||
private Long cardBalance; | |||||
// 签信息 | // 签信息 | ||||
@NotBlank | @NotBlank | ||||
@Size(max = 16) | @Size(max = 16) | ||||
@NotBlank | @NotBlank | ||||
@ApiModelProperty(value = "obu版本号") | @ApiModelProperty(value = "obu版本号") | ||||
private String obuVersion;// obu版本号; | private String obuVersion;// obu版本号; | ||||
@NotNull | |||||
@ApiModelProperty(value = "OBU状态") | |||||
private ObuStatus obuStatus; | |||||
} | } |
@Getter | @Getter | ||||
@Setter | @Setter | ||||
@Accessors(chain = true) | @Accessors(chain = true) | ||||
public class DeviceQueryRecordResponseDTO extends BaseModel { | |||||
public class DeviceQueryResponseDTO extends BaseModel { | |||||
@ApiModelProperty(value = "id") | @ApiModelProperty(value = "id") | ||||
private String id; | private String id; | ||||
package cn.com.taiji.iaw.manager.ass; | package cn.com.taiji.iaw.manager.ass; | ||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | 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 { | public interface DeviceQueryRecordManager { | ||||
DeviceQueryRecordResponseDTO saveRecord(DeviceQueryRecordRequestDTO requestDTO) throws ServiceHandleException; | |||||
DeviceQueryResponseDTO saveRecord(DeviceQueryRequestDTO requestDTO) throws ServiceHandleException; | |||||
CardObuQueryResponseDTO cardObuQuery(CardObuQueryRequestDTO req); | |||||
} | } |
package cn.com.taiji.iaw.manager.ass; | package cn.com.taiji.iaw.manager.ass; | ||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | 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.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.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import cn.com.taiji.core.repo.jpa.managew.DeviceQueryRecordRepo; | 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 cn.com.taiji.iaw.manager.AbstractCommManager; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
@Autowired | @Autowired | ||||
private DeviceQueryRecordRepo recordRepo; | private DeviceQueryRecordRepo recordRepo; | ||||
@Autowired | |||||
private QtkCardInfoRepo cardInfoRepo; | |||||
@Autowired | |||||
private QtkObuInfoRepo obuInfoRepo; | |||||
/** | /** | ||||
* 设备查询记录记录 | * 设备查询记录记录 | ||||
*/ | */ | ||||
@Override | @Override | ||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public DeviceQueryRecordResponseDTO saveRecord(DeviceQueryRecordRequestDTO requestDTO) throws ServiceHandleException { | |||||
public DeviceQueryResponseDTO saveRecord(DeviceQueryRequestDTO requestDTO) throws ServiceHandleException { | |||||
DeviceQueryRecord record = copyProperties(requestDTO, new DeviceQueryRecord()); | DeviceQueryRecord record = copyProperties(requestDTO, new DeviceQueryRecord()); | ||||
record.setOpenId(findOpenIdByToken(requestDTO.getAccessToken())); | record.setOpenId(findOpenIdByToken(requestDTO.getAccessToken())); | ||||
record.setSourceType(requestDTO.getOrderSource()); | record.setSourceType(requestDTO.getOrderSource()); | ||||
record.setQueryTime(LocalDateTime.now()); | record.setQueryTime(LocalDateTime.now()); | ||||
recordRepo.save(record); | recordRepo.save(record); | ||||
DeviceQueryRecordResponseDTO resDTO = new DeviceQueryRecordResponseDTO(); | |||||
DeviceQueryResponseDTO resDTO = new DeviceQueryResponseDTO(); | |||||
resDTO.setId(record.getId()); | resDTO.setId(record.getId()); | ||||
return resDTO; | 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; | |||||
} | |||||
} | } |