Commit f398625d authored by 王夏晖's avatar 王夏晖

拓扑图节点图片维护功能

parent 956d13e8
......@@ -228,13 +228,13 @@ public class BusEnergyPlanServiceImpl implements BusEnergyPlanService {
public List<Map<String, Object>> queryDeviceTp() {
List<Map<String, Object>> list = busEnergyPlanRepository.queryDeviceTp();
for(Map<String, Object> m : list){
if(m.get("DEV_TP_IMG")!=null && !m.get("DEV_TP_IMG").toString().equals("") && !m.get("DEV_TP_IMG").toString().equals("null")){
/*if(m.get("DEV_TP_IMG")!=null && !m.get("DEV_TP_IMG").toString().equals("") && !m.get("DEV_TP_IMG").toString().equals("null")){
String type = "";
String img = UploadUtil.GetImageStr(m.get("DEV_TP_IMG").toString());
m.put("IMG", img);
}else{
m.put("IMG","");
}
}*/
}
return list;
}
......@@ -308,6 +308,11 @@ public class BusEnergyPlanServiceImpl implements BusEnergyPlanService {
}
}
executeMap.put(tmap.get("dev_num").toString()+","+tmap.get("tm").toString(),flag);
SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String now = simple.format(new Date());
if(simple.parse(tmap.get("tm").toString()).getTime()>simple.parse(now).getTime()){
executeMap.put(tmap.get("dev_num").toString()+","+tmap.get("tm").toString(),"-1");
}
}
List<Map<String, Object>> planList = queryEnergyPlanList(proid,day);
for(Map<String, Object> plan : planList){
......
package org.rcisoft.business.manage.controller;
/*固定导入*/
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.manage.entity.TopologyNode;
import org.rcisoft.business.manage.service.TopologyNodeService;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.controller.PaginationController;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* Created by on 2018-6-5 9:01:15.
*/
@RestController
@RequestMapping("manage/topologynode")
public class TopologyNodeController extends PaginationController<TopologyNode> {
@Autowired
private TopologyNodeService topologyNodeServiceImpl;
@ApiOperation(value="添加", notes="添加")
@PostMapping(value = "/add")
public Result add(@RequestParam MultipartFile file) {
return Result.builder(topologyNodeServiceImpl.save(file),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
null);
}
@ApiOperation(value="删除", notes="删除")
@DeleteMapping("/delete")
public Result delete(@RequestParam String id) {
return Result.builder(topologyNodeServiceImpl.remove(id));
}
@ApiOperation(value="拓扑图节点图片列表", notes="拓扑图节点图片列表")
@GetMapping("/query")
public Result query() {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
topologyNodeServiceImpl.queryTopologyNodes());
}
}
package org.rcisoft.business.manage.dao;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.manage.entity.TopologyNode;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* Created with on 2018-6-5 9:01:15.
*/
@Repository
public interface TopologyNodeRepository extends BaseMapper<TopologyNode> {
@Select("<script>select * from topology_node</script>")
List<Map<String,Object>> queryTopologyNodes();
}
package org.rcisoft.business.manage.entity;
import lombok.*;
import org.rcisoft.core.entity.IdNotDataEntity;
import javax.persistence.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created with on 2018-6-5 9:01:15.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "topology_node")
public class TopologyNode{
private String id;
private String nodeNm;
private String url;
}
package org.rcisoft.business.manage.service;
import org.rcisoft.core.model.PersistModel;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
/**
* Created by on 2018-6-5 9:01:15.
*/
public interface TopologyNodeService {
/**
* 保存
* @return
*/
PersistModel save(MultipartFile file);
/**
* 删除
* @return
*/
PersistModel remove(String id);
List<Map<String,Object>> queryTopologyNodes();
}
......@@ -118,7 +118,7 @@ public class BusDeviceTpServiceImpl implements BusDeviceTpService {
FileUtils.copyInputStreamToFile(file.getInputStream(), saveFile);
BusDeviceTp busDeviceTp = new BusDeviceTp();
busDeviceTp.setDevTpId(devTpId);
busDeviceTp.setDevTpImg(savePath);
busDeviceTp.setDevTpImg(devTpId + suffixName);
merge(busDeviceTp);
line = 1;
}catch(Exception e){
......
package org.rcisoft.business.manage.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.rcisoft.business.manage.dao.TopologyNodeRepository;
import org.rcisoft.business.manage.entity.TopologyNode;
import org.rcisoft.business.manage.service.TopologyNodeService;
import org.rcisoft.core.model.PersistModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Created by on 2018-6-5 9:01:15.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class TopologyNodeServiceImpl implements TopologyNodeService {
@Autowired
private TopologyNodeRepository topologyNodeRepository;
@Value("${filepath.topologynode}")
private String filepath;
/**
* 保存 topologyNode
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(MultipartFile file){
int line = 1;
String fileName = file.getOriginalFilename();
String suffixName = fileName.substring(fileName.lastIndexOf("."));
String id = UUID.randomUUID().toString().replace("-","");
//文件路径
String savePath = filepath + id + suffixName;
File saveFile = new File(savePath);
if(saveFile.exists()){
saveFile.delete();
}
try{
FileUtils.copyInputStreamToFile(file.getInputStream(), saveFile);
TopologyNode tn = new TopologyNode();
tn.setId(id);
tn.setUrl(id + suffixName);
topologyNodeRepository.insertSelective(tn);
line = 1;
}catch(Exception e){
e.printStackTrace();
line = 0;
}
return new PersistModel(line);
}
/**
* 删除
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(String id){
int line = 0;
String message = "";
if(id!=null && !id.equals("")){
Example example = new Example(TopologyNode.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id",id);
line = topologyNodeRepository.deleteByExample(example);
}else{
message = "ID为空,删除失败";
}
return new PersistModel(line,message);
}
@Override
public List<Map<String, Object>> queryTopologyNodes() {
return topologyNodeRepository.queryTopologyNodes();
}
}
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