1. 联调

This commit is contained in:
邱贞招 2024-04-03 21:09:13 +08:00
parent 00a3c22c2f
commit b24f2abc2d
11 changed files with 99 additions and 41 deletions

View File

@ -1,11 +1,17 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.AsUser;
import com.ruoyi.device.domain.AsPlant;
import com.ruoyi.device.domain.AsUserCollection; import com.ruoyi.device.domain.AsUserCollection;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.device.service.IAsPlantService;
import com.ruoyi.device.service.IAsUserCollectionService; import com.ruoyi.device.service.IAsUserCollectionService;
import com.ruoyi.device.service.IAsUserService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -35,6 +41,12 @@ public class AsUserCollectionController extends BaseController
@Autowired @Autowired
private IAsUserCollectionService asUserCollectionService; private IAsUserCollectionService asUserCollectionService;
@Resource
private IAsUserService asUserService;
@Resource
private IAsPlantService asPlantService;
/** /**
* 查询用户收藏列表 * 查询用户收藏列表
*/ */
@ -44,6 +56,16 @@ public class AsUserCollectionController extends BaseController
{ {
startPage(); startPage();
List<AsUserCollection> list = asUserCollectionService.selectAsUserCollectionList(asUserCollection); List<AsUserCollection> list = asUserCollectionService.selectAsUserCollectionList(asUserCollection);
for (AsUserCollection asUserCollection1:list) {
AsUser asUser = asUserService.selectUserById(asUserCollection1.getUserId());
if(ObjectUtils.isNotEmpty(asUser)){
asUserCollection1.setUserName(asUser.getUserName());
}
AsPlant asPlant = asPlantService.selectAsPlantByPlantId(asUserCollection1.getPlantId());
if(ObjectUtils.isNotEmpty(asPlant)){
asUserCollection1.setPlantName(asPlant.getPlantName());
}
}
return getDataTable(list); return getDataTable(list);
} }
@ -78,7 +100,8 @@ public class AsUserCollectionController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody AsUserCollection asUserCollection) public AjaxResult add(@RequestBody AsUserCollection asUserCollection)
{ {
return toAjax(asUserCollectionService.insertAsUserCollection(asUserCollection)); Long aLong = asUserCollectionService.insertAsUserCollection(asUserCollection);
return success(aLong);
} }
/** /**

View File

@ -31,7 +31,7 @@ public class AccessTokenUtil {
String accessToken = wxMaService.getAccessToken(); String accessToken = wxMaService.getAccessToken();
cachedToken = accessToken; cachedToken = accessToken;
// 更新 token 过期时间 // 更新 token 过期时间
tokenExpirationTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(7200L); tokenExpirationTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(3600L);
return cachedToken; return cachedToken;
} }
return cachedToken; return cachedToken;

View File

@ -177,8 +177,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="养殖难度" prop="complexity"> <el-form-item label="种植难度" prop="complexity">
<el-select v-model="form.complexity" placeholder="请选择养殖难度"> <el-select v-model="form.complexity" placeholder="请选择种植难度">
<el-option <el-option
v-for="dict in dict.type.as_plant_complexity" v-for="dict in dict.type.as_plant_complexity"
:key="dict.value" :key="dict.value"

View File

@ -32,31 +32,31 @@
<el-table v-loading="loading" :data="collectionList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="collectionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="id" align="center" prop="collectionId" />--> <!-- <el-table-column label="id" align="center" prop="collectionId" />-->
<el-table-column label="用户" align="center" prop="userId" /> <el-table-column label="用户" align="center" prop="userName" />
<el-table-column label="植物" align="center" prop="plantId" /> <el-table-column label="植物" align="center" prop="plantName" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<template slot-scope="scope"> <!-- <template slot-scope="scope">-->
<el-button <!-- <el-button-->
size="mini" <!-- size="mini"-->
type="text" <!-- type="text"-->
icon="el-icon-edit" <!-- icon="el-icon-edit"-->
@click="handleUpdate(scope.row)" <!-- @click="handleUpdate(scope.row)"-->
v-hasPermi="['system:collection:edit']" <!-- v-hasPermi="['system:collection:edit']"-->
>修改</el-button> <!-- >修改</el-button>-->
<el-button <!-- <el-button-->
size="mini" <!-- size="mini"-->
type="text" <!-- type="text"-->
icon="el-icon-delete" <!-- icon="el-icon-delete"-->
@click="handleDelete(scope.row)" <!-- @click="handleDelete(scope.row)"-->
v-hasPermi="['system:collection:remove']" <!-- v-hasPermi="['system:collection:remove']"-->
>删除</el-button> <!-- >删除</el-button>-->
</template> <!-- </template>-->
</el-table-column> <!-- </el-table-column>-->
</el-table> </el-table>
<pagination <pagination

View File

@ -337,7 +337,8 @@ public class AppController extends BaseController
@PostMapping("/collection") @PostMapping("/collection")
public AjaxResult add(@RequestBody AsUserCollection asUserCollection) public AjaxResult add(@RequestBody AsUserCollection asUserCollection)
{ {
return toAjax(asUserCollectionService.insertAsUserCollection(asUserCollection)); Long aLong = asUserCollectionService.insertAsUserCollection(asUserCollection);
return success(aLong);
} }
/** /**

View File

@ -50,6 +50,10 @@ public class AsPlant extends BaseEntity
@Excel(name = "光照周期") @Excel(name = "光照周期")
private String beam; private String beam;
/** 光照周期 */
@Excel(name = "光照周期")
private String beamStr;
/** 光照周期 */ /** 光照周期 */
@Excel(name = "光照周期") @Excel(name = "光照周期")
private List<String> beamIds; private List<String> beamIds;
@ -70,6 +74,10 @@ public class AsPlant extends BaseEntity
@Excel(name = "功能") @Excel(name = "功能")
private String func; private String func;
/** 功能 */
@Excel(name = "功能")
private String funcStr;
/** 功能 */ /** 功能 */
@Excel(name = "功能") @Excel(name = "功能")
private List<String> funcs; private List<String> funcs;
@ -78,6 +86,10 @@ public class AsPlant extends BaseEntity
@Excel(name = "适合的空间") @Excel(name = "适合的空间")
private String fitSpace; private String fitSpace;
/** 适合的空间 */
@Excel(name = "适合的空间")
private String fitSpaceStr;
/** 适合的空间ids */ /** 适合的空间ids */
@Excel(name = "适合的空间ids") @Excel(name = "适合的空间ids")
private List<String> fitSpaces; private List<String> fitSpaces;
@ -86,6 +98,10 @@ public class AsPlant extends BaseEntity
@Excel(name = "水分要求") @Excel(name = "水分要求")
private String moisture; private String moisture;
/** 水分要求 */
@Excel(name = "水分要求")
private String moistureStr;
/** 水分要求ids */ /** 水分要求ids */
@Excel(name = "水分要求ids") @Excel(name = "水分要求ids")
private List<String> moistures; private List<String> moistures;

View File

@ -22,10 +22,18 @@ public class AsUserCollection extends BaseEntity
@Excel(name = "用户") @Excel(name = "用户")
private Long userId; private Long userId;
/** 用户名 */
@Excel(name = "用户名")
private String userName;
/** 植物id */ /** 植物id */
@Excel(name = "植物id") @Excel(name = "植物id")
private Long plantId; private Long plantId;
/** 植物名 */
@Excel(name = "植物名")
private String plantName;
/** 植物对象 */ /** 植物对象 */
@Excel(name = "植物对象") @Excel(name = "植物对象")
private AsPlant plant; private AsPlant plant;

View File

@ -34,7 +34,7 @@ public interface IAsUserCollectionService
* @param asUserCollection 用户收藏 * @param asUserCollection 用户收藏
* @return 结果 * @return 结果
*/ */
public int insertAsUserCollection(AsUserCollection asUserCollection); public Long insertAsUserCollection(AsUserCollection asUserCollection);
/** /**
* 修改用户收藏 * 修改用户收藏

View File

@ -7,6 +7,7 @@ import java.util.List;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.device.domain.vo.IdentifyRes; import com.ruoyi.device.domain.vo.IdentifyRes;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.AsPlantIdentifyLogMapper; import com.ruoyi.device.mapper.AsPlantIdentifyLogMapper;
@ -50,6 +51,7 @@ public class AsPlantIdentifyLogServiceImpl implements IAsPlantIdentifyLogService
for (AsPlantIdentifyLog log:asPlantIdentifyLogs ) { for (AsPlantIdentifyLog log:asPlantIdentifyLogs ) {
String response = log.getResponse(); String response = log.getResponse();
IdentifyRes identifyRes = JSONObject.parseObject(response, IdentifyRes.class); IdentifyRes identifyRes = JSONObject.parseObject(response, IdentifyRes.class);
if(ObjectUtils.isNotEmpty(identifyRes.getResult())){
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for (IdentifyRes.PlantItem item : identifyRes.getResult()) { for (IdentifyRes.PlantItem item : identifyRes.getResult()) {
BigDecimal b = item.getScore().multiply(new BigDecimal(100)).setScale(1, RoundingMode.HALF_UP); BigDecimal b = item.getScore().multiply(new BigDecimal(100)).setScale(1, RoundingMode.HALF_UP);
@ -57,6 +59,7 @@ public class AsPlantIdentifyLogServiceImpl implements IAsPlantIdentifyLogService
} }
log.setResponse(s.toString()); log.setResponse(s.toString());
} }
}
return asPlantIdentifyLogs; return asPlantIdentifyLogs;
} }

View File

@ -47,10 +47,16 @@ public class AsPlantServiceImpl extends ServiceImpl<AsPlantMapper, AsPlant> impl
public AsPlant selectAsPlantByPlantId(Long plantId) public AsPlant selectAsPlantByPlantId(Long plantId)
{ {
AsPlant asPlant = asPlantMapper.selectAsPlantByPlantId(plantId); AsPlant asPlant = asPlantMapper.selectAsPlantByPlantId(plantId);
if(ObjectUtils.isNotEmpty(asPlant)){
showBeam(asPlant); showBeam(asPlant);
showFunc(asPlant); showFunc(asPlant);
showFitSpace(asPlant); showFitSpace(asPlant);
showMoisture(asPlant); showMoisture(asPlant);
handleBeam(asPlant);
handleFuns(asPlant);
handleFitSpace(asPlant);
handleMoisture(asPlant);
}
return asPlant; return asPlant;
} }
@ -141,7 +147,7 @@ public class AsPlantServiceImpl extends ServiceImpl<AsPlantMapper, AsPlant> impl
sb.append(","); sb.append(",");
} }
} }
asPlant1.setBeam(sb.toString()); asPlant1.setBeamStr(sb.toString());
} }
} }
/** 处理功能数据*/ /** 处理功能数据*/
@ -159,7 +165,7 @@ public class AsPlantServiceImpl extends ServiceImpl<AsPlantMapper, AsPlant> impl
sb.append(","); sb.append(",");
} }
} }
asPlant1.setFunc(sb.toString()); asPlant1.setFuncStr(sb.toString());
} }
} }
/** 适合的空间*/ /** 适合的空间*/
@ -177,7 +183,7 @@ public class AsPlantServiceImpl extends ServiceImpl<AsPlantMapper, AsPlant> impl
sb.append(","); sb.append(",");
} }
} }
asPlant1.setFitSpace(sb.toString()); asPlant1.setFitSpaceStr(sb.toString());
} }
} }
/** 水分要求*/ /** 水分要求*/
@ -195,7 +201,7 @@ public class AsPlantServiceImpl extends ServiceImpl<AsPlantMapper, AsPlant> impl
sb.append(","); sb.append(",");
} }
} }
asPlant1.setMoisture(sb.toString()); asPlant1.setMoistureStr(sb.toString());
} }
} }

View File

@ -61,10 +61,11 @@ public class AsUserCollectionServiceImpl implements IAsUserCollectionService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertAsUserCollection(AsUserCollection asUserCollection) public Long insertAsUserCollection(AsUserCollection asUserCollection)
{ {
asUserCollection.setCreateTime(DateUtils.getNowDate()); asUserCollection.setCreateTime(DateUtils.getNowDate());
return asUserCollectionMapper.insertAsUserCollection(asUserCollection); asUserCollectionMapper.insertAsUserCollection(asUserCollection);
return asUserCollection.getCollectionId();
} }
/** /**