|
@@ -21,6 +21,7 @@ import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@RestController
|
|
@@ -31,14 +32,16 @@ public class WbsTreeContractStatisticsClientImpl implements WbsTreeContractStati
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
private final StringRedisTemplate redisTemplate;
|
|
|
private static final Logger log = LoggerFactory.getLogger(WbsTreeContractStatisticsClientImpl.class);
|
|
|
+ private static final String INFORMATION_QUERY_STATUS_STATISTICS_KEY = "blade:statistics:information_query_statistics_key";
|
|
|
|
|
|
- @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ @Scheduled(cron = "0/30 * * * * ?")
|
|
|
public void updateInformationQueryStatus() {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
- List<String> taskIds = redisTemplate.opsForList().range("information_query_status_statistics_key", 0, 100);
|
|
|
- if (taskIds != null && !taskIds.isEmpty()) {
|
|
|
- List<InformationQuery> queryList = jdbcTemplate.query("select wbs_id, classify, contract_id from u_information_query where id in (select form_data_id from u_task where id in (?) and is_deleted = 0) and is_deleted = 0 group by contract_id,wbs_id,classify",
|
|
|
- new Object[]{String.join(",", taskIds)}, new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
+ List<String> queryIds = redisTemplate.opsForList().range(INFORMATION_QUERY_STATUS_STATISTICS_KEY, 0, 100);
|
|
|
+ if (queryIds != null && !queryIds.isEmpty()) {
|
|
|
+ String ids = queryIds.stream().distinct().collect(Collectors.joining(","));
|
|
|
+ List<InformationQuery> queryList = jdbcTemplate.query("select wbs_id, classify, contract_id from u_information_query where id in ( " + ids +" ) and is_deleted = 0 group by contract_id,wbs_id,classify",
|
|
|
+ new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
if (!queryList.isEmpty()) {
|
|
|
for (InformationQuery query : queryList) {
|
|
|
if (map.containsKey(query.getWbsId() + "," + query.getContractId() + "," + query.getClassify())) {
|
|
@@ -48,9 +51,13 @@ public class WbsTreeContractStatisticsClientImpl implements WbsTreeContractStati
|
|
|
wbsTreeContractStatisticsService.updateInformationNumber(query.getWbsId(), query.getClassify(), query.getContractId());
|
|
|
map.put(query.getWbsId() + "," + query.getContractId() + "," + query.getClassify(), "");
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ redisTemplate.opsForList().rightPush("blade:statistics:information_query_statistics_key", query.getId() + "");
|
|
|
+ log.error("updateInformationQueryStatus wbsId = {}, contractId = {}, classify = {}", query.getWbsId(), query.getContractId(), query.getClassify() , e);
|
|
|
}
|
|
|
}
|
|
|
+ for (String queryId : queryIds) {
|
|
|
+ redisTemplate.opsForList().remove("blade:statistics:information_query_statistics_key", 1, queryId);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -125,7 +132,7 @@ public class WbsTreeContractStatisticsClientImpl implements WbsTreeContractStati
|
|
|
String[] pKeyIds = nodeIds.split(",");
|
|
|
for (String pKeyId : pKeyIds) {
|
|
|
try {
|
|
|
- wbsTreeContractStatisticsService.insertWbsTreeContractStatistics(Long.parseLong(pKeyId), 1);
|
|
|
+ wbsTreeContractStatisticsService.updateIsDeleted(Long.parseLong(pKeyId), 1);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -140,7 +147,7 @@ public class WbsTreeContractStatisticsClientImpl implements WbsTreeContractStati
|
|
|
String[] pKeyIds = nodeIds.split(",");
|
|
|
for (String pKeyId : pKeyIds) {
|
|
|
try {
|
|
|
- wbsTreeContractStatisticsService.recycleWbsTreeContractStatistics(Long.parseLong(pKeyId));
|
|
|
+ wbsTreeContractStatisticsService.updateIsDeleted(Long.parseLong(pKeyId), 0);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|