|
|
|
@ -1,13 +1,20 @@
|
|
|
|
|
package com.shxy.xymanager_service.impl;
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.entity.SimInfo;
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalSimcard;
|
|
|
|
|
import com.shxy.xymanager_common.entity.Terminals;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.SimInfoMapper;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalSimcardMapper;
|
|
|
|
|
import com.shxy.xymanager_service.service.NewCacheService;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalSimcardService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
@ -17,6 +24,10 @@ public class TerminalSimcardServiceImpl implements TerminalSimcardService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
TerminalSimcardMapper simcardMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
SimInfoMapper simInfoMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
NewCacheService newCacheService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TerminalSimcard getSimcard(Integer termId) {
|
|
|
|
@ -33,4 +44,87 @@ public class TerminalSimcardServiceImpl implements TerminalSimcardService {
|
|
|
|
|
simcardMapper.updateByPrimaryKey(simcard);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void syncOne(Integer termId, String iccid1, String iccid2) {
|
|
|
|
|
TerminalSimcard card = simcardMapper.selectByPrimaryKey(termId);
|
|
|
|
|
if (card == null) {
|
|
|
|
|
card = new TerminalSimcard();
|
|
|
|
|
card.setTermId(termId);
|
|
|
|
|
card.setIccid1(iccid1);
|
|
|
|
|
card.setIccid2(iccid2);
|
|
|
|
|
this.syncOne(card);
|
|
|
|
|
simcardMapper.insert(card);
|
|
|
|
|
} else {
|
|
|
|
|
boolean changed = false;
|
|
|
|
|
if (StringUtils.isNotBlank(iccid1)) {
|
|
|
|
|
if (!iccid1.equals(card.getIccid1())) {
|
|
|
|
|
card.setIccid1(iccid1);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtils.isNotBlank(card.getIccid1())) {
|
|
|
|
|
card.setIccid1(iccid1);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(iccid2)) {
|
|
|
|
|
if (!iccid2.equals(card.getIccid2())) {
|
|
|
|
|
card.setIccid2(iccid2);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtils.isNotBlank(card.getIccid2())) {
|
|
|
|
|
card.setIccid2(iccid2);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (changed) {
|
|
|
|
|
this.syncOne(card);
|
|
|
|
|
simcardMapper.updateByPrimaryKey(card);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void syncOne(TerminalSimcard simcard) {
|
|
|
|
|
if (StringUtils.isNotBlank(simcard.getIccid1())) {
|
|
|
|
|
SimInfo sim = simInfoMapper.selectByPrimaryKey(simcard.getIccid1());
|
|
|
|
|
if (sim != null) {
|
|
|
|
|
simcard.setMsisdn1(sim.getMsisdn());
|
|
|
|
|
simcard.setImsi1(sim.getImsi());
|
|
|
|
|
simcard.setType1(sim.getType());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
simcard.setMsisdn1(null);
|
|
|
|
|
simcard.setImsi1(null);
|
|
|
|
|
simcard.setType1(null);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(simcard.getIccid2())) {
|
|
|
|
|
SimInfo sim = simInfoMapper.selectByPrimaryKey(simcard.getIccid2());
|
|
|
|
|
if (sim != null) {
|
|
|
|
|
simcard.setMsisdn2(sim.getMsisdn());
|
|
|
|
|
simcard.setImsi2(sim.getImsi());
|
|
|
|
|
simcard.setType2(sim.getType());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
simcard.setMsisdn2(null);
|
|
|
|
|
simcard.setImsi2(null);
|
|
|
|
|
simcard.setType2(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void syncAll() {
|
|
|
|
|
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap();
|
|
|
|
|
Iterator<Integer> it = terminalMap.keySet().iterator();
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
Integer termId = it.next();
|
|
|
|
|
TerminalSimcard simcard = simcardMapper.selectByPrimaryKey(termId);
|
|
|
|
|
if (simcard != null) {
|
|
|
|
|
this.syncOne(simcard);
|
|
|
|
|
simcardMapper.updateByPrimaryKey(simcard);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|