作者 钟来

添加解码器安装流程

正在显示 25 个修改的文件 包含 1034 行增加118 行删除
... ... @@ -7,6 +7,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
... ... @@ -678,91 +679,57 @@ public class PublicSQL {
* @param objectlist 对象列表
* @return
*/
public String saveOrUpdateObjectList(List<Object> objectlist)
{
StringBuffer sb =new StringBuffer();
String update = "";
for(int i = 0; i<objectlist.size();i++)
{
Object object = objectlist.get(i);
public String saveOrUpdateObjectList(List<Object> objectlist) {
if (objectlist == null || objectlist.isEmpty()) {
throw new IllegalArgumentException("objectlist cannot be empty");
}
Field[] fields = object.getClass().getDeclaredFields( );
if(i==0)
{
String tableName = changTableNameFromObject(object);
sb.append("INSERT INTO `"+tableName+"` ");
sb.append("(");
for(Field field:fields)
{
PublicSQLConfig publicSQLConfig = field.getAnnotation(PublicSQLConfig.class);
if(null != publicSQLConfig && !publicSQLConfig.isSelect())
{
continue;
}
if(!"".equals(update) )
{
sb.append(",");
update += ",";
}
sb.append("`"+com.ruoyi.common.utils.StringUtils.toUnderScoreCase(field.getName())+"`");
update += "`"+com.ruoyi.common.utils.StringUtils.toUnderScoreCase(field.getName())+"`"+"=VALUES("+"`"+com.ruoyi.common.utils.StringUtils.toUnderScoreCase(field.getName())+"`)";
}
sb.append(")");
sb.append("VALUES ");
}else{
sb.append(",");
StringBuilder sb = new StringBuilder();
StringBuilder update = new StringBuilder();
Object firstObject = objectlist.get(0);
String tableName = changTableNameFromObject(firstObject);
Field[] fields = firstObject.getClass().getDeclaredFields();
// 拼字段列表
sb.append("INSERT INTO `").append(tableName).append("` (");
List<Field> validFields = new ArrayList<>();
for (Field field : fields) {
PublicSQLConfig cfg = field.getAnnotation(PublicSQLConfig.class);
if (cfg != null && !cfg.isSelect()) {
continue;
}
for(int j=0;j<fields.length;j++)
{
Field field = fields[j];
Method method;
try {
PublicSQLConfig publicSQLConfig = field.getAnnotation(PublicSQLConfig.class);
if(null != publicSQLConfig && !publicSQLConfig.isSelect())
{
continue;
}
method = object.getClass().getMethod("get"+com.ruoyi.common.utils.StringUtils.getName(field.getName()));
Object value = method.invoke(object);
if(null == value)
{
value = "";
}
if(j!=0)
{
sb.append(",");
}else{
sb.append("(");
}
sb.append("#{"+ field.getName()+"}");
if(j==fields.length-1)
{
sb.append(")");
}
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
validFields.add(field);
}
for (int i = 0; i < validFields.size(); i++) {
Field field = validFields.get(i);
String column = com.ruoyi.common.utils.StringUtils.toUnderScoreCase(field.getName());
if (i > 0) {
sb.append(",");
update.append(",");
}
sb.append("`").append(column).append("`");
update.append("`").append(column).append("`=VALUES(`").append(column).append("`)");
}
sb.append(") VALUES ");
// 拼 values
for (int i = 0; i < objectlist.size(); i++) {
if (i > 0) sb.append(",");
sb.append("(");
for (int j = 0; j < validFields.size(); j++) {
if (j > 0) sb.append(",");
sb.append("#{list[").append(i).append("].").append(validFields.get(j).getName()).append("}");
}
sb.append(")");
}
sb.append(" ON DUPLICATE KEY UPDATE ");
sb.append(update);
sb.append(" ON DUPLICATE KEY UPDATE ").append(update);
return sb.toString();
}
public String getObjectListBySQL(Map<String, Object> para)
{
return para.get("sql")+"";
... ...
... ... @@ -4,11 +4,12 @@ import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.zhonglai.luhui.datasource.enums.DataSource;
import com.zhonglai.luhui.datasource.enums.DataSourceType;
import com.zhonglai.luhui.user.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhonglai.luhui.user.mapper.UserBaseInfoMapper;
import com.zhonglai.luhui.user.domain.UserBaseInfo;
import com.zhonglai.luhui.user.service.IUserBaseInfoService;
import org.springframework.transaction.annotation.Transactional;
/**
* 基础用户信息Service业务层处理
... ... @@ -23,6 +24,22 @@ public class UserBaseInfoServiceImpl implements IUserBaseInfoService
@Autowired
private UserBaseInfoMapper userBaseInfoMapper;
@Autowired
private IUserAccountInfoService userAccountInfoService;
@Autowired
private IUserAddressInfoService userAddressInfoService;
@Autowired
private IUserAuthInfoService userAuthInfoService;
@Autowired
private IUserExtraInfoService userExtraInfoService;
@Autowired
private IUserLoginInfoService userLoginInfoService;
@Autowired
private IUserLoginService userLoginService;
@Autowired
private IUserOfficialInfoService userOfficialInfoService;
@Autowired
private IUserSocialInfoService userSocialInfoService;
/**
* 查询基础用户信息
*
... ... @@ -66,6 +83,7 @@ public class UserBaseInfoServiceImpl implements IUserBaseInfoService
* @param userBaseInfo 基础用户信息
* @return 结果
*/
@Transactional
@Override
public int updateUserBaseInfo(UserBaseInfo userBaseInfo)
{
... ... @@ -78,9 +96,18 @@ public class UserBaseInfoServiceImpl implements IUserBaseInfoService
* @param ids 需要删除的基础用户信息主键
* @return 结果
*/
@Transactional
@Override
public int deleteUserBaseInfoByIds(Integer[] ids)
{
userAccountInfoService.deleteUserAccountInfoByIds(ids);
userAddressInfoService.deleteUserAddressInfoByIds(ids);
userAuthInfoService.deleteUserAuthInfoByIds(ids);
userExtraInfoService.deleteUserExtraInfoByIds(ids);
userOfficialInfoService.deleteUserOfficialInfoByIds(ids);
userSocialInfoService.deleteUserSocialInfoByIds(ids);
userLoginInfoService.deleteUserLoginInfoByIds(ids);
userLoginService.deleteUserLoginByIds(ids);
return userBaseInfoMapper.deleteUserBaseInfoByIds(ids);
}
... ...
... ... @@ -24,12 +24,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectUserBaseInfoVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="loginName != null "> and login_name like concat('%', #{loginName}, '%')</if>
<if test="name != null and name != ''"> and `name` like concat('%', #{name}, '%')</if>
<if test="nickname != null and nickname != ''"> and nickname like concat('%', #{nickname}, '%')</if>
<if test="gender != null "> and gender = #{gender}</if>
<if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
<if test="email != null and email != ''"> and email like concat('%', #{email}, '%')</if>
<if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
<if test="params.keyValue != null and params.keyValue != ''"> and (
login_name like concat('%', #{params.keyValue}, '%')
or email like concat('%', #{params.keyValue}, '%')
or nickname like concat('%', #{params.keyValue}, '%')
or phone like concat('%', #{params.keyValue}, '%')
or `name` like concat('%', #{params.keyValue}, '%')
)
</if>
</where>
</select>
... ... @@ -41,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertUserBaseInfo" parameterType="UserBaseInfo" useGeneratedKeys="true" keyProperty="id">
insert into user_base_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="loginName != null">loginName,</if>
<if test="loginName != null">login_name,</if>
<if test="name != null">`name`,</if>
<if test="nickname != null">nickname,</if>
<if test="gender != null">gender,</if>
... ... @@ -78,13 +87,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteUserBaseInfoById" parameterType="Integer">
delete from user_base_info where id = #{id}
<!-- 按删除顺序依赖关系:子表在前,主表在后 -->
delete from user_account_info where id = #{id};
delete from user_address_info where id = #{id};
delete from user_auth_info where id = #{id};
delete from user_extra_info where id = #{id};
delete from user_login where user_id = #{id};
delete from user_login_info where id = #{id};
delete from user_official_info where id = #{id};
delete from user_social_info where id = #{id};
delete from user_base_info where id = #{id};
</delete>
<delete id="deleteUserBaseInfoByIds" parameterType="String">
delete from user_base_info where id in
<delete id="deleteUserBaseInfoByIds" parameterType="Integer">
<!-- 先删关联表,再删主表 -->
delete from user_base_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</foreach>;
</delete>
</mapper>
\ No newline at end of file
... ...
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}', 2006, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
values('${functionName}', '${parentMenuId}, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
... ...
package com.zhonglai.luhui.device.domain;
import com.ruoyi.common.annotation.PublicSQLConfig;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.ruoyi.common.tool.BaseEntity;
/**
* 流水鱼plc通讯解析协议配置对象 iot_lsy_plc_config
*
* @author zhonglai
* @date 2025-11-10
*/
@ApiModel("流水鱼plc通讯解析协议配置")
public class IotLsyPlcConfig extends BaseEntity
{
@PublicSQLConfig(isSelect=false)
private static final long serialVersionUID = 1L;
/** 主键 */
@ApiModelProperty(value="主键")
private Integer id;
/** 变量名称 */
@ApiModelProperty(value="变量名称")
private String alterName;
/** 变量地址 */
@ApiModelProperty(value="变量地址")
private String alterAddr;
/** 上传名称 */
@ApiModelProperty(value="上传名称")
private String upName;
/** 上传间隔 */
@ApiModelProperty(value="上传间隔")
private Integer upInterval;
/** 项目类型(1流水槽,2工厂化,3其它) */
@ApiModelProperty(value="项目类型",allowableValues="1=流水槽,2工厂化,3其它")
private String prejectType;
/** 产品id */
@ApiModelProperty(value="产品id")
private String deviceType;
public void setId(Integer id)
{
this.id = id;
}
public Integer getId()
{
return id;
}
public void setAlterName(String alterName)
{
this.alterName = alterName;
}
public String getAlterName()
{
return alterName;
}
public void setAlterAddr(String alterAddr)
{
this.alterAddr = alterAddr;
}
public String getAlterAddr()
{
return alterAddr;
}
public void setUpName(String upName)
{
this.upName = upName;
}
public String getUpName()
{
return upName;
}
public void setUpInterval(Integer upInterval)
{
this.upInterval = upInterval;
}
public Integer getUpInterval()
{
return upInterval;
}
public void setPrejectType(String prejectType)
{
this.prejectType = prejectType;
}
public String getPrejectType()
{
return prejectType;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("alterName", getAlterName())
.append("alterAddr", getAlterAddr())
.append("upName", getUpName())
.append("upInterval", getUpInterval())
.append("createTime", getCreateTime())
.append("prejectType", getPrejectType())
.append("productId", getDeviceType())
.toString();
}
}
... ...
package com.zhonglai.luhui.device.mapper;
import java.util.List;
import com.zhonglai.luhui.device.domain.IotLsyPlcConfig;
/**
* 流水鱼plc通讯解析协议配置Mapper接口
*
* @author zhonglai
* @date 2025-11-10
*/
public interface IotLsyPlcConfigMapper
{
/**
* 查询流水鱼plc通讯解析协议配置
*
* @param id 流水鱼plc通讯解析协议配置主键
* @return 流水鱼plc通讯解析协议配置
*/
public IotLsyPlcConfig selectIotLsyPlcConfigById(Integer id);
/**
* 查询流水鱼plc通讯解析协议配置列表
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 流水鱼plc通讯解析协议配置集合
*/
public List<IotLsyPlcConfig> selectIotLsyPlcConfigList(IotLsyPlcConfig iotLsyPlcConfig);
/**
* 新增流水鱼plc通讯解析协议配置
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 结果
*/
public int insertIotLsyPlcConfig(IotLsyPlcConfig iotLsyPlcConfig);
/**
* 修改流水鱼plc通讯解析协议配置
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 结果
*/
public int updateIotLsyPlcConfig(IotLsyPlcConfig iotLsyPlcConfig);
/**
* 删除流水鱼plc通讯解析协议配置
*
* @param id 流水鱼plc通讯解析协议配置主键
* @return 结果
*/
public int deleteIotLsyPlcConfigById(Integer id);
/**
* 批量删除流水鱼plc通讯解析协议配置
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteIotLsyPlcConfigByIds(Integer[] ids);
}
... ...
package com.zhonglai.luhui.device.service;
import java.util.List;
import com.zhonglai.luhui.device.domain.IotLsyPlcConfig;
/**
* 流水鱼plc通讯解析协议配置Service接口
*
* @author zhonglai
* @date 2025-11-10
*/
public interface IIotLsyPlcConfigService
{
/**
* 查询流水鱼plc通讯解析协议配置
*
* @param id 流水鱼plc通讯解析协议配置主键
* @return 流水鱼plc通讯解析协议配置
*/
public IotLsyPlcConfig selectIotLsyPlcConfigById(Integer id);
/**
* 查询流水鱼plc通讯解析协议配置列表
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 流水鱼plc通讯解析协议配置集合
*/
public List<IotLsyPlcConfig> selectIotLsyPlcConfigList(IotLsyPlcConfig iotLsyPlcConfig);
/**
* 新增流水鱼plc通讯解析协议配置
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 结果
*/
public int insertIotLsyPlcConfig(IotLsyPlcConfig iotLsyPlcConfig);
/**
* 修改流水鱼plc通讯解析协议配置
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 结果
*/
public int updateIotLsyPlcConfig(IotLsyPlcConfig iotLsyPlcConfig);
/**
* 批量删除流水鱼plc通讯解析协议配置
*
* @param ids 需要删除的流水鱼plc通讯解析协议配置主键集合
* @return 结果
*/
public int deleteIotLsyPlcConfigByIds(Integer[] ids);
/**
* 删除流水鱼plc通讯解析协议配置信息
*
* @param id 流水鱼plc通讯解析协议配置主键
* @return 结果
*/
public int deleteIotLsyPlcConfigById(Integer id);
}
... ...
package com.zhonglai.luhui.device.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.zhonglai.luhui.device.domain.IotLsyPlcConfig;
import com.zhonglai.luhui.device.mapper.IotLsyPlcConfigMapper;
import com.zhonglai.luhui.device.service.IIotLsyPlcConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 流水鱼plc通讯解析协议配置Service业务层处理
*
* @author zhonglai
* @date 2025-11-10
*/
@Service
public class IotLsyPlcConfigServiceImpl implements IIotLsyPlcConfigService
{
@Autowired
private IotLsyPlcConfigMapper iotLsyPlcConfigMapper;
/**
* 查询流水鱼plc通讯解析协议配置
*
* @param id 流水鱼plc通讯解析协议配置主键
* @return 流水鱼plc通讯解析协议配置
*/
@Override
public IotLsyPlcConfig selectIotLsyPlcConfigById(Integer id)
{
return iotLsyPlcConfigMapper.selectIotLsyPlcConfigById(id);
}
/**
* 查询流水鱼plc通讯解析协议配置列表
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 流水鱼plc通讯解析协议配置
*/
@Override
public List<IotLsyPlcConfig> selectIotLsyPlcConfigList(IotLsyPlcConfig iotLsyPlcConfig)
{
return iotLsyPlcConfigMapper.selectIotLsyPlcConfigList(iotLsyPlcConfig);
}
/**
* 新增流水鱼plc通讯解析协议配置
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 结果
*/
@Override
public int insertIotLsyPlcConfig(IotLsyPlcConfig iotLsyPlcConfig)
{
iotLsyPlcConfig.setCreateTime(DateUtils.getNowDate());
return iotLsyPlcConfigMapper.insertIotLsyPlcConfig(iotLsyPlcConfig);
}
/**
* 修改流水鱼plc通讯解析协议配置
*
* @param iotLsyPlcConfig 流水鱼plc通讯解析协议配置
* @return 结果
*/
@Override
public int updateIotLsyPlcConfig(IotLsyPlcConfig iotLsyPlcConfig)
{
return iotLsyPlcConfigMapper.updateIotLsyPlcConfig(iotLsyPlcConfig);
}
/**
* 批量删除流水鱼plc通讯解析协议配置
*
* @param ids 需要删除的流水鱼plc通讯解析协议配置主键
* @return 结果
*/
@Override
public int deleteIotLsyPlcConfigByIds(Integer[] ids)
{
return iotLsyPlcConfigMapper.deleteIotLsyPlcConfigByIds(ids);
}
/**
* 删除流水鱼plc通讯解析协议配置信息
*
* @param id 流水鱼plc通讯解析协议配置主键
* @return 结果
*/
@Override
public int deleteIotLsyPlcConfigById(Integer id)
{
return iotLsyPlcConfigMapper.deleteIotLsyPlcConfigById(id);
}
}
... ...
<?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.zhonglai.luhui.device.mapper.IotLsyPlcConfigMapper">
<resultMap type="IotLsyPlcConfig" id="IotLsyPlcConfigResult">
<result property="id" column="id" />
<result property="alterName" column="alter_name" />
<result property="alterAddr" column="alter_addr" />
<result property="upName" column="up_name" />
<result property="upInterval" column="up_interval" />
<result property="createTime" column="create_time" />
<result property="prejectType" column="preject_type" />
<result property="deviceType" column="device_type" />
</resultMap>
<sql id="selectIotLsyPlcConfigVo">
select id, alter_name, alter_addr, up_name, up_interval, create_time, preject_type, device_type from iot_lsy_plc_config
</sql>
<select id="selectIotLsyPlcConfigList" parameterType="IotLsyPlcConfig" resultMap="IotLsyPlcConfigResult">
<include refid="selectIotLsyPlcConfigVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="alterName != null and alterName != ''"> and alter_name like concat('%', #{alterName}, '%')</if>
<if test="alterAddr != null and alterAddr != ''"> and alter_addr = #{alterAddr}</if>
<if test="upName != null and upName != ''"> and up_name like concat('%', #{upName}, '%')</if>
<if test="upInterval != null "> and up_interval = #{upInterval}</if>
<if test="prejectType != null "> and preject_type = #{prejectType}</if>
<if test="deviceType != null "> and device_type = #{deviceType}</if>
</where>
</select>
<select id="selectIotLsyPlcConfigById" parameterType="Integer" resultMap="IotLsyPlcConfigResult">
<include refid="selectIotLsyPlcConfigVo"/>
where id = #{id}
</select>
<insert id="insertIotLsyPlcConfig" parameterType="IotLsyPlcConfig" useGeneratedKeys="true" keyProperty="id">
insert into iot_lsy_plc_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alterName != null and alterName != ''">alter_name,</if>
<if test="alterAddr != null and alterAddr != ''">alter_addr,</if>
<if test="upName != null and upName != ''">up_name,</if>
<if test="upInterval != null">up_interval,</if>
<if test="createTime != null">create_time,</if>
<if test="prejectType != null">preject_type,</if>
<if test="deviceType != null">device_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alterName != null and alterName != ''">#{alterName},</if>
<if test="alterAddr != null and alterAddr != ''">#{alterAddr},</if>
<if test="upName != null and upName != ''">#{upName},</if>
<if test="upInterval != null">#{upInterval},</if>
<if test="createTime != null">#{createTime},</if>
<if test="prejectType != null">#{prejectType},</if>
<if test="deviceType != null">#{deviceType},</if>
</trim>
</insert>
<update id="updateIotLsyPlcConfig" parameterType="IotLsyPlcConfig">
update iot_lsy_plc_config
<trim prefix="SET" suffixOverrides=",">
<if test="alterName != null and alterName != ''">alter_name = #{alterName},</if>
<if test="alterAddr != null and alterAddr != ''">alter_addr = #{alterAddr},</if>
<if test="upName != null and upName != ''">up_name = #{upName},</if>
<if test="upInterval != null">up_interval = #{upInterval},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="prejectType != null">preject_type = #{prejectType},</if>
<if test="deviceType != null">device_type = #{deviceType},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteIotLsyPlcConfigById" parameterType="Integer">
delete from iot_lsy_plc_config where id = #{id}
</delete>
<delete id="deleteIotLsyPlcConfigByIds" parameterType="Integer">
delete from iot_lsy_plc_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
... ...
package com.zhonglai.luhui.admin.controller.iot;
import java.util.ArrayList;
import java.util.List;
import com.zhonglai.luhui.dao.service.PublicService;
import com.zhonglai.luhui.datasource.enums.DataSource;
import com.zhonglai.luhui.datasource.enums.DataSourceType;
import javax.servlet.http.HttpServletResponse;
import com.zhonglai.luhui.device.service.IIotLsyPlcConfigService;
import com.zhonglai.luhui.device.service.impl.IotLsyPlcConfigServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.zhonglai.luhui.action.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zhonglai.luhui.dao.service.PublicTemplateService;
import com.zhonglai.luhui.device.domain.IotLsyPlcConfig;
import com.zhonglai.luhui.sys.utils.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 流水鱼plc通讯解析协议配置Controller
*
* @author zhonglai
* @date 2025-11-10
*/
@Api(tags = "流水鱼plc通讯解析协议配置")
@RestController
@RequestMapping("/iot/device/lsy_plc_config")
public class IotLsyPlcConfigController extends BaseController
{
@Autowired
private IIotLsyPlcConfigService iIotLsyPlcConfigService;
@Autowired
private PublicTemplateService publicTemplateService;
@Autowired
private PublicService publicService;
@ApiOperation(value ="查询流水鱼plc通讯解析协议配置列表",notes="\n" +
"公共参数描述:\n" +
"条件参数:\n" +
"timeMap; //时间条件(如:{\"create_time\":[开始时间,结束时间]})\n" +
"keyValue; //模糊匹配的关键字(如:[\"value\",\"name,no\"])\n" +
"queryParams; //字段对应的比较符号(如:{\"id\":\"EQ\"})\n" +
"orderBy; //排序(如:\"id desc,name asc\")\n" +
"\n" +
"分页参数:\n" +
"pageNum; //当前记录起始索引,从1开始\n" +
"pageSize; //每页显示记录数")
@PreAuthorize("@ss.hasPermi('device:lsy_plc_config:list')")
@GetMapping("/list")
public TableDataInfo list(IotLsyPlcConfig iotLsyPlcConfig)
{
startPage();
List<IotLsyPlcConfig> list = iIotLsyPlcConfigService.selectIotLsyPlcConfigList(iotLsyPlcConfig);
return getDataTable(list);
}
@ApiOperation("导出流水鱼plc通讯解析协议配置列表")
@PreAuthorize("@ss.hasPermi('device:lsy_plc_config:export')")
@Log(title = "流水鱼plc通讯解析协议配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IotLsyPlcConfig iotLsyPlcConfig)
{
List<IotLsyPlcConfig> list = publicTemplateService.selectTList(iotLsyPlcConfig);
ExcelUtil<IotLsyPlcConfig> util = new ExcelUtil<IotLsyPlcConfig>(IotLsyPlcConfig.class);
util.exportExcel(response, list, "流水鱼plc通讯解析协议配置数据");
}
@ApiOperation("获取流水鱼plc通讯解析协议配置详细信息")
@PreAuthorize("@ss.hasPermi('device:lsy_plc_config:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(publicTemplateService.getTById(id, IotLsyPlcConfig.class));
}
@ApiOperation("批量添加/修改流水鱼plc通讯解析协议配置")
@PreAuthorize("@ss.hasPermi('device:lsy_plc_config:saveOrUpdateAll')")
@Log(title = "流水鱼plc通讯解析协议配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult saveOrUpdateAll(@RequestBody List<IotLsyPlcConfig> iotLsyPlcConfigList)
{
List<Object> objectList = new ArrayList<>(iotLsyPlcConfigList);
return toAjax(publicService.saveOrUpdateObjectList(objectList));
}
@ApiOperation("修改流水鱼plc通讯解析协议配置")
@PreAuthorize("@ss.hasPermi('device:lsy_plc_config:edit')")
@Log(title = "流水鱼plc通讯解析协议配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody IotLsyPlcConfig iotLsyPlcConfig)
{
return toAjax(publicTemplateService.edit((iotLsyPlcConfig)));
}
@ApiOperation("删除流水鱼plc通讯解析协议配置")
@PreAuthorize("@ss.hasPermi('device:lsy_plc_config:remove')")
@Log(title = "流水鱼plc通讯解析协议配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(iIotLsyPlcConfigService.deleteIotLsyPlcConfigByIds(ids));
}
}
\ No newline at end of file
... ...
... ... @@ -46,9 +46,6 @@ public class IotThingsModelTemplateController extends BaseController
@Autowired
private IIotThingsModelTemplateService iotThingsModelTemplateService;
@Autowired
private IIotProductService iIotProductService;
/**
* 查询物模型模板列表
*/
... ...
package com.zhonglai.luhui.admin.controller.user;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.utils.DESUtil;
import com.ruoyi.common.utils.StringUtils;
import com.zhonglai.luhui.admin.dto.AddAllUserDto;
import com.zhonglai.luhui.dao.service.PublicService;
import com.zhonglai.luhui.datasource.enums.DataSource;
import com.zhonglai.luhui.datasource.enums.DataSourceType;
import javax.servlet.http.HttpServletResponse;
import com.zhonglai.luhui.user.domain.*;
import com.zhonglai.luhui.user.service.IUserBaseInfoService;
import com.zhonglai.luhui.user.service.IUserLoginService;
import com.zhonglai.luhui.user.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
... ... @@ -47,8 +48,24 @@ public class UserBaseInfoController extends BaseController
@Autowired
private IUserBaseInfoService userBaseInfoService;
@Autowired
private PublicTemplateService publicTemplateService;
private IUserAddressInfoService userAddressInfoService;
@Autowired
private IUserAccountInfoService userAccountInfoService;
@Autowired
private IUserAuthInfoService userAuthInfoService;
@Autowired
private IUserExtraInfoService userExtraInfoService;
@Autowired
private IUserLoginInfoService userLoginInfoService;
@Autowired
private IUserLoginService userLoginService;
@Autowired
private IUserOfficialInfoService userOfficialInfoService;
@Autowired
private IUserSocialInfoService userSocialInfoService;
@Autowired
private PublicService publicService;
@ApiOperation(value ="查询基础用户信息列表",notes="\n" +
"公共参数描述:\n" +
"条件参数:\n" +
... ... @@ -118,27 +135,46 @@ public class UserBaseInfoController extends BaseController
@PostMapping
public AjaxResult addAll(@RequestBody AddAllUserDto addAllUserDto)
{
StringBuffer sql = new StringBuffer("SELECT COUNT(0) ct FROM user_base_info where 1=2");
UserBaseInfo userBaseInfo = addAllUserDto.getUserBaseInfo();
if(StringUtils.isNotEmpty(userBaseInfo.getEmail()))
{
sql.append(" or email='"+userBaseInfo.getEmail()+"'");
}
if(StringUtils.isNotEmpty(userBaseInfo.getPhone()))
{
sql.append(" or phone='"+userBaseInfo.getPhone()+"'");
}
if(StringUtils.isNotEmpty(userBaseInfo.getLoginName()))
{
sql.append(" or login_name='"+userBaseInfo.getLoginName()+"'");
}
List<Map<String,Object>> list = publicService.getObjectListBySQL(sql.toString());
if(null != list && list.size() !=0 && list.get(0).get("ct") != null && Integer.parseInt(list.get(0).get("ct").toString()) > 0)
{
return error("用户邮箱或者手机或者登录名信息已存在");
}
userBaseInfoService.insertUserBaseInfo(userBaseInfo);
if (null != addAllUserDto.getUserAccountInfo())
{
addAllUserDto.getUserAccountInfo().setId(userBaseInfo.getId());
publicTemplateService.add(addAllUserDto.getUserAccountInfo());
userAccountInfoService.insertUserAccountInfo(addAllUserDto.getUserAccountInfo());
}
if (null != addAllUserDto.getUserAddressInfo())
{
addAllUserDto.getUserAddressInfo().setId(userBaseInfo.getId());
publicTemplateService.add(addAllUserDto.getUserAddressInfo());
userAddressInfoService.insertUserAddressInfo(addAllUserDto.getUserAddressInfo());
}
if (null != addAllUserDto.getUserAuthInfo())
{
addAllUserDto.getUserAuthInfo().setId(userBaseInfo.getId());
publicTemplateService.add(addAllUserDto.getUserAuthInfo());
userAuthInfoService.insertUserAuthInfo(addAllUserDto.getUserAuthInfo());
}
if (null != addAllUserDto.getUserExtraInfo())
{
addAllUserDto.getUserExtraInfo().setId(userBaseInfo.getId());
publicTemplateService.add(addAllUserDto.getUserExtraInfo());
userExtraInfoService.insertUserExtraInfo(addAllUserDto.getUserExtraInfo());
}
if (null != addAllUserDto.getUserLogin() && StringUtils.isNotEmpty(addAllUserDto.getUserLogin().getLoginPass()))
{
... ... @@ -146,22 +182,22 @@ public class UserBaseInfoController extends BaseController
String userLoginPassKey = DESUtil.randomString(9);
addAllUserDto.getUserLogin().setLoginPass(DESUtil.encode(addAllUserDto.getUserLogin().getLoginPass(), userLoginPassKey));
addAllUserDto.getUserLogin().setUserLoginPassKey(userLoginPassKey);
publicTemplateService.add(addAllUserDto.getUserLogin());
userLoginService.insertUserLogin(addAllUserDto.getUserLogin());
}
if (null != addAllUserDto.getUserLoginInfo())
{
addAllUserDto.getUserLoginInfo().setId(userBaseInfo.getId());
publicTemplateService.add(addAllUserDto.getUserLoginInfo());
userLoginInfoService.insertUserLoginInfo(addAllUserDto.getUserLoginInfo());
}
if (null != addAllUserDto.getUserOfficialInfo())
{
addAllUserDto.getUserOfficialInfo().setId(userBaseInfo.getId());
publicTemplateService.add(addAllUserDto.getUserOfficialInfo());
userOfficialInfoService.insertUserOfficialInfo(addAllUserDto.getUserOfficialInfo());
}
if (null != addAllUserDto.getUserSocialInfo())
{
addAllUserDto.getUserSocialInfo().setId(userBaseInfo.getId());
publicTemplateService.add(addAllUserDto.getUserSocialInfo());
userSocialInfoService.insertUserSocialInfo(addAllUserDto.getUserSocialInfo());
}
return AjaxResult.success(addAllUserDto);
}
... ...
#!/bin/bash
IP=$(hostname -I | awk '{print $1}')
echo "$IP" > /root/lh-device-modbus-terminal/zlmediakit_config/ip.txt
... ...
[Unit]
Description=My Startup Script
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/root/lh-device-modbus-terminal/bin/write-ip.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
... ...
一、使用 apt 安装 curl
sudo apt update
sudo apt install curl -y
执行完后,验证是否安装成功:
curl --version
二、使用 curl 安装 1Panel
bash -c "$(curl -sSL https://resource.fit2cloud.com/1panel/package/v2/quick_start.sh)"
... ...
1. 修改 SSH 配置文件
打开配置文件:
sudo nano /etc/ssh/sshd_config
找到以下这一行(可能被注释掉了):
#PermitRootLogin prohibit-password
将其修改为:
PermitRootLogin yes
如果你只想允许 root 用密钥登录,使用:
PermitRootLogin without-password
或新版中等价于:
PermitRootLogin prohibit-password
2. 设置 root 密码(如果还没有)
sudo passwd root
3. 重启 SSH 服务
sudo systemctl restart ssh
4. 测试远程登录
使用 SSH 客户端登录:
ssh root@your.debian.ip
\ No newline at end of file
... ...
#配置网络自动获取
# 立即验证脚本是否是 Windows 格式,如果出现:CRLF 就是这个问题。
file setup_network.sh
# 修复方法,安装 dos2unix::
apt install dos2unix
dos2unix setup_network.sh
# 最后再次执行:如果是root用户需要删除脚本里面sudo
./setup_network.sh
# 安装1panel
./安装1panel.sh
# 开机启动ip获取
chmod +x /root/lh-device-modbus-terminal/bin/write-ip.sh
cp bin/write_ip.service /etc/systemd/system/write_ip.service
systemctl daemon-reload
systemctl enable write_ip.service # 开机自启
systemctl start write_ip.service # 立即执行
systemctl status write_ip.service # 查看状态
# 创建自定义网络
docker network create lh-net
# 安装ZLMediaKit
# 你的镜像文件是 zlmediakit.tar,用以下命令导入:
docker load -i zlmediakit.tar
# 导入后可以查看镜像名:
docker images
# 创建宿主机挂载目录
mkdir -p /root/lh-device-modbus-terminal/zlmediakit_config
# 启动 ZLMediaKit 容器 + 挂载配置目录
docker run -d --name zlmediakit --network lh-net --restart always -p 1935:1935 -p 80:80 -p 443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -v /root/lh-device-modbus-terminal/zlmediakit_config:/opt/media/conf 913391c90121
# 安装LH设备MODBUS终端
docker load -i lh-device-modbus-terminal.tar
docker images
docker run -d --name lh-device-modbus-terminal --network lh-net --restart on-failure:5 -e TZ=Asia/Shanghai -v /root/lh-device-modbus-terminal:/app 74a802bd9e47 bash -c "cd /app && java -jar lh-device-modbus-terminal.jar /app/configs"
\ No newline at end of file
... ...
... ... @@ -41,15 +41,20 @@ public class Main {
}
Map<String, List<PlcSystem>> plcsMap = InitPlcConfig.initPlcConfigFromFile(jsonPath);
if(null != plcsMap && plcsMap.size()>0)
{
CollectPlcDataTask collectPlcDataTask = new CollectPlcDataTask();
collectPlcDataTask.collect(mqttService);
}else {
log.warn("找不到plc配置不执行plc逻辑");
}
String camerapath = Main.class.getClassLoader().getResource("configs/camera.properties").getPath();;
if (null != configPath)
{
camerapath = configPath+"/camera.properties";
}
CameraConfig.init(camerapath,plcsMap.get("cameras"));
CollectPlcDataTask collectPlcDataTask = new CollectPlcDataTask();
collectPlcDataTask.collect(mqttService);
CameraConfig.init(camerapath);
CameraDataTask cameraDataTask = new CameraDataTask();
cameraDataTask.collect(mqttService);
... ...
... ... @@ -7,6 +7,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zhonglai.luhui.device.modbus.terminal.camera.Camera;
import com.zhonglai.luhui.device.modbus.terminal.camera.WebRtcService;
... ... @@ -47,7 +48,7 @@ public class CameraConfig {
public static final List<Camera> cameraList = new ArrayList<>();
public static void init(String configPath, List<PlcSystem> list) {
public static void init(String configPath) {
Properties properties = loadProperties(configPath);
yuerleApiUrl = properties.getProperty("yuerleApiUrl");
... ... @@ -56,9 +57,10 @@ public class CameraConfig {
webrtcSecret = StringUtils.defaultIfBlank(properties.getProperty("webrtcSecret"), getWebrtcSecret());
localIp = Optional.ofNullable(getLocalIp()).orElseGet(CameraConfig::getLocalIpAddress);
if (WebRtcService.isWebrtcOnline())
String cameras = properties.getProperty("cameras");
if (WebRtcService.isWebrtcOnline() && StringUtils.isNotEmpty(cameras))
{
List<PlcSystem> list = JSONArray.parseArray(cameras,PlcSystem.class);
addCamera(list);
}
}
... ...
... ... @@ -24,10 +24,19 @@ public class InitPlcConfig {
* @throws IOException
*/
public static Map<String, List<PlcSystem>> initPlcConfigFromFile(String jsonPath) throws IOException {
File configFile = new File(jsonPath);
if (!configFile.exists())
{
return null;
}
ObjectMapper mapper = new ObjectMapper();
Map<String, List<PlcSystem>> plcsMap = mapper.readValue(new File(jsonPath),
Map<String, List<PlcSystem>> plcsMap = mapper.readValue(configFile,
new TypeReference<Map<String, List<PlcSystem>>>() {});
List<PlcSystem> plcSystems = plcsMap.get("plcs");
if (plcSystems == null || plcSystems.size() == 0)
{
return null;
}
for (PlcSystem plc : plcSystems)
{
CachPlcConfig cachPlcConfig = plcsConfigMap.get(plc.getId());
... ...
... ... @@ -89,9 +89,16 @@ public class ModbusMasterMessage {
* 关闭所有 Master
*/
public static void closeAll() {
masterCache.values().forEach(ModbusMaster::destroy);
masterCache.clear();
lockMap.clear();
if(null != masterCache)
{
masterCache.values().forEach(ModbusMaster::destroy);
masterCache.clear();
}
if (null != lockMap)
{
lockMap.clear();
}
}
}
... ...
... ... @@ -32,9 +32,12 @@ public class CameraDataTask {
public void collect(MqttService mqttService) {
ScheduledThreadPool.scheduler.scheduleAtFixedRate(() -> {
try {
if (WebRtcService.isWebrtcOnline())
boolean isWebrtcOnline = WebRtcService.isWebrtcOnline();
if (isWebrtcOnline)
{
pubMqttData(mqttService);
}else {
logger.info("webrtc服务未启动");
}
}catch (Exception e)
... ...
yuerleApiUrl=https://ly.api.yu2le.com/bigScreen/getYsLocalIp
webrtc_app=yuerle
webrtc_host=zlmediakit
\ No newline at end of file
webrtc_host=zlmediakit
cameras=[{"id": "FY6803425","connectConfig": {"pass": "Luhui586"}}]
\ No newline at end of file
... ...
{
"cameras": [
{
"id": "FW8199460",
"connectConfig": {"pass": "Luhui586"}
}
],
"plcs": [
{
"id": "2_1",
... ...
; auto-generated by mINI class {
[api]
apiDebug=1
defaultSnap=./www/logo.png
downloadRoot=./www
secret=nkgs0WLCCZsmQU50hpMi7ibtFEJEq3bF
snapRoot=./www/snap/
[cluster]
origin_url=
retry_count=3
timeout_sec=15
[ffmpeg]
bin=/usr/bin/ffmpeg
cmd=%s -re -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s
log=./ffmpeg/ffmpeg.log
restart_sec=0
snap=%s -i %s -y -f mjpeg -frames:v 1 -an %s
[general]
broadcast_player_count_changed=0
check_nvidia_dev=1
enableVhost=0
enable_ffmpeg_log=0
flowThreshold=1024
listen_ip=::
maxStreamWaitMS=15000
mediaServerId=your_server_id
mergeWriteMS=0
resetWhenRePlay=1
streamNoneReaderDelayMS=20000
unready_frame_cache=100
wait_add_track_ms=3000
wait_audio_track_data_ms=1000
wait_track_ready_ms=10000
[hls]
broadcastRecordTs=0
deleteDelaySec=10
fastRegister=0
fileBufSize=65536
segDelay=0
segDur=2
segKeep=0
segNum=3
segRetain=5
[hook]
alive_interval=10.0
enable=0
on_flow_report=
on_http_access=
on_play=
on_publish=
on_record_mp4=
on_record_ts=
on_rtp_server_timeout=
on_rtsp_auth=
on_rtsp_realm=
on_send_rtp_stopped=
on_server_exited=
on_server_keepalive=
on_server_started=
on_shell_login=
on_stream_changed=
on_stream_none_reader=
on_stream_not_found=
retry=1
retry_delay=3.0
stream_changed_schemas=rtsp/rtmp/fmp4/ts/hls/hls.fmp4
timeoutSec=10
[http]
allow_cross_domains=1
allow_ip_range=::1,127.0.0.1,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255
charSet=utf-8
dirMenu=1
forbidCacheSuffix=
forwarded_ip_header=
keepAliveSecond=30
maxReqSize=40960
notFound=<html><head><title>404 Not Found</title></head><body bgcolor="white"><center><h1>您访问的资源不存在!</h1></center><hr><center>ZLMediaKit(git hash:7b1f8fe/2025-05-02T16:23:25+08:00,branch:master,build time:2025-05-02T08:24:31)</center></body></html>
port=80
rootPath=./www
sendBufSize=65536
sslport=443
virtualPath=
[multicast]
addrMax=239.255.255.255
addrMin=239.0.0.0
udpTTL=64
[protocol]
add_mute_audio=1
auto_close=0
continue_push_ms=15000
enable_audio=1
enable_fmp4=1
enable_hls=1
enable_hls_fmp4=0
enable_mp4=0
enable_rtmp=1
enable_rtsp=1
enable_ts=1
fmp4_demand=0
hls_demand=0
hls_save_path=./www
modify_stamp=2
mp4_as_player=0
mp4_max_second=3600
mp4_save_path=./www
paced_sender_ms=0
rtmp_demand=0
rtsp_demand=0
ts_demand=0
[record]
appName=record
enableFmp4=0
fastStart=0
fileBufSize=65536
fileRepeat=0
sampleMS=500
[rtc]
bfilter=0
datachannel_echo=1
externIP=
maxRtpCacheMS=5000
maxRtpCacheSize=2048
max_bitrate=0
min_bitrate=0
nackIntervalRatio=1.0
nackMaxCount=15
nackMaxMS=3000
nackMaxSize=2048
nackRtpSize=8
port=8000
preferredCodecA=PCMA,PCMU,opus,mpeg4-generic
preferredCodecV=H264,H265,AV1,VP9,VP8
rembBitRate=0
start_bitrate=0
tcpPort=8000
timeoutSec=15
[rtmp]
directProxy=1
enhanced=0
handshakeSecond=15
keepAliveSecond=15
port=1935
sslport=0
[rtp]
audioMtuSize=600
h264_stap_a=1
lowLatency=0
rtpMaxSize=10
videoMtuSize=1400
[rtp_proxy]
dumpDir=
gop_cache=1
h264_pt=98
h265_pt=99
opus_pt=100
port=10000
port_range=30000-35000
ps_pt=96
rtp_g711_dur_ms=100
timeoutSec=15
udp_recv_socket_buffer=4194304
[rtsp]
authBasic=0
directProxy=1
handshakeSecond=15
keepAliveSecond=15
lowLatency=0
port=554
rtpTransportType=-1
sslport=0
[shell]
maxReqSize=1024
port=0
[srt]
latencyMul=4
passPhrase=
pktBufSize=8192
port=9000
timeoutSec=5
; } ---
... ...