diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java index 701273e..c8e47b1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java @@ -318,6 +318,8 @@ public class AppController extends BaseController @ApiOperation("ai接口") public AjaxResult aiPost(@PathVariable("recordId") Long recordId, @RequestBody AiPostReq aiPostReq) { + //删除同一次预约调用多次ai接口的图片数据 + imageService.deleteTImageByThirdId(recordId); saveImage(aiPostReq,recordId); ObjectMapper mapper = new ObjectMapper(); String URL = RequestParamsUtil.HTTP + ip + RequestParamsUtil.SEPARATOR + port + url; @@ -342,7 +344,13 @@ public class AppController extends BaseController tRecord.setAiResult2(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue)); tRecordService.updateTRecord(tRecord); } - return AjaxResult.success(jsonObject); + Map data = new HashMap<>(); + data.put("result",jsonObject); + TImage tImage = new TImage(); + tImage.setThirdId(recordId); + List images = imageService.selectTImageList(tImage); + data.put("image", images); + return AjaxResult.success(data); } @GetMapping("/image/{recordId}") @@ -359,43 +367,45 @@ public class AppController extends BaseController private void saveImage(AiPostReq aiPostReq,Long recordId) { + Base64ResizedRmgSm base64_resized_img_sm = aiPostReq.getBase64_resized_img_sm(); Base64ResizedRmgSx base64_resized_img_sx = aiPostReq.getBase64_resized_img_sx(); - Map smMap = imageKey(base64_resized_img_sm,"base64_resized_img_sm"); -// Map sxMap = imageKey(base64_resized_img_sx, "base64_resized_img_sx"); -// smMap.putAll(sxMap); -// sxMap.forEach((name,value)->{ -// TImage tImage = new TImage(); -// tImage.setThirdId(recordId); -// tImage.setCreateTime(new Date()); -// tImage.setName(name); -// String path=GenerateImage(value); -// tImage.setPath(path); -// imageService.insertTImage(tImage); -// }); - } - - public Map imageKey(Base64ResizedRmgSm param,String key){ Map map = new HashMap<>(); - if(!StringUtils.isEmpty(param.getFront())){ - map.put(key+"-front",param.getFront()); + if(!StringUtils.isEmpty(base64_resized_img_sm.getFront())){ + map.put("sm_front",base64_resized_img_sm.getFront()); } -// if(!StringUtils.isEmpty(param.getLeft())){ -// map.put(key+"-left",param.getLeft()); -// } -// if(!StringUtils.isEmpty(param.getFront())){ -// map.put(key+"-right",param.getRight()); -// } -// if(!CollectionUtils.isEmpty(param.getOther())){ -// for (int i = 0; i < param.getOther().size(); i++) -// { -// map.put(key+"-other"+i,param.getOther().get(i)); -// } -// } - return map; - + if(!StringUtils.isEmpty(base64_resized_img_sx.getFront())){ + map.put("sx_front",base64_resized_img_sx.getFront()); + } + map.forEach((name,value)->{ + TImage tImage = new TImage(); + tImage.setThirdId(recordId); + tImage.setCreateTime(new Date()); + tImage.setName(name); + String path=GenerateImage(value); + tImage.setPath(path); + imageService.insertTImage(tImage); + }); } +// public Map imageKey(Base64ResizedRmgSm param,String key){ +// +//// if(!StringUtils.isEmpty(param.getLeft())){ +//// map.put(key+"-left",param.getLeft()); +//// } +//// if(!StringUtils.isEmpty(param.getFront())){ +//// map.put(key+"-right",param.getRight()); +//// } +//// if(!CollectionUtils.isEmpty(param.getOther())){ +//// for (int i = 0; i < param.getOther().size(); i++) +//// { +//// map.put(key+"-other"+i,param.getOther().get(i)); +//// } +//// } +// return map; +// +// } + public JSONObject removeBase64Image(JSONObject jsonObject,Long recordId) { String []keys={"img_sz","img_sz_yudian","img_sz_yuban","img_sz_liewen","img_st","img_sx","img_sx_vein"}; @@ -416,13 +426,13 @@ public class AppController extends BaseController String imgStr=parents.get(i).getJSONObject(imageKey).getString("v"); String path=GenerateImage(imgStr); parents.get(i).getJSONObject(keys[i]).put("v",null); -// TImage tImage = new TImage(); -// tImage.setName(imageKey); -// tImage.setPath(path); -// tImage.setCreateTime(new Date()); -// tImage.setThirdId(recordId); -// imageService.insertTImage(tImage); - //保存图片到数据库,thirdId(recordId),path,name(imageKey) + TImage tImage = new TImage(); + tImage.setName(imageKey); + tImage.setPath(path); + tImage.setCreateTime(new Date()); + tImage.setThirdId(recordId); + imageService.insertTImage(tImage); +// 保存图片到数据库,thirdId(recordId),path,name(imageKey) } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TImageMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TImageMapper.java index 4c5a875..0fec12e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TImageMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TImageMapper.java @@ -5,15 +5,15 @@ import com.ruoyi.system.domain.TImage; /** * 图片Mapper接口 - * + * * @author ruoyi * @date 2022-08-15 */ -public interface TImageMapper +public interface TImageMapper { /** * 查询图片 - * + * * @param id 图片主键 * @return 图片 */ @@ -21,7 +21,7 @@ public interface TImageMapper /** * 查询图片列表 - * + * * @param tImage 图片 * @return 图片集合 */ @@ -29,7 +29,7 @@ public interface TImageMapper /** * 新增图片 - * + * * @param tImage 图片 * @return 结果 */ @@ -37,7 +37,7 @@ public interface TImageMapper /** * 修改图片 - * + * * @param tImage 图片 * @return 结果 */ @@ -45,7 +45,7 @@ public interface TImageMapper /** * 删除图片 - * + * * @param id 图片主键 * @return 结果 */ @@ -53,9 +53,11 @@ public interface TImageMapper /** * 批量删除图片 - * + * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteTImageByIds(Long[] ids); + + int deleteTImageByThirdId(Long id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITImageService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITImageService.java index da06410..5586c57 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITImageService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITImageService.java @@ -5,15 +5,15 @@ import com.ruoyi.system.domain.TImage; /** * 图片Service接口 - * + * * @author ruoyi * @date 2022-08-15 */ -public interface ITImageService +public interface ITImageService { /** * 查询图片 - * + * * @param id 图片主键 * @return 图片 */ @@ -21,7 +21,7 @@ public interface ITImageService /** * 查询图片列表 - * + * * @param tImage 图片 * @return 图片集合 */ @@ -29,7 +29,7 @@ public interface ITImageService /** * 新增图片 - * + * * @param tImage 图片 * @return 结果 */ @@ -37,7 +37,7 @@ public interface ITImageService /** * 修改图片 - * + * * @param tImage 图片 * @return 结果 */ @@ -45,7 +45,7 @@ public interface ITImageService /** * 批量删除图片 - * + * * @param ids 需要删除的图片主键集合 * @return 结果 */ @@ -53,9 +53,11 @@ public interface ITImageService /** * 删除图片信息 - * + * * @param id 图片主键 * @return 结果 */ public int deleteTImageById(Long id); + + int deleteTImageByThirdId(Long id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TImageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TImageServiceImpl.java index 246a418..2c145e8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TImageServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TImageServiceImpl.java @@ -10,19 +10,19 @@ import com.ruoyi.system.service.ITImageService; /** * 图片Service业务层处理 - * + * * @author ruoyi * @date 2022-08-15 */ @Service -public class TImageServiceImpl implements ITImageService +public class TImageServiceImpl implements ITImageService { @Autowired private TImageMapper tImageMapper; /** * 查询图片 - * + * * @param id 图片主键 * @return 图片 */ @@ -34,7 +34,7 @@ public class TImageServiceImpl implements ITImageService /** * 查询图片列表 - * + * * @param tImage 图片 * @return 图片 */ @@ -46,7 +46,7 @@ public class TImageServiceImpl implements ITImageService /** * 新增图片 - * + * * @param tImage 图片 * @return 结果 */ @@ -59,7 +59,7 @@ public class TImageServiceImpl implements ITImageService /** * 修改图片 - * + * * @param tImage 图片 * @return 结果 */ @@ -71,7 +71,7 @@ public class TImageServiceImpl implements ITImageService /** * 批量删除图片 - * + * * @param ids 需要删除的图片主键 * @return 结果 */ @@ -83,7 +83,7 @@ public class TImageServiceImpl implements ITImageService /** * 删除图片信息 - * + * * @param id 图片主键 * @return 结果 */ @@ -92,4 +92,10 @@ public class TImageServiceImpl implements ITImageService { return tImageMapper.deleteTImageById(id); } + + @Override + public int deleteTImageByThirdId(Long id) + { + return tImageMapper.deleteTImageByThirdId(id); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java index 9a158df..7ceae93 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java @@ -163,9 +163,9 @@ public class TRecordServiceImpl implements ITRecordService } List records = tRecords.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList()); List jsonKeyList = new ArrayList(){{ - add("shemian-sz_avg_red"); - add("st_avg_yellow"); - add("sx_vein_color"); + add("shemian-img_sz"); + add("img_st"); + add("img_sx"); }}; RecordHistoryDataResp recordHistoryDataRespMap = getDataList(records,jsonKeyList); return AjaxResult.success(recordHistoryDataRespMap); @@ -199,9 +199,9 @@ public class TRecordServiceImpl implements ITRecordService Integer value3 ; try { - value1 = jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject(keys0[0]).getInteger(keys0[1]); - value2 = jsonObject.getJSONObject("data").getJSONObject("shetai").getInteger(key1); - value3 = jsonObject.getJSONObject("data").getJSONObject("shexia").getInteger(key2); + value1 = jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject(keys0[0]).getJSONObject(keys0[1]).getInteger("anomaly"); + value2 = jsonObject.getJSONObject("data").getJSONObject("shetai").getJSONObject(key1).getInteger("anomaly"); + value3 = jsonObject.getJSONObject("data").getJSONObject("shexia").getJSONObject(key2).getInteger("anomaly"); }catch (Exception e){ throw new ServiceException("JSON格式错误"); } diff --git a/ruoyi-system/src/main/resources/mapper/system/TImageMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TImageMapper.xml index 4ff15aa..4ec325a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TImageMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TImageMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -18,18 +18,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + insert into t_image @@ -62,9 +62,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from t_image where id in + delete from t_image where id in #{id} - \ No newline at end of file + + + + delete from t_image where third_id = #{id} + +