|
|
|
@ -1,20 +1,25 @@ |
|
|
|
package com.biutag.supervisiondata.rest; |
|
|
|
package com.biutag.supervisiondata.rest; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.biutag.supervisiondata.common.interfaces.CompletableFutureUtil; |
|
|
|
import com.biutag.supervisiondata.common.interfaces.CompletableFutureUtil; |
|
|
|
import com.biutag.supervisiondata.common.response.RS; |
|
|
|
import com.biutag.supervisiondata.common.response.RS; |
|
|
|
import com.biutag.supervisiondata.config.cache.RedisDao; |
|
|
|
import com.biutag.supervisiondata.config.cache.RedisDao; |
|
|
|
import com.biutag.supervisiondata.lock.LocalLock; |
|
|
|
import com.biutag.supervisiondata.lock.LocalLock; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.ads.GBaseSYRKXX; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.dwd.GBaseJJD; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcJJDAi; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.repository.GBaseSYRKXXRepository; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.repository.WdpcJJDAiRepository; |
|
|
|
import com.biutag.supervisiondata.service.ModelClueService; |
|
|
|
import com.biutag.supervisiondata.service.ModelClueService; |
|
|
|
import com.biutag.supervisiondata.service.RiskScoreRuleService; |
|
|
|
import com.biutag.supervisiondata.service.RiskScoreRuleService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author kami on 2024-11-19 15:32:09 |
|
|
|
* @author kami on 2024-11-19 15:32:09 |
|
|
|
@ -59,6 +64,98 @@ public class ApiController { |
|
|
|
return (String) RedisDao.getInstance().leftPop("jjd"); |
|
|
|
return (String) RedisDao.getInstance().leftPop("jjd"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final GBaseSYRKXXRepository repository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final WdpcJJDAiRepository aiRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@CrossOrigin |
|
|
|
|
|
|
|
@PostMapping("/set/data") |
|
|
|
|
|
|
|
public String setData(@RequestBody JSONObject data) { |
|
|
|
|
|
|
|
String str = (String) RedisDao.getInstance().opsForHashGetByGroupAndKey("jjd_cache", data.getString("id")); |
|
|
|
|
|
|
|
if(str == null) { |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
GBaseJJD jjd = JSON.parseObject(str, GBaseJJD.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String res = data.getString("content"); |
|
|
|
|
|
|
|
res = res.replaceFirst("```json","").replaceAll("```", ""); |
|
|
|
|
|
|
|
JSONObject jb = JSON.parseObject(res); |
|
|
|
|
|
|
|
JSONArray array = jb.getJSONArray("information"); |
|
|
|
|
|
|
|
if(array.isEmpty()) { |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WdpcJJDAi> aiList = new ArrayList<>(); |
|
|
|
|
|
|
|
Map<String, Integer> group = new WeakHashMap<>(); |
|
|
|
|
|
|
|
List<String> idCodes = new ArrayList<>(); |
|
|
|
|
|
|
|
List<String> mobiles = new ArrayList<>(); |
|
|
|
|
|
|
|
for (int i = 0; i < array.size(); i++) { |
|
|
|
|
|
|
|
WdpcJJDAi ai = new WdpcJJDAi(); |
|
|
|
|
|
|
|
JSONObject obj = array.getJSONObject(i); |
|
|
|
|
|
|
|
ai.setBjsj(jjd.getBjsj()); |
|
|
|
|
|
|
|
ai.setJjdbh(ai.getJjdbh()); |
|
|
|
|
|
|
|
ai.setGroup(Optional.of(group.get(obj.getString("group"))).orElse(group.size())); |
|
|
|
|
|
|
|
group.put(obj.getString("group"), group.size()); |
|
|
|
|
|
|
|
ai.setMobile(Optional.ofNullable(obj.getString("mobile")).orElse("")); |
|
|
|
|
|
|
|
ai.setName(Optional.ofNullable(obj.getString("name")).orElse("")); |
|
|
|
|
|
|
|
ai.setIdCode(Optional.ofNullable(obj.getString("idCode")).orElse("")); |
|
|
|
|
|
|
|
ai.setReason(obj.getString("reason")); |
|
|
|
|
|
|
|
if(!ai.getIdCode().isEmpty() && !ai.getIdCode().equals("暂无")) { |
|
|
|
|
|
|
|
idCodes.add(ai.getIdCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!ai.getMobile().isEmpty() && !ai.getMobile().equals("暂无")) { |
|
|
|
|
|
|
|
mobiles.add(ai.getMobile()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
aiList.add(ai); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
LambdaQueryWrapper<GBaseSYRKXX> wrapper = new LambdaQueryWrapper<GBaseSYRKXX>(); |
|
|
|
|
|
|
|
if(!idCodes.isEmpty()) { |
|
|
|
|
|
|
|
wrapper.in(GBaseSYRKXX::getGmsfhm, idCodes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!idCodes.isEmpty() && !mobiles.isEmpty()) { |
|
|
|
|
|
|
|
wrapper.or().in(GBaseSYRKXX::getLxdh, mobiles); |
|
|
|
|
|
|
|
} else if(!mobiles.isEmpty()) { |
|
|
|
|
|
|
|
wrapper.in(GBaseSYRKXX::getLxdh, mobiles); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<GBaseSYRKXX> xxList = repository.list(wrapper); |
|
|
|
|
|
|
|
Map<String, GBaseSYRKXX> xxMap = new WeakHashMap<>(); |
|
|
|
|
|
|
|
Map<String, List<GBaseSYRKXX>> xxMMap = new WeakHashMap<>(); |
|
|
|
|
|
|
|
for (GBaseSYRKXX syrkxx : xxList) { |
|
|
|
|
|
|
|
xxMap.put(syrkxx.getGmsfhm(), syrkxx); |
|
|
|
|
|
|
|
xxMMap.computeIfAbsent(syrkxx.getLxdh(), k -> new ArrayList<>()).add(syrkxx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WdpcJJDAi ai : aiList) { |
|
|
|
|
|
|
|
GBaseSYRKXX xx = xxMap.get(ai.getIdCode()); |
|
|
|
|
|
|
|
if(xx != null) { |
|
|
|
|
|
|
|
ai.setSyrkMobile(xx.getLxdh()); |
|
|
|
|
|
|
|
ai.setSyrkName(Optional.ofNullable(xx.getXm()).orElse("")); |
|
|
|
|
|
|
|
ai.setSyrkIdCode(Optional.ofNullable(xx.getGmsfhm()).orElse("")); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<GBaseSYRKXX> tmp = xxMMap.get(ai.getMobile()); |
|
|
|
|
|
|
|
if(tmp == null || tmp.isEmpty()) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (GBaseSYRKXX syrkxx : tmp) { |
|
|
|
|
|
|
|
if(xx == null) { |
|
|
|
|
|
|
|
xx = syrkxx; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(syrkxx.getXm().equals(ai.getName())) { |
|
|
|
|
|
|
|
xx = syrkxx; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ai.setSyrkMobile(xx.getLxdh()); |
|
|
|
|
|
|
|
ai.setSyrkName(Optional.ofNullable(xx.getXm()).orElse("")); |
|
|
|
|
|
|
|
ai.setSyrkIdCode(Optional.ofNullable(xx.getGmsfhm()).orElse("")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!aiList.isEmpty()) { |
|
|
|
|
|
|
|
aiRepository.saveBatch(aiList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/model/{modelId}") |
|
|
|
@GetMapping("/model/{modelId}") |
|
|
|
public RS<Void> score(@PathVariable Integer modelId) { |
|
|
|
public RS<Void> score(@PathVariable Integer modelId) { |
|
|
|
System.out.println("开始执行模型" + modelId); |
|
|
|
System.out.println("开始执行模型" + modelId); |
|
|
|
|