删除版本相关功能完善

This commit is contained in:
SjS 2025-05-16 10:33:36 +08:00
parent decbefe7d7
commit c0f41d8f7a
14 changed files with 455 additions and 301 deletions

View File

@ -1,6 +1,7 @@
package com.ruoyi.common.core.domain;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

View File

@ -25,13 +25,22 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="型号" prop="model">
<el-input
v-model="queryParams.model"
placeholder="请输入型号"
<el-select
v-model="queryParams.modelId"
filterable
clearable
@keyup.enter.native="handleQuery"
placeholder="请输入或选择型号"
@change="handleQuery"
>
<el-option
v-for="item in modelOptions"
:key="item.modelId"
:label="`${item.model}${item.modelName}`"
:value="item.modelId"
/>
</el-select>
</el-form-item>
<el-form-item label="Mac号" prop="mac">
<el-input
@ -46,6 +55,7 @@
v-model="queryParams.onlineStatus"
placeholder="请选择在线状态"
clearable
@change="handleQuery"
>
<el-option
v-for="dict in dict.type.as_online_status"
@ -69,10 +79,12 @@
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>搜索
</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>重置
</el-button
>
</el-form-item>
</el-form>
@ -87,7 +99,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['device:device:add']"
>新增</el-button
>新增
</el-button
>
</el-col>
<el-col :span="1.5">
@ -99,7 +112,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['device:device:edit']"
>修改</el-button
>修改
</el-button
>
</el-col>
<el-col :span="1.5">
@ -111,7 +125,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['device:device:remove']"
>删除</el-button
>删除
</el-button
>
</el-col>
<el-col :span="1.5">
@ -122,7 +137,8 @@
size="mini"
@click="handleExport"
v-hasPermi="['device:device:export']"
>导出</el-button
>导出
</el-button
>
</el-col>
<right-toolbar
@ -137,20 +153,19 @@
:data="deviceList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="deviceId" />
<el-table-column label="分类" align="center" prop="classifyName" />
<el-table-column label="设备Mac号" align="center" prop="mac" />
<el-table-column label="型号" align="center" prop="model" />
<el-table-column label="型号名称" align="center" prop="modelName" />
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="设备Mac号" align="center" prop="mac"/>
<el-table-column label="分类" align="center" prop="classifyName"/>
<el-table-column label="型号" align="center" prop="model"/>
<el-table-column label="型号名称" align="center" prop="modelName"/>
<el-table-column label="型号图片" align="center" prop="modelPicture" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.modelPicture" :width="50" :height="50" />
<image-preview :src="scope.row.modelPicture" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="版本号" align="center" prop="version" />
<el-table-column label="设备名称" align="center" prop="deviceName" />
<el-table-column label="用户" align="center" prop="userName" >
<el-table-column label="版本号" align="center" prop="version"/>
<el-table-column label="设备名称" align="center" prop="deviceName"/>
<el-table-column label="用户" align="center" prop="userName">
<template slot-scope="scope">
<router-link :to="'/user/user/userName/index/' + scope.row.userName" class="link-type">
<span>{{ scope.row.userName }}</span>
@ -159,7 +174,7 @@
</el-table-column>
<el-table-column label="设备图片" align="center" prop="picture" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.picture" :width="50" :height="50" />
<image-preview :src="scope.row.picture" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column
@ -183,7 +198,6 @@
</el-table-column>
<el-table-column
label="操作"
:width="200"
@ -197,7 +211,8 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['device:device:edit']"
>修改</el-button
>修改
</el-button
>
<el-button
size="mini"
@ -205,7 +220,8 @@
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['device:device:remove']"
>删除</el-button
>删除
</el-button
>
</template>
</el-table-column>
@ -249,7 +265,7 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="用户" prop="userId" >
<el-form-item label="用户" prop="userId">
<el-select
v-model="form.userId"
filterable
@ -295,7 +311,7 @@
<!-- 图片 -->
<el-form-item label="图片" prop="picture">
<image-upload v-model="form.picture" />
<image-upload v-model="form.picture"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -362,8 +378,6 @@
<!-- </el-col>-->
<script>
import {
listDevice,
@ -377,10 +391,11 @@ import {
getadd,
getxiug,
} from "@/api/device/device";
import { listClassify } from "@/api/device/classify";
import { listVersion } from "@/api/device/version";
import { listModel } from "@/api/device/model";
import { listUser } from "@/api/user/user";
import {listClassify} from "@/api/device/classify";
import {listVersion} from "@/api/device/version";
import {listModel} from "@/api/device/model";
import {listUser} from "@/api/user/user";
import model from "@/views/device/model/index.vue";
export default {
name: "Device",
@ -392,9 +407,9 @@ export default {
],
data() {
return {
checkedval:false,
value2: new Date(2016,9,12,18,40,12),
value1:'',
checkedval: false,
value2: new Date(2016, 9, 12, 18, 40, 12),
value1: '',
addflag: false,
addlist: [],
@ -475,7 +490,7 @@ export default {
classifyOptions: [],
//
versionOptions: [],
weekday:'',
weekday: '',
//
loading: true,
//
@ -503,14 +518,17 @@ export default {
modelName: null,
modelPicture: null,
model: null,
modelId: null,
mac: null,
orderBy: 'createTime',
order: 'desc',
onlineStatus: null,
nickName: null,
},
deviceidedit:'',
indexsedit:'',
isSwitchedit:'',
sjmiao:'',
deviceidedit: '',
indexsedit: '',
isSwitchedit: '',
sjmiao: '',
//
form: {
sprayTimeMin: null, //
@ -548,23 +566,23 @@ export default {
//
rules: {
deviceName: [
{ required: true, message: "设备名称不能为空", trigger: "blur" },
{required: true, message: "设备名称不能为空", trigger: "blur"},
],
classifyId: [
{ required: true, message: "分类不能为空", trigger: "blur" },
{required: true, message: "分类不能为空", trigger: "blur"},
],
pre: [
{ required: true, message: "设备名称不能为空", trigger: "blur" },
{required: true, message: "设备名称不能为空", trigger: "blur"},
],
versionId: [
{ required: true, message: "版本不能为空", trigger: "blur" },
{required: true, message: "版本不能为空", trigger: "blur"},
],
// classifyName: [
// { required: true, message: "", trigger: "blur" }
// ],
modelId: [{ required: true, message: "型号不能为空", trigger: "blur" }],
modelId: [{required: true, message: "型号不能为空", trigger: "blur"}],
// userId: [{ required: true, message: "", trigger: "blur" }],
mac: [{ required: true, message: "mac值不能为空", trigger: "blur" }],
mac: [{required: true, message: "mac值不能为空", trigger: "blur"}],
},
};
},
@ -573,9 +591,13 @@ export default {
if (userName != null) {
this.queryParams.userName = userName;
}
this.loadModelOptions();
this.getList();
},
computed: {
model() {
return model
},
// 0000000
dayBinaryString() {
//
@ -604,11 +626,16 @@ export default {
},
},
methods: {
loadModelOptions() {
listModel().then(response => {
this.modelOptions = response.rows;
});
},
// switchwater(){
// console.log(this.form.waterIntensity);
// },
//
inpqx(){
inpqx() {
if (this.checkedval == true) {
this.riindex = 1
this.yiindex = 1
@ -644,13 +671,13 @@ export default {
this.indexsedit = item.index;
this.isSwitchedit = item.isSwitch;
this.value = item.mode;
this.value1 = new Date(2016,9,12,item.startTime.slice(0, 2),item.startTime.slice(3, 5),item.startTime.slice(6, 8));
this.value1 = new Date(2016, 9, 12, item.startTime.slice(0, 2), item.startTime.slice(3, 5), item.startTime.slice(6, 8));
const miao = this.formatSeconds(item.wateringDuration)
this.value2 = new Date(2016,9,12,miao.slice(0, 2),miao.slice(3, 5),miao.slice(6, 8));
this.value2 = new Date(2016, 9, 12, miao.slice(0, 2), miao.slice(3, 5), miao.slice(6, 8));
this.weekday = item.week
// const weekday = weekdays.toString()
// console.log(this.weekday);
if(this.weekday == '1111111'){
if (this.weekday == '1111111') {
this.riindex = 1
this.yiindex = 1
this.erindex = 1
@ -659,7 +686,7 @@ export default {
this.wuindex = 1
this.liuindex = 1
this.funxz()
}else{
} else {
this.weekday = String(this.weekday);
this.weekday = this.weekday.padStart(7, '0')
this.yiindex = this.weekday.charAt(6)
@ -677,8 +704,8 @@ export default {
return parseInt(arr[0], 10) * 3600 + parseInt(arr[1], 10) * 60 + parseInt(arr[2], 10);
},
btnedit(){
this.addlist.push(this.yiindex==''?0:this.yiindex, this.erindex==''?0:this.erindex, this.sanindex == '' ? 0:this.sanindex, this.siindex == '' ? 0 :this.siindex, this.wuindex == 0 ? 0 :this.wuindex, this.liuindex == '' ? 0 : this.liuindex,this.riindex == '' ? 0 :this.riindex)
btnedit() {
this.addlist.push(this.yiindex == '' ? 0 : this.yiindex, this.erindex == '' ? 0 : this.erindex, this.sanindex == '' ? 0 : this.sanindex, this.siindex == '' ? 0 : this.siindex, this.wuindex == 0 ? 0 : this.wuindex, this.liuindex == '' ? 0 : this.liuindex, this.riindex == '' ? 0 : this.riindex)
console.log(this.addlist);
this.addlist = this.addlist.reverse().join('');
this.value1 = this.extractedTime(this.value1)
@ -688,11 +715,11 @@ export default {
let data = {
deviceId: this.deviceidedit,
startTimeStr: this.value1,
wateringDuration:this.sjmiao,
wateringDuration: this.sjmiao,
week: this.addlist,
mode:this.value,
isSwitch:this.isSwitchedit,
index:this.indexsedit
mode: this.value,
isSwitch: this.isSwitchedit,
index: this.indexsedit
}
getxiug(data).then(res => {
this.$message({
@ -722,7 +749,7 @@ export default {
//
return [hours, minutes, seconds];
},
},
extractedTime(originalDateString) {
//
const date = new Date(originalDateString);
@ -1078,7 +1105,8 @@ export default {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
.catch(() => {
});
},
//
onCheckboxChange(item) {
@ -1300,6 +1328,7 @@ export default {
background: #3dada9 !important;
color: #fff !important;
}
.circulate {
width: 600px;
height: 100%;
@ -1315,6 +1344,7 @@ export default {
padding-bottom: 20px;
box-sizing: border-box;
}
.circulatetext {
width: 100%;
display: flex;
@ -1326,6 +1356,7 @@ export default {
color: #3d3d3d;
line-height: 40px;
}
.circulateday {
width: 432px;
height: 60px;
@ -1335,10 +1366,12 @@ export default {
color: #3dada9;
line-height: 40px;
}
.circulatelist {
display: flex;
justify-content: space-between;
}
.circulatelist span {
width: 50px;
height: 50px;
@ -1349,6 +1382,7 @@ export default {
line-height: 50px;
border-radius: 50%;
}
.adddingshi {
width: 1000px;
background-color: #fff;
@ -1370,6 +1404,7 @@ export default {
.qx a:hover {
color: #409eff;
}
.mask {
width: 100%;
height: 100vh;
@ -1380,6 +1415,7 @@ export default {
z-index: 98;
left: 0;
}
/* 定时样式 */
.anniu {
text-align: right;
@ -1387,6 +1423,7 @@ export default {
padding-bottom: 40px;
box-sizing: border-box;
}
.dingshibox {
width: 1000px;
background-color: #fff;
@ -1400,12 +1437,14 @@ export default {
overflow: auto;
z-index: 99;
}
.dingshibox ul {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
padding-right: 40px;
}
.dingshibox ul li {
/* display: inline-block !important; */
flex: 0 0 calc(50% - 10px);
@ -1428,13 +1467,16 @@ export default {
margin-left: 10px;
color: #666;
}
.activeli {
background-color: #1890ff !important;
color: #fff !important;
}
.day ul li:hover {
cursor: pointer;
}
.day .title {
padding-left: 55px;
color: #1890ff;
@ -1442,19 +1484,23 @@ export default {
display: flex;
height: 20px;
}
.kongb {
width: 100%;
height: 220px;
}
.switch-margin {
margin-right: 40px;
float: right;
padding: 15px 0 0 0;
}
.margin-5px {
margin-left: 5px;
width: 90%;
}
.fontdesc {
font-size: 14px;
font-weight: 600;
@ -1471,29 +1517,36 @@ export default {
padding: 5px;
height: 200px;
}
.div1 {
margin-left: 20px;
padding: 5px 0 0 0;
height: 40px;
}
.div1:hover {
background-color: #e7e7e7;
}
.span1 {
font-weight: 500;
float: left;
}
.span2 {
float: right;
width: 100px !important;
}
.span3 {
float: right;
line-height: 30px;
}
.el-form-item {
margin-bottom: 10px;
}
.font11 {
font-size: 11px;
color: #7a7a7a;
@ -1502,24 +1555,30 @@ export default {
.col-style {
margin-top: 10px;
}
.switch-water .el-slider__button {
width: 30px;
height: 30px;
background-color: #1890ff;
}
.switch-water {
padding-top: 25px;
padding-right: 20px;
}
.margin-top20 {
margin-top: 20px;
}
.el-select {
width: 100%;
}
.col-style {
margin-right: 15px;
}
.el-col-12 {
width: 48%;
}

View File

@ -83,7 +83,6 @@
<!-- 列表区 -->
<el-table v-loading="loading" :data="versionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="versionId" />
<el-table-column label="型号" align="center" prop="model" />
<el-table-column label="型号名称" align="center" prop="modelName" />
<el-table-column label="版本号" align="center" prop="version" />

View File

@ -101,7 +101,7 @@ public class AsDeviceVersionController extends BaseController
@PreAuthorize("@ss.hasPermi('device:version:remove')")
@Log(title = "固件版本", businessType = BusinessType.DELETE)
@DeleteMapping("/{versionIds}")
public AjaxResult remove(@PathVariable Long[] versionIds)
public AjaxResult remove(@PathVariable List<Long> versionIds)
{
return toAjax(asDeviceVersionService.deleteAsDeviceVersionByVersionIds(versionIds));
}

View File

@ -79,4 +79,7 @@ public class AsModel extends BaseEntity
@Excel(name = "介绍视频")
private String video;
@Excel(name = "版本ID列表")
private List<Long> versionIdList;
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.device.domain.AsDeviceVersion;
import org.apache.ibatis.annotations.Param;
/**
* 固件版本Mapper接口
@ -65,7 +66,7 @@ public interface AsDeviceVersionMapper extends BaseMapper<AsDeviceVersion>
* @param versionIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteAsDeviceVersionByVersionIds(Long[] versionIds);
public int deleteAsDeviceVersionByVersionIds(@Param("ids") List<Long> versionIds);
public List<String> selectAsDeviceVersionByModelId(Long modelId);

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.device.domain.AsDeviceVersion;
import com.ruoyi.device.domain.AsModel;
import com.ruoyi.device.domain.vo.AsModelVO;
import org.apache.ibatis.annotations.Param;
/**
* 型号列表Mapper接口
@ -81,4 +82,5 @@ public interface AsModelMapper extends BaseMapper<AsModel>
public AsModelVO checkModelByPre(AsModel asModel);
List<AsModelVO> selectAsModelByVersionIds(@Param("ids") List<Long> versionIds);
}

View File

@ -58,7 +58,7 @@ public interface IAsDeviceVersionService
* @param versionIds 需要删除的固件版本主键集合
* @return 结果
*/
public int deleteAsDeviceVersionByVersionIds(Long[] versionIds);
public int deleteAsDeviceVersionByVersionIds(List<Long> versionIds);
/**
* 删除固件版本信息

View File

@ -91,4 +91,11 @@ public interface IAsModelService
* @return
*/
AsModelVO selectAsModelByPre(AsModel asModel);
/**
* 根据版本号查询对应的设备信息
* @param versionIds
* @return
*/
List<AsModelVO> selectAsModelByVersionIds(List<Long> versionIds);
}

View File

@ -306,6 +306,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
}
// 设置版本数据
AsDeviceVersion asDeviceVersion = versionMapper.selectAsDeviceVersionByVersionId(model.getVersionId());
ServiceUtil.assertion(asDeviceVersion == null,"当前型号版本信息不存在,请绑定版本后再进行操作");
asDevice.setVersion(asDeviceVersion.getVersion());
asDevice.setVersionId(model.getVersionId());
asDevice.setIsDefault("1");
@ -521,8 +522,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
i = asDeviceMapper.insertAsDevice(device);
}
ServiceUtil.assertion(i == 0, "绑定失败!");
// 切换默认设备
// toggleDevice(asDevice.getUserId(), asDevice.getDeviceId());
logger.info("=================【绑定设备】成功==================");
return Boolean.TRUE;
});

View File

@ -5,15 +5,20 @@ import java.util.Collections;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.device.domain.AsModel;
import com.ruoyi.device.domain.vo.AsModelVO;
import com.ruoyi.device.mapper.AsModelMapper;
import com.ruoyi.device.service.IAsModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.AsDeviceVersionMapper;
import com.ruoyi.device.domain.AsDeviceVersion;
import com.ruoyi.device.service.IAsDeviceVersionService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import javax.annotation.Resource;
@ -31,6 +36,11 @@ public class AsDeviceVersionServiceImpl extends ServiceImpl<AsDeviceVersionMappe
@Resource
private IAsModelService asModelService;
@Autowired
private TransactionTemplate transactionTemplate;
@Autowired
private AsModelMapper asModelMapper;
/**
* 查询固件版本
*
@ -75,7 +85,7 @@ public class AsDeviceVersionServiceImpl extends ServiceImpl<AsDeviceVersionMappe
@Override
public int insertAsDeviceVersion(AsDeviceVersion asDeviceVersion)
{
asDeviceVersion.setCreateTime(DateUtils.getNowDate());
asDeviceVersion.setCreateLocalDateTime(LocalDateTime.now());
return asDeviceVersionMapper.insertAsDeviceVersion(asDeviceVersion);
}
@ -91,10 +101,26 @@ public class AsDeviceVersionServiceImpl extends ServiceImpl<AsDeviceVersionMappe
asDeviceVersion.setUpdateTime(DateUtils.getNowDate());
// 更新对应的设备固件版本为最新的版本
AsDeviceVersion latestAsDeviceVersion = asDeviceVersionMapper.selectLatestAsDeviceVersion(asDeviceVersion.getModelId());
ServiceUtil.assertion(latestAsDeviceVersion==null,"设备未绑定过固件版本");
AsModel asModel = asModelService.selectAsModelByModelId(asDeviceVersion.getModelId());
ServiceUtil.assertion(asModel==null,"该型号不存在");
if (asDeviceVersion.getCreateLocalDateTime().isAfter(latestAsDeviceVersion.getCreateLocalDateTime())){
asModel.setVersion(asDeviceVersion.getVersion());
asModel.setVersionId(asDeviceVersion.getVersionId());
}else {
asModel.setVersionId(latestAsDeviceVersion.getVersionId());
asModelService.updateAsModel(asModel);
return asDeviceVersionMapper.updateAsDeviceVersion(asDeviceVersion);
asModel.setVersion(latestAsDeviceVersion.getVersion());
}
Boolean execute = transactionTemplate.execute(e -> {
// 更新型号对应的版本号
int i = asModelMapper.updateAsModel(asModel);
ServiceUtil.assertion(i == 0, "修改失败!");
i = asDeviceVersionMapper.updateAsDeviceVersion(asDeviceVersion);
ServiceUtil.assertion(i == 0, "修改失败!");
return Boolean.TRUE;
});
if(Boolean.FALSE.equals(execute))throw new ServiceException("修改失败");
return 1;
}
/**
@ -104,9 +130,22 @@ public class AsDeviceVersionServiceImpl extends ServiceImpl<AsDeviceVersionMappe
* @return 结果
*/
@Override
public int deleteAsDeviceVersionByVersionIds(Long[] versionIds)
public int deleteAsDeviceVersionByVersionIds(List<Long> versionIds)
{
return asDeviceVersionMapper.deleteAsDeviceVersionByVersionIds(versionIds);
List<AsModelVO> asModelVOS = asModelService.selectAsModelByVersionIds(versionIds);
Boolean execute = transactionTemplate.execute(e -> {
for (AsModelVO asModelVO : asModelVOS) {
asModelVO.setVersionId(null);
int i = asModelMapper.updateAsModel(asModelVO);
ServiceUtil.assertion(i == 0, "删除失败!");
}
int i = asDeviceVersionMapper.deleteAsDeviceVersionByVersionIds(versionIds);
ServiceUtil.assertion(i == 0, "删除失败!");
return Boolean.TRUE;
});
if(Boolean.FALSE.equals(execute))throw new ServiceException("删除失败");
return 1;
}
/**
@ -127,15 +166,19 @@ public class AsDeviceVersionServiceImpl extends ServiceImpl<AsDeviceVersionMappe
}
@Override
@Transactional
public int insertAsDeviceVersionAndUpdateAsModel(AsDeviceVersion asDeviceVersion) {
asDeviceVersion.setCreateLocalDateTime(LocalDateTime.now());
int rows = asDeviceVersionMapper.insertAsDeviceVersion(asDeviceVersion);
if (rows > 0) {
Boolean execute = transactionTemplate.execute(e -> {
// 更新型号对应的版本号
int i = asDeviceVersionMapper.insertAsDeviceVersion(asDeviceVersion);
ServiceUtil.assertion(i == 0, "修改失败!");
AsModel asModel = asModelService.selectAsModelByModelId(asDeviceVersion.getModelId());
asModel.setVersionId(asDeviceVersion.getVersionId());
asModelService.updateAsModel(asModel);
}
return rows;
i = asModelMapper.updateAsModel(asModel);
ServiceUtil.assertion(i == 0, "修改失败!");
return Boolean.TRUE;
});
if(Boolean.FALSE.equals(execute))throw new ServiceException("修改失败");
return 1;
}
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.device.service.impl;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -154,16 +155,31 @@ public class AsModelServiceImpl extends ServiceImpl<AsModelMapper, AsModel> impl
AsDeviceClassify deviceClassify = classifyMapper.selectAsDeviceClassifyByClassifyId(asModel.getClassifyId());
String classifyName = deviceClassify.getClassifyName();
asModel.setClassifyName(classifyName);
Boolean execute = transactionTemplate.execute(e -> {
// 插入型号数据
int i = asModelMapper.updateAsModel(asModel);
asModelVideoMapper.updateAsModelVideo(asModel);
ServiceUtil.assertion(i == 0, "更新失败!");
// 更新型号视频表
if (asModel.getVideo() != null) {
i = asModelVideoMapper.updateAsModelVideo(asModel);
ServiceUtil.assertion(i == 0, "更新失败!");
}
// 更新设备对应的型号
AsDeviceQuery device = new AsDeviceQuery();
device.setModelId(asModel.getModelId());
List<AsDevice> asDevices = deviceMapper.selectAsDeviceList(device);
if (!asDevices.isEmpty()) {
for(AsDevice device1: asDevices){
device1.setModel(asModel.getModel());
deviceMapper.updateAsDevice(device1);
i = deviceMapper.updateAsDevice(device1);
ServiceUtil.assertion(i == 0, "更新失败!");
}
return i;
}
return Boolean.TRUE;
});
if(Boolean.FALSE.equals(execute))throw new ServiceException("更新失败");
return 1;
}
/**
@ -242,4 +258,11 @@ public class AsModelServiceImpl extends ServiceImpl<AsModelMapper, AsModel> impl
ServiceUtil.assertion(asModelVO == null,"当前型号不存在");
return asModelVO;
}
@Override
public List<AsModelVO> selectAsModelByVersionIds(List<Long> versionIds) {
AsModel asModel = new AsModel();
asModel.setVersionIdList(versionIds);
return asModelMapper.selectAsModelByVersionIds(versionIds);
}
}

View File

@ -124,9 +124,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from as_device_version where version_id = #{versionId}
</delete>
<delete id="deleteAsDeviceVersionByVersionIds" parameterType="String">
<delete id="deleteAsDeviceVersionByVersionIds" parameterType="Long">
delete from as_device_version where version_id in
<foreach item="versionId" collection="array" open="(" separator="," close=")">
<foreach item="versionId" collection="ids" open="(" separator="," close=")">
#{versionId}
</foreach>
</delete>

View File

@ -1,29 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.device.mapper.AsModelMapper">
<resultMap type="AsModel" id="AsModelResult">
<result property="modelId" column="model_id" />
<result property="classifyId" column="classify_id" />
<result property="modelName" column="model_name" />
<result property="model" column="model" />
<result property="picture" column="picture" />
<result property="idCode" column="id_code" />
<result property="classifyName" column="classify_name" />
<result property="versionId" column="version_id" />
<result property="introduce" column="introduce" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="modelId" column="model_id"/>
<result property="classifyId" column="classify_id"/>
<result property="modelName" column="model_name"/>
<result property="model" column="model"/>
<result property="picture" column="picture"/>
<result property="idCode" column="id_code"/>
<result property="classifyName" column="classify_name"/>
<result property="versionId" column="version_id"/>
<result property="introduce" column="introduce"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectAsModelVo">
select
am.model_id,
select am.model_id,
am.classify_id,
am.model_name,
am.article_id,
@ -51,13 +50,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAsModelList" parameterType="AsModel" resultMap="AsModelResult">
<include refid="selectAsModelVo"/>
<where>
<if test="modelName != null and modelName != ''"> and am.model_name like concat('%', #{modelName}, '%')</if>
<if test="model != null and model != ''"> and am.model = #{model}</if>
<if test="picture != null and picture != ''"> and am.picture = #{picture}</if>
<if test="idCode != null and idCode != ''"> and am.id_code = #{idCode}</if>
<if test="classifyName != null and classifyName != ''"> and am.classify_name like concat('%', #{classifyName}, '%')</if>
<if test="versionId != null "> and am.version_id = #{versionId}</if>
<if test="introduce != null and introduce != ''"> and am.introduce = #{introduce}</if>
<if test="modelName != null and modelName != ''">and am.model_name like concat('%', #{modelName}, '%')</if>
<if test="model != null and model != ''">and am.model = #{model}</if>
<if test="picture != null and picture != ''">and am.picture = #{picture}</if>
<if test="idCode != null and idCode != ''">and am.id_code = #{idCode}</if>
<if test="classifyName != null and classifyName != ''">and am.classify_name like concat('%',
#{classifyName}, '%')
</if>
<if test="versionId != null ">and am.version_id = #{versionId}</if>
<if test="introduce != null and introduce != ''">and am.introduce = #{introduce}</if>
</where>
</select>
@ -67,7 +68,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkModelUnique" parameterType="String" resultMap="AsModelResult">
select model_id, model from as_model where model = #{model} limit 1
select model_id, model
from as_model
where model = #{model} limit 1
</select>
<select id="selectAsModelByModel" parameterType="string" resultMap="AsModelResult">
@ -78,11 +81,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="checkModelByPre" resultType="com.ruoyi.device.domain.vo.AsModelVO">
<include refid="selectAsModelVo"/>
<where>
<if test="pre != null and pre != ''">and FIND_IN_SET (#{pre},am.pre) </if>
<if test="pre != null and pre != ''">and FIND_IN_SET (#{pre},am.pre)</if>
<if test="modelId != null and modelId != ''">and am.model_id != #{modelId}</if>
</where>
</select>
<select id="selectAsModelByVersionIds" resultType="com.ruoyi.device.domain.vo.AsModelVO">
select
am.model_id,
am.version_id
from as_model am
where am.version_id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertAsModel" parameterType="AsModel" useGeneratedKeys="true" keyProperty="modelId">
insert into as_model
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -131,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="idCode != null">id_code = #{idCode},</if>
<if test="classifyName != null">classify_name = #{classifyName},</if>
<if test="versionId != null">version_id = #{versionId},</if>
<if test="versionId == null">version_id = null,</if>
<if test="introduce != null">introduce = #{introduce},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
@ -143,7 +158,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteAsModelByModelId" parameterType="Long">
delete from as_model where model_id = #{modelId}
delete
from as_model
where model_id = #{modelId}
</delete>
<delete id="deleteAsModelByModelIds" parameterType="String">