在连续多日使用《店铺商品列表监控》流程的基础上,可以进一步调用本流程,将本地文件中保存的商品列表划分为今日和以前两张表格,然后以商品ID为键联接(LEFT JOIN)今日和以前两张表格。在得到的结果中,第一个字段a1是今日商品ID,第二个字段a2是商品标题,第三个字段a3是商品价格,第四个字段a4是商品主图,第五个字段a5是以前商品ID,第六个字段a6是以前商品标题,第七个字段a7是以前商品价格,第八个字段a8是以前商品主图。
最后分别判断三种情况:
- 对于a2与a6不相等的任意一行,就必然是改标题的商品;
- 对于a3与a7不相等的任意一行,就必然是调价格的商品;
- 对于a4与a8不相等的任意一行,就必然是换主图的商品。
流程图如下所示。
三种情况分别输出对比结果到调试6、调试7和调试8节点。可以看到:
- 调试6节点显示一条记录,也就是表头,这表明查询结果为空,没有任何商品改标题;
- 调试7节点显示95条记录,即1条表头、94个商品调整了价格;
- 调试8节点显示56表记录,即1条表头、55个商品更换了主图。
流程配置内容如下所示,用户可复制后导入到流程管理系统。部署后,点击“注入”节点即可在调试6、调试7、调试8节点得到对应的更改记录。
此外,一旦部署,本流程还会监控本地文件“data/8125_stdout.log”。一旦用户调用了《店铺商品列表监控》流程,本流程也会随机自动进行调用,无需用户手动注入。
[
{
"id": "47d512da301e9401",
"type": "tab",
"label": "店铺商品列表调价改标题换图",
"disabled": false,
"info": "",
"env": []
},
{
"id": "395a3b6531863515",
"type": "file in",
"z": "47d512da301e9401",
"name": "",
"filename": "data/8125_stdout.log",
"filenameType": "str",
"format": "lines",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 345,
"y": 165.45454025268555,
"wires": [
[
"f49a27b8cfbbbfe7"
]
]
},
{
"id": "46ac81aaf4f4c370",
"type": "watch",
"z": "47d512da301e9401",
"name": "",
"files": "data/8125_stdout.log",
"recursive": "",
"x": 105,
"y": 165.45454025268555,
"wires": [
[
"395a3b6531863515"
]
]
},
{
"id": "7fd6d96034f2476e",
"type": "inject",
"z": "47d512da301e9401",
"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": [
[
"395a3b6531863515"
]
]
},
{
"id": "87b6535b608cfbcc",
"type": "switch",
"z": "47d512da301e9401",
"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": [
[
"8bd00dbf3bc1e1f5"
],
[
"ad59c463d0fdd6d5"
]
]
},
{
"id": "59324a314aa1e7db",
"type": "json",
"z": "47d512da301e9401",
"name": "",
"property": "payload",
"action": "obj",
"pretty": false,
"x": 675,
"y": 165.45454025268555,
"wires": [
[
"b804e9a53fcec76b"
]
]
},
{
"id": "b804e9a53fcec76b",
"type": "change",
"z": "47d512da301e9401",
"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": [
[
"674a7471c8a991b7",
"c34d419b0e58a180"
]
]
},
{
"id": "48a0d40874a59190",
"type": "join",
"z": "47d512da301e9401",
"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": [
[
"13bcda36f57c2873"
]
]
},
{
"id": "13bcda36f57c2873",
"type": "change",
"z": "47d512da301e9401",
"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": "8bd00dbf3bc1e1f5",
"type": "join",
"z": "47d512da301e9401",
"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": [
[
"b2a198df6abecd7b"
]
]
},
{
"id": "ad59c463d0fdd6d5",
"type": "join",
"z": "47d512da301e9401",
"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": "",
"reduceFixup": "",
"x": 145,
"y": 365.45454025268555,
"wires": [
[
"6526483bfd1fb632"
]
]
},
{
"id": "f49a27b8cfbbbfe7",
"type": "switch",
"z": "47d512da301e9401",
"name": "有效记录",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "{",
"vt": "str"
}
],
"checkall": "true",
"repair": true,
"outputs": 1,
"x": 545,
"y": 165.45454025268555,
"wires": [
[
"59324a314aa1e7db"
]
]
},
{
"id": "674a7471c8a991b7",
"type": "change",
"z": "47d512da301e9401",
"name": "日期",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "date",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1015,
"y": 165.45454025268555,
"wires": [
[
"48a0d40874a59190"
]
]
},
{
"id": "c34d419b0e58a180",
"type": "delay",
"z": "47d512da301e9401",
"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": [
[
"87b6535b608cfbcc"
]
]
},
{
"id": "0ec906439eb4d8d0",
"type": "debug",
"z": "47d512da301e9401",
"name": "调试 6",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1130,
"y": 480,
"wires": []
},
{
"id": "b2a198df6abecd7b",
"type": "change",
"z": "47d512da301e9401",
"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": [
[
"d7de26a8228d72e4"
]
]
},
{
"id": "6526483bfd1fb632",
"type": "change",
"z": "47d512da301e9401",
"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": [
[
"dff76ad3ff0b062c"
]
]
},
{
"id": "e1987420fee676d3",
"type": "dsjrbql",
"z": "47d512da301e9401",
"name": "以商品ID联接今日和以前两表",
"code": "select * join b on a1 == b1",
"join": true,
"x": 500,
"y": 480,
"wires": [
[
"5a810d1c2327523a"
]
]
},
{
"id": "d7de26a8228d72e4",
"type": "dsjrbql",
"z": "47d512da301e9401",
"name": "商品ID标题价格主图",
"code": "SELECT a1, ARRAY_AGG(a['标题'], v => v[0]), ARRAY_AGG(a['价格'], v => v[0]), ARRAY_AGG(a['主图'], v => v[0]) GROUP BY a1",
"join": false,
"x": 760,
"y": 360,
"wires": [
[
"e1987420fee676d3"
]
]
},
{
"id": "dff76ad3ff0b062c",
"type": "dsjrbql",
"z": "47d512da301e9401",
"name": "商品ID标题价格主图",
"code": "SELECT a1, ARRAY_AGG(a['标题'], v => v[0]), ARRAY_AGG(a['价格'], v => v[0]), ARRAY_AGG(a['主图'], v => v[0]) GROUP BY a1",
"join": false,
"x": 200,
"y": 480,
"wires": [
[
"e1987420fee676d3"
]
]
},
{
"id": "a336dc44e4f08159",
"type": "dsjrbql",
"z": "47d512da301e9401",
"name": "改标题的商品列表",
"code": "select * where a2 != a6",
"join": false,
"x": 930,
"y": 480,
"wires": [
[
"0ec906439eb4d8d0"
]
]
},
{
"id": "8244f45ed52a82f3",
"type": "dsjrbql",
"z": "47d512da301e9401",
"name": "调价格的商品列表",
"code": " SELECT * WHERE a3 != a7",
"join": false,
"x": 930,
"y": 560,
"wires": [
[
"3631ee81b8005f2d"
]
]
},
{
"id": "da1970c04f6a7c24",
"type": "dsjrbql",
"z": "47d512da301e9401",
"name": "换主图的商品列表",
"code": "SELECT * WHERE a4 != a8",
"join": false,
"x": 930,
"y": 640,
"wires": [
[
"68435c96811651f6"
]
]
},
{
"id": "3631ee81b8005f2d",
"type": "debug",
"z": "47d512da301e9401",
"name": "调试 7",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1130,
"y": 560,
"wires": []
},
{
"id": "68435c96811651f6",
"type": "debug",
"z": "47d512da301e9401",
"name": "调试 8",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1130,
"y": 640,
"wires": []
},
{
"id": "5a810d1c2327523a",
"type": "switch",
"z": "47d512da301e9401",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "nnull"
},
{
"t": "nnull"
}
],
"checkall": "true",
"repair": true,
"outputs": 3,
"x": 710,
"y": 560,
"wires": [
[
"a336dc44e4f08159"
],
[
"8244f45ed52a82f3"
],
[
"da1970c04f6a7c24"
]
]
}
]
结束