#20230506 欣影管理平台杆塔管理功能代码
parent
4d7bfca302
commit
739c3cd717
@ -0,0 +1,78 @@
|
|||||||
|
package com.shxy.xymanager_admin.controller;
|
||||||
|
|
||||||
|
import com.shxy.xymanager_common.annotation.Log;
|
||||||
|
import com.shxy.xymanager_common.base.BaseController;
|
||||||
|
import com.shxy.xymanager_common.base.ResponseReult;
|
||||||
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||||
|
import com.shxy.xymanager_common.bean.ServiceStatus;
|
||||||
|
import com.shxy.xymanager_common.model.TerminalApkInfoListModel;
|
||||||
|
import com.shxy.xymanager_common.vo.PageVo;
|
||||||
|
import com.shxy.xymanager_common.vo.TerminalApkVo;
|
||||||
|
import com.shxy.xymanager_common.vo.TerminalUploadVo;
|
||||||
|
import com.shxy.xymanager_service.service.UploadService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiResponse;
|
||||||
|
import io.swagger.annotations.ApiResponses;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
|
@Api(value = "上传接口", tags = "上传接口相关")
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
public class UploadController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
UploadService uploadService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "上传APK", notes = "上传APK接口", httpMethod = "POST")
|
||||||
|
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||||
|
@RequestMapping("/uploadApk")
|
||||||
|
@Log(title = "上传APK", type = "新增")
|
||||||
|
public ResponseReult<String> issueApk(@RequestBody TerminalUploadVo vo) {
|
||||||
|
ServiceBody<String> serviceBody = uploadService.upload(vo);
|
||||||
|
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||||
|
return ResponseReult.success(serviceBody.getData());
|
||||||
|
} else {
|
||||||
|
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "查询APK列表", notes = "查询APK列表接口", httpMethod = "POST")
|
||||||
|
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||||
|
@RequestMapping("/listApk")
|
||||||
|
@Log(title = "查询APK列表", type = "查询")
|
||||||
|
public ResponseReult<TerminalApkInfoListModel> listApk(@RequestBody PageVo vo) {
|
||||||
|
ServiceBody<TerminalApkInfoListModel> serviceBody = uploadService.listApk(vo);
|
||||||
|
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||||
|
return ResponseReult.success(serviceBody.getData());
|
||||||
|
} else {
|
||||||
|
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "下发APK", notes = "下发APK接口", httpMethod = "POST")
|
||||||
|
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
|
||||||
|
@RequestMapping("/issueApk")
|
||||||
|
@Log(title = "下发APK", type = "查询")
|
||||||
|
public ResponseReult<Boolean> issueApk(@RequestBody TerminalApkVo vo) {
|
||||||
|
ServiceBody<Boolean> serviceBody = uploadService.issueApk(vo);
|
||||||
|
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
|
||||||
|
return ResponseReult.success(serviceBody.getData());
|
||||||
|
} else {
|
||||||
|
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.shxy.xymanager_common.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TerminalApkInfoDto implements Serializable {
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.shxy.xymanager_common.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TerminalUpload implements Serializable {
|
||||||
|
private String path ;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public TerminalUpload(String path,String name,String version){
|
||||||
|
this.path = path;
|
||||||
|
this.name = name;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.shxy.xymanager_common.model;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道列表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "APK信息列表", description = "APK信息列表")
|
||||||
|
public class TerminalApkInfoListModel implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "APK信息列表", example = "[]")
|
||||||
|
private List<ApkBean> list;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "总记录数", example = "120")
|
||||||
|
private long total;
|
||||||
|
@ApiModelProperty(value = "总页数", example = "120")
|
||||||
|
private int totalpage;
|
||||||
|
@ApiModelProperty(value = "当前页", example = "1")
|
||||||
|
private int currentpage;
|
||||||
|
@ApiModelProperty(value = "每页记录数", example = "1")
|
||||||
|
private int pagesize;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ApkBean {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "APKid", example = "123456")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上传路径", example = "123456")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "APK名称", example = "123456")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "版本号", example = "123456")
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.shxy.xymanager_common.util;
|
||||||
|
|
||||||
|
import com.shxy.xymanager_common.util.spring.SpringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 上传文件
|
||||||
|
* @author cy
|
||||||
|
*/
|
||||||
|
public class UploadUtils
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static String upload(MultipartFile file,String path) throws IOException {
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
String newName = UUID.randomUUID().toString()+fileName.substring(fileName.indexOf("."));
|
||||||
|
|
||||||
|
File saveFile = new File(path+newName);
|
||||||
|
if(!saveFile.getParentFile().exists()){
|
||||||
|
saveFile.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
file.transferTo(saveFile);
|
||||||
|
return saveFile.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.shxy.xymanager_common.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "APK请求参数", description = "APK请求参数")
|
||||||
|
public class TerminalApkVo {
|
||||||
|
|
||||||
|
@NotNull(message = "装置通道编号")
|
||||||
|
@ApiModelProperty(value = "装置通道编号", example = "123455")
|
||||||
|
private List<String> cmdid;
|
||||||
|
|
||||||
|
@NotNull(message = "文件路径")
|
||||||
|
@ApiModelProperty(value = "文件路径", example = "123455")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.shxy.xymanager_common.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "上传参数", description = "上传参数")
|
||||||
|
public class TerminalUploadVo {
|
||||||
|
|
||||||
|
@NotNull(message = "装置通道编号")
|
||||||
|
@ApiModelProperty(value = "装置通道编号", example = "123455")
|
||||||
|
private MultipartFile file;
|
||||||
|
|
||||||
|
@NotNull(message = "apk版本")
|
||||||
|
@ApiModelProperty(value = "apk版本", example = "123455")
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.shxy.xymanager_dao.dao;
|
||||||
|
|
||||||
|
import com.shxy.xymanager_common.dto.TerminalApkInfoDto;
|
||||||
|
import com.shxy.xymanager_common.entity.TerminalUpload;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TerminalUploadDao {
|
||||||
|
|
||||||
|
int insert(TerminalUpload upload);
|
||||||
|
|
||||||
|
List<TerminalApkInfoDto> selectAll();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?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="com.shxy.xymanager_dao.dao.TerminalUploadDao">
|
||||||
|
|
||||||
|
|
||||||
|
<resultMap id="ApkInfoMap" type="com.shxy.xymanager_common.dto.TerminalApkInfoDto">
|
||||||
|
<id column="id" jdbcType="INTEGER" property="id"/>
|
||||||
|
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||||
|
<result column="path" jdbcType="VARCHAR" property="path"/>
|
||||||
|
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<insert id="insert" parameterType="com.shxy.xymanager_common.entity.TerminalUpload">
|
||||||
|
insert into terminal_upload (path, name,version)
|
||||||
|
values (#{path,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{version,jdbcType=VARCHAR})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="selectAll" resultMap="ApkInfoMap">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
path,
|
||||||
|
version
|
||||||
|
from terminal_upload
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,109 @@
|
|||||||
|
package com.shxy.xymanager_service.impl;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||||
|
import com.shxy.xymanager_common.dto.TerminalApkInfoDto;
|
||||||
|
import com.shxy.xymanager_common.entity.TerminalUpload;
|
||||||
|
import com.shxy.xymanager_common.enums.CommonStatus;
|
||||||
|
import com.shxy.xymanager_common.exception.Asserts;
|
||||||
|
import com.shxy.xymanager_common.model.TerminalApkInfoListModel;
|
||||||
|
import com.shxy.xymanager_common.model.TerminalListModel;
|
||||||
|
import com.shxy.xymanager_common.page.PageUtils;
|
||||||
|
import com.shxy.xymanager_common.util.UploadUtils;
|
||||||
|
import com.shxy.xymanager_common.vo.PageVo;
|
||||||
|
import com.shxy.xymanager_common.vo.TerminalApkVo;
|
||||||
|
import com.shxy.xymanager_common.vo.TerminalUploadVo;
|
||||||
|
import com.shxy.xymanager_dao.dao.TerminalUploadDao;
|
||||||
|
import com.shxy.xymanager_service.interaction.Cma;
|
||||||
|
import com.shxy.xymanager_service.service.UploadService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.swing.text.html.parser.Entity;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备服务实现层
|
||||||
|
*
|
||||||
|
* @author 晶晶
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class UploadServiceImpl implements UploadService {
|
||||||
|
|
||||||
|
@Value("${upload.path}")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TerminalUploadDao uploadDao;
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${cma.server}")
|
||||||
|
private String server;
|
||||||
|
|
||||||
|
@Value("${cma.port}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ServiceBody<String> upload(TerminalUploadVo vo) {
|
||||||
|
String fileName = vo.getFile().getOriginalFilename();
|
||||||
|
try {
|
||||||
|
path = UploadUtils.upload(vo.getFile(), path);
|
||||||
|
TerminalUpload upload = new TerminalUpload(path, fileName,vo.getVersion());
|
||||||
|
uploadDao.insert(upload);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("upload.exception", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Asserts.success(path);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServiceBody<TerminalApkInfoListModel> listApk(PageVo vo) {
|
||||||
|
TerminalApkInfoListModel model = new TerminalApkInfoListModel();
|
||||||
|
int pageindex = vo.getPageindex();
|
||||||
|
int pagesize = vo.getPagesize();
|
||||||
|
PageUtils.SetPage(pageindex, pagesize);
|
||||||
|
List<TerminalApkInfoDto> apkInfoDtoList = uploadDao.selectAll();
|
||||||
|
PageInfo pageData = PageUtils.getPageData(apkInfoDtoList);
|
||||||
|
int currentpage = pageData.getPageNum();
|
||||||
|
model.setCurrentpage(currentpage);
|
||||||
|
long total = pageData.getTotal();
|
||||||
|
model.setTotal(total);
|
||||||
|
|
||||||
|
int pageSize = pageData.getPageSize();
|
||||||
|
model.setPagesize(pageSize);
|
||||||
|
int pages = pageData.getPages();
|
||||||
|
model.setTotalpage(pages);
|
||||||
|
return Asserts.success(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServiceBody<Boolean> issueApk(TerminalApkVo vo) {
|
||||||
|
Cma cma = new Cma(server, port);
|
||||||
|
|
||||||
|
vo.getCmdid().stream().forEach(var -> {
|
||||||
|
cma.upgrade(var, vo.getPath());
|
||||||
|
});
|
||||||
|
|
||||||
|
return Asserts.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.shxy.xymanager_service.interaction;
|
|
||||||
|
|
||||||
import com.sun.jna.Library;
|
|
||||||
import com.sun.jna.Native;
|
|
||||||
|
|
||||||
public class CmaDLL implements Library {
|
|
||||||
CmaDLL INSTANCE = (CmaDLL) Native.loadLibrary("xympj.dll",CmaDLL.class);
|
|
||||||
}
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.shxy.xymanager_service.service;
|
||||||
|
|
||||||
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||||
|
import com.shxy.xymanager_common.model.TerminalApkInfoListModel;
|
||||||
|
import com.shxy.xymanager_common.vo.PageVo;
|
||||||
|
import com.shxy.xymanager_common.vo.TerminalApkVo;
|
||||||
|
import com.shxy.xymanager_common.vo.TerminalUploadVo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author CY
|
||||||
|
*/
|
||||||
|
public interface UploadService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有通道树状列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ServiceBody<String> upload(TerminalUploadVo vo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询APK列表
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ServiceBody<TerminalApkInfoListModel> listApk(PageVo vo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下发APK
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ServiceBody<Boolean> issueApk(TerminalApkVo vo);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue