opt:设备状态监控wql改成mybatis plus
This commit is contained in:
@@ -39,6 +39,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -61,8 +62,13 @@ public class UserController {
|
||||
return new ResponseEntity(TableDataInfo.build(userService.getUserDetail(query, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增用户")
|
||||
@PostMapping(value = "/getUserList")
|
||||
public ResponseEntity<Object> query() {
|
||||
List<SysUser> userList = userService.list(new QueryWrapper<SysUser>().eq("is_used", true));
|
||||
return new ResponseEntity(userList, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增用户")
|
||||
@PostMapping
|
||||
// @SaCheckPermission("user:add")
|
||||
public ResponseEntity<Object> create(@RequestBody Map user) {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.nl.wms.basedata.master.devicestatus.controller;
|
||||
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.DeviceStatusService;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dao.DeviceStatus;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dto.DeviceStatusQuery;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @date 2021-12-06
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/devicestatus")
|
||||
@Slf4j
|
||||
public class DeviceStatusController {
|
||||
|
||||
private final DeviceStatusService deviceStatusService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询设备状态监控")
|
||||
public ResponseEntity<Object> query(DeviceStatusQuery whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(deviceStatusService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增客户基础表")
|
||||
public ResponseEntity<Object> create(@RequestBody DeviceStatus jo) {
|
||||
deviceStatusService.create(jo);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
@Log("修改客户基础表")
|
||||
public ResponseEntity<Object> update(@RequestBody DeviceStatus jo) {
|
||||
deviceStatusService.update(jo);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.nl.wms.basedata.master.devicestatus.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dao.DeviceStatus;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dto.DeviceStatusQuery;
|
||||
|
||||
/**
|
||||
* @author liuxy
|
||||
* @description 服务接口
|
||||
* @date 2023-04-20
|
||||
**/
|
||||
public interface DeviceStatusService extends IService<DeviceStatus> {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
IPage<DeviceStatus> queryAll(DeviceStatusQuery whereJson, PageQuery page);
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param jo /
|
||||
*/
|
||||
void create(DeviceStatus jo);
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
*/
|
||||
void update(DeviceStatus jo);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.nl.wms.basedata.master.devicestatus.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: zds
|
||||
* @date: 2024-09-27
|
||||
* @description:
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("em_bi_devicestatus")
|
||||
public class DeviceStatus implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "devicestatus_id", type = IdType.NONE)
|
||||
private String devicestatus_id;
|
||||
|
||||
private String device_code;
|
||||
|
||||
private String device_name;
|
||||
|
||||
private String product_area;
|
||||
|
||||
private String plan;
|
||||
|
||||
private String device_type;
|
||||
|
||||
private String mode;
|
||||
|
||||
private String mode_update_time;
|
||||
|
||||
private String error;
|
||||
|
||||
private String error_msg;
|
||||
|
||||
private String error_update_time;
|
||||
|
||||
private String is_upload;
|
||||
|
||||
private String upload_time;
|
||||
|
||||
private String upload_flag;
|
||||
|
||||
private String upload_user;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.wms.basedata.master.devicestatus.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dao.DeviceStatus;
|
||||
import org.nl.wms.basedata.master.faultdevice.service.dao.FaultDevice;
|
||||
|
||||
/**
|
||||
* @author: zds
|
||||
* @date: 2024-09-27
|
||||
* @description:
|
||||
*/
|
||||
public interface DeviceStatusMapper extends BaseMapper<DeviceStatus> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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">
|
||||
<mapper namespace="org.nl.wms.basedata.master.devicestatus.service.dao.mapper.DeviceStatusMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.wms.basedata.master.devicestatus.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author: zds
|
||||
* @date: 2024-09-27
|
||||
* @description:
|
||||
*/
|
||||
@Data
|
||||
public class DeviceStatusQuery implements Serializable {
|
||||
//设备编码或设备名称
|
||||
private String search;
|
||||
//车间区域
|
||||
private String product_area;
|
||||
//类型
|
||||
private String device_type;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.nl.wms.basedata.master.devicestatus.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.DeviceStatusService;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dao.DeviceStatus;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dao.mapper.DeviceStatusMapper;
|
||||
import org.nl.wms.basedata.master.devicestatus.service.dto.DeviceStatusQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* @author liuxy
|
||||
* @description 服务实现
|
||||
* @date 2023-04-20
|
||||
**/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, DeviceStatus> implements DeviceStatusService {
|
||||
|
||||
@Autowired
|
||||
private DeviceStatusMapper deviceStatusMapper;
|
||||
|
||||
@Override
|
||||
public IPage<DeviceStatus> queryAll(DeviceStatusQuery whereJson, PageQuery page) {
|
||||
|
||||
IPage<DeviceStatus> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
LambdaQueryWrapper<DeviceStatus> lam = new LambdaQueryWrapper<DeviceStatus>();
|
||||
|
||||
lam.eq(ObjectUtil.isNotEmpty(whereJson.getDevice_type()), DeviceStatus::getDevice_type, whereJson.getDevice_type())
|
||||
.eq(ObjectUtil.isNotEmpty(whereJson.getProduct_area()), DeviceStatus::getProduct_area, whereJson.getProduct_area())
|
||||
.and(ObjectUtil.isNotEmpty(whereJson.getSearch()),blam -> blam.like(DeviceStatus::getDevice_code, whereJson.getSearch()).or()
|
||||
.like(DeviceStatus::getDevice_name, whereJson.getSearch()))
|
||||
.orderByDesc(DeviceStatus::getDevice_code);
|
||||
deviceStatusMapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(DeviceStatus jo) {
|
||||
LambdaQueryWrapper<DeviceStatus> lam = new LambdaQueryWrapper<DeviceStatus>();
|
||||
lam.eq(DeviceStatus::getDevice_code,jo.getDevice_code());
|
||||
DeviceStatus deviceStatus = deviceStatusMapper.selectOne(lam);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(deviceStatus)) {
|
||||
throw new BadRequestException("已存在相同的设备编码!");
|
||||
}else{//新增
|
||||
deviceStatusMapper.insert(jo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DeviceStatus jo) {
|
||||
LambdaQueryWrapper<DeviceStatus> lam = new LambdaQueryWrapper<DeviceStatus>();
|
||||
lam.eq(DeviceStatus::getDevice_code,jo.getDevice_code());
|
||||
DeviceStatus deviceStatus = deviceStatusMapper.selectOne(lam);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(deviceStatus)) {
|
||||
String devicestatus_id = deviceStatus.getDevicestatus_id();
|
||||
if(devicestatus_id.equals(jo.getDevicestatus_id())){
|
||||
deviceStatusMapper.updateById(jo);
|
||||
}else{
|
||||
throw new BadRequestException("已存在相同的设备编码!");
|
||||
}
|
||||
}else{//新增
|
||||
deviceStatusMapper.insert(jo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package org.nl.wms.basedata.master.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.wms.basedata.master.service.DeviceStatusService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @date 2021-12-06
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@RequestMapping("/api/devicestatus")
|
||||
@Slf4j
|
||||
public class DeviceStatusController {
|
||||
|
||||
private final DeviceStatusService deviceStatusService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询设备状态监控")
|
||||
|
||||
//@PreAuthorize("@el.check('customerbase:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(deviceStatusService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增客户基础表")
|
||||
|
||||
//@PreAuthorize("@el.check('customerbase:add')")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject jo) {
|
||||
deviceStatusService.create(jo);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
@Log("修改客户基础表")
|
||||
|
||||
//@PreAuthorize("@el.check('customerbase:edit')")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject jo) {
|
||||
deviceStatusService.update(jo);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除客户基础表")
|
||||
|
||||
//@PreAuthorize("@el.check('customerbase:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
deviceStatusService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package org.nl.wms.basedata.master.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.basedata.master.service.dto.CustomerbaseDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @description 服务接口
|
||||
* @date 2021-12-06
|
||||
**/
|
||||
public interface DeviceStatusService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param whereJson 条件参数
|
||||
* @return List<CustomerbaseDto>
|
||||
*/
|
||||
List<CustomerbaseDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param jo /
|
||||
*/
|
||||
void create(JSONObject jo);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param jo /
|
||||
*/
|
||||
void update(JSONObject jo);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package org.nl.wms.basedata.master.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.basedata.master.service.DeviceStatusService;
|
||||
import org.nl.wms.basedata.master.service.dto.CustomerbaseDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @description 服务实现
|
||||
* @date 2021-12-06
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DeviceStatusServiceImpl implements DeviceStatusService {
|
||||
@Autowired
|
||||
private DeviceStatusService deviceStatusService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String where = "1=1";
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicestatus");
|
||||
String search = (String) whereJson.get("search");
|
||||
if (!StrUtil.isEmpty(search)) {
|
||||
where += " AND (device_code like '%" + search + "%' OR device_name like '%" + search + "%')";
|
||||
}
|
||||
String product_area = (String) whereJson.get("product_area");
|
||||
if (!StrUtil.isEmpty(product_area)) {
|
||||
where += " AND product_area = '" + product_area + "'";
|
||||
}
|
||||
String device_type = (String) whereJson.get("device_type");
|
||||
if (!StrUtil.isEmpty(device_type)) {
|
||||
where += " AND device_type = '" + device_type + "'";
|
||||
}
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), where, "device_code desc");
|
||||
final JSONObject json = rb.pageResult();
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomerbaseDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
List<CustomerbaseDto> list = arr.toJavaList(CustomerbaseDto.class);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(JSONObject jo) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicestatus");
|
||||
if (ObjectUtil.isNotEmpty(jo.getJSONArray("upload_user"))) {
|
||||
JSONArray rows = jo.getJSONArray("upload_user");
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
String msg = "";
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
if (i != rows.size() - 1) {
|
||||
msg += rows.getString(i) + ",";
|
||||
} else {
|
||||
msg += rows.getString(i);
|
||||
}
|
||||
}
|
||||
jo.put("upload_user", msg);
|
||||
}
|
||||
try {
|
||||
wo.insert(jo);
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("存在相同的设备编码!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(JSONObject jo) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicestatus");
|
||||
String device_code = jo.getString("device_code");
|
||||
try {
|
||||
if (!jo.containsKey("need_update_flag")) {
|
||||
JSONArray rows = jo.getJSONArray("upload_user");
|
||||
if (ObjectUtil.isEmpty(rows)) {
|
||||
rows = new JSONArray();
|
||||
}
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
String msg = "";
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
if (i != rows.size() - 1) {
|
||||
msg += rows.getString(i) + ",";
|
||||
} else {
|
||||
msg += rows.getString(i);
|
||||
}
|
||||
}
|
||||
map.put("upload_user", msg);
|
||||
wo.update(map, "device_code = '" + device_code + "'");
|
||||
} else {
|
||||
wo.update(jo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("存在相同的设备编码!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("md_cs_customerbase");
|
||||
for (Long cust_id : ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("cust_id", String.valueOf(cust_id));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", now);
|
||||
wo.update(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user