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;
import java.util.List;
import javax.annotation.Resource;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.device.service.IAsPlantService;
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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -35,6 +41,12 @@ public class AsUserCollectionController extends BaseController
@Autowired
private IAsUserCollectionService asUserCollectionService;
@Resource
private IAsUserService asUserService;
@Resource
private IAsPlantService asPlantService;
/**
* 查询用户收藏列表
*/
@ -44,6 +56,16 @@ public class AsUserCollectionController extends BaseController
{
startPage();
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);
}
@ -78,7 +100,8 @@ public class AsUserCollectionController extends BaseController
@PostMapping
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();
cachedToken = accessToken;
// 更新 token 过期时间
tokenExpirationTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(7200L);
tokenExpirationTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(3600L);
return cachedToken;
}
return cachedToken;

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ public interface IAsUserCollectionService
* @param asUserCollection 用户收藏
* @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.ruoyi.common.utils.DateUtils;
import com.ruoyi.device.domain.vo.IdentifyRes;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.AsPlantIdentifyLogMapper;
@ -50,12 +51,14 @@ public class AsPlantIdentifyLogServiceImpl implements IAsPlantIdentifyLogService
for (AsPlantIdentifyLog log:asPlantIdentifyLogs ) {
String response = log.getResponse();
IdentifyRes identifyRes = JSONObject.parseObject(response, IdentifyRes.class);
StringBuilder s = new StringBuilder();
for (IdentifyRes.PlantItem item : identifyRes.getResult()) {
BigDecimal b = item.getScore().multiply(new BigDecimal(100)).setScale(1, RoundingMode.HALF_UP);
s.append(item.getName()).append(":").append(b).append("%,");
if(ObjectUtils.isNotEmpty(identifyRes.getResult())){
StringBuilder s = new StringBuilder();
for (IdentifyRes.PlantItem item : identifyRes.getResult()) {
BigDecimal b = item.getScore().multiply(new BigDecimal(100)).setScale(1, RoundingMode.HALF_UP);
s.append(item.getName()).append(":").append(b).append("%,");
}
log.setResponse(s.toString());
}
log.setResponse(s.toString());
}
return asPlantIdentifyLogs;
}

View File

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

View File

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