feat():设备编码不允许重复创建

master
jiyufei 2 months ago
parent 56afb9a1c1
commit 5d89f11376

@ -31,7 +31,7 @@ public interface YysDeviceService extends IService<YysDeviceEntity> {
//副表数据方法
String checkForm(YysDeviceForm form, int i);
void saveOrUpdate(YysDeviceForm yysDeviceForm, String id, boolean isSave) throws Exception;
String saveOrUpdate(YysDeviceForm yysDeviceForm, String id, boolean isSave);
/**
* code

@ -22,6 +22,7 @@ import jnpf.service.YysDeviceMaterialService;
import jnpf.service.YysDeviceService;
import jnpf.service.YysDeviceUpkeepService;
import jnpf.util.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -309,7 +310,7 @@ public class YysDeviceServiceImpl extends ServiceImpl<YysDeviceMapper, YysDevice
*/
@Override
@Transactional
public void saveOrUpdate(YysDeviceForm yysDeviceForm, String id, boolean isSave) throws Exception {
public String saveOrUpdate(YysDeviceForm yysDeviceForm, String id, boolean isSave){
UserInfo userInfo = userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
yysDeviceForm = JsonUtil.getJsonToBean(
@ -317,6 +318,11 @@ public class YysDeviceServiceImpl extends ServiceImpl<YysDeviceMapper, YysDevice
YysDeviceEntity entity = JsonUtil.getJsonToBean(yysDeviceForm, YysDeviceEntity.class);
if (isSave) {
LambdaQueryWrapper<YysDeviceMaterialEntity> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(YysDeviceMaterialEntity::getDeviceCode, entity.getDeviceCode());
if (CollectionUtils.isNotEmpty(yysDeviceMaterialService.list(wrapper1))) {
return "不可以重复创建";
}
String mainId = RandomUtil.uuId();
entity.setCreatorTime(DateUtil.getNowDate());
entity.setCreatorUserId(userInfo.getUserId());
@ -335,6 +341,7 @@ public class YysDeviceServiceImpl extends ServiceImpl<YysDeviceMapper, YysDevice
//向设备维保表同步数据
yysDeviceUpkeepService.syncSaveOrUpdate(entity);
}
return "操作成功";
}
@Override

@ -116,12 +116,12 @@ public class YysDeviceController {
if (StringUtil.isNotEmpty(b)) {
return ActionResult.fail(b);
}
try {
yysDeviceService.saveOrUpdate(yysDeviceForm, null, true);
} catch (Exception e) {
return ActionResult.fail("新增数据失败");
}
String result = yysDeviceService.saveOrUpdate(yysDeviceForm, null, true);
if (result.contains("成功")) {
return ActionResult.success("创建成功");
} else {
return ActionResult.fail(result);
}
}
/**
@ -268,15 +268,14 @@ public class YysDeviceController {
}
YysDeviceEntity entity = yysDeviceService.getInfo(id);
if (entity != null) {
try {
yysDeviceService.saveOrUpdate(yysDeviceForm, id, false);
} catch (Exception e) {
return ActionResult.fail("修改数据失败");
}
return ActionResult.success("更新成功");
String result = yysDeviceService.saveOrUpdate(yysDeviceForm, id, false);
if (result.contains("成功")) {
return ActionResult.success(result);
} else {
return ActionResult.fail("更新失败,数据不存在");
return ActionResult.fail(result);
}
}
return ActionResult.fail("更新失败,数据不存在");
}
/**

@ -1,87 +1,43 @@
<template>
<el-dialog
:title="!dataForm.id ? '新建' : '编辑'"
:close-on-click-modal="false"
append-to-body
:visible.sync="visible"
class="JNPF-dialog JNPF-dialog_center"
lock-scroll
width="850px"
>
<el-dialog :title="!dataForm.id ? '新建' : '编辑'" :close-on-click-modal="false" append-to-body :visible.sync="visible"
class="JNPF-dialog JNPF-dialog_center" lock-scroll width="850px">
<el-row :gutter="15" class="">
<el-form
ref="formRef"
:model="dataForm"
:rules="dataRule"
size="small"
label-width="100px"
label-position="right"
>
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px"
label-position="right">
<template v-if="!loading">
<!-- 具体表单 -->
<el-col :span="24">
<jnpf-form-tip-item label="设备编号" prop="deviceCode">
<JnpfInput
v-model="dataForm.deviceCode"
@change="changeData('deviceCode', -1)"
placeholder="请输入设备编号"
clearable
:style="{ width: '100%' }"
>
<JnpfInput v-model="dataForm.deviceCode" @change="changeData('deviceCode', -1)" placeholder="请输入设备编号"
clearable :disabled="!isDisabled" :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="24">
<jnpf-form-tip-item label="设备名称" prop="deviceName">
<JnpfInput
v-model="dataForm.deviceName"
@change="changeData('deviceName', -1)"
placeholder="请输入设备名称"
clearable
:style="{ width: '100%' }"
>
<JnpfInput v-model="dataForm.deviceName" @change="changeData('deviceName', -1)" placeholder="请输入设备名称"
clearable :style="{ width: '100%' }">
</JnpfInput>
</jnpf-form-tip-item>
</el-col>
<el-col :span="24">
<jnpf-form-tip-item label="所属部门" prop="deviceDept">
<JnpfDepSelect
v-model="dataForm.deviceDept"
@change="changeData('deviceDept', -1)"
placeholder="请选择所属部门"
selectType="all"
:ableIds="ableAll.deviceDeptableIds"
clearable
:style="{ width: '100%' }"
>
<JnpfDepSelect v-model="dataForm.deviceDept" @change="changeData('deviceDept', -1)" placeholder="请选择所属部门"
selectType="all" :ableIds="ableAll.deviceDeptableIds" clearable :style="{ width: '100%' }">
</JnpfDepSelect>
</jnpf-form-tip-item>
</el-col>
<el-col :span="24">
<jnpf-form-tip-item label="设备类型" prop="deivceType">
<JnpfSelect
v-model="dataForm.deivceType"
@change="changeData('deivceType', -1)"
placeholder="请选择"
clearable
:style="{ width: '100%' }"
:options="deivceTypeOptions"
:props="deivceTypeProps"
>
<JnpfSelect v-model="dataForm.deivceType" @change="changeData('deivceType', -1)" placeholder="请选择"
clearable :style="{ width: '100%' }" :options="deivceTypeOptions" :props="deivceTypeProps">
</JnpfSelect>
</jnpf-form-tip-item>
</el-col>
<el-col :span="24">
<jnpf-form-tip-item label="启用状态" prop="enabledStatus">
<JnpfSelect
v-model="dataForm.enabledStatus"
@change="changeData('enabledStatus', -1)"
placeholder="请选择"
clearable
:style="{ width: '100%' }"
:options="enabledStatusOptions"
:props="enabledStatusProps"
>
<JnpfSelect v-model="dataForm.enabledStatus" @change="changeData('enabledStatus', -1)" placeholder="请选择"
clearable :style="{ width: '100%' }" :options="enabledStatusOptions" :props="enabledStatusProps">
</JnpfSelect>
</jnpf-form-tip-item>
</el-col>
@ -115,12 +71,7 @@
<h2>绑定物料列表</h2>
</div>
<el-table :data="dataForm.data" size="mini">
<el-table-column
type="index"
width="50"
label="序号"
align="center"
/>
<el-table-column type="index" width="50" label="序号" align="center" />
<!-- <el-table-column label="序号">
<template slot-scope="scope">
{{ scope.row.deviceCode }}
@ -138,31 +89,15 @@
</el-table-column>
<el-table-column label="8小时产量">
<template slot-scope="scope">
<JnpfInputNumber
v-model="scope.row.eightOutput"
@change="changeData('eightOutput', -1)"
placeholder="请输入"
clearable
:style="{ width: '100%' }"
:precision="2"
:step="1"
:min="0"
>
<JnpfInputNumber v-model="scope.row.eightOutput" @change="changeData('eightOutput', -1)"
placeholder="请输入" clearable :style="{ width: '100%' }" :precision="2" :step="1" :min="0">
</JnpfInputNumber>
</template>
</el-table-column>
<el-table-column label="12小时产量">
<template slot-scope="scope">
<JnpfInputNumber
v-model="scope.row.twelveOutput"
@change="changeData('twelveOutput', -1)"
placeholder="请输入"
clearable
:style="{ width: '100%' }"
:precision="2"
:step="1"
:min="0"
>
<JnpfInputNumber v-model="scope.row.twelveOutput" @change="changeData('twelveOutput', -1)"
placeholder="请输入" clearable :style="{ width: '100%' }" :precision="2" :step="1" :min="0">
</JnpfInputNumber>
</template>
</el-table-column>
@ -175,25 +110,15 @@
<!-- 表单结束 -->
</template>
</el-form>
<SelectDialog
v-if="selectDialogVisible"
:config="currTableConf"
:formData="dataForm"
ref="selectDialog"
@select="addForSelect"
@close="selectDialogVisible = false"
/>
<SelectDialog v-if="selectDialogVisible" :config="currTableConf" :formData="dataForm" ref="selectDialog"
@select="addForSelect" @close="selectDialogVisible = false" />
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false"> </el-button>
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading">
</el-button
>
</el-button>
</span>
<MaterialListDialog
ref="materialListDialog"
@cbSltdChg="fnSltdMaterialChg"
/>
<MaterialListDialog ref="materialListDialog" @cbSltdChg="fnSltdMaterialChg" />
</el-dialog>
</template>
@ -302,6 +227,9 @@ export default {
};
},
computed: {
isDisabled() {
return !this.dataForm.id;
},
...mapGetters(["userInfo"])
},
watch: {},
@ -312,6 +240,7 @@ export default {
},
mounted() { },
methods: {
fnMaterialListDialog() {
this.$nextTick(() => {
this.$refs.materialListDialog.init(this.dataForm.data);

Loading…
Cancel
Save