去掉了设备表
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
|
||||
package org.nl.wms.pdm.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.wms.pdm.service.DeviceService;
|
||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author geng by
|
||||
* @date 2022-05-25
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "生产设备管理")
|
||||
@RequestMapping("/api/device")
|
||||
@Slf4j
|
||||
public class DeviceController {
|
||||
|
||||
private final DeviceService deviceService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询生产设备")
|
||||
@ApiOperation("查询生产设备")
|
||||
//@SaCheckPermission("device:list")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(deviceService.queryAll(whereJson,page),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增生产设备")
|
||||
@ApiOperation("新增生产设备")
|
||||
//@SaCheckPermission("device:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody DeviceDto dto){
|
||||
deviceService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改生产设备")
|
||||
@ApiOperation("修改生产设备")
|
||||
//@SaCheckPermission("device:edit")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody DeviceDto dto){
|
||||
deviceService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除生产设备")
|
||||
@ApiOperation("删除生产设备")
|
||||
//@SaCheckPermission("device:del")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
deviceService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/changeActive")
|
||||
@Log("修改点位启用状态")
|
||||
@ApiOperation("修改点位启用状态")
|
||||
public ResponseEntity<Object> changeActive(@RequestBody JSONObject json) {
|
||||
deviceService.changeActive(json);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
|
||||
package org.nl.wms.pdm.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author geng by
|
||||
* @date 2022-05-25
|
||||
**/
|
||||
public interface DeviceService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param whereJson 条件参数
|
||||
* @return List<DeviceDto>
|
||||
*/
|
||||
List<DeviceDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param device_id ID
|
||||
* @return Device
|
||||
*/
|
||||
DeviceDto findById(Long device_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
* @param code code
|
||||
* @return Device
|
||||
*/
|
||||
DeviceDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param dto /
|
||||
*/
|
||||
void create(DeviceDto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param dto /
|
||||
*/
|
||||
void update(DeviceDto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
|
||||
void changeActive(JSONObject json);
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
|
||||
package org.nl.wms.pdm.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.pdm.service.DeviceService;
|
||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author geng by
|
||||
* @description 服务实现
|
||||
* @date 2022-05-25
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String search = MapUtil.getStr(whereJson, "search");
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "1");
|
||||
if (!StrUtil.isEmpty(search)) {
|
||||
map.put("search", "%" + search + "%");
|
||||
}
|
||||
JSONObject json = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "device.device_model, device.device_code");
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(DeviceDto.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDto findById(Long device_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONObject json = wo.query("device_id = '" + device_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DeviceDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONObject json = wo.query("device_code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DeviceDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(DeviceDto dto) {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
//编码唯一性校验
|
||||
String device_code = dto.getDevice_code();
|
||||
DeviceDto byCode = this.findByCode(device_code);
|
||||
if (ObjectUtil.isNotEmpty(byCode)) throw new BadRequestException("编码已存在!");
|
||||
dto.setDevice_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DeviceDto dto) {
|
||||
DeviceDto entity = this.findById(dto.getDevice_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
//编码唯一性校验
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
String where = "is_delete = '0' and device_code = '" + dto.getDevice_code() + "' and device_id != '" + dto.getDevice_id() + "'";
|
||||
|
||||
JSONObject jsonObject = wo.query(where).uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject)) {
|
||||
throw new BadRequestException("编码已存在!");
|
||||
}
|
||||
|
||||
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
for (Long device_id : ids) {
|
||||
wo.delete("device_id = '" + device_id + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeActive(JSONObject json) {
|
||||
String is_used = "1";
|
||||
if (StrUtil.equals("1", json.getString("is_used"))) {
|
||||
is_used = "0";
|
||||
}
|
||||
json.put("is_used", is_used);
|
||||
WQLObject.getWQLObject("PDM_BI_Device").update(json);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -1,74 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/device',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/device/',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/device',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getWorkprocedure() {
|
||||
return request({
|
||||
url: 'api/device/getWorkprocedure',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getItemByDevice(data) {
|
||||
return request({
|
||||
url: 'api/device/getItemByDevice',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function savaDeviceItem(data) {
|
||||
return request({
|
||||
url: 'api/device/savaDeviceItem',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getItemByDeviceId(data) {
|
||||
return request({
|
||||
url: 'api/device/getItemByDeviceId',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function copyAdd(data) {
|
||||
return request({
|
||||
url: 'api/device/copyAdd',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function changeActive(data) {
|
||||
return request({
|
||||
url: 'api/device/changeActive',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getWorkprocedure, getItemByDeviceId, copyAdd, changeActive }
|
||||
@@ -1,156 +0,0 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<label class="el-form-item-label">模糊搜索</label>
|
||||
<el-input
|
||||
v-model="query.search"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="请输入设备编码或名称"
|
||||
style="width: 220px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
|
||||
<el-form-item label="设备编码" prop="device_code">
|
||||
<el-input v-model="form.device_code" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称" prop="device_name">
|
||||
<el-input v-model="form.device_name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设备型号">
|
||||
<el-input v-model="form.device_model" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设备产能">
|
||||
<el-input v-model="form.productivity" type="number" oninput="value = value.replace(/[^\d]/g, '')" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="外部编码">
|
||||
<el-input v-model="form.extend_code" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" :rows="3" type="textarea" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="device_code" label="设备编码" />
|
||||
<el-table-column prop="device_name" label="设备名称" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="device_model" label="设备型号" min-width="100" show-overflow-tooltip >
|
||||
<template slot-scope="scope">
|
||||
{{ dict.label.pdm_device_type[scope.row.device_model] }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="productivity" label="设备产能" />
|
||||
<el-table-column label="是否启用" align="center" prop="is_used">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
:value="format_is_used(scope.row.is_used)"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
@change="changeEnabled(scope.row, scope.row.is_used)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" />
|
||||
<el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudDevice from '@/api/wms/pdm/device'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
const defaultForm = { device_id: null, device_code: null, device_name: null, device_model: null, workprocedure_id: null, extend_code: null, devicebill_id: null, remark: null, is_active: null, create_id: null, create_name: null, create_time: null, is_delete: null, productivity: null }
|
||||
export default {
|
||||
name: 'Device',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
dicts: ['pdm_device_type'],
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: '生产设备', url: 'api/device', idField: 'device_id', sort: 'device_id,desc',
|
||||
optShow: {
|
||||
add: true,
|
||||
edit: false,
|
||||
del: false,
|
||||
reset: true,
|
||||
download: false
|
||||
},
|
||||
crudMethod: { ...crudDevice }})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {
|
||||
},
|
||||
rules: {
|
||||
device_code: [
|
||||
{ required: true, message: '设备编码不能为空', trigger: 'blur' }
|
||||
],
|
||||
device_name: [
|
||||
{ required: true, message: '设备名称不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
changeEnabled(data, val) {
|
||||
let msg = '此操作将停用设备,是否继续!'
|
||||
if (val !== '1') {
|
||||
msg = '此操作将启用设备,是否继续!'
|
||||
}
|
||||
this.$confirm(msg, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
crudDevice.changeActive(data).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
}).catch(() => {
|
||||
data.is_used = !data.is_used
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
format_is_used(is_used) {
|
||||
return is_used === '1'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user