|
|
|
@ -7,9 +7,14 @@ 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.pojo.constants.Prompt; |
|
|
|
import com.biutag.supervisiondata.pojo.constants.Prompt; |
|
|
|
import com.biutag.supervisiondata.pojo.constants.RedisKey; |
|
|
|
import com.biutag.supervisiondata.pojo.constants.RedisKey; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.pojo.domain.AiData; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.pojo.domain.AiResult; |
|
|
|
import com.biutag.supervisiondata.pojo.entity.dwd.GBaseJJD; |
|
|
|
import com.biutag.supervisiondata.pojo.entity.dwd.GBaseJJD; |
|
|
|
import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcJJDInstance; |
|
|
|
import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcJJDInstance; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.wdpc2.WdpcJJD; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.wdpc2.WdpcJJDResult; |
|
|
|
import com.biutag.supervisiondata.repository.WdpcJJDInstanceRepository; |
|
|
|
import com.biutag.supervisiondata.repository.WdpcJJDInstanceRepository; |
|
|
|
|
|
|
|
import com.biutag.supervisiondata.repository.WdpcJJDResultRepository; |
|
|
|
import com.biutag.supervisiondata.service.AiService; |
|
|
|
import com.biutag.supervisiondata.service.AiService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -68,20 +73,63 @@ public class JJDController { |
|
|
|
return RS.success(); |
|
|
|
return RS.success(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/ai/get") |
|
|
|
|
|
|
|
public String aiGet() { |
|
|
|
|
|
|
|
String data = (String) RedisDao.getInstance().leftPop(RedisKey.JJD_CACHE); |
|
|
|
|
|
|
|
WdpcJJD jjd = JSON.parseObject(data, WdpcJJD.class); |
|
|
|
|
|
|
|
AiData aiData = new AiData(); |
|
|
|
|
|
|
|
aiData.setContent(String.format(Prompt.NORMAL, |
|
|
|
|
|
|
|
Optional.ofNullable(jjd.getBjrxm()).orElse(" - "), |
|
|
|
|
|
|
|
Optional.ofNullable(jjd.getBjrzjhm()).orElse(" - "), |
|
|
|
|
|
|
|
Optional.ofNullable(jjd.getBjdh()).orElse(" - "), |
|
|
|
|
|
|
|
Optional.ofNullable(jjd.getBjnr()).orElse(" - "), |
|
|
|
|
|
|
|
Optional.ofNullable(jjd.getCjqk()).orElse(" - "))); |
|
|
|
|
|
|
|
aiData.setId(jjd.getJjdbh()); |
|
|
|
|
|
|
|
return JSON.toJSONString(aiData); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final WdpcJJDResultRepository resultRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@CrossOrigin |
|
|
|
|
|
|
|
@PostMapping("/ai/set") |
|
|
|
|
|
|
|
public String aiSet(@RequestBody AiResult result) { |
|
|
|
|
|
|
|
String res = result.getResult().replaceFirst("```json", "").replaceAll("```", "").replaceAll("\n", ""); |
|
|
|
|
|
|
|
JSONObject jb = JSON.parseObject(res); |
|
|
|
|
|
|
|
JSONArray array = jb.getJSONArray("informations"); |
|
|
|
|
|
|
|
Integer modelId = jb.getInteger("type"); |
|
|
|
|
|
|
|
if (array.isEmpty()) { |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.info("{}", array); |
|
|
|
|
|
|
|
List<WdpcJJDResult> aiList = new ArrayList<>(); |
|
|
|
|
|
|
|
for (int i = 0; i < array.size(); i++) { |
|
|
|
|
|
|
|
JSONObject obj = array.getJSONObject(i); |
|
|
|
|
|
|
|
WdpcJJDResult instance = new WdpcJJDResult(); |
|
|
|
|
|
|
|
instance.setModelId(modelId); |
|
|
|
|
|
|
|
instance.setJjdbh(result.getId()); |
|
|
|
|
|
|
|
instance.setMobile(Optional.ofNullable(obj.getString("mobile")).orElse("")); |
|
|
|
|
|
|
|
instance.setName(Optional.ofNullable(obj.getString("name")).orElse("")); |
|
|
|
|
|
|
|
instance.setIdCode(Optional.ofNullable(obj.getString("idCode")).orElse("")); |
|
|
|
|
|
|
|
aiList.add(instance); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
resultRepository.saveBatch(aiList); |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@CrossOrigin |
|
|
|
@CrossOrigin |
|
|
|
@PostMapping("/instance/set") |
|
|
|
@PostMapping("/instance/set") |
|
|
|
public String instanceSet(@RequestBody JSONObject data) { |
|
|
|
public String instanceSet(@RequestBody JSONObject data) { |
|
|
|
String str = (String) RedisDao.getInstance().get("jjd_instance:".concat(data.getString("id"))); |
|
|
|
String str = (String) RedisDao.getInstance().get("jjd_instance:".concat(data.getString("id"))); |
|
|
|
if(str == null) { |
|
|
|
if (str == null) { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
GBaseJJD jjd = JSON.parseObject(str, GBaseJJD.class); |
|
|
|
GBaseJJD jjd = JSON.parseObject(str, GBaseJJD.class); |
|
|
|
|
|
|
|
|
|
|
|
String res = data.getString("content"); |
|
|
|
String res = data.getString("content"); |
|
|
|
res = res.replaceFirst("```json","").replaceAll("```", "").replaceAll("\n",""); |
|
|
|
res = res.replaceFirst("```json", "").replaceAll("```", "").replaceAll("\n", ""); |
|
|
|
JSONObject jb = JSON.parseObject(res); |
|
|
|
JSONObject jb = JSON.parseObject(res); |
|
|
|
JSONArray array = jb.getJSONArray("informations"); |
|
|
|
JSONArray array = jb.getJSONArray("informations"); |
|
|
|
if(array.isEmpty()) { |
|
|
|
if (array.isEmpty()) { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("{}", array); |
|
|
|
log.info("{}", array); |
|
|
|
@ -103,7 +151,7 @@ public class JJDController { |
|
|
|
instance.setIdCode(Optional.ofNullable(obj.getString("idCode")).orElse("")); |
|
|
|
instance.setIdCode(Optional.ofNullable(obj.getString("idCode")).orElse("")); |
|
|
|
aiList.add(instance); |
|
|
|
aiList.add(instance); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!aiList.isEmpty()) { |
|
|
|
if (!aiList.isEmpty()) { |
|
|
|
wdpcJJDInstanceRepository.saveBatch(aiList); |
|
|
|
wdpcJJDInstanceRepository.saveBatch(aiList); |
|
|
|
} |
|
|
|
} |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
|