上传apk
This commit is contained in:
parent
0b12332114
commit
2459915ed9
|
|
@ -10,6 +10,7 @@ import com.bonus.canteen.core.alloc.domain.AllocCanteen;
|
||||||
import com.bonus.canteen.core.alloc.domain.AllocStall;
|
import com.bonus.canteen.core.alloc.domain.AllocStall;
|
||||||
import com.bonus.canteen.core.alloc.mapper.AllocCanteenMapper;
|
import com.bonus.canteen.core.alloc.mapper.AllocCanteenMapper;
|
||||||
import com.bonus.canteen.core.alloc.mapper.AllocStallMapper;
|
import com.bonus.canteen.core.alloc.mapper.AllocStallMapper;
|
||||||
|
import com.bonus.canteen.core.device.dto.ApkDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||||
import com.bonus.canteen.core.device.service.IDoubleScreenMachineService;
|
import com.bonus.canteen.core.device.service.IDoubleScreenMachineService;
|
||||||
|
|
@ -118,6 +119,11 @@ public class DoubleScreenMachineController extends BaseController {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "上传APK")
|
||||||
|
@PostMapping({"/uploadApk"})
|
||||||
|
public AjaxResult uploadApk(@RequestBody @Valid ApkDTO dto) {
|
||||||
|
this.screenMachineService.uploadApk(dto);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.bonus.canteen.core.device.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApkDTO {
|
||||||
|
private String version;
|
||||||
|
private String versionName;
|
||||||
|
private String apkName;
|
||||||
|
private String apkPath;
|
||||||
|
private String updateContent;
|
||||||
|
private String deployUser;
|
||||||
|
private String type;
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.core.device.mapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bonus.canteen.core.device.domain.DeviceBind;
|
import com.bonus.canteen.core.device.domain.DeviceBind;
|
||||||
|
import com.bonus.canteen.core.device.dto.ApkDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||||
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
||||||
|
|
@ -81,4 +82,10 @@ public interface DoubleScreenMachineMapper {
|
||||||
int checkIsExistDeviceName(@Param("deviceName") @NotBlank(message = "设备名称必填") String deviceName,@Param("deviceId") String deviceId);
|
int checkIsExistDeviceName(@Param("deviceName") @NotBlank(message = "设备名称必填") String deviceName,@Param("deviceId") String deviceId);
|
||||||
|
|
||||||
int checkIsExistDeviceSn(@Param("deviceSn") @NotBlank(message = "设备sn码必填") String deviceSn,@Param("deviceId") String deviceId);
|
int checkIsExistDeviceSn(@Param("deviceSn") @NotBlank(message = "设备sn码必填") String deviceSn,@Param("deviceId") String deviceId);
|
||||||
|
|
||||||
|
ApkDTO getApkByType(@Param("type") String type,@Param("version") String version);
|
||||||
|
|
||||||
|
int updateApk(ApkDTO dto);
|
||||||
|
|
||||||
|
int insertApk(ApkDTO dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.core.device.service;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.canteen.core.device.domain.DeviceBind;
|
import com.bonus.canteen.core.device.domain.DeviceBind;
|
||||||
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
||||||
|
import com.bonus.canteen.core.device.dto.ApkDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||||
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
||||||
|
|
@ -49,4 +50,6 @@ public interface IDoubleScreenMachineService {
|
||||||
* @param sn
|
* @param sn
|
||||||
*/
|
*/
|
||||||
void updateTimeBySn(String sn);
|
void updateTimeBySn(String sn);
|
||||||
|
|
||||||
|
void uploadApk(@Valid ApkDTO dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
package com.bonus.canteen.core.device.service.impl;
|
package com.bonus.canteen.core.device.service.impl;
|
||||||
|
|
||||||
|
import java.sql.SQLIntegrityConstraintViolationException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.bonus.canteen.core.common.utils.MqUtil;
|
import com.bonus.canteen.core.common.utils.MqUtil;
|
||||||
|
import com.bonus.canteen.core.device.dto.ApkDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||||
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
||||||
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
|
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
|
||||||
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.houqin.constant.GlobalConstants;
|
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||||
import com.bonus.common.houqin.mq.constant.LeMqConstant;
|
import com.bonus.common.houqin.mq.constant.LeMqConstant;
|
||||||
import com.bonus.common.houqin.utils.id.Id;
|
import com.bonus.common.houqin.utils.id.Id;
|
||||||
|
|
@ -49,43 +52,43 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void insert(DeviceDTO dto) {
|
public void insert(DeviceDTO dto) {
|
||||||
if (dto == null){
|
if (dto == null) {
|
||||||
throw new RuntimeException("参数为空");
|
throw new RuntimeException("参数为空");
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isEmpty(dto.getDeviceName()) || ObjectUtil.isEmpty(dto.getDeviceSn()) || ObjectUtil.isEmpty(dto.getDeviceName())
|
if (ObjectUtil.isEmpty(dto.getDeviceName()) || ObjectUtil.isEmpty(dto.getDeviceSn()) || ObjectUtil.isEmpty(dto.getDeviceName())
|
||||||
|| ObjectUtil.isEmpty(dto.getAreaId()) || ObjectUtil.isEmpty(dto.getCanteenId()) || ObjectUtil.isEmpty(dto.getStallId())){
|
|| ObjectUtil.isEmpty(dto.getAreaId()) || ObjectUtil.isEmpty(dto.getCanteenId()) || ObjectUtil.isEmpty(dto.getStallId())) {
|
||||||
throw new RuntimeException("请先讲填写所有必填项,再提交相关数据!");
|
throw new RuntimeException("请先讲填写所有必填项,再提交相关数据!");
|
||||||
}
|
}
|
||||||
dto.setTenantId(GlobalConstants.TENANT_ID);
|
dto.setTenantId(GlobalConstants.TENANT_ID);
|
||||||
dto.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
dto.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||||
//判断设备sn、设备编号、设备名称是否存在
|
//判断设备sn、设备编号、设备名称是否存在
|
||||||
int count = mapper.checkIsExistDeviceNum(dto.getDeviceNum(),null);
|
int count = mapper.checkIsExistDeviceNum(dto.getDeviceNum(), null);
|
||||||
if (count > 0){
|
if (count > 0) {
|
||||||
throw new RuntimeException("设备编号已存在");
|
throw new RuntimeException("设备编号已存在");
|
||||||
}
|
}
|
||||||
count = mapper.checkIsExistDeviceName(dto.getDeviceName(),null);
|
count = mapper.checkIsExistDeviceName(dto.getDeviceName(), null);
|
||||||
if (count > 0){
|
if (count > 0) {
|
||||||
throw new RuntimeException("设备名称已存在");
|
throw new RuntimeException("设备名称已存在");
|
||||||
}
|
}
|
||||||
count = mapper.checkIsExistDeviceSn(dto.getDeviceSn(),null);
|
count = mapper.checkIsExistDeviceSn(dto.getDeviceSn(), null);
|
||||||
if (count > 0){
|
if (count > 0) {
|
||||||
throw new RuntimeException("设备sn已存在");
|
throw new RuntimeException("设备sn已存在");
|
||||||
}
|
}
|
||||||
int code = mapper.insertMachine(dto);
|
int code = mapper.insertMachine(dto);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("设备新增失败");
|
throw new RuntimeException("设备新增失败");
|
||||||
}
|
}
|
||||||
code = mapper.insertMachineBind(dto);
|
code = mapper.insertMachineBind(dto);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("设备绑定失败");
|
throw new RuntimeException("设备绑定失败");
|
||||||
}
|
}
|
||||||
dto.setId(Id.next());
|
dto.setId(Id.next());
|
||||||
code = mapper.insertDeviceRecipe(dto);
|
code = mapper.insertDeviceRecipe(dto);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("添加菜谱关联失败");
|
throw new RuntimeException("添加菜谱关联失败");
|
||||||
}
|
}
|
||||||
//发送mq
|
//发送mq
|
||||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0,"update");
|
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0, "update");
|
||||||
MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_INFO_V4, dto.getDeviceSn());
|
MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_INFO_V4, dto.getDeviceSn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,41 +100,41 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update(DeviceDTO dto) {
|
public void update(DeviceDTO dto) {
|
||||||
if (dto == null){
|
if (dto == null) {
|
||||||
throw new RuntimeException("参数为空");
|
throw new RuntimeException("参数为空");
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isEmpty(dto.getDeviceName()) || ObjectUtil.isEmpty(dto.getDeviceSn()) || ObjectUtil.isEmpty(dto.getDeviceName())
|
if (ObjectUtil.isEmpty(dto.getDeviceName()) || ObjectUtil.isEmpty(dto.getDeviceSn()) || ObjectUtil.isEmpty(dto.getDeviceName())
|
||||||
|| ObjectUtil.isEmpty(dto.getAreaId()) || ObjectUtil.isEmpty(dto.getCanteenId()) || ObjectUtil.isEmpty(dto.getStallId())){
|
|| ObjectUtil.isEmpty(dto.getAreaId()) || ObjectUtil.isEmpty(dto.getCanteenId()) || ObjectUtil.isEmpty(dto.getStallId())) {
|
||||||
throw new RuntimeException("请先讲填写所有必填项,再提交相关数据!");
|
throw new RuntimeException("请先讲填写所有必填项,再提交相关数据!");
|
||||||
}
|
}
|
||||||
//判断设备sn、设备编号、设备名称是否存在
|
//判断设备sn、设备编号、设备名称是否存在
|
||||||
int count = mapper.checkIsExistDeviceNum(dto.getDeviceNum(), dto.getDeviceId());
|
int count = mapper.checkIsExistDeviceNum(dto.getDeviceNum(), dto.getDeviceId());
|
||||||
if (count > 0){
|
if (count > 0) {
|
||||||
throw new RuntimeException("设备编号已存在");
|
throw new RuntimeException("设备编号已存在");
|
||||||
}
|
}
|
||||||
count = mapper.checkIsExistDeviceName(dto.getDeviceName(), dto.getDeviceId());
|
count = mapper.checkIsExistDeviceName(dto.getDeviceName(), dto.getDeviceId());
|
||||||
if (count > 0){
|
if (count > 0) {
|
||||||
throw new RuntimeException("设备名称已存在");
|
throw new RuntimeException("设备名称已存在");
|
||||||
}
|
}
|
||||||
count = mapper.checkIsExistDeviceSn(dto.getDeviceSn(), dto.getDeviceId());
|
count = mapper.checkIsExistDeviceSn(dto.getDeviceSn(), dto.getDeviceId());
|
||||||
if (count > 0){
|
if (count > 0) {
|
||||||
throw new RuntimeException("设备sn已存在");
|
throw new RuntimeException("设备sn已存在");
|
||||||
}
|
}
|
||||||
int code = mapper.updateMachine(dto);
|
int code = mapper.updateMachine(dto);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("设备更新失败");
|
throw new RuntimeException("设备更新失败");
|
||||||
}
|
}
|
||||||
code = mapper.updateMachineBind(dto);
|
code = mapper.updateMachineBind(dto);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("设备绑定更新失败");
|
throw new RuntimeException("设备绑定更新失败");
|
||||||
}
|
}
|
||||||
code = mapper.updateDeviceRecipe(dto);
|
code = mapper.updateDeviceRecipe(dto);
|
||||||
|
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("修改菜谱关联失败");
|
throw new RuntimeException("修改菜谱关联失败");
|
||||||
}
|
}
|
||||||
//发送mq
|
//发送mq
|
||||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0,"update");
|
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0, "update");
|
||||||
MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_INFO_V4, dto.getDeviceSn());
|
MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_INFO_V4, dto.getDeviceSn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,11 +148,11 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delete(String deviceId) {
|
public void delete(String deviceId) {
|
||||||
int code = mapper.deleteMachine(deviceId);
|
int code = mapper.deleteMachine(deviceId);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("设备删除失败");
|
throw new RuntimeException("设备删除失败");
|
||||||
}
|
}
|
||||||
code = mapper.deleteMachineBind(deviceId);
|
code = mapper.deleteMachineBind(deviceId);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("设备绑定删除失败");
|
throw new RuntimeException("设备绑定删除失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -162,8 +165,22 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
|
||||||
@Override
|
@Override
|
||||||
public void updateTimeBySn(String sn) {
|
public void updateTimeBySn(String sn) {
|
||||||
int code = mapper.updateTimeBySn(sn);
|
int code = mapper.updateTimeBySn(sn);
|
||||||
if (code == 0){
|
if (code == 0) {
|
||||||
throw new RuntimeException("更新时间失败");
|
throw new RuntimeException("更新时间失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadApk(ApkDTO dto) {
|
||||||
|
try {
|
||||||
|
ApkDTO apkDTO = mapper.getApkByType(dto.getType(), dto.getVersion());
|
||||||
|
if (apkDTO != null) {
|
||||||
|
mapper.updateApk(dto);
|
||||||
|
} else {
|
||||||
|
mapper.insertApk(dto);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("操作失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,12 +180,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
and device_id != #{deviceId}
|
and device_id != #{deviceId}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getApkByType" resultType="com.bonus.canteen.core.device.dto.ApkDTO">
|
||||||
|
select * from app_version where type = #{type} and version = #{version}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertDeviceRecipe">
|
<insert id="insertDeviceRecipe">
|
||||||
insert into device_recipe(id,device_id, canteen_id,stall_id,
|
insert into device_recipe(id,device_id, canteen_id,stall_id,
|
||||||
revision)
|
revision)
|
||||||
values (#{id},#{deviceId}, #{canteenId}, #{stallId},'0')
|
values (#{id},#{deviceId}, #{canteenId}, #{stallId},'0')
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="insertApk">
|
||||||
|
insert into app_version(version, version_name, apk_name, apk_path, update_content, deploy_user, type)
|
||||||
|
values (#{version}, #{versionName}, #{apkName}, #{apkPath}, #{updateContent}, #{deployUser}, #{type})
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateDeviceRecipe" >
|
<update id="updateDeviceRecipe" >
|
||||||
update device_recipe
|
update device_recipe
|
||||||
|
|
@ -202,4 +209,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</set>
|
</set>
|
||||||
where device_id = #{deviceId}
|
where device_id = #{deviceId}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateApk">
|
||||||
|
update app_version
|
||||||
|
<set>
|
||||||
|
<if test="version != null and version != ''">
|
||||||
|
version = #{version},
|
||||||
|
</if>
|
||||||
|
<if test="versionName != null and versionName != ''">
|
||||||
|
version_name = #{versionName},
|
||||||
|
</if>
|
||||||
|
<if test="apkName != null and apkName != ''">
|
||||||
|
apk_name = #{apkName},
|
||||||
|
</if>
|
||||||
|
<if test="apkPath != null and apkPath != ''">
|
||||||
|
apk_path = #{apkPath},
|
||||||
|
</if>
|
||||||
|
<if test="updateContent != null and updateContent != ''">
|
||||||
|
update_content = #{updateContent},
|
||||||
|
</if>
|
||||||
|
<if test="updateContent != null and updateContent != ''">
|
||||||
|
update_content = #{updateContent},
|
||||||
|
</if>
|
||||||
|
<if test="deployUser != null and deployUser != ''">
|
||||||
|
deploy_user = #{deployUser},
|
||||||
|
</if>
|
||||||
|
<if test="type != null and type != ''">
|
||||||
|
type = #{type},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where version = #{version}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue