Commit 0d3429a5 authored by 王夏晖's avatar 王夏晖

修改设备的后台管理功能

parent 8f467709
......@@ -40,10 +40,9 @@ public class BusDeviceController extends PaginationController<BusDevice> {
private BusDeviceService busDeviceServiceImpl;
@ApiOperation(value="添加", notes="添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@ApiOperation(value="添加设备", notes="添加设备")
@PostMapping(value = "/add")
public Result add(@Valid BusDevice busDevice, BindingResult bindingResult) {
public Result add(@Valid BusDevice busDevice) {
PersistModel data = busDeviceServiceImpl.save(busDevice);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -51,22 +50,10 @@ public class BusDeviceController extends PaginationController<BusDevice> {
busDevice);
}
@ApiOperation(value="逻辑删除", notes="逻辑删除")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "varchar")})
@DeleteMapping("/delete/{id:\\w+}")
public Result delete(@PathVariable String id) {
BusDevice busDevice = new BusDevice();
PersistModel data = busDeviceServiceImpl.remove(busDevice);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
id);
}
@ApiOperation(value="修改", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PutMapping("/update/{id:\\w+}")
public Result update(@Valid BusDevice busDevice, BindingResult bindingResult) {
@ApiOperation(value="修改设备", notes="修改设备")
@PutMapping("/update")
public Result update(@Valid BusDevice busDevice) {
PersistModel data = busDeviceServiceImpl.merge(busDevice);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -74,19 +61,28 @@ public class BusDeviceController extends PaginationController<BusDevice> {
busDevice);
}
@ApiOperation(value="查看单 ", notes="查看单 ")
@GetMapping("/detail/{id:\\w+}")
public Result detail(@PathVariable String id) {
@ApiOperation(value="删除设备", notes="删除设备")
@PutMapping("/delete")
public Result delete(@RequestParam String devid) {
PersistModel data = busDeviceServiceImpl.delete(devid);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
devid);
}
@ApiOperation(value="查看单个设备", notes="查看单个设备")
@GetMapping("/detail")
public Result detail(@RequestParam String devid) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
busDeviceServiceImpl.findById(id));
busDeviceServiceImpl.findById(devid));
}
@ApiOperation(value="查看 集合", notes="查看 集合")
@ApiOperation(value="查看设备列表", notes="查看设备列表")
@GetMapping(value = "/queryBusDeviceByPagination")
public GridModel listByPagination(BusDevice busDevice) {
// busDevice.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
busDeviceServiceImpl.findAllByPagination(getPaginationUtility(), busDevice);
return getGridModelResponse();
}
......
......@@ -10,6 +10,7 @@ import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* Created with on 2018-4-12 15:33:23.
......@@ -21,9 +22,8 @@ public interface BusDeviceRepository extends BaseMapper<BusDevice> {
* 分页查询 busDevice
*
*/
@Select("<script>select * from bus_device where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
@Select("<script>select * from bus_device where 1=1 and pro_id = #{proId} " +
"<if test=''></if>"
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BusDevice> queryBusDevices(BusDevice busDevice);
......@@ -48,5 +48,13 @@ public interface BusDeviceRepository extends BaseMapper<BusDevice> {
* @return
*/
String getSysNameBySysId(@Param("sysId") String sysId);
/**
* 查询设备是否有原始数据
* @param map
* @return
*/
@Select("<script>select a.tm from total_original a,bus_device b where a.dev_num = b.dev_num and b.dev_id = #{dev_id} limit 1</script>")
List<Map<String,Object>> queryOriginalByDev(Map<String,Object> map);
}
......@@ -19,13 +19,6 @@ public interface BusDeviceService {
*/
PersistModel save(BusDevice busDevice);
/**
* 逻辑删除
* @param busDevice
* @return
*/
PersistModel remove(BusDevice busDevice);
/**
* 修改
* @param busDevice
......@@ -33,12 +26,19 @@ public interface BusDeviceService {
*/
PersistModel merge(BusDevice busDevice);
/**
* 删除
* @param busDevice
* @return
*/
PersistModel delete(String devid);
/**
* 根据id查询
* @param id
* @return
*/
BusDevice findById(String id);
List<BusDevice> findById(String id);
/**
* 分页查询
......
......@@ -3,6 +3,7 @@ package org.rcisoft.business.device.assets.service.impl;
import org.rcisoft.business.device.assets.dao.BusDeviceRepository;
import org.rcisoft.business.device.assets.service.BusDeviceService;
import org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo;
import org.rcisoft.business.manage.entity.BusDevicetpParam;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.device.assets.entity.BusDevice;
......@@ -14,8 +15,13 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example;
/**
* Created by on 2018-4-12 15:33:23.
......@@ -38,35 +44,45 @@ public class BusDeviceServiceImpl implements BusDeviceService {
@Override
public PersistModel save(BusDevice busDevice){
//增加操作
// UserUtil.setCurrentPersistOperation(busDevice);
busDevice.setDevId(UUID.randomUUID().toString().replace("-",""));
int line = busDeviceRepository.insertSelective(busDevice);
return new PersistModel(line);
}
/**
* 逻辑删除
* 修改 busDevice
* @param busDevice
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(BusDevice busDevice){
// UserUtil.setCurrentMergeOperation(busDevice);
// busDevice.setDeleted();
int line = busDeviceRepository.logicalDelete(busDevice);
public PersistModel merge(BusDevice busDevice){
int line = 0;
Example example = new Example(BusDevice.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("devId",busDevice.getDevId());
line = busDeviceRepository.updateByExample(busDevice,example);
return new PersistModel(line);
}
/**
* 修改 busDevice
* @param busDevice
* @return
*/
* 删除
* @param devid
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel merge(BusDevice busDevice){
// UserUtil.setCurrentMergeOperation(busDevice);
int line = busDeviceRepository.updateByPrimaryKeySelective(busDevice);
public PersistModel delete(String devid) {
int line = 0;
Example example = new Example(BusDevice.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("devId",devid);
Map<String,Object> map = new HashMap<>();
map.put("dev_id",devid);
if(busDeviceRepository.queryOriginalByDev(map)==null || busDeviceRepository.queryOriginalByDev(map).size()<1){
line = busDeviceRepository.deleteByExample(example);
}
return new PersistModel(line);
}
......@@ -76,9 +92,11 @@ public class BusDeviceServiceImpl implements BusDeviceService {
* @return
*/
@Override
public BusDevice findById(String id)
{
return busDeviceRepository.selectByPrimaryKey(id);
public List<BusDevice> findById(String id){
Example example = new Example(BusDevice.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("devId",id);
return busDeviceRepository.selectByExample(example);
}
/**
......@@ -89,9 +107,11 @@ public class BusDeviceServiceImpl implements BusDeviceService {
@Override
public List<BusDevice> findAllByPagination(PageUtil<BusDevice> paginationUtility,
BusDevice busDevice){
// busDevice.setStart();
// busDevice.setNotDeleted();
return busDeviceRepository.queryBusDevices(busDevice);
//避免查出所有设备
if(busDevice.getProId()!=null && !busDevice.getProId().equals("")){
return busDeviceRepository.queryBusDevices(busDevice);
}
return null;
}
/*
通过项目id与子系统id获取子系统中的所有设备
......
......@@ -43,7 +43,7 @@ public class BusDeviceTpServiceImpl implements BusDeviceTpService {
int line = busDeviceTpRepository.insertSelective(busDeviceTp);
return new PersistModel(line);
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel delete(BusDeviceTp busDeviceTp) {
int line = 0;
......
......@@ -44,7 +44,7 @@ public class BusDevicetpParamServiceImpl implements BusDevicetpParamService {
}
return new PersistModel(line);
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel update(BusDevicetpParamList busDevicetpParamList) {
PersistModel data = delete(busDevicetpParamList.getBusDevicetpParamList().get(0));
......@@ -53,7 +53,7 @@ public class BusDevicetpParamServiceImpl implements BusDevicetpParamService {
}
return new PersistModel(1);
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel delete(BusDevicetpParam busDevicetpParam) {
Example example = new Example(BusDevicetpParam.class);
......
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