若依微服务1.4.0

1、设备管理增加重启,并且只有网关和直连设备可以控制
2、数据处理完善对图片的处理
3、增加手机端的接口
4、tenantId写到header中,以便在保存数据时获取
5、角色管理租户可增删改查
dev 1.4.1
xins 1 year ago
parent 5d20ff6f48
commit 53d37173a4

@ -0,0 +1,123 @@
package com.ruoyi.basic.controller;
import com.ruoyi.basic.api.domain.HwTenant;
import com.ruoyi.basic.service.IHwTenantService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
* Controller
*
* @author xins
* @date 2023-09-04
*/
@RestController
@RequestMapping("/tenant")
public class HwTenantController extends BaseController
{
@Autowired
private IHwTenantService hwTenantService;
/**
*
*/
@RequiresPermissions("business:tenant:list")
@GetMapping("/list")
public TableDataInfo list(HwTenant hwTenant)
{
List<HwTenant> list = new ArrayList<HwTenant>();
startPage();
//todo 放到add中
list = hwTenantService.selectHwTenantList(hwTenant);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("business:tenant:export")
@Log(title = "租户信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HwTenant hwTenant)
{
List<HwTenant> list = hwTenantService.selectHwTenantList(hwTenant);
ExcelUtil<HwTenant> util = new ExcelUtil<HwTenant>(HwTenant.class);
util.exportExcel(response, list, "租户信息数据");
}
/**
*
*/
@RequiresPermissions("business:tenant:query")
@GetMapping(value = "/{tenantId}")
public AjaxResult getInfo(@PathVariable("tenantId") Long tenantId)
{
return success(hwTenantService.selectHwTenantByTenantId(tenantId));
}
/**
*
*/
@RequiresPermissions("business:tenant:add")
@Log(title = "租户信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody HwTenant hwTenant)
{
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
hwTenant.setIsRegister("0");
hwTenant.setCreateBy(sysUser.getNickName());
return toAjax(hwTenantService.insertHwTenant(hwTenant));
}
/**
*
*/
@RequiresPermissions("business:tenant:edit")
@Log(title = "租户信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody HwTenant hwTenant)
{LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
hwTenant.setUpdateBy(sysUser.getNickName());
return toAjax(hwTenantService.updateHwTenant(hwTenant));
}
/**
*
*/
@RequiresPermissions("business:tenant:remove")
@Log(title = "租户信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{tenantIds}")
public AjaxResult remove(@PathVariable Long[] tenantIds)
{
return toAjax(hwTenantService.deleteHwTenantByTenantIds(tenantIds));
}
/**
*
*/
@GetMapping("/getTenants")
public R<List<HwTenant>> getTenants(HwTenant hwTenant)
{
return R.ok(hwTenantService.selectHwTenantList(hwTenant));
}
}

@ -0,0 +1,79 @@
package com.ruoyi.business.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* hw_fence_area
*
* @author xins
* @date 2023-09-19
*/
public class HwFenceArea extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 电子围栏区域ID */
private Long fenceAreaId;
/** 电子围栏ID */
@Excel(name = "电子围栏ID")
private Long electronicFenceId;
/** 区域形状1、多边形2、圆形 */
@Excel(name = "区域形状", readConverterExp = "1=、多边形2、圆形")
private String areaShapeFlag;
/** 区域范围:为多边形时保存格式,经度,纬度多个以_隔开为圆形时的中心点和半径,隔开 */
@Excel(name = "区域范围:为多边形时保存格式,经度,纬度多个以_隔开为圆形时的中心点和半径,隔开")
private String areaRange;
public void setFenceAreaId(Long fenceAreaId)
{
this.fenceAreaId = fenceAreaId;
}
public Long getFenceAreaId()
{
return fenceAreaId;
}
public void setElectronicFenceId(Long electronicFenceId)
{
this.electronicFenceId = electronicFenceId;
}
public Long getElectronicFenceId()
{
return electronicFenceId;
}
public void setAreaShapeFlag(String areaShapeFlag)
{
this.areaShapeFlag = areaShapeFlag;
}
public String getAreaShapeFlag()
{
return areaShapeFlag;
}
public void setAreaRange(String areaRange)
{
this.areaRange = areaRange;
}
public String getAreaRange()
{
return areaRange;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("fenceAreaId", getFenceAreaId())
.append("electronicFenceId", getElectronicFenceId())
.append("areaShapeFlag", getAreaShapeFlag())
.append("areaRange", getAreaRange())
.toString();
}
}

@ -0,0 +1,61 @@
package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwFenceArea;
/**
* Mapper
*
* @author xins
* @date 2023-09-19
*/
public interface HwFenceAreaMapper
{
/**
*
*
* @param fenceAreaId
* @return
*/
public HwFenceArea selectHwFenceAreaByFenceAreaId(Long fenceAreaId);
/**
*
*
* @param hwFenceArea
* @return
*/
public List<HwFenceArea> selectHwFenceAreaList(HwFenceArea hwFenceArea);
/**
*
*
* @param hwFenceArea
* @return
*/
public int insertHwFenceArea(HwFenceArea hwFenceArea);
/**
*
*
* @param hwFenceArea
* @return
*/
public int updateHwFenceArea(HwFenceArea hwFenceArea);
/**
*
*
* @param fenceAreaId
* @return
*/
public int deleteHwFenceAreaByFenceAreaId(Long fenceAreaId);
/**
*
*
* @param fenceAreaIds
* @return
*/
public int deleteHwFenceAreaByFenceAreaIds(Long[] fenceAreaIds);
}

@ -0,0 +1,10 @@
package com.ruoyi.business.service;
import com.ruoyi.business.domain.HwDevice;
public interface IHwCommonService {
public void createTdTable(HwDevice hwDevice);
public void updateMqttAut(HwDevice hwDevice);
}

@ -0,0 +1,66 @@
<?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.ruoyi.business.mapper.HwFenceAreaMapper">
<resultMap type="HwFenceArea" id="HwFenceAreaResult">
<result property="fenceAreaId" column="fence_area_id" />
<result property="electronicFenceId" column="electronic_fence_id" />
<result property="areaShapeFlag" column="area_shape_flag" />
<result property="areaRange" column="area_range" />
</resultMap>
<sql id="selectHwFenceAreaVo">
select fence_area_id, electronic_fence_id, area_shape_flag, area_range from hw_fence_area
</sql>
<select id="selectHwFenceAreaList" parameterType="HwFenceArea" resultMap="HwFenceAreaResult">
<include refid="selectHwFenceAreaVo"/>
<where>
<if test="electronicFenceId != null "> and electronic_fence_id = #{electronicFenceId}</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''"> and area_shape_flag = #{areaShapeFlag}</if>
<if test="areaRange != null and areaRange != ''"> and area_range = #{areaRange}</if>
</where>
</select>
<select id="selectHwFenceAreaByFenceAreaId" parameterType="Long" resultMap="HwFenceAreaResult">
<include refid="selectHwFenceAreaVo"/>
where fence_area_id = #{fenceAreaId}
</select>
<insert id="insertHwFenceArea" parameterType="HwFenceArea" useGeneratedKeys="true" keyProperty="fenceAreaId">
insert into hw_fence_area
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="electronicFenceId != null">electronic_fence_id,</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">area_shape_flag,</if>
<if test="areaRange != null">area_range,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="electronicFenceId != null">#{electronicFenceId},</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">#{areaShapeFlag},</if>
<if test="areaRange != null">#{areaRange},</if>
</trim>
</insert>
<update id="updateHwFenceArea" parameterType="HwFenceArea">
update hw_fence_area
<trim prefix="SET" suffixOverrides=",">
<if test="electronicFenceId != null">electronic_fence_id = #{electronicFenceId},</if>
<if test="areaShapeFlag != null and areaShapeFlag != ''">area_shape_flag = #{areaShapeFlag},</if>
<if test="areaRange != null">area_range = #{areaRange},</if>
</trim>
where fence_area_id = #{fenceAreaId}
</update>
<delete id="deleteHwFenceAreaByFenceAreaId" parameterType="Long">
delete from hw_fence_area where fence_area_id = #{fenceAreaId}
</delete>
<delete id="deleteHwFenceAreaByFenceAreaIds" parameterType="String">
delete from hw_fence_area where fence_area_id in
<foreach item="fenceAreaId" collection="array" open="(" separator="," close=")">
#{fenceAreaId}
</foreach>
</delete>
</mapper>

@ -1,7 +1,10 @@
package com.ruoyi.dataprocess.common;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.uuid.Seq;
import com.ruoyi.common.core.utils.uuid.UUID;
import org.apache.commons.io.FilenameUtils;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -86,7 +89,7 @@ public class ImageUtils {
* @author xins
* @date 2023-09-04 15:59
*/
public static String convertBase64ToImage(String base64Str, String imagePath, String imageType, Long deviceId) {
/*public static String convertBase64ToImage(String base64Str, String imagePath, String imageType, Long deviceId) {
// 解密
try {
String fileName = UUID.randomUUID().toString().concat(".").concat(imageType);
@ -124,7 +127,7 @@ public class ImageUtils {
return null;
}
}
}*/
public static String getFileContent(FileInputStream fis, String encoding) throws IOException {
@ -139,13 +142,76 @@ public class ImageUtils {
}
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists()) {
if (!desc.getParentFile().exists()) {
desc.getParentFile().mkdirs();
}
}
return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
}
private static final String getPathFileName(String fileName) throws IOException {
String pathFileName = "/" + fileName;
return pathFileName;
}
public static final String extractFilename(String originalFileName, String imagePath, String extension) {
return StringUtils.format("{}/{}/{}_{}.{}", imagePath, DateUtils.datePath(),
FilenameUtils.getBaseName(originalFileName), Seq.getId(Seq.uploadSeqType), extension);
}
/**
* @param: base64
* @param: imageFileName
* @description base64
* @author xins
* @date 2023-09-04 15:59
*/
public static String convertBase64ToImage(String baseDir, String base64Str, String imagePath, String extension) throws IOException {
// 解密
try {
String originalFileName = UUID.randomUUID().toString();
String fileName = extractFilename(originalFileName, imagePath, extension);
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
// 去掉base64前缀 data:image/jpeg;base64,
base64Str = base64Str.substring(base64Str.indexOf(",", 1) + 1);
// 解密解密的结果是一个byte数组
Base64.Decoder decoder = Base64.getDecoder();
byte[] imgbytes = decoder.decode(base64Str);
for (int i = 0; i < imgbytes.length; ++i) {
if (imgbytes[i] < 0) {
imgbytes[i] += 256;
}
}
// 保存图片
OutputStream out = new FileOutputStream(absPath);
out.write(imgbytes);
out.flush();
out.close();
// 返回图片的相对路径 = 图片分类路径+图片名+图片后缀
return getPathFileName(fileName);
} catch (IOException e) {
throw new IOException(e.getMessage(), e);
}
}
public static void main(String[] args) throws IOException {
// 从txt文件中读取base64字符串
FileInputStream fis = new FileInputStream("e://base64test/base64test5.txt");
String base64Str = getFileContent(fis, "UTF-8");
String[] imagePatternArr = {"png", "jpg", "jpeg"};
String imageType = ImageUtils.getImageType(base64Str, imagePatternArr);
ImageUtils.convertBase64ToImage(base64Str,"images",imageType,2L);
// ImageUtils.convertBase64ToImage(base64Str,"images",imageType,2L);
// 将base64字符串翻译成图片

Loading…
Cancel
Save