作者 钟来

坤泰日志功能对接

... ... @@ -70,6 +70,16 @@ public class IotTerminal extends MyBaseEntity implements Serializable
private String operation_token;
@ApiModelProperty("管理用户id")
private Long sys_user_id;
@ApiModelProperty("排序")
private Integer order_by;
public Integer getOrder_by() {
return order_by;
}
public void setOrder_by(Integer order_by) {
this.order_by = order_by;
}
public Long getSys_user_id() {
return sys_user_id;
... ...
... ... @@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="create_time" column="create_time" />
<result property="sensor_number" column="sensor_number" />
<result property="sys_user_id" column="sys_user_id" />
<result property="order_by" column="order_by" />
<association property="userTerminalGroupRelation" column="id" javaType="UserTerminalGroupRelation" resultMap="userTerminalGroupRelationResult" />
<association property="iotDevice" column="device_id" javaType="IotDevice" resultMap="iotDeviceResult" />
</resultMap>
... ... @@ -96,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope}
</if>
</where>
order by a.create_time desc
order by a.create_time desc,a.order_by asc
</select>
<select id="selectIotTerminalListByUserId" parameterType="IotTerminal" resultMap="IotTerminalResult">
... ... @@ -139,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mqtt_username != null">mqtt_username,</if>
<if test="data_update_time != null">data_update_time,</if>
<if test="sys_user_id != null and sys_user_id != ''">sys_user_id,</if>
<if test="order_by != null and order_by != ''">order_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="device_id != null">#{device_id},</if>
... ... @@ -151,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mqtt_username != null">#{mqtt_username},</if>
<if test="data_update_time != null">#{data_update_time},</if>
<if test="sys_user_id != null">#{sys_user_id},</if>
<if test="order_by != null">#{order_by},</if>
</trim>
</insert>
... ... @@ -166,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mqtt_username != null">mqtt_username = #{mqtt_username},</if>
<if test="data_update_time != null">data_update_time = #{data_update_time},</if>
<if test="sys_user_id != null">sys_user_id = #{sys_user_id},</if>
<if test="order_by != null">order_by = #{order_by},</if>
</trim>
where id = #{id}
</update>
... ... @@ -185,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="selectNotUserIotTerminalListByImei" parameterType="String" resultMap="IotTerminalResult">
SELECT a.* FROM `iot_terminal` a LEFT JOIN `user_terminal_group_relation` b ON a.`id`=b.`iot_terminal_id` WHERE b.user_info_id is null AND a.`device_id`= #{device_id}
SELECT a.* FROM `iot_terminal` a LEFT JOIN `user_terminal_group_relation` b ON a.`id`=b.`iot_terminal_id` WHERE b.user_info_id is null AND a.`device_id`= #{device_id} ORDER BY `order_by` ASC
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -129,19 +129,59 @@ public class TestController {
@ApiOperation("修改多维表格数据")
@RequestMapping(value = "upExcelData")
public AjaxResult upExcelData(Integer system_type,String log_id,String excel_id,String sheet_id,@RequestBody String sub_data) throws IOException {
LogExcelSub logExcelSub = new LogExcelSub();
logExcelSub.setExcel_id(excel_id);
logExcelSub.setSheet_id(sheet_id);
logExcelSub.setSystem_type(system_type);
logExcelSub.setLog_id(log_id);
Long nub = publicService.getObjectListTotle(logExcelSub,null);
logExcelSub.setSub_data(sub_data);
if(0==nub)
String[] ls = log_id.split(" ");
if(ls.length>1) //表示有多个数据提交
{
return AjaxResult.success(publicService.insert(logExcelSub));
JSONObject jsonObject = JSONObject.parseObject(sub_data);
for (int i=0;i<ls.length;i++)
{
LogExcelSub logExcelSub = new LogExcelSub();
logExcelSub.setExcel_id(excel_id);
logExcelSub.setSheet_id(sheet_id);
logExcelSub.setSystem_type(system_type);
String l = ls[i];
logExcelSub.setLog_id(l);
Long nub = publicService.getObjectListTotle(logExcelSub,null);
JSONObject sub_data_json = new JSONObject();
for (String k:jsonObject.keySet())
{
String values = jsonObject.getString( k);
String[] vss = values.split(" ");
if(vss.length==ls.length)
{
sub_data_json.put(k,vss[i]);
}else {
sub_data_json.put(k,"");
}
}
logExcelSub.setSub_data(sub_data_json.toJSONString());
if(0==nub)
{
publicService.insert(logExcelSub);
}else {
publicService.updateObject(logExcelSub,"system_type,excel_id,sheet_id,log_id");
}
}
return AjaxResult.success(ls.length);
}else {
LogExcelSub logExcelSub = new LogExcelSub();
logExcelSub.setExcel_id(excel_id);
logExcelSub.setSheet_id(sheet_id);
logExcelSub.setSystem_type(system_type);
logExcelSub.setLog_id(log_id);
Long nub = publicService.getObjectListTotle(logExcelSub,null);
logExcelSub.setSub_data(sub_data);
if(0==nub)
{
return AjaxResult.success(publicService.insert(logExcelSub));
}
return AjaxResult.success(publicService.updateObject(logExcelSub,"system_type,excel_id,sheet_id,log_id"));
}
return AjaxResult.success(publicService.updateObject(logExcelSub,"system_type,excel_id,sheet_id,log_id"));
}
@ApiOperation("查询多维表格数据")
... ...
... ... @@ -96,7 +96,7 @@ public class UserTerminalGroupRelationController extends BaseController
{
stringBuffer.append(" AND b.product_id="+product_id);
}
List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT b.*,a.id group_id,c.`things_model_value` host_things_model_value,c.`things_model_config` host_things_model_config FROM `user_terminal_group_relation` a LEFT JOIN `iot_terminal` b ON a.`iot_terminal_id`=b.`id` LEFT JOIN `iot_device` c ON b.`device_id`=c.`client_id` WHERE a.user_info_id="+SecurityUtils.getUserId().intValue()+stringBuffer);
List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT b.*,a.id group_id,c.`things_model_value` host_things_model_value,c.`things_model_config` host_things_model_config FROM `user_terminal_group_relation` a LEFT JOIN `iot_terminal` b ON a.`iot_terminal_id`=b.`id` LEFT JOIN `iot_device` c ON b.`device_id`=c.`client_id` WHERE a.user_info_id="+SecurityUtils.getUserId().intValue()+stringBuffer+" order by iot_terminal_group_id asc,b.order_by asc");
return AjaxResult.success(list);
}
... ...