在连续两日使用《店铺商品列表监控》流程的基础上,可以进一步调用本流程,将本地文件中保存的商品列表划分为今日和以前两张表格,然后以商品ID为键联接(LEFT JOIN)今日和以前两张表格。在得到的结果中,第一个字段a1是今日商品ID,第二个字段a2是商品标题,第三个字段a3是以前商品ID,只要是a1与a3不相等的任意一行,就必然是a3为空值的情况,此时a1的值就是某个上新的商品ID。
流程图如下所示。
一旦部署,本流程还会监控本地文件“data/8125_stdout.log”。一旦用户调用了《店铺商品列表监控》流程,本流程也会随机自动进行调用,无需用户手动注入。
本流程的上新检测结果将保存到“data/8125_newon.log”这个文件中,一天一行。
流程配置内容如下所示,用户可复制后导入到流程管理系统。部署后,点击“注入”节点即可在“调试6”节点得到新品ID和标题信息。
[
{
"id": "bbe96bda4a4f5359",
"type": "tab",
"label": "1688店铺商品列表上新",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c1c6f488f5b7f376",
"type": "file in",
"z": "bbe96bda4a4f5359",
"name": "",
"filename": "data/8125_stdout.log",
"filenameType": "str",
"format": "lines",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 345,
"y": 165.45454025268555,
"wires": [
[
"e5fe647fb2bfe51b"
]
]
},
{
"id": "c4e01bb697561c48",
"type": "watch",
"z": "bbe96bda4a4f5359",
"name": "",
"files": "data/8125_stdout.log",
"recursive": "",
"x": 105,
"y": 165.45454025268555,
"wires": [
[
"c1c6f488f5b7f376"
]
]
},
{
"id": "dc2e7d0bc3a294c1",
"type": "inject",
"z": "bbe96bda4a4f5359",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 88.6363639831543,
"y": 62.72726821899414,
"wires": [
[
"c1c6f488f5b7f376"
]
]
},
{
"id": "0c9c09f0939fa884",
"type": "switch",
"z": "bbe96bda4a4f5359",
"name": "按日期分为今天和以前",
"property": "date",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "今天的日期",
"vt": "global"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": true,
"outputs": 2,
"x": 538.6363639831543,
"y": 282.72726821899414,
"wires": [
[
"0cc7a74c8575f823"
],
[
"660978f648f19cf5"
]
]
},
{
"id": "2c949aa6a044e4f8",
"type": "json",
"z": "bbe96bda4a4f5359",
"name": "",
"property": "payload",
"action": "obj",
"pretty": false,
"x": 675,
"y": 165.45454025268555,
"wires": [
[
"753e75c1349eedfd",
"7f8b72a6d1a64ac0"
]
]
},
{
"id": "753e75c1349eedfd",
"type": "change",
"z": "bbe96bda4a4f5359",
"name": "日期和列表",
"rules": [
{
"t": "set",
"p": "date",
"pt": "msg",
"to": "$substring(payload.日期, 0, 10)",
"tot": "jsonata"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$map(payload.数据, function($v, $index){$index > 0 ? $append($v, $substring(payload.日期, 0, 10))})",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 835,
"y": 165.45454025268555,
"wires": [
[
"88e697425c1dd0da",
"4ed3fc4dd0dbf138"
]
]
},
{
"id": "edc66e4af21d5dde",
"type": "join",
"z": "bbe96bda4a4f5359",
"name": "所有日期",
"mode": "auto",
"build": "array",
"property": "date",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 118.6363639831543,
"y": 282.72726821899414,
"wires": [
[
"c479dde719ed938b"
]
]
},
{
"id": "c479dde719ed938b",
"type": "change",
"z": "bbe96bda4a4f5359",
"name": "今天的日期",
"rules": [
{
"t": "set",
"p": "今天的日期",
"pt": "global",
"to": "$sort(payload)[-1]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 288.6363639831543,
"y": 282.72726821899414,
"wires": [
[]
]
},
{
"id": "0cc7a74c8575f823",
"type": "join",
"z": "bbe96bda4a4f5359",
"name": "今天的商品列表",
"mode": "custom",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "1",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "num",
"reduceFixup": "",
"x": 779.5454711914062,
"y": 276.36363410949707,
"wires": [
[
"d857ea07f6104126"
]
]
},
{
"id": "660978f648f19cf5",
"type": "join",
"z": "bbe96bda4a4f5359",
"name": "以前的商品列表",
"mode": "custom",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 145,
"y": 365.45454025268555,
"wires": [
[
"44317d8c49946ccd"
]
]
},
{
"id": "6786cd17b757503f",
"type": "debug",
"z": "bbe96bda4a4f5359",
"name": "调试 4",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 795,
"y": 45.45454025268555,
"wires": []
},
{
"id": "e5fe647fb2bfe51b",
"type": "switch",
"z": "bbe96bda4a4f5359",
"name": "有效记录",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "{",
"vt": "str"
}
],
"checkall": "true",
"repair": true,
"outputs": 1,
"x": 545,
"y": 165.45454025268555,
"wires": [
[
"2c949aa6a044e4f8"
]
]
},
{
"id": "7f8b72a6d1a64ac0",
"type": "debug",
"z": "bbe96bda4a4f5359",
"name": "调试 5",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 515,
"y": 45.45454025268555,
"wires": []
},
{
"id": "88e697425c1dd0da",
"type": "change",
"z": "bbe96bda4a4f5359",
"name": "日期",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "date",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1015,
"y": 165.45454025268555,
"wires": [
[
"edc66e4af21d5dde",
"6786cd17b757503f"
]
]
},
{
"id": "4ed3fc4dd0dbf138",
"type": "delay",
"z": "bbe96bda4a4f5359",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 270.45454025268555,
"y": 210.90908432006836,
"wires": [
[
"0c9c09f0939fa884"
]
]
},
{
"id": "c93c9e4557860d37",
"type": "debug",
"z": "bbe96bda4a4f5359",
"name": "调试 6",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1030,
"y": 380,
"wires": []
},
{
"id": "d857ea07f6104126",
"type": "change",
"z": "bbe96bda4a4f5359",
"name": "插入表头",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$append([[\"商品ID\",\"标题\",\"价格\",\"月成交额\",\"月成交笔数\",\"累计成交笔数\",\"代发成交笔数\",\"月销量\",\"累计销量\",\"主图\",\"商品属性\",\"类目ID\",\"店内搜索网址\",\"店内搜索页码\"]], payload.$)",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 957.7272911071777,
"y": 276.36363220214844,
"wires": [
[
"d578d8ddeef9ea3d"
]
]
},
{
"id": "44317d8c49946ccd",
"type": "change",
"z": "bbe96bda4a4f5359",
"name": "插入表头",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$append([[\"商品ID\",\"标题\",\"价格\",\"月成交额\",\"月成交笔数\",\"累计成交笔数\",\"代发成交笔数\",\"月销量\",\"累计销量\",\"主图\",\"商品属性\",\"类目ID\",\"店内搜索网址\",\"店内搜索页码\"]], payload.$)",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "right",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 325,
"y": 365.45454025268555,
"wires": [
[
"55b979ba29c6236d"
]
]
},
{
"id": "81760d6e951054a2",
"type": "dsjrbql",
"z": "bbe96bda4a4f5359",
"name": "以商品ID联接今日和以前两表",
"code": "select * left join b on a1 == b1",
"join": true,
"x": 380,
"y": 460,
"wires": [
[
"22aa571e2f09eeae"
]
]
},
{
"id": "d578d8ddeef9ea3d",
"type": "dsjrbql",
"z": "bbe96bda4a4f5359",
"name": "商品ID和标题两个字段",
"code": "SELECT a1, ARRAY_AGG(a2, v => v[0]) GROUP BY a1",
"join": false,
"x": 800,
"y": 340,
"wires": [
[
"81760d6e951054a2"
]
]
},
{
"id": "55b979ba29c6236d",
"type": "dsjrbql",
"z": "bbe96bda4a4f5359",
"name": "商品ID字段",
"code": "SELECT DISTINCT a1",
"join": false,
"x": 130,
"y": 460,
"wires": [
[
"81760d6e951054a2"
]
]
},
{
"id": "22aa571e2f09eeae",
"type": "dsjrbql",
"z": "bbe96bda4a4f5359",
"name": "找到新品",
"code": "select * where a1 != a3",
"join": false,
"x": 600,
"y": 460,
"wires": [
[
"d8b73900a0c6d50c"
]
]
},
{
"id": "5a39c255309aabbf",
"type": "file",
"z": "bbe96bda4a4f5359",
"name": "",
"filename": "data/8125_newon.log",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 980,
"y": 460,
"wires": [
[]
]
},
{
"id": "d8b73900a0c6d50c",
"type": "change",
"z": "bbe96bda4a4f5359",
"name": "设定日期",
"rules": [
{
"t": "set",
"p": "payload[0][2]",
"pt": "msg",
"to": "今天的日期",
"tot": "global"
},
{
"t": "set",
"p": "payload[0][1]",
"pt": "msg",
"to": "标题",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 760,
"y": 460,
"wires": [
[
"c93c9e4557860d37",
"5a39c255309aabbf"
]
]
}
]