@@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.StringUtils; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
@@ -39,9 +38,6 @@ public class BlackManagerImpl extends AbstractIawManager implements BlackManager | |||
@Override | |||
public BlackQueryResponseDTO query(BlackQueryRequestDTO req) throws ManagerException { | |||
if (StringUtils.isEmpty(req.getCustomerId())){ | |||
throw new ManagerException("用户id必填!"); | |||
} | |||
List<BlackQueryModel> modelList = Lists.newArrayList(); | |||
//查询卡黑名单列表 | |||
List<BlackQueryModel> cardList = queryBlackCard(req); | |||
@@ -66,6 +62,9 @@ public class BlackManagerImpl extends AbstractIawManager implements BlackManager | |||
if(req.getOrderSource() == SourceType.SERVICE_HALL){ | |||
cardInfos = cardInfoRepo.listByAgencyIdAndVehicleId(findAgencyIdByToken(req.getAccessToken()),req.getVehicleId()); | |||
}else { | |||
if (StringUtils.isEmpty(req.getCustomerId())){ | |||
throw new ManagerException("用户id必填!"); | |||
} | |||
cardInfos = cardInfoRepo.listByCustomerIdAndVehicleId(req.getCustomerId(), req.getVehicleId()); | |||
} | |||
if (CollectionTools.isEmpty(cardInfos)){ | |||
@@ -99,6 +98,9 @@ public class BlackManagerImpl extends AbstractIawManager implements BlackManager | |||
if (req.getOrderSource() == SourceType.SERVICE_HALL){ | |||
obuInfos = obuInfoRepo.listByAgencyIdAndVehicleId(findAgencyIdByToken(req.getAccessToken()),req.getVehicleId()); | |||
}else{ | |||
if (StringUtils.isEmpty(req.getCustomerId())){ | |||
throw new ManagerException("用户id必填!"); | |||
} | |||
obuInfos = obuInfoRepo.listByCustomerIdAndVehicleId(req.getCustomerId(), req.getVehicleId()); | |||
} | |||
if (CollectionTools.isEmpty(obuInfos)){ |
@@ -12,6 +12,7 @@ import okhttp3.OkHttpClient; | |||
import okhttp3.Request; | |||
import okhttp3.Response; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.stereotype.Service; | |||
import java.io.IOException; | |||
@@ -25,9 +26,13 @@ import java.io.IOException; | |||
@Service | |||
public class GetWeChatOpenIdManager extends AbstractManager { | |||
private static final String appId = "wxa2d9acdd1054e69b"; | |||
@Value("${wx.newmini.appid}") | |||
private String appId; | |||
// private String appId = "wxa2d9acdd1054e69b"; | |||
private static final String secret = "03bb0a5ce08fe6ccfeca4b7fe485a61e"; | |||
@Value("${wx.newmini.secret}") | |||
private String secret; | |||
// private String secret = "03bb0a5ce08fe6ccfeca4b7fe485a61e"; | |||
private static final String url = "https://api.weixin.qq.com/sns/jscode2session"; | |||
@@ -23,7 +23,6 @@ import cn.com.taiji.core.model.comm.protocol.ods.ois.issue.OisBasicDataUpdateReq | |||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||
import cn.com.taiji.core.repo.jpa.basic.*; | |||
import cn.com.taiji.core.repo.jpa.log.BlsInterfaceLogRepo; | |||
import org.checkerframework.checker.units.qual.A; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
@@ -31,6 +30,7 @@ import org.springframework.util.StringUtils; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.List; | |||
@Service | |||
@@ -51,8 +51,9 @@ public class BlackCardInManager extends AbstractCommManager implements LogManage | |||
public AbstractBlsResponse serviceHandle(CardInRequest request) throws ServiceHandleException { | |||
try { | |||
long begin = System.currentTimeMillis(); | |||
LocalDateTime blackDate = LocalDateTime.now(); | |||
if (StringUtils.isEmpty(request.getOrgCode())) { | |||
throw GlyServiceError.NO_DATA_ERR.toHandleException("请求参数orgCode必填!"); | |||
throw GlyServiceError.FORMAT_VALIDATE_ERR.toHandleException("请求参数orgCode必填!"); | |||
} | |||
QtkBlackCard blackCard = null; | |||
//发送,调部中心接口 | |||
@@ -62,17 +63,18 @@ public class BlackCardInManager extends AbstractCommManager implements LogManage | |||
List<QtkBlackCard> blackCardList = blackCardRepo.queryByCardIdAndType(request.getCardId(), CardBlackType.fromCode(request.getType())); | |||
//可能已在部黑名单中,但本地无数据,本地无数据则新增一条 | |||
if (CollectionTools.isEmpty(blackCardList)) { | |||
blackCard = addBlackCard(request); | |||
blackCard = addBlackCard(request,blackDate); | |||
}else { | |||
blackCard = CollectionTools.extractOne(blackCardList); | |||
blackDate = blackCard.getCreateTime(); | |||
} | |||
//更新qtkCardInfo | |||
updateCardInfo(request); | |||
updateCardInfo(request,blackDate); | |||
} else { | |||
if (StringUtils.isEmpty(uploadResponse.getMsg())){ | |||
uploadResponse.setMsg("请重试!"); | |||
} | |||
throw GlyServiceError.NO_DATA_ERR.toHandleException(uploadResponse.getMsg()); | |||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException(uploadResponse.getMsg()); | |||
} | |||
//添加一条事务,方便定时器处理调用失败的情况 | |||
transactionManager.addTransaction(TransactionBizType.BLACK_CARD_SYNC, blackCard.getId(), 0, blackCard.getCardId()); | |||
@@ -83,6 +85,7 @@ public class BlackCardInManager extends AbstractCommManager implements LogManage | |||
} | |||
AbstractBlsResponse blsResponse = new AbstractBlsResponse(); | |||
blsResponse.setUploadStatus(1); | |||
blsResponse.setReceiveTime(blackDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))); | |||
return onSuccess(request, blsResponse, BlsInterfaceLog.class, System.currentTimeMillis() - begin); | |||
} catch (Exception e) { | |||
logger.error("异常", e); | |||
@@ -90,7 +93,7 @@ public class BlackCardInManager extends AbstractCommManager implements LogManage | |||
} | |||
} | |||
private void updateCardInfo(CardInRequest request) { | |||
private void updateCardInfo(CardInRequest request, LocalDateTime blackDate) { | |||
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(request.getCardId()); | |||
if (cardInfo == null){ | |||
return; | |||
@@ -101,7 +104,7 @@ public class BlackCardInManager extends AbstractCommManager implements LogManage | |||
return; | |||
} | |||
cardInfo.setCardStatus(cardStatus); | |||
cardInfo.setUpdateTime(LocalDateTime.now()); | |||
cardInfo.setUpdateTime(blackDate); | |||
cardInfoRepo.merge(cardInfo); | |||
} | |||
@@ -141,13 +144,12 @@ public class BlackCardInManager extends AbstractCommManager implements LogManage | |||
} | |||
} | |||
private QtkBlackCard addBlackCard(CardInRequest request) { | |||
private QtkBlackCard addBlackCard(CardInRequest request, LocalDateTime blackDate) { | |||
QtkBlackCard blackCard = copyProperties(request, new QtkBlackCard()); | |||
LocalDateTime now = LocalDateTime.now(); | |||
blackCard.setIssuerId("520101");//固定的 | |||
blackCard.setStatus(1); | |||
blackCard.setCreateTime(now); | |||
blackCard.setCreationTime(now); | |||
blackCard.setCreateTime(blackDate); | |||
blackCard.setCreationTime(blackDate); | |||
blackCard.setType(CardBlackType.fromCode(request.getType())); | |||
blackCard.setSourceIn(SourceType.valueOf(request.getSourceIn())); | |||
blackCard.setAgencyId(request.getOrgCode());//AbstractSignTypeRequest类里加了个orgCode,中台接口转发到接口系统会自动带上值,值实际为agentId |
@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; | |||
import org.springframework.util.StringUtils; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.List; | |||
@Service | |||
@@ -48,6 +49,7 @@ public class BlackCardOutManager extends AbstractCommManager implements LogManag | |||
public AbstractBlsResponse serviceHandle(CardOutRequest req) throws ServiceHandleException { | |||
try { | |||
long begin = System.currentTimeMillis(); | |||
LocalDateTime outDate = LocalDateTime.now(); | |||
List<QtkBlackCard> blackCardList = blackCardRepo.queryByCardIdAndType(req.getCardId(), CardBlackType.fromCode(req.getType())); | |||
if (CollectionTools.isEmpty(blackCardList)){ | |||
throw GlyServiceError.NO_DATA_ERR.toHandleException("未查询到该类型卡号黑名单!"); | |||
@@ -57,11 +59,10 @@ public class BlackCardOutManager extends AbstractCommManager implements LogManag | |||
YgzCardBlackUploadResponse uploadResponse = blackCardInManager.cardBlackUpload(req.getCardId(), 2, req.getType()); | |||
if (uploadResponse.getUploadStatus() == 1 || uploadResponse.getUploadStatus() == 2){ | |||
QtkBlackCard blackCard = blackCardList.get(0); | |||
LocalDateTime now = LocalDateTime.now(); | |||
blackCardHis = copyProperties(blackCard, new QtkBlackCardHis(), "id","createTime"); | |||
blackCardHis.setStatus(2);//2-反白 | |||
blackCardHis.setCreateTime(now); | |||
blackCardHis.setReleaseTime(now); | |||
blackCardHis.setCreateTime(outDate); | |||
blackCardHis.setReleaseTime(outDate); | |||
blackCardHis.setReasonIn(blackCard.getReason()); | |||
blackCardHis.setReasonOut(req.getReason()); | |||
blackCardHis.setStaffIdIn(blackCard.getStaffId()); | |||
@@ -73,7 +74,7 @@ public class BlackCardOutManager extends AbstractCommManager implements LogManag | |||
//删除下黑数据 | |||
blackCardRepo.deleteAll(blackCardList); | |||
//更新qtkCardInfo | |||
updateCardInfo(req); | |||
updateCardInfo(req,outDate); | |||
}else { | |||
if (StringUtils.isEmpty(uploadResponse.getMsg())){ | |||
uploadResponse.setMsg("请重试!"); | |||
@@ -91,6 +92,7 @@ public class BlackCardOutManager extends AbstractCommManager implements LogManag | |||
AbstractBlsResponse blsResponse = new AbstractBlsResponse(); | |||
blsResponse.setUploadStatus(1); | |||
blsResponse.setReceiveTime(outDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))); | |||
return onSuccess(req, blsResponse, BlsInterfaceLog.class, System.currentTimeMillis() - begin); | |||
} catch (ServiceHandleException e) { | |||
logger.error("异常",e); | |||
@@ -98,7 +100,7 @@ public class BlackCardOutManager extends AbstractCommManager implements LogManag | |||
} | |||
} | |||
private void updateCardInfo(CardOutRequest request) { | |||
private void updateCardInfo(CardOutRequest request, LocalDateTime outDate) { | |||
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(request.getCardId()); | |||
if (cardInfo == null){ | |||
return; | |||
@@ -112,7 +114,7 @@ public class BlackCardOutManager extends AbstractCommManager implements LogManag | |||
return; | |||
} | |||
cardInfo.setCardStatus(CardStatus.ZC); | |||
cardInfo.setUpdateTime(LocalDateTime.now()); | |||
cardInfo.setUpdateTime(outDate); | |||
cardInfoRepo.merge(cardInfo); | |||
} | |||
@@ -7,7 +7,6 @@ import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.common.pub.CollectionTools; | |||
import cn.com.taiji.core.entity.basic.QtkBlackObu; | |||
import cn.com.taiji.core.entity.basic.QtkBlackObuHis; | |||
import cn.com.taiji.core.entity.basic.QtkCardInfo; | |||
import cn.com.taiji.core.entity.basic.QtkObuInfo; | |||
import cn.com.taiji.core.entity.dict.basic.*; | |||
import cn.com.taiji.core.entity.dict.issue.TransactionBizType; | |||
@@ -28,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; | |||
import org.springframework.util.StringUtils; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.List; | |||
@@ -49,6 +49,7 @@ public class BlackObuInManager extends AbstractCommManager implements LogManager | |||
public AbstractBlsResponse serviceHandle(ObuInRequest req) throws ServiceHandleException { | |||
try { | |||
long begin = System.currentTimeMillis(); | |||
LocalDateTime blackDate = LocalDateTime.now(); | |||
if (StringUtils.isEmpty(req.getOrgCode())) { | |||
throw GlyServiceError.NO_DATA_ERR.toHandleException("请求参数orgCode必填!"); | |||
} | |||
@@ -59,12 +60,13 @@ public class BlackObuInManager extends AbstractCommManager implements LogManager | |||
List<QtkBlackObu> blackObuList = blackObuRepo.queryByObuIdAndType(req.getObuId(), ObuBlackType.fromCode(req.getType())); | |||
//可能已在部黑名单中,但本地无数据,本地无数据则新增一条 | |||
if (CollectionTools.isEmpty(blackObuList)) { | |||
blackObu = addBlackObu(req); | |||
blackObu = addBlackObu(req,blackDate); | |||
}else { | |||
blackObu = CollectionTools.extractOne(blackObuList); | |||
blackDate = blackObu.getCreateTime(); | |||
} | |||
//更新qtkObuInfo | |||
updateObuInfo(req); | |||
updateObuInfo(req,blackDate); | |||
} else { | |||
if (StringUtils.isEmpty(uploadResponse.getMsg())){ | |||
uploadResponse.setMsg("请重试!"); | |||
@@ -81,6 +83,7 @@ public class BlackObuInManager extends AbstractCommManager implements LogManager | |||
//返回 | |||
AbstractBlsResponse blsResponse = new AbstractBlsResponse(); | |||
blsResponse.setUploadStatus(1); | |||
blsResponse.setReceiveTime(blackDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))); | |||
return onSuccess(req, blsResponse, BlsInterfaceLog.class, System.currentTimeMillis() - begin); | |||
} catch (Exception e) { | |||
logger.error("异常", e); | |||
@@ -88,7 +91,7 @@ public class BlackObuInManager extends AbstractCommManager implements LogManager | |||
} | |||
} | |||
private void updateObuInfo(ObuInRequest request) { | |||
private void updateObuInfo(ObuInRequest request, LocalDateTime blackDate) { | |||
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(request.getObuId()); | |||
if (obuInfo == null){ | |||
return; | |||
@@ -99,7 +102,7 @@ public class BlackObuInManager extends AbstractCommManager implements LogManager | |||
return; | |||
} | |||
obuInfo.setObuStatus(obuStatus); | |||
obuInfo.setUpdateTime(LocalDateTime.now()); | |||
obuInfo.setUpdateTime(blackDate); | |||
obuInfoRepo.merge(obuInfo); | |||
} | |||
@@ -141,14 +144,13 @@ public class BlackObuInManager extends AbstractCommManager implements LogManager | |||
} | |||
} | |||
private QtkBlackObu addBlackObu(ObuInRequest req) { | |||
private QtkBlackObu addBlackObu(ObuInRequest req, LocalDateTime blackDate) { | |||
QtkBlackObu blackObu = copyProperties(req, new QtkBlackObu()); | |||
LocalDateTime now = LocalDateTime.now(); | |||
blackObu.setIssuerId("520101");//固定的 | |||
blackObu.setType(ObuBlackType.fromCode(req.getType())); | |||
blackObu.setStatus(1); | |||
blackObu.setCreateTime(now); | |||
blackObu.setCreationTime(now); | |||
blackObu.setCreateTime(blackDate); | |||
blackObu.setCreationTime(blackDate); | |||
blackObu.setType(ObuBlackType.fromCode(req.getType())); | |||
blackObu.setSourceIn(SourceType.valueOf(req.getSourceIn())); | |||
blackObu.setAgencyId(req.getOrgCode());//AbstractSignTypeRequest类里加了个orgCode,中台接口转发到接口系统会自动带上值,值实际为agentId |
@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; | |||
import org.springframework.util.StringUtils; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.List; | |||
@@ -49,6 +50,7 @@ public class BlackObuOutManager extends AbstractCommManager implements LogManage | |||
public AbstractBlsResponse serviceHandle(ObuOutRequest req) throws ServiceHandleException { | |||
try { | |||
long begin = System.currentTimeMillis(); | |||
LocalDateTime outDate = LocalDateTime.now(); | |||
List<QtkBlackObu> blackObuList = blackObuRepo.queryByObuIdAndType(req.getObuId(), ObuBlackType.fromCode(req.getType())); | |||
if (CollectionTools.isEmpty(blackObuList)){ | |||
throw GlyServiceError.NO_DATA_ERR.toHandleException("未查询到该类型签号黑名单!"); | |||
@@ -58,11 +60,10 @@ public class BlackObuOutManager extends AbstractCommManager implements LogManage | |||
YgzObuBlackUploadResponse uploadResponse = blackObuInManager.obuBlackUpload(req.getObuId(), 2, req.getType()); | |||
if (uploadResponse.getUploadStatus() == 1 || uploadResponse.getUploadStatus() == 2){ | |||
QtkBlackObu blackObu = blackObuList.get(0); | |||
LocalDateTime now = LocalDateTime.now(); | |||
blackObuHis = copyProperties(blackObu, new QtkBlackObuHis(), "id","createTime"); | |||
blackObuHis.setStatus(2);//2-反白 | |||
blackObuHis.setCreateTime(now); | |||
blackObuHis.setReleaseTime(now); | |||
blackObuHis.setCreateTime(outDate); | |||
blackObuHis.setReleaseTime(outDate); | |||
blackObuHis.setReasonIn(blackObu.getReason()); | |||
blackObuHis.setReasonOut(req.getReason()); | |||
blackObuHis.setStaffIdIn(blackObu.getStaffId()); | |||
@@ -74,7 +75,7 @@ public class BlackObuOutManager extends AbstractCommManager implements LogManage | |||
//删除下黑数据 | |||
blackObuRepo.deleteAll(blackObuList); | |||
// | |||
updateObuInfo(req); | |||
updateObuInfo(req,outDate); | |||
}else { | |||
if (StringUtils.isEmpty(uploadResponse.getMsg())){ | |||
uploadResponse.setMsg("请重试!"); | |||
@@ -91,6 +92,7 @@ public class BlackObuOutManager extends AbstractCommManager implements LogManage | |||
AbstractBlsResponse blsResponse = new AbstractBlsResponse(); | |||
blsResponse.setUploadStatus(1); | |||
blsResponse.setReceiveTime(outDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))); | |||
return onSuccess(req, blsResponse, BlsInterfaceLog.class, System.currentTimeMillis() - begin); | |||
} catch (ServiceHandleException e) { | |||
logger.error("异常",e); | |||
@@ -98,7 +100,7 @@ public class BlackObuOutManager extends AbstractCommManager implements LogManage | |||
} | |||
} | |||
private void updateObuInfo(ObuOutRequest request) { | |||
private void updateObuInfo(ObuOutRequest request, LocalDateTime outDate) { | |||
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(request.getObuId()); | |||
if (obuInfo == null){ | |||
return; | |||
@@ -112,7 +114,7 @@ public class BlackObuOutManager extends AbstractCommManager implements LogManage | |||
return; | |||
} | |||
obuInfo.setObuStatus(ObuStatus.ZC); | |||
obuInfo.setUpdateTime(LocalDateTime.now()); | |||
obuInfo.setUpdateTime(outDate); | |||
obuInfoRepo.merge(obuInfo); | |||
} | |||