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

修改设备的后台管理功能

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