Commit 2e36366e authored by wuqinghua's avatar wuqinghua

2022/2/12 吴卿华

parent 0e0d90ad
package com.zehong.web.codeconfig;
import java.util.Random;
public class CodeConFig {
//生成四位随机数
public static String RandomCode(){
//生成一个6位随机数
String radom = String.valueOf(new Random().nextInt(999999));
String substring = radom.substring(0,4);
return substring;
}
}
...@@ -6,6 +6,7 @@ import com.zehong.system.domain.Listaw; ...@@ -6,6 +6,7 @@ import com.zehong.system.domain.Listaw;
import com.zehong.system.domain.TDetailInfoList; import com.zehong.system.domain.TDetailInfoList;
import com.zehong.system.domain.TDeviceInfoS; import com.zehong.system.domain.TDeviceInfoS;
import com.zehong.system.service.ITEmployedPeopleInfoService; import com.zehong.system.service.ITEmployedPeopleInfoService;
import com.zehong.web.codeconfig.CodeConFig;
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.*; import org.springframework.web.bind.annotation.*;
...@@ -77,8 +78,12 @@ public class TDeviceInfoController extends BaseController ...@@ -77,8 +78,12 @@ public class TDeviceInfoController extends BaseController
@PostMapping @PostMapping
public void add(@RequestBody Listaw listaw) public void add(@RequestBody Listaw listaw)
{ {
//生成四位随机码
String code = CodeConFig.RandomCode();
listaw.gettDeviceInfo().setDeviceCode(code);
//添加设备信息表数据 并且返回新增id //添加设备信息表数据 并且返回新增id
tDeviceInfoService.insertTDeviceInfo(listaw.gettDeviceInfo()); tDeviceInfoService.insertTDeviceInfo(listaw.gettDeviceInfo());
if (listaw.gettDeviceInfoS()!=null){ if (listaw.gettDeviceInfoS()!=null){
//将关联设备信息与设备进行绑定 //将关联设备信息与设备进行绑定
tDeviceInfoService.updatetRelationDeviceDetailInfo(listaw.gettDeviceInfoS(),listaw.gettDeviceInfo().getDeviceId(),listaw.gettDeviceInfo().getRelationDeviceType()); tDeviceInfoService.updatetRelationDeviceDetailInfo(listaw.gettDeviceInfoS(),listaw.gettDeviceInfo().getDeviceId(),listaw.gettDeviceInfo().getRelationDeviceType());
......
...@@ -294,7 +294,7 @@ ...@@ -294,7 +294,7 @@
<el-col :span="11"> <el-col :span="11">
<el-form-item label="设备编号" prop="deviceCode"> <el-form-item label="设备编号" prop="deviceCode">
<el-input v-model="form.deviceCode" placeholder="请输入设备编号" /> <el-input v-model="form.deviceCode" placeholder="请输入设备编号" :disabled="true"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
...@@ -566,18 +566,10 @@ export default { ...@@ -566,18 +566,10 @@ export default {
{ required: true, message: "请输入设备名称", trigger: "blur" }, { required: true, message: "请输入设备名称", trigger: "blur" },
// { min: 0, max: 20, message: "长度20位", trigger: "blur" }, // { min: 0, max: 20, message: "长度20位", trigger: "blur" },
], ],
deviceCode: [
{ required: true, message: "请输入设备编号", trigger: "blur" },
// { min: 0, max: 20, message: "长度20位", trigger: "blur" },
],
deviceAddr: [ deviceAddr: [
{ required: true, message: "请输入所在地址", trigger: "blur" }, { required: true, message: "请输入所在地址", trigger: "blur" },
// { min: 0, max: 30, message: "长度30位", trigger: "blur" }, // { min: 0, max: 30, message: "长度30位", trigger: "blur" },
], ],
deviceModel: [
{ required: true, message: "请输入设备型号", trigger: "blur" },
// { min: 0, max: 20, message: "长度20位", trigger: "blur" },
],
deviceType: [ deviceType: [
{ required: true, message: "请选择设备类型", trigger: "blur" }, { required: true, message: "请选择设备类型", trigger: "blur" },
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment