|
|
@@ -5,6 +5,7 @@ import com.utic.its.asn1.its.CurrentLinkState;
|
|
|
import com.utic.its.asn1.its.IncidentConditions;
|
|
|
import com.utic.its.common.annotation.SqlOperation;
|
|
|
import com.utic.its.common.dao.mapper.BatchDaoService;
|
|
|
+import com.utic.its.common.dto.CenterDto;
|
|
|
import com.utic.its.common.entity.TbCenter;
|
|
|
import com.utic.its.common.entity.TbRcvLog;
|
|
|
import com.utic.its.rota.utic.client.dao.mapper.RotaUticClientMapper;
|
|
|
@@ -12,9 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Repository
|
|
|
@@ -28,9 +27,15 @@ public class RotaUticClientRepository extends BatchDaoService {
|
|
|
this.mapper = mapper;
|
|
|
}
|
|
|
|
|
|
- public List<HashMap<String, Object>> getRcvLinkTraffic(String regDate, String fromCenterId, String toCenterId, List<CurrentLinkState> req) {
|
|
|
- //HashMap<Long, Long> linkMap = new HashMap<Long, Long>();
|
|
|
+ public List<HashMap<String, Object>> getRcvLinkTraffic(CenterDto center, String regDate, String fromCenterId, String toCenterId, List<CurrentLinkState> req) {
|
|
|
+ if (regDate.equals(center.getRcvLinkRegDate())) {
|
|
|
+ center.setRcvLinkRegDate(regDate);
|
|
|
+ center.initRcvLinkDupCheckSet();
|
|
|
+ }
|
|
|
+ Set<String> dupCheckSet = center.getRcvLinkDupCheckSet(); // 중복 체크용
|
|
|
|
|
|
+ int total = req.size();
|
|
|
+ int dup = 0;
|
|
|
List<HashMap<String, Object>> lists = new ArrayList<>();
|
|
|
for (CurrentLinkState obj : req) {
|
|
|
HashMap<String, Object> param = new HashMap<>();
|
|
|
@@ -63,6 +68,14 @@ public class RotaUticClientRepository extends BatchDaoService {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ // 중복 키 생성
|
|
|
+ if (dupCheckSet.contains(linkNumber)) {
|
|
|
+ dup++;
|
|
|
+ //log.info("RcvLinkTraffic: duplicate ==> {}", linkNumber);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dupCheckSet.add(linkNumber);
|
|
|
+
|
|
|
param.put("REGDATE", regDate);
|
|
|
param.put("TOCENTERID", toCenterId);
|
|
|
param.put("LINKNUMBER", linkNumber);
|
|
|
@@ -74,6 +87,9 @@ public class RotaUticClientRepository extends BatchDaoService {
|
|
|
|
|
|
lists.add(param);
|
|
|
}
|
|
|
+ if (dup > 0) {
|
|
|
+ log.warn("getRcvLinkTraffic: {}, {}, Total: {} / Duplicate: {}.", fromCenterId, regDate, total, dup);
|
|
|
+ }
|
|
|
return lists;
|
|
|
}
|
|
|
|
|
|
@@ -88,8 +104,21 @@ public class RotaUticClientRepository extends BatchDaoService {
|
|
|
}
|
|
|
|
|
|
@SqlOperation(type = SqlOperation.SqlType.INSERT, table = "RCV_LINK_TRAFFIC", param = "fromCenterId", param2 = "regDate")
|
|
|
- public int insertRcvLinkTraffic(String regDate, String fromCenterId, String toCenterId, List<CurrentLinkState> req) {
|
|
|
- return insertBatch("insertRcvLinkTraffic", getRcvLinkTraffic(regDate, fromCenterId, toCenterId, req));
|
|
|
+ public int insertRcvLinkTraffic(CenterDto center, String regDate, String fromCenterId, String toCenterId, List<CurrentLinkState> req) {
|
|
|
+ List<HashMap<String, Object>> reqJob = getRcvLinkTraffic(center, regDate, fromCenterId, toCenterId, req);
|
|
|
+ int reqCount = reqJob.size();
|
|
|
+ if (reqCount == 0) {
|
|
|
+ return req.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ int result = insertBatchRcvTraffic("insertRcvLinkTraffic", fromCenterId, regDate, reqJob);
|
|
|
+ if (result != reqCount) {
|
|
|
+ log.warn("insertRcvLinkTraffic: {}, curRegDate: {}, setRegDate: {}, curCount: {}, setCount: {}",
|
|
|
+ fromCenterId,
|
|
|
+ regDate, center.getRcvLinkRegDate(),
|
|
|
+ reqCount, center.getRcvLinkDupCheckSet().size());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@SqlOperation(type = SqlOperation.SqlType.DELETE, table = "RCV_LINK_TRAFFIC")
|