78554C",“dayNumber”:14,“clearSinkTime”:16,“blockCurrent”:500,“hormoneStopStart”:500,“pigStatusChild”:3,“fodderCalibratValue”:1000,“touchBarEnable”:0,“touchBarLeadWeight”:350,“probeRecoverTime”:160,“hormoneDay”:0,“devicewater”:0,“deviceFeed”:0,“targetFeed”:1000,“touchBarCheckCycle”:23,“dayFeed”:0,“units”:66,“UIVersion”:“V1.0.0”,“dayWater”:0,“ydayFeed”:0,“valveCalibratPulse”:1000,“connectSignal”:100,“SWVersion”:“V4.0.0”,“probeThreshold”:2000,“mealId”:3,“touchBarTouchNum”:2,“line”:“dd”,“clearFeedTime”:15,“hormoneWeight”:200,“pigStatus”:1,“waterFeedRatio”:“0:10”,“targetFix”:2,“feedMode”:1,“motorCurrent”:0,“valveCalibratValue”:1200,“noloadCurrent”:10,“wifiPswd”:“sgd123456”,“planId”:8,“roomtype”:1,“ydayWater”:0,“deviceId”:“SCMFP220024EC4A78554C”,“HWVersion”:“V4.0”,“building”:“3tty”,“motorPulse”:1452,“foragetype”:9,“mqttAddr”:“mqtt://192.168.10.36”,“name”:“分娩舍3tty栋66单元dd排999栏”,“alarmNum”:-4}, 1, 0.0, 0.0,SCMFP220024EC4A78554C ), desc: syntax error near ‘{“sonCount”:10,“ipAddr”:“192.168.200.5”,“mqttPort”:1883,"runSta’ (invalid data or symbol) ; uncategorized SQLException; SQL state ; error code [534]; TDengine ERROR (0x216): sql: INSERT INTO iot_device_record_day( tbname, create_time, props, connect,day_feed,day_water,device_id ) VALUES ( ‘iot_device_record_day_SCMFP220024EC4A78554C’, NOW(), {“sonCount”:10,“ipAddr”:“192.168.200.5”,“mqttPort”:1883,“runState”:3,“deviceOffStartTime”:500,“probeState”:4095,“deviceOffDay”:0,“hormoneStopEnd”:600,“probeEnable”:1,“wifiSsid”:“SGD”,“connect”:1,“motorDuty”:1000,“hormoneTime”:5,“deviceOffEndTime”:600,“fence”:999,“deviceName”:“SCMFP220024EC4A78554C”,“dayNumber”:14,“clearSinkTime”:16,“blockCurrent”:500,“hormoneStopStart”:500,“pigStatusChild”:3,“fodderCalibratValue”:1000,“touchBarEnable”:0,“touchBarLeadWeight”:350,“probeRecoverTime”:160,“hormoneDay”:0,“devicewater”:0,“deviceFeed”:0,“targetFeed”:1000,“touchBarCheckCycle”:23,“dayFeed”:0,“units”:66,“UIVersion”:“V1.0.0”,“dayWater”:0,“ydayFeed”:0,“valveCalibratPulse”:1000,“connectSignal”:100,“SWVersion”:“V4.0.0”,“probeThreshold”:2000,“mealId”:3,“touchBarTouchNum”:2,“line”:“dd”,“clearFeedTime”:15,“hormoneWeight”:200,“pigStatus”:1,“waterFeedRatio”:“0:10”,“targetFix”:2,“feedMode”:1,“motorCurrent”:0,“valveCalibratValue”:1200,“noloadCurrent”:10,“wifiPswd”:“”,“planId”:8,“roomtype”:1,“ydayWater”:0,“deviceId”:“SCMFP220024EC4A78554C”,“HWVersion”:“V4.0”,“building”:“3tty”,“motorPulse”:1452,“foragetype”:9,“mqttAddr”:“mqtt://192.168.10.36”,“name”:“分娩舍3tty栋66单元dd排999栏”,“alarmNum”:-4}, 1, 0.0, 0.0,SCMFP220024EC4A78554C ), desc: syntax error near ‘{“sonCount”:10,“ipAddr”:“192.168.200.5”,“mqttPort”:1883,"runSta’ (invalid data or symbol); nested exception is java.sql.SQLException: TDengine ERROR (0x216): sql: INSERT INTO iot_device_record_day( tbname, create_time, props, connect,day_feed,day_water,device_id ) VALUES ( ‘iot_device_record_day_SCMFP220024EC4A78554C’, NOW(), {“sonCount”:10,“ipAddr”:“192.168.200.5”,“mqttPort”:1883,“runState”:3,“deviceOffStartTime”:500,“probeState”:4095,“deviceOffDay”:0,“hormoneStopEnd”:600,“probeEnable”:1,“wifiSsid”:“SGD”,“connect”:1,“motorDuty”:1000,“hormoneTime”:5,“deviceOffEndTime”:600,“fence”:999,“deviceName”:“SCMFP220024EC4A78554C”,“dayNumber”:14,“clearSinkTime”:16,“blockCurrent”:500,“hormoneStopStart”:500,“pigStatusChild”:3,“fodderCalibratValue”:1000,“touchBarEnable”:0,“touchBarLeadWeight”:350,“probeRecoverTime”:160,“hormoneDay”:0,“devicewater”:0,“deviceFeed”:0,“targetFeed”:1000,“touchBarCheckCycle”:23,“dayFeed”:0,“units”:66,“UIVersion”:“V1.0.0”,“dayWater”:0,“ydayFeed”:0,“valveCalibratPulse”:1000,“connectSignal”:100,“SWVersion”:“V4.0.0”,“probeThreshold”:2000,“mealId”:3,“touchBarTouchNum”:2,“line”:“dd”,“clearFeedTime”:15,“hormoneWeight”:200,“pigStatus”:1,“waterFeedRatio”:“0:10”,“targetFix”:2,“feedMode”:1,“motorCurrent”:0,“valveCalibratValue”:1200,“noloadCurrent”:10,“wifiPswd”:“sgd123456”,“planId”:8,“roomtype”:1,“ydayWater”:0,“deviceId”:“SCMFP220024EC4A78554C”,“HWVersion”:“V4.0”,“building”:“3tty”,“motorPulse”:1452,“foragetype”:9,“mqttAddr”:“mqtt://192.168.10.36”,“name”:“分娩舍3tty栋66单元dd排999栏”,“alarmNum”:-4}, 1, 0.0, 0.0,SCMFP220024EC4A78554C ), desc: syntax error near ‘{“sonCount”:10,“ipAddr”:“”,“mqttPort”:1883,"runSta’ (invalid data or symbol)
把now()放后面
语法错误真正的触发点在 JSON 前的 {。TDengine 不支持原生 JSON 类型, {…} 不能直接作为字面量插入, 必须当作字符串(单引号包裹)或通过参数绑定。
你第一条失败的语句把 JSON 原样拼进 SQL, 使用的是全角/智能引号 “ ”,TDengine 解析器只接受 ASCII 单引号 ’ 作为字符串定界, 双引号用于标识符, 结果看到 { 时直接报 syntax error。
把 NOW() 移到最后能成功, 真实原因是你改用了 MyBatis 的预编译参数绑定 (#{} 会占位成 ?), JSON 内容以字符串参数传递, 驱动自动处理转义, 不再直接拼接导致的语法错误。列顺序本身不是决定性因素(除非与表定义不匹配), 只是你在那次调整中同时改变了参数传递方式。