Commit e15e037f by 焦荣

新增采集设备厂商附件和设备详情页面(修改柱状图和页面基本信息)

parent 0a2b9128
......@@ -33,7 +33,7 @@ public class SysClientCsController {
//保存设备厂商
@PostMapping("/saveClientCs")
@ResponseBody
public XzxtRestResult saveClientCs(SysClientCs sysClientCs){
public XzxtRestResult saveClientCs(SysClientCs sysClientCs,String demoList){
return sysClientCsService.SaveClientCs(sysClientCs);
}
......
package com.founder.cjqx.controller;
import java.io.*;
import com.founder.cjqx.service.SysClientCsfjService;
import com.founder.model.*;
import com.founder.model.amsis.SysClientCsfj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import static com.founder.utils.SequenceUtil.getNextId;
/**
*
* 上传文件接口
*/
@EnableAutoConfiguration(exclude = {MultipartAutoConfiguration.class})
@EnableCaching
@RestController
public class SysClientCsfjController {
@Autowired
private SysClientCsfjService sysClientCsfjService;
/**
* 根据文件路径删除文件
*
* @param deleteFilePaths
* @return
*/
@RequestMapping("/deleteFile")
public JSONObject deleteFile(@RequestParam("deleteFilePaths") String[] deleteFilePaths) {
JSONObject resultJSON = new JSONObject();
JSONArray dataArray = new JSONArray();
try {
for (String deleteFilePath : deleteFilePaths) {
JSONObject fileDelete = new JSONObject();
if (!"".equals(deleteFilePath) && null != deleteFilePath) {
File file = new File(deleteFilePath);
if (file.exists() && file.isFile()) {
//删除文件
file.delete();
//判断文件夹是否为空为空删除该文件夹
File fileParent = new File(file.getParent());
if (fileParent.isDirectory() && fileParent.listFiles().length == 0) {
fileParent.delete();
}
fileDelete.put("path", deleteFilePath);
fileDelete.put("code", 0);
fileDelete.put("info", "删除成功");
} else {
fileDelete.put("path", deleteFilePath);
fileDelete.put("code", 1);
fileDelete.put("info", "该文件不存在");
}
dataArray.add(fileDelete);
}
}
resultJSON.put("code", 0);
resultJSON.put("info", "删除成功");
resultJSON.put("data", dataArray);
} catch (Exception e) {
e.printStackTrace();
resultJSON.put("code", 1);
resultJSON.put("info", e.getMessage());
}
return resultJSON;
}
/**
* 文件上传
* @param file
* @param csid
* @return
* @throws Exception
*/
@RequestMapping(value = "/dupload")
@ResponseBody
public JSONObject dupload(@RequestParam("file") MultipartFile file, @RequestParam("csid") String csid) {
SysClientCsfj clientCsfj = new SysClientCsfj();
JSONObject resultJSON = new JSONObject();
String id = getNextId();
try {
if(!file.isEmpty()){
clientCsfj.setId(id);
clientCsfj.setCsid(csid);
clientCsfj.setDzwjbt(file.getOriginalFilename());
clientCsfj.setDzwjdx((int)file.getSize());
int begin = file.getOriginalFilename().indexOf(".");
int last = file.getOriginalFilename().length();
String wjgs = file.getOriginalFilename().substring(begin, last);
clientCsfj.setDzwjgs(wjgs);
clientCsfj.setDzwjmc(file.getOriginalFilename());
clientCsfj.setDzwjnr(file.getBytes());
sysClientCsfjService.SaveClientCsfj(clientCsfj);
}
} catch (IOException e) {
e.printStackTrace();
}
// clientCsfj.setJlsj(file.);
// resultJSON.put("fileDir", fileDir);
//resultJSON.put("filePath", file.getOriginalFilename());
resultJSON.put("zjid",id);
resultJSON.put("size", file.getSize());
resultJSON.put("code", 0);
return resultJSON;
}
/*
获取设备附件list
*/
@GetMapping("/sysClientCsfjlist")
@ResponseBody
public ResultMap sysClientCsfjlist(Model model, SysClientCsfj sysClientCsfj, HttpServletRequest request){
ResultMap resultMap=new ResultMap();
User user =(User)request.getSession().getAttribute("User");
resultMap =sysClientCsfjService.ClientCsfjList(sysClientCsfj);
return resultMap;
}
//服务删除
@DeleteMapping("/ClientCsfj/{id}")
@ResponseBody
public XzxtRestResult deleteClientVpfj(@PathVariable("id") String id){
return sysClientCsfjService.deleteClientCsfj(id);
}
/**
* 文件下载
*/
@RequestMapping(value = "/fdownloadfile")
@ResponseBody
public void downloadfile(HttpServletResponse response,@RequestParam("id") String id) {
SysClientCsfj clientCsfj = new SysClientCsfj();
clientCsfj = sysClientCsfjService.getClientCsfjbyid(id);
String gs = clientCsfj.getDzwjgs();
String filename = clientCsfj.getDzwjbt();
String type = null;
if (gs.equalsIgnoreCase("doc")) {
type = "application/msword";
} else if (gs.equalsIgnoreCase(".xls")) {
type = "application/x-xls";
} else if (gs.equalsIgnoreCase(".pdf")) {
type = "application/pdf";
} else if (gs.equalsIgnoreCase(".jpg")) {
type = "application/x-jpg";
} else if (gs.equalsIgnoreCase(".bmp")) {
type = "application/x-bmp";
} else if (gs.equalsIgnoreCase(".png")) {
type = "application/x-png";
} else if (gs.equalsIgnoreCase(".ppt")) {
type = "application/x-ppt";
} else if (gs.equalsIgnoreCase(".zip")) {
type = "application/zip";
} else if (gs.equalsIgnoreCase(".gzip")) {
type = "application/gzip";
} else {// 其它格式,设置成未知名格式文件传输流。
type = "application/octet-stream";
}
byte[] wjnr = clientCsfj.getDzwjnr();
// this.getResponse().setCharacterEncoding("utf-8");
response.setContentType(type);
OutputStream os = null;
try {
response.setHeader("Content-disposition", "attachment;filename=" + (java.net.URLEncoder.encode(filename, "UTF-8") + gs).trim());
os = response.getOutputStream();
os.write(wjnr);
os.flush();
// os.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
// return "success";
}
}
\ No newline at end of file
......@@ -17,6 +17,9 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import static com.cc.utls.Base64Util.xzxtencode;
/**
......@@ -129,7 +132,20 @@ public class SysClientVpController {
//查看详情
@GetMapping("/DetailVp/{id}")
public String getDetailVp(@PathVariable("id") String id, Model model){
model.addAttribute("ClientVp",sysClientVpService.SelectClientVp(id).getData());
SysClientVp clientVp = (SysClientVp)sysClientVpService.SelectClientVp(id).getData();
List<SysClientVp> clientYlist = sysClientVpService.ClientYlist(clientVp.getIp());
String getMCjsj = sysClientVpService.getMCjsj(clientVp.getIp());
//封装月份与使用次数
List<String> lyysjstr = new ArrayList();
List<Integer> lyycsstr = new ArrayList();
for(SysClientVp vp:clientYlist){
lyysjstr.add(vp.getYysjstr());
lyycsstr.add(vp.getYycsstr());
}
model.addAttribute("ClientVp",clientVp);
model.addAttribute("lyysjstr",lyysjstr);
model.addAttribute("lyycsstr",lyycsstr);
model.addAttribute("getMCjsj",getMCjsj);
return "cjqx/files";
}
}
package com.founder.cjqx.dao;
import com.founder.model.SysClientCs;
import com.founder.model.amsis.SysClientCsfj;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface SysClientCsfjMapper {
List<SysClientCsfj> selectPageList(SysClientCsfj sysClientCsfj);
List<SysClientCsfj> selectClientCsfj(SysClientCsfj sysClientCsfj);
int selectPageCount(SysClientCsfj sysClientCsfj);
int saveSysClientCsfj(SysClientCsfj sysClientCsfj);
SysClientCsfj selectSysClientCsfj(String id);
int updateSysClientCsfj(SysClientCsfj sysClientCsfj);
int deleteSysClientCsfj(String id);
}
\ No newline at end of file
......@@ -17,4 +17,6 @@ public interface SysClientVpMapper {
int updateSysClientVp(SysClientVp sysClientVp);
int deleteSysClientVp(String id);
int checkSysClientVp(SysClientVp sysClientVp);
List<SysClientVp> ClientYlist(String ip);
String getMCjsj(String ip);
}
\ No newline at end of file
package com.founder.cjqx.service;
import com.founder.model.ResultMap;
import com.founder.model.SysClientCs;
import com.founder.model.XzxtRestResult;
import com.founder.model.amsis.SysClientCsfj;
/**
* Created by libin on 2018/4/12.
*/
public interface SysClientCsfjService {
SysClientCsfj getClientCsfj(SysClientCsfj SysClientCsfj);
public SysClientCsfj getClientCsfjbyid(String id);
XzxtRestResult SaveClientCsfj(SysClientCsfj SysClientCsfj);
XzxtRestResult SelectClientCsfj(String id);
XzxtRestResult updateClientCsfj(SysClientCsfj SysClientCsfj);
XzxtRestResult deleteClientCsfj(String id);
ResultMap ClientCsfjList(SysClientCsfj SysClientCsfj);
}
......@@ -5,6 +5,8 @@ import com.founder.model.SysClientVp;
import com.founder.model.User;
import com.founder.model.XzxtRestResult;
import java.util.List;
/**
* Created by libin on 2018/4/12.
*/
......@@ -16,5 +18,7 @@ public interface SysClientVpService {
XzxtRestResult updateClientVp(SysClientVp sysClientVp);
XzxtRestResult deleteClientVp(String id);
XzxtRestResult spClientVp(String id, String spzt, User user);
List<SysClientVp> ClientYlist(String ip);
String getMCjsj(String ip);
}
......@@ -51,8 +51,13 @@ public class SysClientCsServiceImpl implements SysClientCsService {
SysClientCs.setId(getNextId());
SysClientCs.setScbz("0");
int num = SysClientCsMapper.saveSysClientCs(SysClientCs);
XzxtRestResult result = new XzxtRestResult();
if (num == 1) {
return XzxtRestResult.build(201, "存入成功");
result.setStatus(201);
result.setMsg("存入成功");
result.setData(SysClientCs.getId());
// return XzxtRestResult.build(201, "存入成功");
return result;
} else {
return XzxtRestResult.build(202, "存入失败");
}
......
package com.founder.cjqx.service.impl;
import com.founder.cjqx.dao.SysClientCsfjMapper;
import com.founder.cjqx.service.SysClientCsfjService;
import com.founder.model.ResultMap;
import com.founder.model.SysClientCs;
import com.founder.model.XzxtRestResult;
import com.founder.model.amsis.SysClientCsfj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
import static com.founder.utils.SequenceUtil.getNextId;
/**
* Created by libin on 2018/4/12.
*/
@Service
public class SysClientCsfjServiceImpl implements SysClientCsfjService {
@Autowired
private SysClientCsfjMapper SysClientCsfjMapper;
@Override
public SysClientCsfj getClientCsfj(SysClientCsfj SysClientCsfj) {
SysClientCsfj SysClientCsfjrst = new SysClientCsfj();
List<SysClientCsfj> SysClientCsfjlist=SysClientCsfjMapper.selectPageList(SysClientCsfj);
if (SysClientCsfjlist!=null&&SysClientCsfjlist.size()>0) {
SysClientCsfjrst = SysClientCsfjlist.get(0);
}
return SysClientCsfjrst ;
}
@Override
public SysClientCsfj getClientCsfjbyid(String id) {
SysClientCsfj SysClientCsfjrst = new SysClientCsfj();
SysClientCsfjrst = SysClientCsfjMapper.selectSysClientCsfj(id);
return SysClientCsfjrst ;
}
@Override
public XzxtRestResult SaveClientCsfj(SysClientCsfj SysClientCsfj) {
SysClientCsfj.setScbz("0");
int num = SysClientCsfjMapper.saveSysClientCsfj(SysClientCsfj);
if (num == 1) {
return XzxtRestResult.build(201, "存入成功");
} else {
return XzxtRestResult.build(202, "存入失败");
}
}
@Override
public XzxtRestResult SelectClientCsfj(String id) {
SysClientCsfj SysClientCsfj=SysClientCsfjMapper.selectSysClientCsfj(id);
if(!StringUtils.isEmpty(SysClientCsfj)){
return XzxtRestResult.build(201,"读取成功",SysClientCsfj);
}else{
return XzxtRestResult.build(202,"读取失败","");
}
}
@Override
public XzxtRestResult updateClientCsfj(SysClientCsfj SysClientCsfj) {
int num = SysClientCsfjMapper.updateSysClientCsfj(SysClientCsfj);
if (num == 1) {
return XzxtRestResult.build(201, "更新成功");
} else {
return XzxtRestResult.build(202, "更新失败");
}
}
@Override
public XzxtRestResult deleteClientCsfj(String id)
{
int num=SysClientCsfjMapper.deleteSysClientCsfj(id);
if(num==1){
return XzxtRestResult.build(201,"删除成功");
}else{
return XzxtRestResult.build(202,"删除失败");
}
}
@Override
public ResultMap ClientCsfjList(SysClientCsfj SysClientCsfj) {
List<SysClientCsfj> SysClientCsfjlist=SysClientCsfjMapper.selectPageList(SysClientCsfj);
ResultMap resultMap=new ResultMap();
if (!StringUtils.isEmpty(SysClientCsfjlist)) {
int totals=SysClientCsfjMapper.selectPageCount(SysClientCsfj);
resultMap.setCount(totals);
resultMap.setData(SysClientCsfjlist);
return resultMap;
}
return resultMap ;
}
}
......@@ -176,4 +176,15 @@ public class SysClientVpServiceImpl implements SysClientVpService {
return XzxtRestResult.build(203,"操作失败");
}
}
@Override
public List<SysClientVp> ClientYlist(String ip){
List<SysClientVp> sysClientVplist = sysClientVpMapper.ClientYlist(ip);
return sysClientVplist;
}
@Override
public String getMCjsj(String ip){
String getMCjsj = sysClientVpMapper.getMCjsj(ip);
return getMCjsj;
}
}
......@@ -121,6 +121,26 @@ public class SysClientVp extends PageBean{
private String spsjstr;
private String yysjstr;
private int yycsstr;
public String getYysjstr() {
return yysjstr;
}
public void setYysjstr(String yysjstr) {
this.yysjstr = yysjstr;
}
public int getYycsstr() {
return yycsstr;
}
public void setYycsstr(int yycsstr) {
this.yycsstr = yycsstr;
}
public String getCjsblxcode() {
return cjsblxcode;
......
package com.founder.model.amsis;
import com.founder.model.PageBean;
import java.util.Date;
public class SysClientCsfj extends PageBean{
private String id;
private String csid;
private String dzwjmc;
private String dzwjbt;
private String dzwjgs;
private byte[] dzwjnr;
private Integer dzwjdx;
private String dzwjwz;
private Date jlsj;
private String scbz;
private String lrdw;
private String lrr;
private Date lrsj;
private Date gxsj;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCsid() {
return csid;
}
public void setCsid(String csid) {
this.csid = csid;
}
public String getDzwjmc() {
return dzwjmc;
}
public void setDzwjmc(String dzwjmc) {
this.dzwjmc = dzwjmc;
}
public String getDzwjbt() {
return dzwjbt;
}
public void setDzwjbt(String dzwjbt) {
this.dzwjbt = dzwjbt;
}
public String getDzwjgs() {
return dzwjgs;
}
public void setDzwjgs(String dzwjgs) {
this.dzwjgs = dzwjgs;
}
public Integer getDzwjdx() {
return dzwjdx;
}
public void setDzwjdx(Integer dzwjdx) {
this.dzwjdx = dzwjdx;
}
public String getDzwjwz() {
return dzwjwz;
}
public void setDzwjwz(String dzwjwz) {
this.dzwjwz = dzwjwz;
}
public Date getJlsj() {
return jlsj;
}
public void setJlsj(Date jlsj) {
this.jlsj = jlsj;
}
public String getScbz() {
return scbz;
}
public void setScbz(String scbz) {
this.scbz = scbz;
}
public String getLrdw() {
return lrdw;
}
public void setLrdw(String lrdw) {
this.lrdw = lrdw;
}
public String getLrr() {
return lrr;
}
public void setLrr(String lrr) {
this.lrr = lrr;
}
public Date getLrsj() {
return lrsj;
}
public void setLrsj(Date lrsj) {
this.lrsj = lrsj;
}
public Date getGxsj() {
return gxsj;
}
public void setGxsj(Date gxsj) {
this.gxsj = gxsj;
}
public byte[] getDzwjnr() {
return dzwjnr;
}
public void setDzwjnr(byte[] dzwjnr) {
this.dzwjnr = dzwjnr;
}
}
\ No newline at end of file
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