Commit b1483ddd98ad7246e0523e2e58da5705827d0b11
Merge branch 'master' into changan-master
# Conflicts: # .gitignore
Showing
20 changed files
with
5829 additions
and
404 deletions
| 1 | # ============================================================================= | 1 | # ============================================================================= |
| 2 | -# 风险场景统计配置(外显配置,放在 jar 运行目录,Spring Boot 自动加载) | ||
| 3 | -# 修改本文件后无需重新打包,重启应用即可生效。 | ||
| 4 | -# | ||
| 5 | -# 新增场景:复制一段 jdy-risk.scenarios[n].xxx,n 递增,按场景类型填字段: | ||
| 6 | -# type=scenario1:全量,满足 总计>=5 且 差值>=1 且 flowState=in-progress-state | ||
| 7 | -# 需填 total-field / diff-field / in-progress-state | ||
| 8 | -# type=scenario2:当月,按 group-field 分组,SI数量/问题数量合计>60% 且 合计>=5 的分组数 | ||
| 9 | -# 需填 date-field / group-field / si-field / qty-field / month-only | ||
| 10 | -# type=scenario3:当月,SI占比>60% 且 总问题数>=5 的行数 | ||
| 11 | -# 需填 date-field / total-field / ratio-field / month-only | ||
| 12 | -# 每个场景的 sync-code 对应启效目标记录的 syncCode,统计结果写入 qx.count-field 字段。 | 2 | +# Risk scenario configuration (external; loaded by Spring Boot from the run dir) |
| 3 | +# After editing, just restart the app (no repackaging needed). | ||
| 4 | +# IMPORTANT: .properties is read as ISO-8859-1. Do NOT put raw Chinese here; | ||
| 5 | +# use \uXXXX escapes for any Chinese value. Comments kept ASCII on purpose. | ||
| 13 | # ============================================================================= | 6 | # ============================================================================= |
| 14 | 7 | ||
| 15 | -# ---------- 简道云(长安) ---------- | 8 | +# ---------- Jiandaoyun (Changan) ---------- |
| 16 | jdy-risk.host=https://jdy.changan.com.cn/api | 9 | jdy-risk.host=https://jdy.changan.com.cn/api |
| 17 | jdy-risk.api-key=lOnr4ms8jfc0gbCwVYS7YtbYQXjBFq979Cc06BcC866427b2a7aAd054598Bc7bB | 10 | jdy-risk.api-key=lOnr4ms8jfc0gbCwVYS7YtbYQXjBFq979Cc06BcC866427b2a7aAd054598Bc7bB |
| 18 | 11 | ||
| 19 | -# ---------- 启效(QX) 写回目标 ---------- | 12 | +# ---------- QX write-back target ---------- |
| 20 | jdy-risk.qx.base-url=https://hfca.uat3.qgutech.com | 13 | jdy-risk.qx.base-url=https://hfca.uat3.qgutech.com |
| 21 | jdy-risk.qx.username=15077901670 | 14 | jdy-risk.qx.username=15077901670 |
| 22 | jdy-risk.qx.password=000000 | 15 | jdy-risk.qx.password=000000 |
| @@ -25,24 +18,30 @@ jdy-risk.qx.app-id=sEOSZ8EPwdrzJB41amD | @@ -25,24 +18,30 @@ jdy-risk.qx.app-id=sEOSZ8EPwdrzJB41amD | ||
| 25 | jdy-risk.qx.query-code=ilr3ne7bPage | 18 | jdy-risk.qx.query-code=ilr3ne7bPage |
| 26 | jdy-risk.qx.sync-query-param=pcqqjoquery | 19 | jdy-risk.qx.sync-query-param=pcqqjoquery |
| 27 | jdy-risk.qx.update-code=11a41Update | 20 | jdy-risk.qx.update-code=11a41Update |
| 21 | +jdy-risk.qx.add-code=11a41Add | ||
| 22 | +jdy-risk.qx.delete-code=ilr3ne7bDel | ||
| 28 | jdy-risk.qx.count-field=chcbxt | 23 | jdy-risk.qx.count-field=chcbxt |
| 29 | jdy-risk.qx.attach-field=hciwkz | 24 | jdy-risk.qx.attach-field=hciwkz |
| 25 | +jdy-risk.qx.time-field=bswivu | ||
| 26 | +# second date field updated together with warning time (only if present) | ||
| 27 | +jdy-risk.qx.time-field-2=dgqshv | ||
| 30 | 28 | ||
| 31 | -# ---------- 场景1:3mis 风险监控(全量) ---------- | 29 | +# ---------- Scenario 1: 3mis (prev month) ---------- |
| 32 | jdy-risk.scenarios[0].id=count_1 | 30 | jdy-risk.scenarios[0].id=count_1 |
| 33 | -jdy-risk.scenarios[0].name=3mis风险监控 | 31 | +jdy-risk.scenarios[0].name=scene1 |
| 34 | jdy-risk.scenarios[0].type=scenario1 | 32 | jdy-risk.scenarios[0].type=scenario1 |
| 35 | jdy-risk.scenarios[0].sync-code=SYNC0001 | 33 | jdy-risk.scenarios[0].sync-code=SYNC0001 |
| 36 | jdy-risk.scenarios[0].app-id=65fd5c0e0d1f1a7ae4f038ec | 34 | jdy-risk.scenarios[0].app-id=65fd5c0e0d1f1a7ae4f038ec |
| 37 | jdy-risk.scenarios[0].entry-id=696f1754f141344a6b794f9c | 35 | jdy-risk.scenarios[0].entry-id=696f1754f141344a6b794f9c |
| 36 | +jdy-risk.scenarios[0].date-field=_widget_1773622123700 | ||
| 38 | jdy-risk.scenarios[0].total-field=_widget_1768888148020 | 37 | jdy-risk.scenarios[0].total-field=_widget_1768888148020 |
| 39 | jdy-risk.scenarios[0].diff-field=_widget_1768888148019 | 38 | jdy-risk.scenarios[0].diff-field=_widget_1768888148019 |
| 40 | jdy-risk.scenarios[0].in-progress-state=0 | 39 | jdy-risk.scenarios[0].in-progress-state=0 |
| 41 | -jdy-risk.scenarios[0].month-only=false | 40 | +jdy-risk.scenarios[0].prev-month-only=true |
| 42 | 41 | ||
| 43 | -# ---------- 场景2:供应商 SI 占比风险监控(当月,按供应商分组) ---------- | 42 | +# ---------- Scenario 2: supplier SI ratio (prev month) ---------- |
| 44 | jdy-risk.scenarios[1].id=count_2 | 43 | jdy-risk.scenarios[1].id=count_2 |
| 45 | -jdy-risk.scenarios[1].name=供应商SI占比风险监控 | 44 | +jdy-risk.scenarios[1].name=scene2 |
| 46 | jdy-risk.scenarios[1].type=scenario2 | 45 | jdy-risk.scenarios[1].type=scenario2 |
| 47 | jdy-risk.scenarios[1].sync-code=SYNC0002 | 46 | jdy-risk.scenarios[1].sync-code=SYNC0002 |
| 48 | jdy-risk.scenarios[1].app-id=65f8060f8666b8a5d1b98d57 | 47 | jdy-risk.scenarios[1].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -51,11 +50,12 @@ jdy-risk.scenarios[1].date-field=_widget_1778638131411 | @@ -51,11 +50,12 @@ jdy-risk.scenarios[1].date-field=_widget_1778638131411 | ||
| 51 | jdy-risk.scenarios[1].group-field=_widget_1778638131431 | 50 | jdy-risk.scenarios[1].group-field=_widget_1778638131431 |
| 52 | jdy-risk.scenarios[1].si-field=_widget_1778638131430 | 51 | jdy-risk.scenarios[1].si-field=_widget_1778638131430 |
| 53 | jdy-risk.scenarios[1].qty-field=_widget_1778638131418 | 52 | jdy-risk.scenarios[1].qty-field=_widget_1778638131418 |
| 54 | -jdy-risk.scenarios[1].month-only=true | 53 | +jdy-risk.scenarios[1].prev-month-only=true |
| 54 | +jdy-risk.scenarios[1].only-warn-rows=true | ||
| 55 | 55 | ||
| 56 | -# ---------- 场景3:工程师 SI 占比风险监控(当月) ---------- | 56 | +# ---------- Scenario 3: engineer SI ratio (prev month) ---------- |
| 57 | jdy-risk.scenarios[2].id=count_3 | 57 | jdy-risk.scenarios[2].id=count_3 |
| 58 | -jdy-risk.scenarios[2].name=工程师SI占比风险监控 | 58 | +jdy-risk.scenarios[2].name=scene3 |
| 59 | jdy-risk.scenarios[2].type=scenario3 | 59 | jdy-risk.scenarios[2].type=scenario3 |
| 60 | jdy-risk.scenarios[2].sync-code=SYNC0003 | 60 | jdy-risk.scenarios[2].sync-code=SYNC0003 |
| 61 | jdy-risk.scenarios[2].app-id=65f8060f8666b8a5d1b98d57 | 61 | jdy-risk.scenarios[2].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -63,12 +63,14 @@ jdy-risk.scenarios[2].entry-id=6a193f03e88046f554dc10bc | @@ -63,12 +63,14 @@ jdy-risk.scenarios[2].entry-id=6a193f03e88046f554dc10bc | ||
| 63 | jdy-risk.scenarios[2].date-field=_widget_1780039427416 | 63 | jdy-risk.scenarios[2].date-field=_widget_1780039427416 |
| 64 | jdy-risk.scenarios[2].total-field=_widget_1780039427422 | 64 | jdy-risk.scenarios[2].total-field=_widget_1780039427422 |
| 65 | jdy-risk.scenarios[2].ratio-field=_widget_1780039778663 | 65 | jdy-risk.scenarios[2].ratio-field=_widget_1780039778663 |
| 66 | -jdy-risk.scenarios[2].month-only=true | 66 | +jdy-risk.scenarios[2].prev-month-only=true |
| 67 | jdy-risk.scenarios[2].extra-field=_widget_1780039427417 | 67 | jdy-risk.scenarios[2].extra-field=_widget_1780039427417 |
| 68 | +jdy-risk.scenarios[2].only-warn-rows=true | ||
| 69 | +jdy-risk.scenarios[2].percent-fields[0]=_widget_1780039778663 | ||
| 68 | 70 | ||
| 69 | -# ---------- 场景4:CR导出-按供应商(升级不含QR/空白,当季度) ---------- | 71 | +# ---------- Scenario 4: CR upgrade - supplier (prev quarter) ---------- |
| 70 | jdy-risk.scenarios[3].id=count_4 | 72 | jdy-risk.scenarios[3].id=count_4 |
| 71 | -jdy-risk.scenarios[3].name=供应商升级风险监控 | 73 | +jdy-risk.scenarios[3].name=scene4 |
| 72 | jdy-risk.scenarios[3].type=scenario4 | 74 | jdy-risk.scenarios[3].type=scenario4 |
| 73 | jdy-risk.scenarios[3].sync-code=SYNC0004 | 75 | jdy-risk.scenarios[3].sync-code=SYNC0004 |
| 74 | jdy-risk.scenarios[3].app-id=65f8060f8666b8a5d1b98d57 | 76 | jdy-risk.scenarios[3].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -78,11 +80,11 @@ jdy-risk.scenarios[3].group-field=_widget_1752543725816 | @@ -78,11 +80,11 @@ jdy-risk.scenarios[3].group-field=_widget_1752543725816 | ||
| 78 | jdy-risk.scenarios[3].up-field=_widget_1752543725813 | 80 | jdy-risk.scenarios[3].up-field=_widget_1752543725813 |
| 79 | jdy-risk.scenarios[3].exclude-values[0]=QR | 81 | jdy-risk.scenarios[3].exclude-values[0]=QR |
| 80 | jdy-risk.scenarios[3].min-count=3 | 82 | jdy-risk.scenarios[3].min-count=3 |
| 81 | -jdy-risk.scenarios[3].quarter-only=true | 83 | +jdy-risk.scenarios[3].prev-quarter-only=true |
| 82 | 84 | ||
| 83 | -# ---------- 场景5:CR导出-按IQ工程师(升级不含QR/空白,当季度) ---------- | 85 | +# ---------- Scenario 5: CR upgrade - engineer (prev quarter) ---------- |
| 84 | jdy-risk.scenarios[4].id=count_5 | 86 | jdy-risk.scenarios[4].id=count_5 |
| 85 | -jdy-risk.scenarios[4].name=工程师升级风险监控 | 87 | +jdy-risk.scenarios[4].name=scene5 |
| 86 | jdy-risk.scenarios[4].type=scenario5 | 88 | jdy-risk.scenarios[4].type=scenario5 |
| 87 | jdy-risk.scenarios[4].sync-code=SYNC0005 | 89 | jdy-risk.scenarios[4].sync-code=SYNC0005 |
| 88 | jdy-risk.scenarios[4].app-id=65f8060f8666b8a5d1b98d57 | 90 | jdy-risk.scenarios[4].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -92,11 +94,12 @@ jdy-risk.scenarios[4].group-field=_widget_1752543725822 | @@ -92,11 +94,12 @@ jdy-risk.scenarios[4].group-field=_widget_1752543725822 | ||
| 92 | jdy-risk.scenarios[4].up-field=_widget_1752543725813 | 94 | jdy-risk.scenarios[4].up-field=_widget_1752543725813 |
| 93 | jdy-risk.scenarios[4].exclude-values[0]=QR | 95 | jdy-risk.scenarios[4].exclude-values[0]=QR |
| 94 | jdy-risk.scenarios[4].min-count=3 | 96 | jdy-risk.scenarios[4].min-count=3 |
| 95 | -jdy-risk.scenarios[4].quarter-only=true | 97 | +jdy-risk.scenarios[4].prev-quarter-only=true |
| 98 | +jdy-risk.scenarios[4].only-warn-rows=true | ||
| 96 | 99 | ||
| 97 | -# ---------- 场景6:三包索赔申诉台账-经销商(当年,次数>=3) ---------- | 100 | +# ---------- Scenario 6: dealer repeated claims (prev month) ---------- |
| 98 | jdy-risk.scenarios[5].id=count_6 | 101 | jdy-risk.scenarios[5].id=count_6 |
| 99 | -jdy-risk.scenarios[5].name=经销商三包索赔风险监控 | 102 | +jdy-risk.scenarios[5].name=scene6 |
| 100 | jdy-risk.scenarios[5].type=scenario6 | 103 | jdy-risk.scenarios[5].type=scenario6 |
| 101 | jdy-risk.scenarios[5].sync-code=SYNC0007 | 104 | jdy-risk.scenarios[5].sync-code=SYNC0007 |
| 102 | jdy-risk.scenarios[5].app-id=65f8060f8666b8a5d1b98d57 | 105 | jdy-risk.scenarios[5].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -104,11 +107,11 @@ jdy-risk.scenarios[5].entry-id=688336be2fbf78b3d44d7174 | @@ -104,11 +107,11 @@ jdy-risk.scenarios[5].entry-id=688336be2fbf78b3d44d7174 | ||
| 104 | jdy-risk.scenarios[5].date-field=_widget_1753429694910 | 107 | jdy-risk.scenarios[5].date-field=_widget_1753429694910 |
| 105 | jdy-risk.scenarios[5].group-field=_widget_1753429694911 | 108 | jdy-risk.scenarios[5].group-field=_widget_1753429694911 |
| 106 | jdy-risk.scenarios[5].min-count=3 | 109 | jdy-risk.scenarios[5].min-count=3 |
| 107 | -jdy-risk.scenarios[5].year-only=true | 110 | +jdy-risk.scenarios[5].prev-month-only=true |
| 108 | 111 | ||
| 109 | -# ---------- 场景7:三包库房进库-超期未处理(180天,排除已出库/已抵扣) ---------- | 112 | +# ---------- Scenario 7: 3bao warehouse overdue (180 days) ---------- |
| 110 | jdy-risk.scenarios[6].id=count_7 | 113 | jdy-risk.scenarios[6].id=count_7 |
| 111 | -jdy-risk.scenarios[6].name=三包库房超期未处理风险监控 | 114 | +jdy-risk.scenarios[6].name=scene7 |
| 112 | jdy-risk.scenarios[6].type=scenario7 | 115 | jdy-risk.scenarios[6].type=scenario7 |
| 113 | jdy-risk.scenarios[6].sync-code=SYNC0008 | 116 | jdy-risk.scenarios[6].sync-code=SYNC0008 |
| 114 | jdy-risk.scenarios[6].app-id=65f8060f8666b8a5d1b98d57 | 117 | jdy-risk.scenarios[6].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -116,7 +119,7 @@ jdy-risk.scenarios[6].entry-id=686b6f72fcb3f02a8ffc8fcd | @@ -116,7 +119,7 @@ jdy-risk.scenarios[6].entry-id=686b6f72fcb3f02a8ffc8fcd | ||
| 116 | jdy-risk.scenarios[6].barcode-field=_widget_1751871346824 | 119 | jdy-risk.scenarios[6].barcode-field=_widget_1751871346824 |
| 117 | jdy-risk.scenarios[6].date-field=_widget_1751871346820 | 120 | jdy-risk.scenarios[6].date-field=_widget_1751871346820 |
| 118 | jdy-risk.scenarios[6].max-age-days=180 | 121 | jdy-risk.scenarios[6].max-age-days=180 |
| 119 | -# 主表只取这几列(经销商代码/经销商名称/入库时间/条码),减小传输 | 122 | +jdy-risk.scenarios[6].monthly-overdue-incremental=true |
| 120 | jdy-risk.scenarios[6].fields[0]=_widget_1751871346816 | 123 | jdy-risk.scenarios[6].fields[0]=_widget_1751871346816 |
| 121 | jdy-risk.scenarios[6].fields[1]=_widget_1751871346817 | 124 | jdy-risk.scenarios[6].fields[1]=_widget_1751871346817 |
| 122 | jdy-risk.scenarios[6].fields[2]=_widget_1751871346820 | 125 | jdy-risk.scenarios[6].fields[2]=_widget_1751871346820 |
| @@ -126,9 +129,9 @@ jdy-risk.scenarios[6].exclude-forms[0].barcode-field=_widget_1751871441626 | @@ -126,9 +129,9 @@ jdy-risk.scenarios[6].exclude-forms[0].barcode-field=_widget_1751871441626 | ||
| 126 | jdy-risk.scenarios[6].exclude-forms[1].entry-id=686b781c11159446bb2583fc | 129 | jdy-risk.scenarios[6].exclude-forms[1].entry-id=686b781c11159446bb2583fc |
| 127 | jdy-risk.scenarios[6].exclude-forms[1].barcode-field=_widget_1751873565337 | 130 | jdy-risk.scenarios[6].exclude-forms[1].barcode-field=_widget_1751873565337 |
| 128 | 131 | ||
| 129 | -# ---------- 场景8:料废登记台账-供应商(上月,未开CR占比>70%) ---------- | 132 | +# ---------- Scenario 8: material-waste - supplier CR ratio (prev month) ---------- |
| 130 | jdy-risk.scenarios[7].id=count_8 | 133 | jdy-risk.scenarios[7].id=count_8 |
| 131 | -jdy-risk.scenarios[7].name=供应商未开CR风险监控 | 134 | +jdy-risk.scenarios[7].name=scene8 |
| 132 | jdy-risk.scenarios[7].type=scenario8 | 135 | jdy-risk.scenarios[7].type=scenario8 |
| 133 | jdy-risk.scenarios[7].sync-code=SYNC0010 | 136 | jdy-risk.scenarios[7].sync-code=SYNC0010 |
| 134 | jdy-risk.scenarios[7].app-id=65f8060f8666b8a5d1b98d57 | 137 | jdy-risk.scenarios[7].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -139,10 +142,14 @@ jdy-risk.scenarios[7].flag-field=_widget_1769502015250 | @@ -139,10 +142,14 @@ jdy-risk.scenarios[7].flag-field=_widget_1769502015250 | ||
| 139 | jdy-risk.scenarios[7].flag-value=\u5426 | 142 | jdy-risk.scenarios[7].flag-value=\u5426 |
| 140 | jdy-risk.scenarios[7].ratio-threshold=0.7 | 143 | jdy-risk.scenarios[7].ratio-threshold=0.7 |
| 141 | jdy-risk.scenarios[7].prev-month-only=true | 144 | jdy-risk.scenarios[7].prev-month-only=true |
| 145 | +jdy-risk.scenarios[7].only-warn-rows=true | ||
| 146 | +jdy-risk.scenarios[7].lookup-field=_widget_1783921957534 | ||
| 147 | +jdy-risk.scenarios[7].lookup-entry-id=6a545b1cc641f0ad493bd9df | ||
| 148 | +jdy-risk.scenarios[7].lookup-name-field=_widget_1783913697901 | ||
| 142 | 149 | ||
| 143 | -# ---------- 场景9:料废登记台账-工程师(上月,未开CR占比>70%) ---------- | 150 | +# ---------- Scenario 9: material-waste - engineer CR ratio (prev month) ---------- |
| 144 | jdy-risk.scenarios[8].id=count_9 | 151 | jdy-risk.scenarios[8].id=count_9 |
| 145 | -jdy-risk.scenarios[8].name=工程师未开CR风险监控 | 152 | +jdy-risk.scenarios[8].name=scene9 |
| 146 | jdy-risk.scenarios[8].type=scenario9 | 153 | jdy-risk.scenarios[8].type=scenario9 |
| 147 | jdy-risk.scenarios[8].sync-code=SYNC0011 | 154 | jdy-risk.scenarios[8].sync-code=SYNC0011 |
| 148 | jdy-risk.scenarios[8].app-id=65f8060f8666b8a5d1b98d57 | 155 | jdy-risk.scenarios[8].app-id=65f8060f8666b8a5d1b98d57 |
| @@ -153,18 +160,758 @@ jdy-risk.scenarios[8].flag-field=_widget_1769502015250 | @@ -153,18 +160,758 @@ jdy-risk.scenarios[8].flag-field=_widget_1769502015250 | ||
| 153 | jdy-risk.scenarios[8].flag-value=\u5426 | 160 | jdy-risk.scenarios[8].flag-value=\u5426 |
| 154 | jdy-risk.scenarios[8].ratio-threshold=0.7 | 161 | jdy-risk.scenarios[8].ratio-threshold=0.7 |
| 155 | jdy-risk.scenarios[8].prev-month-only=true | 162 | jdy-risk.scenarios[8].prev-month-only=true |
| 163 | +jdy-risk.scenarios[8].only-warn-rows=true | ||
| 164 | +jdy-risk.scenarios[8].lookup-field=_widget_1783921957534 | ||
| 165 | +jdy-risk.scenarios[8].lookup-entry-id=6a545b1cc641f0ad493bd9df | ||
| 166 | +jdy-risk.scenarios[8].lookup-name-field=_widget_1783913697901 | ||
| 167 | + | ||
| 168 | +# ---------- Scenario 10: claim-rate difference (current month) ---------- | ||
| 169 | +jdy-risk.scenarios[9].id=count_10 | ||
| 170 | +jdy-risk.scenarios[9].name=scene10 | ||
| 171 | +jdy-risk.scenarios[9].type=scenario10 | ||
| 172 | +jdy-risk.scenarios[9].sync-code=SYNC0006 | ||
| 173 | +jdy-risk.scenarios[9].app-id=65f8060f8666b8a5d1b98d57 | ||
| 174 | +jdy-risk.scenarios[9].entry-id=695f08df7680113783af422c | ||
| 175 | +jdy-risk.scenarios[9].date-field=_widget_1767835871184 | ||
| 176 | +jdy-risk.scenarios[9].diff-field=_widget_1767835871192 | ||
| 177 | +jdy-risk.scenarios[9].abs-threshold=0.05 | ||
| 178 | +jdy-risk.scenarios[9].month-only=true | ||
| 179 | +jdy-risk.scenarios[9].percent-fields[0]=_widget_1767835871192 | ||
| 180 | + | ||
| 181 | +# ---------- Scenario 11: 3bao stocktake barcode diff (all data) ---------- | ||
| 182 | +jdy-risk.scenarios[10].id=count_11 | ||
| 183 | +jdy-risk.scenarios[10].name=scene11 | ||
| 184 | +jdy-risk.scenarios[10].type=scenario11 | ||
| 185 | +jdy-risk.scenarios[10].sync-code=SYNC009 | ||
| 186 | +jdy-risk.scenarios[10].app-id=65f8060f8666b8a5d1b98d57 | ||
| 187 | +jdy-risk.scenarios[10].entry-id=6ab4d9abd87880e5d89e137c | ||
| 188 | +jdy-risk.scenarios[10].barcode-field=_widget_1790237099873 | ||
| 189 | +jdy-risk.scenarios[10].compare-entry-id=6ab4dc5ff51dec2d82337f32 | ||
| 190 | +jdy-risk.scenarios[10].compare-barcode-field=_widget_1790237791434 | ||
| 191 | +jdy-risk.scenarios[10].exclude-forms[0].entry-id=686b781c11159446bb2583fc | ||
| 192 | +jdy-risk.scenarios[10].exclude-forms[0].barcode-field=_widget_1751873565337 | ||
| 193 | + | ||
| 194 | +# ---------- Scenario 12: confidential agreement - missing signature (current year, SYNC0038) ---------- | ||
| 195 | +jdy-risk.scenarios[11].id=count_12 | ||
| 196 | +jdy-risk.scenarios[11].name=scene12 | ||
| 197 | +jdy-risk.scenarios[11].type=scenario12 | ||
| 198 | +jdy-risk.scenarios[11].sync-code=SYNC0038 | ||
| 199 | +jdy-risk.scenarios[11].app-id=662b1048948f7cc7d489bdd4 | ||
| 200 | +jdy-risk.scenarios[11].entry-id=69d6eccd53a601ab7f2d05ec | ||
| 201 | +jdy-risk.scenarios[11].date-field=_widget_1775780546733 | ||
| 202 | +jdy-risk.scenarios[11].year-only=true | ||
| 203 | +jdy-risk.scenarios[11].pairs[0].person-field=_widget_1775693007217 | ||
| 204 | +jdy-risk.scenarios[11].pairs[0].sign-field=_widget_1775693007223 | ||
| 205 | +jdy-risk.scenarios[11].pairs[1].person-field=_widget_1775693007219 | ||
| 206 | +jdy-risk.scenarios[11].pairs[1].sign-field=_widget_1775693007225 | ||
| 207 | +jdy-risk.scenarios[11].pairs[2].person-field=_widget_1775693007218 | ||
| 208 | +jdy-risk.scenarios[11].pairs[2].sign-field=_widget_1775693007226 | ||
| 209 | +jdy-risk.scenarios[11].pairs[3].person-field=_widget_1775693007220 | ||
| 210 | +jdy-risk.scenarios[11].pairs[3].sign-field=_widget_1775693007227 | ||
| 211 | +jdy-risk.scenarios[11].pairs[4].person-field=_widget_1775693007221 | ||
| 212 | +jdy-risk.scenarios[11].pairs[4].sign-field=_widget_1775693007228 | ||
| 213 | + | ||
| 214 | +# ---------- Scenario 13: weighing - stay time anomaly (prev month, SYNC0042) ---------- | ||
| 215 | +jdy-risk.scenarios[12].id=count_13 | ||
| 216 | +jdy-risk.scenarios[12].name=scene13 | ||
| 217 | +jdy-risk.scenarios[12].type=scenario13 | ||
| 218 | +jdy-risk.scenarios[12].sync-code=SYNC0042 | ||
| 219 | +jdy-risk.scenarios[12].app-id=662b1048948f7cc7d489bdd4 | ||
| 220 | +jdy-risk.scenarios[12].entry-id=6aa3a551b26cc791596892dc | ||
| 221 | +jdy-risk.scenarios[12].date-field=_widget_1789109585493 | ||
| 222 | +jdy-risk.scenarios[12].prev-month-only=true | ||
| 223 | +jdy-risk.scenarios[12].duration-field=_widget_1789109585495 | ||
| 224 | +jdy-risk.scenarios[12].duration-threshold=10 | ||
| 225 | +jdy-risk.scenarios[12].abnormal-field=_widget_1791451544499 | ||
| 226 | +jdy-risk.scenarios[12].abnormal-value=\u5b58\u5728\u5f02\u5e38 | ||
| 227 | +jdy-risk.scenarios[12].reason-field=_widget_1789464764187 | ||
| 228 | + | ||
| 229 | +# ---------- Scenario 14: unqualified material - same supplier >=3/year (SYNC0048) ---------- | ||
| 230 | +jdy-risk.scenarios[13].id=count_14 | ||
| 231 | +jdy-risk.scenarios[13].name=scene14 | ||
| 232 | +jdy-risk.scenarios[13].type=scenario14 | ||
| 233 | +jdy-risk.scenarios[13].sync-code=SYNC0048 | ||
| 234 | +jdy-risk.scenarios[13].app-id=662b1048948f7cc7d489bdd4 | ||
| 235 | +jdy-risk.scenarios[13].entry-id=6a0bace9e162c4f1abdbcf70 | ||
| 236 | +jdy-risk.scenarios[13].date-field=_widget_1779150058654 | ||
| 237 | +jdy-risk.scenarios[13].year-only=true | ||
| 238 | +jdy-risk.scenarios[13].group-field=_widget_1779150058655 | ||
| 239 | +jdy-risk.scenarios[13].min-count=3 | ||
| 240 | + | ||
| 241 | +# ---------- Scenario 15: maintenance - missing conditional photos (prev month, SYNC0044) ---------- | ||
| 242 | +jdy-risk.scenarios[14].id=count_15 | ||
| 243 | +jdy-risk.scenarios[14].name=scene15 | ||
| 244 | +jdy-risk.scenarios[14].type=scenario15 | ||
| 245 | +jdy-risk.scenarios[14].sync-code=SYNC0044 | ||
| 246 | +jdy-risk.scenarios[14].app-id=662b1048948f7cc7d489bdd4 | ||
| 247 | +jdy-risk.scenarios[14].entry-id=69d758c153a601ab7f51c1f9 | ||
| 248 | +jdy-risk.scenarios[14].date-field=updateTime | ||
| 249 | +jdy-risk.scenarios[14].prev-month-only=true | ||
| 250 | +jdy-risk.scenarios[14].flow-state-value=1 | ||
| 251 | +jdy-risk.scenarios[14].photo-rules[0].flag-field=_widget_1776388345381 | ||
| 252 | +jdy-risk.scenarios[14].photo-rules[0].photo-field=_widget_1776388345389 | ||
| 253 | +jdy-risk.scenarios[14].photo-rules[1].flag-field=_widget_1776388345383 | ||
| 254 | +jdy-risk.scenarios[14].photo-rules[1].photo-field=_widget_1776388345391 | ||
| 255 | +jdy-risk.scenarios[14].photo-rules[2].flag-field=_widget_1776388345385 | ||
| 256 | +jdy-risk.scenarios[14].photo-rules[2].photo-field=_widget_1776388345393 | ||
| 257 | + | ||
| 258 | +# ---------- Scenario 16: budget accuracy - over budget without reason (current month, SYNC0045) ---------- | ||
| 259 | +jdy-risk.scenarios[15].id=count_16 | ||
| 260 | +jdy-risk.scenarios[15].name=scene16 | ||
| 261 | +jdy-risk.scenarios[15].type=scenario16 | ||
| 262 | +jdy-risk.scenarios[15].sync-code=SYNC0045 | ||
| 263 | +jdy-risk.scenarios[15].app-id=662b1048948f7cc7d489bdd4 | ||
| 264 | +jdy-risk.scenarios[15].entry-id=6a0d247a6532e2088f09f939 | ||
| 265 | +jdy-risk.scenarios[15].date-field=createTime | ||
| 266 | +jdy-risk.scenarios[15].month-only=true | ||
| 267 | +jdy-risk.scenarios[15].flag-field=_widget_1779777375824 | ||
| 268 | +jdy-risk.scenarios[15].flag-values[0]=\u9ad8\u9884\u7b97 | ||
| 269 | +jdy-risk.scenarios[15].flag-values[1]=\u4f4e\u9884\u7b97 | ||
| 270 | +jdy-risk.scenarios[15].reason-field=_widget_1788772233922 | ||
| 271 | + | ||
| 272 | +# ---------- Scenario 17: maintenance overdue >15 days (prev month by updateTime, SYNC0046) ---------- | ||
| 273 | +jdy-risk.scenarios[16].id=count_17 | ||
| 274 | +jdy-risk.scenarios[16].name=scene17 | ||
| 275 | +jdy-risk.scenarios[16].type=scenario17 | ||
| 276 | +jdy-risk.scenarios[16].sync-code=SYNC0046 | ||
| 277 | +jdy-risk.scenarios[16].app-id=662b1048948f7cc7d489bdd4 | ||
| 278 | +jdy-risk.scenarios[16].entry-id=69d758c153a601ab7f51c1f9 | ||
| 279 | +jdy-risk.scenarios[16].date-field=updateTime | ||
| 280 | +jdy-risk.scenarios[16].prev-month-only=true | ||
| 281 | +jdy-risk.scenarios[16].flow-state-value=1 | ||
| 282 | +jdy-risk.scenarios[16].plan-field=_widget_1776388345379 | ||
| 283 | +jdy-risk.scenarios[16].actual-field=_widget_1776388345403 | ||
| 284 | +jdy-risk.scenarios[16].overdue-days=15 | ||
| 285 | + | ||
| 286 | +# ---------- Scenario 18: auto reminder - audit docs not submitted (current month, SYNC0047) ---------- | ||
| 287 | +jdy-risk.scenarios[17].id=count_18 | ||
| 288 | +jdy-risk.scenarios[17].name=scene18 | ||
| 289 | +jdy-risk.scenarios[17].type=scenario18 | ||
| 290 | +jdy-risk.scenarios[17].sync-code=SYNC0047 | ||
| 291 | +jdy-risk.scenarios[17].app-id=662b1048948f7cc7d489bdd4 | ||
| 292 | +jdy-risk.scenarios[17].entry-id=6aced5f5a8deddb8f92a9a1b | ||
| 293 | +jdy-risk.scenarios[17].date-field=_widget_1791940252731 | ||
| 294 | +jdy-risk.scenarios[17].month-only=true | ||
| 295 | +jdy-risk.scenarios[17].flag-field=_widget_1791940252732 | ||
| 296 | +jdy-risk.scenarios[17].flag-values[0]=\u672a\u63d0\u4ea4 | ||
| 297 | +jdy-risk.scenarios[17].reason-field=_widget_1791940252734 | ||
| 298 | + | ||
| 299 | +# ---------- Scenario 19: repeated similar project within 3 months (prev month, SYNC0043) ---------- | ||
| 300 | +jdy-risk.scenarios[18].id=count_19 | ||
| 301 | +jdy-risk.scenarios[18].name=scene19 | ||
| 302 | +jdy-risk.scenarios[18].type=scenario19 | ||
| 303 | +jdy-risk.scenarios[18].sync-code=SYNC0043 | ||
| 304 | +jdy-risk.scenarios[18].app-id=662b1048948f7cc7d489bdd4 | ||
| 305 | +jdy-risk.scenarios[18].entry-id=6ad0719e22f52b6b8f7d7891 | ||
| 306 | +jdy-risk.scenarios[18].date-field=createTime | ||
| 307 | +jdy-risk.scenarios[18].prev-month-only=true | ||
| 308 | +jdy-risk.scenarios[18].flag-field=_widget_1792045471473 | ||
| 309 | +jdy-risk.scenarios[18].flag-values[0]=\u662f | ||
| 310 | + | ||
| 311 | +# ---------- Scenario 23: CS95 fuel consumption (prev month, SYNC0013) ---------- | ||
| 312 | +jdy-risk.scenarios[19].id=count_23 | ||
| 313 | +jdy-risk.scenarios[19].name=scene23 | ||
| 314 | +jdy-risk.scenarios[19].type=scenario20 | ||
| 315 | +jdy-risk.scenarios[19].sync-code=SYNC0013 | ||
| 316 | +jdy-risk.scenarios[19].app-id=6630634752eab8bdecbaee7d | ||
| 317 | +jdy-risk.scenarios[19].entry-id=695df62e76801137838d4785 | ||
| 318 | +jdy-risk.scenarios[19].date-field=_widget_1767769739507 | ||
| 319 | +jdy-risk.scenarios[19].half-month-only=true | ||
| 320 | +jdy-risk.scenarios[19].flow-state-value=1 | ||
| 321 | +jdy-risk.scenarios[19].flag-field=_widget_1779093489906 | ||
| 322 | +jdy-risk.scenarios[19].flag-values[0]=\u662f | ||
| 323 | +jdy-risk.scenarios[19].fuel-amount-field=_widget_1779093489909 | ||
| 324 | +jdy-risk.scenarios[19].start-km-field=_widget_1767770394897 | ||
| 325 | +jdy-risk.scenarios[19].end-km-field=_widget_1767770394898 | ||
| 326 | +jdy-risk.scenarios[19].subform-field=_widget_1779416742773 | ||
| 327 | +jdy-risk.scenarios[19].subform-start-field=_widget_1779932645938 | ||
| 328 | +jdy-risk.scenarios[19].min-value=9 | ||
| 329 | +jdy-risk.scenarios[19].max-value=13 | ||
| 330 | +jdy-risk.scenarios[19].include-previous-row=true | ||
| 331 | + | ||
| 332 | +# ---------- Scenario 24: CS75 fuel consumption (prev month, SYNC0014) ---------- | ||
| 333 | +jdy-risk.scenarios[20].id=count_24 | ||
| 334 | +jdy-risk.scenarios[20].name=scene24 | ||
| 335 | +jdy-risk.scenarios[20].type=scenario20 | ||
| 336 | +jdy-risk.scenarios[20].sync-code=SYNC0014 | ||
| 337 | +jdy-risk.scenarios[20].app-id=6630634752eab8bdecbaee7d | ||
| 338 | +jdy-risk.scenarios[20].entry-id=695df62e76801137838d4785 | ||
| 339 | +jdy-risk.scenarios[20].date-field=_widget_1767769739507 | ||
| 340 | +jdy-risk.scenarios[20].half-month-only=true | ||
| 341 | +jdy-risk.scenarios[20].flow-state-value=1 | ||
| 342 | +jdy-risk.scenarios[20].flag-field=_widget_1779093489911 | ||
| 343 | +jdy-risk.scenarios[20].flag-values[0]=\u662f | ||
| 344 | +jdy-risk.scenarios[20].fuel-amount-field=_widget_1779093489913 | ||
| 345 | +jdy-risk.scenarios[20].start-km-field=_widget_1767918395737 | ||
| 346 | +jdy-risk.scenarios[20].end-km-field=_widget_1767918395742 | ||
| 347 | +jdy-risk.scenarios[20].subform-field=_widget_1779416742817 | ||
| 348 | +jdy-risk.scenarios[20].subform-start-field=_widget_1779416742834 | ||
| 349 | +jdy-risk.scenarios[20].min-value=8 | ||
| 350 | +jdy-risk.scenarios[20].max-value=11 | ||
| 351 | +jdy-risk.scenarios[20].include-previous-row=true | ||
| 352 | + | ||
| 353 | +# ---------- Scenario 25: Transit fuel consumption (prev month, SYNC0015; Excel has current + previous) ---------- | ||
| 354 | +jdy-risk.scenarios[21].id=count_25 | ||
| 355 | +jdy-risk.scenarios[21].name=scene25 | ||
| 356 | +jdy-risk.scenarios[21].type=scenario20 | ||
| 357 | +jdy-risk.scenarios[21].sync-code=SYNC0015 | ||
| 358 | +jdy-risk.scenarios[21].app-id=6630634752eab8bdecbaee7d | ||
| 359 | +jdy-risk.scenarios[21].entry-id=695df62e76801137838d4785 | ||
| 360 | +jdy-risk.scenarios[21].date-field=_widget_1767769739507 | ||
| 361 | +jdy-risk.scenarios[21].half-month-only=true | ||
| 362 | +jdy-risk.scenarios[21].flow-state-value=1 | ||
| 363 | +jdy-risk.scenarios[21].flag-field=_widget_1779093489926 | ||
| 364 | +jdy-risk.scenarios[21].flag-values[0]=\u662f | ||
| 365 | +jdy-risk.scenarios[21].fuel-amount-field=_widget_1779093489925 | ||
| 366 | +jdy-risk.scenarios[21].start-km-field=_widget_1767921522987 | ||
| 367 | +jdy-risk.scenarios[21].end-km-field=_widget_1767921522988 | ||
| 368 | +jdy-risk.scenarios[21].subform-field=_widget_1779416742867 | ||
| 369 | +jdy-risk.scenarios[21].subform-start-field=_widget_1779416742869 | ||
| 370 | +jdy-risk.scenarios[21].min-value=9 | ||
| 371 | +jdy-risk.scenarios[21].max-value=16 | ||
| 372 | +jdy-risk.scenarios[21].include-previous-row=true | ||
| 373 | + | ||
| 374 | +# ---------- Scenario 26: labor company evaluation - bottom 3 for 3 consecutive months (SYNC0016) ---------- | ||
| 375 | +jdy-risk.scenarios[22].id=count_26 | ||
| 376 | +jdy-risk.scenarios[22].name=scene26 | ||
| 377 | +jdy-risk.scenarios[22].type=scenario21 | ||
| 378 | +jdy-risk.scenarios[22].sync-code=SYNC0016 | ||
| 379 | +jdy-risk.scenarios[22].app-id=689eb35228eeda25cbb2084e | ||
| 380 | +jdy-risk.scenarios[22].entry-id=69c4f27622c92f4b21be8d7e | ||
| 381 | +jdy-risk.scenarios[22].date-field=_widget_1774514807959 | ||
| 382 | +jdy-risk.scenarios[22].prev-three-months=true | ||
| 383 | +jdy-risk.scenarios[22].flag-field=_widget_1792396908333 | ||
| 384 | +jdy-risk.scenarios[22].flag-values[0]=\u662f | ||
| 385 | +jdy-risk.scenarios[22].bottom-count=3 | ||
| 386 | +jdy-risk.scenarios[22].company-fields[0]=_widget_1774514807956 | ||
| 387 | +jdy-risk.scenarios[22].company-fields[1]=_widget_1774581058600 | ||
| 388 | +jdy-risk.scenarios[22].company-fields[2]=_widget_1774581058602 | ||
| 389 | +jdy-risk.scenarios[22].company-fields[3]=_widget_1774581058603 | ||
| 390 | +jdy-risk.scenarios[22].company-fields[4]=_widget_1774581058604 | ||
| 391 | +jdy-risk.scenarios[22].company-fields[5]=_widget_1774581058605 | ||
| 392 | +jdy-risk.scenarios[22].company-fields[6]=_widget_1774581058606 | ||
| 393 | +jdy-risk.scenarios[22].company-fields[7]=_widget_1774581058601 | ||
| 394 | + | ||
| 395 | +# ---------- Scene 30: outsourced supplier avg score < 70 (year to date, SYNC0026) ---------- | ||
| 396 | +jdy-risk.scenarios[23].id=count_30 | ||
| 397 | +jdy-risk.scenarios[23].name=scene30 | ||
| 398 | +jdy-risk.scenarios[23].type=scenario23 | ||
| 399 | +jdy-risk.scenarios[23].sync-code=SYNC0026 | ||
| 400 | +jdy-risk.scenarios[23].app-id=6920308e1f3cd4a6f2d84ad7 | ||
| 401 | +jdy-risk.scenarios[23].entry-id=6a5ee84a23d9fee897a66f77 | ||
| 402 | +jdy-risk.scenarios[23].date-field=_widget_1784604746508 | ||
| 403 | +jdy-risk.scenarios[23].year-only=true | ||
| 404 | +jdy-risk.scenarios[23].group-field=_widget_1784604746504 | ||
| 405 | +jdy-risk.scenarios[23].score-field=_widget_1784604746509 | ||
| 406 | +jdy-risk.scenarios[23].avg-threshold=70 | ||
| 407 | + | ||
| 408 | +# ---------- Scene 31: month count <=3 and lag >=1 (prev quarter, SYNC0017) ---------- | ||
| 409 | +jdy-risk.scenarios[24].id=count_31 | ||
| 410 | +jdy-risk.scenarios[24].name=scene31 | ||
| 411 | +jdy-risk.scenarios[24].type=scenario24 | ||
| 412 | +jdy-risk.scenarios[24].sync-code=SYNC0017 | ||
| 413 | +jdy-risk.scenarios[24].app-id=6a335614b872e2fd8e9abbe0 | ||
| 414 | +jdy-risk.scenarios[24].entry-id=6a38e2205f7b92cf7e36bdfe | ||
| 415 | +jdy-risk.scenarios[24].date-field=_widget_1786946231912 | ||
| 416 | +jdy-risk.scenarios[24].prev-quarter-only=true | ||
| 417 | +jdy-risk.scenarios[24].plan-field=_widget_1786952804322 | ||
| 418 | +jdy-risk.scenarios[24].actual-field=_widget_1786946231912 | ||
| 419 | +jdy-risk.scenarios[24].lag-days=31 | ||
| 420 | +jdy-risk.scenarios[24].min-month-count=0 | ||
| 421 | +jdy-risk.scenarios[24].max-month-count=3 | ||
| 422 | +jdy-risk.scenarios[24].min-lag-count=1 | ||
| 423 | + | ||
| 424 | +# ---------- Scene 32: 3<count<=5 and lag >=2 (prev quarter, SYNC0018) ---------- | ||
| 425 | +jdy-risk.scenarios[25].id=count_32 | ||
| 426 | +jdy-risk.scenarios[25].name=scene32 | ||
| 427 | +jdy-risk.scenarios[25].type=scenario24 | ||
| 428 | +jdy-risk.scenarios[25].sync-code=SYNC0018 | ||
| 429 | +jdy-risk.scenarios[25].app-id=6a335614b872e2fd8e9abbe0 | ||
| 430 | +jdy-risk.scenarios[25].entry-id=6a38e2205f7b92cf7e36bdfe | ||
| 431 | +jdy-risk.scenarios[25].date-field=_widget_1786946231912 | ||
| 432 | +jdy-risk.scenarios[25].prev-quarter-only=true | ||
| 433 | +jdy-risk.scenarios[25].plan-field=_widget_1786952804322 | ||
| 434 | +jdy-risk.scenarios[25].actual-field=_widget_1786946231912 | ||
| 435 | +jdy-risk.scenarios[25].lag-days=31 | ||
| 436 | +jdy-risk.scenarios[25].min-month-count=4 | ||
| 437 | +jdy-risk.scenarios[25].max-month-count=5 | ||
| 438 | +jdy-risk.scenarios[25].min-lag-count=2 | ||
| 439 | + | ||
| 440 | +# ---------- Scene 33: 5<count<=10 and lag >=3 (prev quarter, SYNC0019) ---------- | ||
| 441 | +jdy-risk.scenarios[26].id=count_33 | ||
| 442 | +jdy-risk.scenarios[26].name=scene33 | ||
| 443 | +jdy-risk.scenarios[26].type=scenario24 | ||
| 444 | +jdy-risk.scenarios[26].sync-code=SYNC0019 | ||
| 445 | +jdy-risk.scenarios[26].app-id=6a335614b872e2fd8e9abbe0 | ||
| 446 | +jdy-risk.scenarios[26].entry-id=6a38e2205f7b92cf7e36bdfe | ||
| 447 | +jdy-risk.scenarios[26].date-field=_widget_1786946231912 | ||
| 448 | +jdy-risk.scenarios[26].prev-quarter-only=true | ||
| 449 | +jdy-risk.scenarios[26].plan-field=_widget_1786952804322 | ||
| 450 | +jdy-risk.scenarios[26].actual-field=_widget_1786946231912 | ||
| 451 | +jdy-risk.scenarios[26].lag-days=31 | ||
| 452 | +jdy-risk.scenarios[26].min-month-count=6 | ||
| 453 | +jdy-risk.scenarios[26].max-month-count=10 | ||
| 454 | +jdy-risk.scenarios[26].min-lag-count=3 | ||
| 455 | + | ||
| 456 | +# ---------- Scene 34: count>10 and lag >=4 (prev quarter, SYNC0020) ---------- | ||
| 457 | +jdy-risk.scenarios[27].id=count_34 | ||
| 458 | +jdy-risk.scenarios[27].name=scene34 | ||
| 459 | +jdy-risk.scenarios[27].type=scenario24 | ||
| 460 | +jdy-risk.scenarios[27].sync-code=SYNC0020 | ||
| 461 | +jdy-risk.scenarios[27].app-id=6a335614b872e2fd8e9abbe0 | ||
| 462 | +jdy-risk.scenarios[27].entry-id=6a38e2205f7b92cf7e36bdfe | ||
| 463 | +jdy-risk.scenarios[27].date-field=_widget_1786946231912 | ||
| 464 | +jdy-risk.scenarios[27].prev-quarter-only=true | ||
| 465 | +jdy-risk.scenarios[27].plan-field=_widget_1786952804322 | ||
| 466 | +jdy-risk.scenarios[27].actual-field=_widget_1786946231912 | ||
| 467 | +jdy-risk.scenarios[27].lag-days=31 | ||
| 468 | +jdy-risk.scenarios[27].min-month-count=11 | ||
| 469 | +jdy-risk.scenarios[27].max-month-count=2147483647 | ||
| 470 | +jdy-risk.scenarios[27].min-lag-count=4 | ||
| 471 | + | ||
| 472 | +# ---------- Scene 35: deviation (budget - winner)/budget >= 40% (prev quarter, SYNC0021) ---------- | ||
| 473 | +jdy-risk.scenarios[28].id=count_35 | ||
| 474 | +jdy-risk.scenarios[28].name=scene35 | ||
| 475 | +jdy-risk.scenarios[28].type=scenario25 | ||
| 476 | +jdy-risk.scenarios[28].sync-code=SYNC0021 | ||
| 477 | +jdy-risk.scenarios[28].app-id=6a335614b872e2fd8e9abbe0 | ||
| 478 | +jdy-risk.scenarios[28].entry-id=6a38e2205f7b92cf7e36bdfe | ||
| 479 | +jdy-risk.scenarios[28].date-field=_widget_1786946231912 | ||
| 480 | +jdy-risk.scenarios[28].prev-quarter-only=true | ||
| 481 | +jdy-risk.scenarios[28].budget-field=_widget_1787898949072 | ||
| 482 | +jdy-risk.scenarios[28].price-field=_widget_1787898949352 | ||
| 483 | +jdy-risk.scenarios[28].deviation-threshold=0.4 | ||
| 484 | + | ||
| 485 | +# ---------- Scene 36: urgent purchase frequency >= 2/quarter (prev quarter, SYNC0022) ---------- | ||
| 486 | +jdy-risk.scenarios[29].id=count_36 | ||
| 487 | +jdy-risk.scenarios[29].name=scene36 | ||
| 488 | +jdy-risk.scenarios[29].type=scenario26 | ||
| 489 | +jdy-risk.scenarios[29].sync-code=SYNC0022 | ||
| 490 | +jdy-risk.scenarios[29].app-id=6a335614b872e2fd8e9abbe0 | ||
| 491 | +jdy-risk.scenarios[29].entry-id=6a38e2205f7b92cf7e36bdfe | ||
| 492 | +jdy-risk.scenarios[29].date-field=_widget_1786946231912 | ||
| 493 | +jdy-risk.scenarios[29].prev-quarter-only=true | ||
| 494 | +jdy-risk.scenarios[29].flag-field=_widget_1787898948974 | ||
| 495 | +jdy-risk.scenarios[29].flag-values[0]=\u662f | ||
| 496 | +jdy-risk.scenarios[29].min-count=2 | ||
| 497 | + | ||
| 498 | +# ---------- Scene 37: contract change ratio by dept >= 10% (year, SYNC0023) ---------- | ||
| 499 | +jdy-risk.scenarios[30].id=count_37 | ||
| 500 | +jdy-risk.scenarios[30].name=scene37 | ||
| 501 | +jdy-risk.scenarios[30].type=scenario27 | ||
| 502 | +jdy-risk.scenarios[30].sync-code=SYNC0023 | ||
| 503 | +jdy-risk.scenarios[30].app-id=6a335614b872e2fd8e9abbe0 | ||
| 504 | +jdy-risk.scenarios[30].entry-id=6a38e2205f7b92cf7e36bdfe | ||
| 505 | +jdy-risk.scenarios[30].date-field=_widget_1786946231912 | ||
| 506 | +jdy-risk.scenarios[30].year-only=true | ||
| 507 | +jdy-risk.scenarios[30].group-field=_widget_1783666105578 | ||
| 508 | +jdy-risk.scenarios[30].flag-field=_widget_1787898949294 | ||
| 509 | +jdy-risk.scenarios[30].flag-values[0]=\u662f | ||
| 510 | +jdy-risk.scenarios[30].ratio-threshold=0.10 | ||
| 511 | + | ||
| 512 | +# ---------- Scene 28: assembly outsourcing settlement vs MES vs parts (prev month, SYNC0024) ---------- | ||
| 513 | +jdy-risk.scenarios[31].id=count_28 | ||
| 514 | +jdy-risk.scenarios[31].name=scene28 | ||
| 515 | +jdy-risk.scenarios[31].type=scenario22 | ||
| 516 | +jdy-risk.scenarios[31].sync-code=SYNC0024 | ||
| 517 | +jdy-risk.scenarios[31].app-id=6920308e1f3cd4a6f2d84ad7 | ||
| 518 | +jdy-risk.scenarios[31].entry-id=6a618c9323d9fee897f8ce78 | ||
| 519 | +jdy-risk.scenarios[31].date-field=_widget_1784777875854 | ||
| 520 | +jdy-risk.scenarios[31].qty-field=_widget_1784777875857 | ||
| 521 | +jdy-risk.scenarios[31].second-entry-id=6a618d14c0fa67afd96b121c | ||
| 522 | +jdy-risk.scenarios[31].second-date-field=_widget_1784778004826 | ||
| 523 | +jdy-risk.scenarios[31].second-qty-field=_widget_1784778004829 | ||
| 524 | + | ||
| 525 | +# ---------- Scene 29: Hefei warehouse receipt vs electrophoresis settlement (prev month, SYNC0025) ---------- | ||
| 526 | +jdy-risk.scenarios[32].id=count_29 | ||
| 527 | +jdy-risk.scenarios[32].name=scene29 | ||
| 528 | +jdy-risk.scenarios[32].type=scenario28 | ||
| 529 | +jdy-risk.scenarios[32].sync-code=SYNC0025 | ||
| 530 | +jdy-risk.scenarios[32].app-id=6920308e1f3cd4a6f2d84ad7 | ||
| 531 | +jdy-risk.scenarios[32].entry-id=69b0cefeebedeb1dbecca68d | ||
| 532 | +jdy-risk.scenarios[32].date-field=_widget_1773195006402 | ||
| 533 | +jdy-risk.scenarios[32].qty-field=_widget_1773195006403 | ||
| 534 | +jdy-risk.scenarios[32].second-entry-id=6a6074bb23d9fee897d951e1 | ||
| 535 | +jdy-risk.scenarios[32].second-date-field=_widget_1784706253892 | ||
| 536 | +jdy-risk.scenarios[32].second-qty-field=_widget_1773195006403 | ||
| 537 | +jdy-risk.scenarios[32].period-start-field=_widget_1784706253893 | ||
| 538 | +jdy-risk.scenarios[32].period-end-field=_widget_1784706253894 | ||
| 539 | + | ||
| 540 | +# ---------- Scene 38: claim process overdue > 30 days (prev month by end time, SYNC0036) ---------- | ||
| 541 | +jdy-risk.scenarios[33].id=count_38 | ||
| 542 | +jdy-risk.scenarios[33].name=scene38 | ||
| 543 | +jdy-risk.scenarios[33].type=scenario29 | ||
| 544 | +jdy-risk.scenarios[33].sync-code=SYNC0036 | ||
| 545 | +jdy-risk.scenarios[33].app-id=67dbb0e3045ce7a6eb1c0724 | ||
| 546 | +jdy-risk.scenarios[33].entry-id=67e6516a7d1f5a7bf76d63b4 | ||
| 547 | +jdy-risk.scenarios[33].date-field=_widget_1784547121026 | ||
| 548 | +jdy-risk.scenarios[33].start-field=_widget_1743147378939 | ||
| 549 | +jdy-risk.scenarios[33].threshold-days=30 | ||
| 550 | +jdy-risk.scenarios[33].prev-month-only=true | ||
| 551 | + | ||
| 552 | +# ---------- Scene 39: return amount TOP3 supplier (prev month, SYNC0027) ---------- | ||
| 553 | +jdy-risk.scenarios[34].id=count_39 | ||
| 554 | +jdy-risk.scenarios[34].name=scene39 | ||
| 555 | +jdy-risk.scenarios[34].type=scenario30 | ||
| 556 | +jdy-risk.scenarios[34].sync-code=SYNC0027 | ||
| 557 | +jdy-risk.scenarios[34].app-id=67bbd034121d45bf2beb0b37 | ||
| 558 | +jdy-risk.scenarios[34].entry-id=6a66fec4d8d61cd5201ce214 | ||
| 559 | +jdy-risk.scenarios[34].subform-field=_widget_1785134788742 | ||
| 560 | +jdy-risk.scenarios[34].sub-part-field=_widget_1785134788744 | ||
| 561 | +jdy-risk.scenarios[34].sub-qty-field=_widget_1785134788745 | ||
| 562 | +jdy-risk.scenarios[34].sub-date-field=_widget_1785134788746 | ||
| 563 | +jdy-risk.scenarios[34].rel-entry-id=6a670697bccb96b113bb8dec | ||
| 564 | +jdy-risk.scenarios[34].rel-part-field=_widget_1785136791804 | ||
| 565 | +jdy-risk.scenarios[34].rel-supplier-field=_widget_1785136791807 | ||
| 566 | +jdy-risk.scenarios[34].rel-enable-field=_widget_1785136791808 | ||
| 567 | +jdy-risk.scenarios[34].rel-time-field=_widget_1785136791809 | ||
| 568 | +jdy-risk.scenarios[34].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 569 | +jdy-risk.scenarios[34].cost-code-field=_widget_1785137897089 | ||
| 570 | +jdy-risk.scenarios[34].cost-value-field=_widget_1785137897094 | ||
| 571 | +jdy-risk.scenarios[34].top-count=3 | ||
| 572 | + | ||
| 573 | +# ---------- Scene 40: return quantity TOP3 supplier (prev month, SYNC0028) ---------- | ||
| 574 | +jdy-risk.scenarios[35].id=count_40 | ||
| 575 | +jdy-risk.scenarios[35].name=scene40 | ||
| 576 | +jdy-risk.scenarios[35].type=scenario31 | ||
| 577 | +jdy-risk.scenarios[35].sync-code=SYNC0028 | ||
| 578 | +jdy-risk.scenarios[35].app-id=67bbd034121d45bf2beb0b37 | ||
| 579 | +jdy-risk.scenarios[35].entry-id=6a66fec4d8d61cd5201ce214 | ||
| 580 | +jdy-risk.scenarios[35].subform-field=_widget_1785134788742 | ||
| 581 | +jdy-risk.scenarios[35].sub-part-field=_widget_1785134788744 | ||
| 582 | +jdy-risk.scenarios[35].sub-qty-field=_widget_1785134788745 | ||
| 583 | +jdy-risk.scenarios[35].sub-date-field=_widget_1785134788746 | ||
| 584 | +jdy-risk.scenarios[35].rel-entry-id=6a670697bccb96b113bb8dec | ||
| 585 | +jdy-risk.scenarios[35].rel-part-field=_widget_1785136791804 | ||
| 586 | +jdy-risk.scenarios[35].rel-supplier-field=_widget_1785136791807 | ||
| 587 | +jdy-risk.scenarios[35].rel-enable-field=_widget_1785136791808 | ||
| 588 | +jdy-risk.scenarios[35].rel-time-field=_widget_1785136791809 | ||
| 589 | +jdy-risk.scenarios[35].top-count=3 | ||
| 590 | + | ||
| 591 | +# ---------- Scene 41: stock amount vs indicator - assembly 88013131 (SYNC0029) ---------- | ||
| 592 | +jdy-risk.scenarios[36].id=count_41 | ||
| 593 | +jdy-risk.scenarios[36].name=scene41 | ||
| 594 | +jdy-risk.scenarios[36].type=scenario32 | ||
| 595 | +jdy-risk.scenarios[36].sync-code=SYNC0029 | ||
| 596 | +jdy-risk.scenarios[36].app-id=67bbd034121d45bf2beb0b37 | ||
| 597 | +jdy-risk.scenarios[36].entry-id=6a670eaab0cfb7d56e1ad94c | ||
| 598 | +jdy-risk.scenarios[36].indicator-code-field=_widget_1785138858238 | ||
| 599 | +jdy-risk.scenarios[36].indicator-target-field=_widget_1785138858240 | ||
| 600 | +jdy-risk.scenarios[36].stock-entry-id=6ad9d06e9813efd5d7d5c5bc | ||
| 601 | +jdy-risk.scenarios[36].stock-month-field=_widget_1793087125262 | ||
| 602 | +jdy-risk.scenarios[36].stock-part-field=_widget_1792659566889 | ||
| 603 | +jdy-risk.scenarios[36].stock-qty-field=_widget_1792659566891 | ||
| 604 | +jdy-risk.scenarios[36].stock-warehouse-field=_widget_1792659566894 | ||
| 605 | +jdy-risk.scenarios[36].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 606 | +jdy-risk.scenarios[36].cost-code-field=_widget_1785137897089 | ||
| 607 | +jdy-risk.scenarios[36].cost-value-field=_widget_1785137897094 | ||
| 608 | +jdy-risk.scenarios[36].aixin-entry-id=6a670f5f9a2a280f6edf4a43 | ||
| 609 | +jdy-risk.scenarios[36].aixin-part-field=_widget_1785139039673 | ||
| 610 | +jdy-risk.scenarios[36].warehouse-code=88013131 | ||
| 611 | +jdy-risk.scenarios[36].prev-month-only=true | ||
| 612 | + | ||
| 613 | +# ---------- Scene 42: stock amount vs indicator - assembly phase2 4020068131 (SYNC0030) ---------- | ||
| 614 | +jdy-risk.scenarios[37].id=count_42 | ||
| 615 | +jdy-risk.scenarios[37].name=scene42 | ||
| 616 | +jdy-risk.scenarios[37].type=scenario32 | ||
| 617 | +jdy-risk.scenarios[37].sync-code=SYNC0030 | ||
| 618 | +jdy-risk.scenarios[37].app-id=67bbd034121d45bf2beb0b37 | ||
| 619 | +jdy-risk.scenarios[37].entry-id=6a670eaab0cfb7d56e1ad94c | ||
| 620 | +jdy-risk.scenarios[37].indicator-code-field=_widget_1785138858238 | ||
| 621 | +jdy-risk.scenarios[37].indicator-target-field=_widget_1785138858240 | ||
| 622 | +jdy-risk.scenarios[37].stock-entry-id=6ad9d06e9813efd5d7d5c5bc | ||
| 623 | +jdy-risk.scenarios[37].stock-month-field=_widget_1793087125262 | ||
| 624 | +jdy-risk.scenarios[37].stock-part-field=_widget_1792659566889 | ||
| 625 | +jdy-risk.scenarios[37].stock-qty-field=_widget_1792659566891 | ||
| 626 | +jdy-risk.scenarios[37].stock-warehouse-field=_widget_1792659566894 | ||
| 627 | +jdy-risk.scenarios[37].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 628 | +jdy-risk.scenarios[37].cost-code-field=_widget_1785137897089 | ||
| 629 | +jdy-risk.scenarios[37].cost-value-field=_widget_1785137897094 | ||
| 630 | +jdy-risk.scenarios[37].aixin-entry-id=6a670f5f9a2a280f6edf4a43 | ||
| 631 | +jdy-risk.scenarios[37].aixin-part-field=_widget_1785139039673 | ||
| 632 | +jdy-risk.scenarios[37].warehouse-code=4020068131 | ||
| 633 | +jdy-risk.scenarios[37].prev-month-only=true | ||
| 634 | + | ||
| 635 | +# ---------- Scene 43: stock amount vs indicator - paint 88012131 (SYNC0031) ---------- | ||
| 636 | +jdy-risk.scenarios[38].id=count_43 | ||
| 637 | +jdy-risk.scenarios[38].name=scene43 | ||
| 638 | +jdy-risk.scenarios[38].type=scenario32 | ||
| 639 | +jdy-risk.scenarios[38].sync-code=SYNC0031 | ||
| 640 | +jdy-risk.scenarios[38].app-id=67bbd034121d45bf2beb0b37 | ||
| 641 | +jdy-risk.scenarios[38].entry-id=6a670eaab0cfb7d56e1ad94c | ||
| 642 | +jdy-risk.scenarios[38].indicator-code-field=_widget_1785138858238 | ||
| 643 | +jdy-risk.scenarios[38].indicator-target-field=_widget_1785138858240 | ||
| 644 | +jdy-risk.scenarios[38].stock-entry-id=6ad9d06e9813efd5d7d5c5bc | ||
| 645 | +jdy-risk.scenarios[38].stock-month-field=_widget_1793087125262 | ||
| 646 | +jdy-risk.scenarios[38].stock-part-field=_widget_1792659566889 | ||
| 647 | +jdy-risk.scenarios[38].stock-qty-field=_widget_1792659566891 | ||
| 648 | +jdy-risk.scenarios[38].stock-warehouse-field=_widget_1792659566894 | ||
| 649 | +jdy-risk.scenarios[38].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 650 | +jdy-risk.scenarios[38].cost-code-field=_widget_1785137897089 | ||
| 651 | +jdy-risk.scenarios[38].cost-value-field=_widget_1785137897094 | ||
| 652 | +jdy-risk.scenarios[38].warehouse-code=88012131 | ||
| 653 | +jdy-risk.scenarios[38].prev-month-only=true | ||
| 654 | + | ||
| 655 | +# ---------- Scene 44: stock amount vs indicator - paint phase2 4020067131 (SYNC0032) ---------- | ||
| 656 | +jdy-risk.scenarios[39].id=count_44 | ||
| 657 | +jdy-risk.scenarios[39].name=scene44 | ||
| 658 | +jdy-risk.scenarios[39].type=scenario32 | ||
| 659 | +jdy-risk.scenarios[39].sync-code=SYNC0032 | ||
| 660 | +jdy-risk.scenarios[39].app-id=67bbd034121d45bf2beb0b37 | ||
| 661 | +jdy-risk.scenarios[39].entry-id=6a670eaab0cfb7d56e1ad94c | ||
| 662 | +jdy-risk.scenarios[39].indicator-code-field=_widget_1785138858238 | ||
| 663 | +jdy-risk.scenarios[39].indicator-target-field=_widget_1785138858240 | ||
| 664 | +jdy-risk.scenarios[39].stock-entry-id=6ad9d06e9813efd5d7d5c5bc | ||
| 665 | +jdy-risk.scenarios[39].stock-month-field=_widget_1793087125262 | ||
| 666 | +jdy-risk.scenarios[39].stock-part-field=_widget_1792659566889 | ||
| 667 | +jdy-risk.scenarios[39].stock-qty-field=_widget_1792659566891 | ||
| 668 | +jdy-risk.scenarios[39].stock-warehouse-field=_widget_1792659566894 | ||
| 669 | +jdy-risk.scenarios[39].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 670 | +jdy-risk.scenarios[39].cost-code-field=_widget_1785137897089 | ||
| 671 | +jdy-risk.scenarios[39].cost-value-field=_widget_1785137897094 | ||
| 672 | +jdy-risk.scenarios[39].warehouse-code=4020067131 | ||
| 673 | +jdy-risk.scenarios[39].prev-month-only=true | ||
| 674 | + | ||
| 675 | +# ---------- Scene 45: stock amount vs indicator - weld 88011131 (SYNC0033) ---------- | ||
| 676 | +jdy-risk.scenarios[40].id=count_45 | ||
| 677 | +jdy-risk.scenarios[40].name=scene45 | ||
| 678 | +jdy-risk.scenarios[40].type=scenario32 | ||
| 679 | +jdy-risk.scenarios[40].sync-code=SYNC0033 | ||
| 680 | +jdy-risk.scenarios[40].app-id=67bbd034121d45bf2beb0b37 | ||
| 681 | +jdy-risk.scenarios[40].entry-id=6a670eaab0cfb7d56e1ad94c | ||
| 682 | +jdy-risk.scenarios[40].indicator-code-field=_widget_1785138858238 | ||
| 683 | +jdy-risk.scenarios[40].indicator-target-field=_widget_1785138858240 | ||
| 684 | +jdy-risk.scenarios[40].stock-entry-id=6ad9d06e9813efd5d7d5c5bc | ||
| 685 | +jdy-risk.scenarios[40].stock-month-field=_widget_1793087125262 | ||
| 686 | +jdy-risk.scenarios[40].stock-part-field=_widget_1792659566889 | ||
| 687 | +jdy-risk.scenarios[40].stock-qty-field=_widget_1792659566891 | ||
| 688 | +jdy-risk.scenarios[40].stock-warehouse-field=_widget_1792659566894 | ||
| 689 | +jdy-risk.scenarios[40].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 690 | +jdy-risk.scenarios[40].cost-code-field=_widget_1785137897089 | ||
| 691 | +jdy-risk.scenarios[40].cost-value-field=_widget_1785137897094 | ||
| 692 | +jdy-risk.scenarios[40].warehouse-code=88011131 | ||
| 693 | +jdy-risk.scenarios[40].prev-month-only=true | ||
| 694 | + | ||
| 695 | +# ---------- Scene 46: stock amount vs indicator - weld phase2 4020066131 (SYNC0034) ---------- | ||
| 696 | +jdy-risk.scenarios[41].id=count_46 | ||
| 697 | +jdy-risk.scenarios[41].name=scene46 | ||
| 698 | +jdy-risk.scenarios[41].type=scenario32 | ||
| 699 | +jdy-risk.scenarios[41].sync-code=SYNC0034 | ||
| 700 | +jdy-risk.scenarios[41].app-id=67bbd034121d45bf2beb0b37 | ||
| 701 | +jdy-risk.scenarios[41].entry-id=6a670eaab0cfb7d56e1ad94c | ||
| 702 | +jdy-risk.scenarios[41].indicator-code-field=_widget_1785138858238 | ||
| 703 | +jdy-risk.scenarios[41].indicator-target-field=_widget_1785138858240 | ||
| 704 | +jdy-risk.scenarios[41].stock-entry-id=6ad9d06e9813efd5d7d5c5bc | ||
| 705 | +jdy-risk.scenarios[41].stock-month-field=_widget_1793087125262 | ||
| 706 | +jdy-risk.scenarios[41].stock-part-field=_widget_1792659566889 | ||
| 707 | +jdy-risk.scenarios[41].stock-qty-field=_widget_1792659566891 | ||
| 708 | +jdy-risk.scenarios[41].stock-warehouse-field=_widget_1792659566894 | ||
| 709 | +jdy-risk.scenarios[41].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 710 | +jdy-risk.scenarios[41].cost-code-field=_widget_1785137897089 | ||
| 711 | +jdy-risk.scenarios[41].cost-value-field=_widget_1785137897094 | ||
| 712 | +jdy-risk.scenarios[41].warehouse-code=4020066131 | ||
| 713 | +jdy-risk.scenarios[41].prev-month-only=true | ||
| 714 | + | ||
| 715 | +# ---------- Scene 47: stock amount vs indicator - stamping 88014131 (SYNC0035) ---------- | ||
| 716 | +jdy-risk.scenarios[42].id=count_47 | ||
| 717 | +jdy-risk.scenarios[42].name=scene47 | ||
| 718 | +jdy-risk.scenarios[42].type=scenario32 | ||
| 719 | +jdy-risk.scenarios[42].sync-code=SYNC0035 | ||
| 720 | +jdy-risk.scenarios[42].app-id=67bbd034121d45bf2beb0b37 | ||
| 721 | +jdy-risk.scenarios[42].entry-id=6a670eaab0cfb7d56e1ad94c | ||
| 722 | +jdy-risk.scenarios[42].indicator-code-field=_widget_1785138858238 | ||
| 723 | +jdy-risk.scenarios[42].indicator-target-field=_widget_1785138858240 | ||
| 724 | +jdy-risk.scenarios[42].stock-entry-id=6ad9d06e9813efd5d7d5c5bc | ||
| 725 | +jdy-risk.scenarios[42].stock-month-field=_widget_1793087125262 | ||
| 726 | +jdy-risk.scenarios[42].stock-part-field=_widget_1792659566889 | ||
| 727 | +jdy-risk.scenarios[42].stock-qty-field=_widget_1792659566891 | ||
| 728 | +jdy-risk.scenarios[42].stock-warehouse-field=_widget_1792659566894 | ||
| 729 | +jdy-risk.scenarios[42].cost-entry-id=6a670ae91c55b87fcd211c5e | ||
| 730 | +jdy-risk.scenarios[42].cost-code-field=_widget_1785137897089 | ||
| 731 | +jdy-risk.scenarios[42].cost-value-field=_widget_1785137897094 | ||
| 732 | +jdy-risk.scenarios[42].warehouse-code=88014131 | ||
| 733 | +jdy-risk.scenarios[42].prev-month-only=true | ||
| 734 | + | ||
| 735 | +# ---------- Scene 20: waste warning stat - unhandled (Kingbase, SYNC0039) ---------- | ||
| 736 | +jdy-risk.scenarios[43].id=count_20 | ||
| 737 | +jdy-risk.scenarios[43].name=scene20 | ||
| 738 | +jdy-risk.scenarios[43].type=scenario33 | ||
| 739 | +jdy-risk.scenarios[43].sync-code=SYNC0039 | ||
| 740 | +jdy-risk.scenarios[43].table=biz_waste_warn_stat | ||
| 741 | +jdy-risk.scenarios[43].handle-field=handle_status | ||
| 742 | +jdy-risk.scenarios[43].handle-values[0]=\u672a\u5904\u7406 | ||
| 743 | +jdy-risk.scenarios[43].handle-values[1]=\u672a\u5904\u7f6e | ||
| 744 | +jdy-risk.scenarios[43].stat-year-field=stat_year | ||
| 745 | +jdy-risk.scenarios[43].stat-month-field=stat_month | ||
| 746 | +jdy-risk.scenarios[43].columns[0]=org_name | ||
| 747 | +jdy-risk.scenarios[43].columns[1]=category_name | ||
| 748 | +jdy-risk.scenarios[43].columns[2]=stat_year | ||
| 749 | +jdy-risk.scenarios[43].columns[3]=stat_month | ||
| 750 | +jdy-risk.scenarios[43].columns[4]=waste_weight | ||
| 751 | +jdy-risk.scenarios[43].columns[5]=erp_finish_qty | ||
| 752 | +jdy-risk.scenarios[43].columns[6]=weigh_weight | ||
| 753 | +jdy-risk.scenarios[43].columns[7]=over_weight | ||
| 754 | +jdy-risk.scenarios[43].columns[8]=warn_threshold | ||
| 755 | +jdy-risk.scenarios[43].columns[9]=actual_ratio | ||
| 756 | +jdy-risk.scenarios[43].columns[10]=handle_status | ||
| 757 | +jdy-risk.scenarios[43].columns[11]=is_alarm | ||
| 758 | +jdy-risk.scenarios[43].columns[12]=warn_notice_user | ||
| 759 | +jdy-risk.scenarios[43].columns[13]=create_time | ||
| 760 | +jdy-risk.scenarios[43].columns[14]=dispose_user | ||
| 761 | +jdy-risk.scenarios[43].columns[15]=dispose_time | ||
| 762 | +jdy-risk.scenarios[43].columns[16]=fill_reason | ||
| 763 | +jdy-risk.scenarios[43].column-labels.org_name=\u5355\u4f4d\u540d\u79f0 | ||
| 764 | +jdy-risk.scenarios[43].column-labels.category_name=\u5e9f\u6599\u7c7b\u522b | ||
| 765 | +jdy-risk.scenarios[43].column-labels.stat_year=\u7edf\u8ba1\u5e74 | ||
| 766 | +jdy-risk.scenarios[43].column-labels.stat_month=\u7edf\u8ba1\u6708 | ||
| 767 | +jdy-risk.scenarios[43].column-labels.waste_weight=\u5e9f\u6599\u91cd\u91cf | ||
| 768 | +jdy-risk.scenarios[43].column-labels.erp_finish_qty=ERP\u5b8c\u5de5\u6570\u91cf | ||
| 769 | +jdy-risk.scenarios[43].column-labels.weigh_weight=\u8fc7\u78c5\u91cd\u91cf | ||
| 770 | +jdy-risk.scenarios[43].column-labels.over_weight=\u8d85\u51fa\u91cd\u91cf | ||
| 771 | +jdy-risk.scenarios[43].column-labels.warn_threshold=\u9884\u8b66\u9608\u503c | ||
| 772 | +jdy-risk.scenarios[43].column-labels.actual_ratio=\u5b9e\u9645\u6bd4\u4f8b | ||
| 773 | +jdy-risk.scenarios[43].column-labels.handle_status=\u5904\u7406\u72b6\u6001 | ||
| 774 | +jdy-risk.scenarios[43].column-labels.is_alarm=\u662f\u5426\u62a5\u8b66 | ||
| 775 | +jdy-risk.scenarios[43].column-labels.warn_notice_user=\u9884\u8b66\u901a\u77e5\u4eba | ||
| 776 | +jdy-risk.scenarios[43].column-labels.create_time=\u521b\u5efa\u65f6\u95f4 | ||
| 777 | +jdy-risk.scenarios[43].column-labels.dispose_user=\u5904\u7406\u4eba | ||
| 778 | +jdy-risk.scenarios[43].column-labels.dispose_time=\u5904\u7406\u65f6\u95f4 | ||
| 779 | +jdy-risk.scenarios[43].column-labels.fill_reason=\u586b\u5199\u539f\u56e0 | ||
| 780 | + | ||
| 781 | +# ---------- Scene 21: weight record - unhandled (Kingbase, SYNC0040) ---------- | ||
| 782 | +jdy-risk.scenarios[44].id=count_21 | ||
| 783 | +jdy-risk.scenarios[44].name=scene21 | ||
| 784 | +jdy-risk.scenarios[44].type=scenario34 | ||
| 785 | +jdy-risk.scenarios[44].sync-code=SYNC0040 | ||
| 786 | +jdy-risk.scenarios[44].table=biz_weight_record | ||
| 787 | +jdy-risk.scenarios[44].date-field=weight_time | ||
| 788 | +jdy-risk.scenarios[44].handle-field=is_handled | ||
| 789 | +jdy-risk.scenarios[44].handle-values[0]=3 | ||
| 790 | +jdy-risk.scenarios[44].handle-values[1]=\u672a\u5904\u7406 | ||
| 791 | +jdy-risk.scenarios[44].handle-values[2]=\u672a\u5904\u7f6e | ||
| 792 | +jdy-risk.scenarios[44].handle-value-labels.3=\u672a\u5904\u7406 | ||
| 793 | +jdy-risk.scenarios[44].columns[0]=weight_serial_no | ||
| 794 | +jdy-risk.scenarios[44].columns[1]=delivery_unit | ||
| 795 | +jdy-risk.scenarios[44].columns[2]=tare_weight | ||
| 796 | +jdy-risk.scenarios[44].columns[3]=net_weight | ||
| 797 | +jdy-risk.scenarios[44].columns[4]=unit | ||
| 798 | +jdy-risk.scenarios[44].columns[5]=weight_time | ||
| 799 | +jdy-risk.scenarios[44].columns[6]=deviation_weight | ||
| 800 | +jdy-risk.scenarios[44].columns[7]=plate_no | ||
| 801 | +jdy-risk.scenarios[44].columns[8]=base_weight | ||
| 802 | +jdy-risk.scenarios[44].columns[9]=is_handled | ||
| 803 | +jdy-risk.scenarios[44].columns[10]=warn_value | ||
| 804 | +jdy-risk.scenarios[44].columns[11]=org_code | ||
| 805 | +jdy-risk.scenarios[44].column-labels.weight_serial_no=\u8fc7\u78c5\u6d41\u6c34\u53f7 | ||
| 806 | +jdy-risk.scenarios[44].column-labels.delivery_unit=\u9001\u8d27\u5355\u4f4d | ||
| 807 | +jdy-risk.scenarios[44].column-labels.tare_weight=\u76ae\u91cd | ||
| 808 | +jdy-risk.scenarios[44].column-labels.net_weight=\u51c0\u91cd | ||
| 809 | +jdy-risk.scenarios[44].column-labels.unit=\u5355\u4f4d | ||
| 810 | +jdy-risk.scenarios[44].column-labels.weight_time=\u8fc7\u78c5\u65f6\u95f4 | ||
| 811 | +jdy-risk.scenarios[44].column-labels.deviation_weight=\u504f\u5dee\u91cd\u91cf | ||
| 812 | +jdy-risk.scenarios[44].column-labels.plate_no=\u8f66\u724c\u53f7 | ||
| 813 | +jdy-risk.scenarios[44].column-labels.base_weight=\u57fa\u51c6\u91cd\u91cf | ||
| 814 | +jdy-risk.scenarios[44].column-labels.is_handled=\u5904\u7406\u72b6\u6001 | ||
| 815 | +jdy-risk.scenarios[44].column-labels.warn_value=\u9884\u8b66\u503c | ||
| 816 | +jdy-risk.scenarios[44].column-labels.org_code=\u5355\u4f4d\u7f16\u7801 | ||
| 817 | + | ||
| 818 | +# ---------- Scene 22: transport weight exception - unhandled (Kingbase, SYNC0041) ---------- | ||
| 819 | +jdy-risk.scenarios[45].id=count_22 | ||
| 820 | +jdy-risk.scenarios[45].name=scene22 | ||
| 821 | +jdy-risk.scenarios[45].type=scenario35 | ||
| 822 | +jdy-risk.scenarios[45].sync-code=SYNC0041 | ||
| 823 | +jdy-risk.scenarios[45].table=biz_weight_trans_exception | ||
| 824 | +jdy-risk.scenarios[45].date-field=weight_time | ||
| 825 | +jdy-risk.scenarios[45].handle-field=is_handled | ||
| 826 | +jdy-risk.scenarios[45].handle-values[0]=\u672a\u5904\u7406 | ||
| 827 | +jdy-risk.scenarios[45].handle-values[1]=\u672a\u5904\u7f6e | ||
| 828 | +jdy-risk.scenarios[45].columns[0]=org_name | ||
| 829 | +jdy-risk.scenarios[45].columns[1]=transport_unit | ||
| 830 | +jdy-risk.scenarios[45].columns[2]=tare_weight | ||
| 831 | +jdy-risk.scenarios[45].columns[3]=net_weight | ||
| 832 | +jdy-risk.scenarios[45].columns[4]=deviation_weight | ||
| 833 | +jdy-risk.scenarios[45].columns[5]=weight_time | ||
| 834 | +jdy-risk.scenarios[45].columns[6]=plate_no | ||
| 835 | +jdy-risk.scenarios[45].columns[7]=material_name | ||
| 836 | +jdy-risk.scenarios[45].columns[8]=lower_limit | ||
| 837 | +jdy-risk.scenarios[45].columns[9]=is_handled | ||
| 838 | +jdy-risk.scenarios[45].columns[10]=exception_desc | ||
| 839 | +jdy-risk.scenarios[45].column-labels.org_name=\u5355\u4f4d\u540d\u79f0 | ||
| 840 | +jdy-risk.scenarios[45].column-labels.transport_unit=\u8fd0\u8f93\u5355\u4f4d | ||
| 841 | +jdy-risk.scenarios[45].column-labels.tare_weight=\u76ae\u91cd | ||
| 842 | +jdy-risk.scenarios[45].column-labels.net_weight=\u51c0\u91cd | ||
| 843 | +jdy-risk.scenarios[45].column-labels.deviation_weight=\u504f\u5dee\u91cd\u91cf | ||
| 844 | +jdy-risk.scenarios[45].column-labels.weight_time=\u8fc7\u78c5\u65f6\u95f4 | ||
| 845 | +jdy-risk.scenarios[45].column-labels.plate_no=\u8f66\u724c\u53f7 | ||
| 846 | +jdy-risk.scenarios[45].column-labels.material_name=\u7269\u6599\u540d\u79f0 | ||
| 847 | +jdy-risk.scenarios[45].column-labels.lower_limit=\u4e0b\u9650\u503c | ||
| 848 | +jdy-risk.scenarios[45].column-labels.is_handled=\u5904\u7406\u72b6\u6001 | ||
| 849 | +jdy-risk.scenarios[45].column-labels.exception_desc=\u5f02\u5e38\u8bf4\u660e | ||
| 850 | + | ||
| 851 | +# ---------- Customer Kingbase ES DB (device domain scenes 20/21/22) ---------- | ||
| 852 | +jdy-risk.kingbase.url=jdbc:kingbase8://10.144.201.35:54321/qixiao-apaas | ||
| 853 | +jdy-risk.kingbase.username=qixiaoadmin | ||
| 854 | +jdy-risk.kingbase.password=Qx@20260821.com | ||
| 855 | +jdy-risk.kingbase.driver-class=com.kingbase8.Driver | ||
| 856 | + | ||
| 857 | +# ---------- Customer MES middle DB (Oracle, scene 28) ---------- | ||
| 858 | +jdy-risk.mes.url=jdbc:oracle:thin:@//10.144.200.229:1521/HFMESMID | ||
| 859 | +jdy-risk.mes.username=ZHIOP_MES | ||
| 860 | +jdy-risk.mes.password=ZHIOP_MES@2026 | ||
| 861 | + | ||
| 862 | +# ---------- Risk scenario scheduled tasks ---------- | ||
| 863 | +jdy-risk.schedule.enabled=true | ||
| 864 | +jdy-risk.schedule.s1-cron=0 0 3 20 * ? | ||
| 865 | +jdy-risk.schedule.s2-cron=0 0 3 5 * ? | ||
| 866 | +jdy-risk.schedule.s3-cron=0 0 3 5 * ? | ||
| 867 | +jdy-risk.schedule.s4-cron=0 0 3 5 1,4,7,10 ? | ||
| 868 | +jdy-risk.schedule.s5-cron=0 0 3 5 1,4,7,10 ? | ||
| 869 | +jdy-risk.schedule.s6-cron=0 0 23 * * ? | ||
| 870 | +jdy-risk.schedule.s7-cron=0 0 3 5 * ? | ||
| 871 | +jdy-risk.schedule.s8-cron=0 0 3 5 * ? | ||
| 872 | +jdy-risk.schedule.s9-cron=0 0 3 5 * ? | ||
| 873 | +jdy-risk.schedule.s10-cron=0 0 3 5 * ? | ||
| 874 | +jdy-risk.schedule.s12-cron=0 0 3 1 * ? | ||
| 875 | +jdy-risk.schedule.s13-cron=0 0 3 10 * ? | ||
| 876 | +jdy-risk.schedule.s14-cron=0 0 3 20 12 ? | ||
| 877 | +jdy-risk.schedule.s15-cron=0 0 3 1 * ? | ||
| 878 | +jdy-risk.schedule.s16-cron=0 0 23 * * ? | ||
| 879 | +jdy-risk.schedule.s17-cron=0 0 3 1 * ? | ||
| 880 | +jdy-risk.schedule.s18-cron=0 0 23 * * ? | ||
| 881 | +jdy-risk.schedule.s19-cron=0 0 1 1 * ? | ||
| 882 | +jdy-risk.schedule.s20-cron=0 0 1 12 * ? | ||
| 883 | +jdy-risk.schedule.s21a-cron=0 0 1 11 * ? | ||
| 884 | +jdy-risk.schedule.s21b-cron=0 0 1 21 * ? | ||
| 885 | +jdy-risk.schedule.s21c-cron=0 0 23 * * ? | ||
| 886 | +jdy-risk.schedule.s22-cron=0 0 1 1 * ? | ||
| 887 | +jdy-risk.schedule.s23-cron=0 0 1 1,16 * ? | ||
| 888 | +jdy-risk.schedule.s24-cron=0 0 1 1,16 * ? | ||
| 889 | +jdy-risk.schedule.s25-cron=0 0 1 1,16 * ? | ||
| 890 | +jdy-risk.schedule.s26-cron=0 0 1 1 * ? | ||
| 891 | +jdy-risk.schedule.s30-cron=0 0 23 * * ? | ||
| 892 | +jdy-risk.schedule.s31-cron=0 0 1 1 1,4,7,10 ? | ||
| 893 | +jdy-risk.schedule.s32-cron=0 0 1 1 1,4,7,10 ? | ||
| 894 | +jdy-risk.schedule.s33-cron=0 0 1 1 1,4,7,10 ? | ||
| 895 | +jdy-risk.schedule.s34-cron=0 0 1 1 1,4,7,10 ? | ||
| 896 | +jdy-risk.schedule.s35-cron=0 0 1 1 1,4,7,10 ? | ||
| 897 | +jdy-risk.schedule.s36-cron=0 0 1 1 1,4,7,10 ? | ||
| 898 | +jdy-risk.schedule.s37-cron=0 0 23 31 12 ? | ||
| 899 | +jdy-risk.schedule.s38-cron=0 0 3 10 * ? | ||
| 900 | +jdy-risk.schedule.s39-cron=0 0 3 5 * ? | ||
| 901 | +jdy-risk.schedule.s40-cron=0 0 3 5 * ? | ||
| 902 | +jdy-risk.schedule.s41-cron=0 0 3 5 * ? | ||
| 903 | +jdy-risk.schedule.s42-cron=0 0 3 5 * ? | ||
| 904 | +jdy-risk.schedule.s43-cron=0 0 3 5 * ? | ||
| 905 | +jdy-risk.schedule.s44-cron=0 0 3 5 * ? | ||
| 906 | +jdy-risk.schedule.s45-cron=0 0 3 5 * ? | ||
| 907 | +jdy-risk.schedule.s46-cron=0 0 3 5 * ? | ||
| 908 | +jdy-risk.schedule.s47-cron=0 0 3 5 * ? | ||
| 156 | 909 | ||
| 157 | # ============================================================================= | 910 | # ============================================================================= |
| 158 | -# 表单同步配置(简道云表单结构/数据 -> 启效指定应用) | ||
| 159 | -# 结构同步接口:POST /api/jdy/form/sync-structure | ||
| 160 | -# 数据同步接口:POST /api/jdy/form/sync-data(当月数据,当天已存在则先删当天再同步) | ||
| 161 | -# 新增表单:复制一段 jdy-form-sync.forms[n].xxx,n 递增 | 911 | +# Form sync configuration |
| 162 | # ============================================================================= | 912 | # ============================================================================= |
| 163 | jdy-form-sync.jdy.host=https://jdy.changan.com.cn/api | 913 | jdy-form-sync.jdy.host=https://jdy.changan.com.cn/api |
| 164 | jdy-form-sync.jdy.api-key=lOnr4ms8jfc0gbCwVYS7YtbYQXjBFq979Cc06BcC866427b2a7aAd054598Bc7bB | 914 | jdy-form-sync.jdy.api-key=lOnr4ms8jfc0gbCwVYS7YtbYQXjBFq979Cc06BcC866427b2a7aAd054598Bc7bB |
| 165 | -# 可选:指定同步月份(yyyy-MM)用于补数/测试;留空=当前自然月(仅 month-only=true 时生效) | ||
| 166 | -# jdy-form-sync.month=2026-08 | ||
| 167 | -# Excel 导出目录(相对 jar 运行目录) | ||
| 168 | jdy-form-sync.export-dir=./export | 915 | jdy-form-sync.export-dir=./export |
| 169 | 916 | ||
| 170 | jdy-form-sync.qx.base-url=https://hfca.uat3.qgutech.com | 917 | jdy-form-sync.qx.base-url=https://hfca.uat3.qgutech.com |
| @@ -172,17 +919,34 @@ jdy-form-sync.qx.username=15077901670 | @@ -172,17 +919,34 @@ jdy-form-sync.qx.username=15077901670 | ||
| 172 | jdy-form-sync.qx.password=000000 | 919 | jdy-form-sync.qx.password=000000 |
| 173 | jdy-form-sync.qx.corp-code=hfca | 920 | jdy-form-sync.qx.corp-code=hfca |
| 174 | jdy-form-sync.qx.app-id=sEOSZ8EPwdrzJB41amD | 921 | jdy-form-sync.qx.app-id=sEOSZ8EPwdrzJB41amD |
| 175 | -jdy-form-sync.qx.app-name=风险预警平台 | 922 | +jdy-form-sync.qx.app-name=\u98ce\u9669\u9884\u8b66\u5e73\u53f0 |
| 176 | 923 | ||
| 177 | -# 待同步表单:3mis争议件大于确定件(合肥长安_技术处) | ||
| 178 | -# 注意:表单名默认从简道云接口取(避免 .properties 的 ISO-8859-1 中文乱码),此处不写中文名 | ||
| 179 | jdy-form-sync.forms[0].app-id=65fd5c0e0d1f1a7ae4f038ec | 924 | jdy-form-sync.forms[0].app-id=65fd5c0e0d1f1a7ae4f038ec |
| 180 | jdy-form-sync.forms[0].entry-id=696f1754f141344a6b794f9c | 925 | jdy-form-sync.forms[0].entry-id=696f1754f141344a6b794f9c |
| 181 | jdy-form-sync.forms[0].fun-code=misDispute | 926 | jdy-form-sync.forms[0].fun-code=misDispute |
| 182 | -# 已有模型 id:填了则原地更新(不新建)。首次同步可留空 | ||
| 183 | jdy-form-sync.forms[0].model-id=P1Vgt89QvFStKh7rDzl | 927 | jdy-form-sync.forms[0].model-id=P1Vgt89QvFStKh7rDzl |
| 184 | -# 日期字段(用于「当月」过滤):简道云 日期时间 | ||
| 185 | jdy-form-sync.forms[0].date-field=_widget_1773622123700 | 928 | jdy-form-sync.forms[0].date-field=_widget_1773622123700 |
| 186 | -# 是否只同步当月;false=同步全部数据(本表单改为全量) | ||
| 187 | jdy-form-sync.forms[0].month-only=false | 929 | jdy-form-sync.forms[0].month-only=false |
| 188 | 930 | ||
| 931 | +# ============================================================================= | ||
| 932 | +# Employee sync (biphr_ddm_empinfo_v -> QX employee form) | ||
| 933 | +# ============================================================================= | ||
| 934 | +emp-sync.kb.host=10.144.201.35 | ||
| 935 | +emp-sync.kb.port=54321 | ||
| 936 | +emp-sync.kb.database=qixiao-apaas | ||
| 937 | +emp-sync.kb.username=qixiaoadmin | ||
| 938 | +emp-sync.kb.password=Qx@20260821.com | ||
| 939 | +emp-sync.kb.table=biphr_ddm_empinfo_v | ||
| 940 | +emp-sync.kb.driver-class=com.kingbase8.Driver | ||
| 941 | +emp-sync.kb.filter=level_2_dept = '\u5408\u80a5\u957f\u5b89\u6c7d\u8f66\u6709\u9650\u516c\u53f8' OR level_3_dept IN ('\u5408\u80a5\u7814\u7a76\u9662','\u5408\u80a5\u957f\u5b89\u91c7\u8d2d\u5904') | ||
| 942 | + | ||
| 943 | +emp-sync.qx.base-url=https://hfca.uat3.qgutech.com | ||
| 944 | +emp-sync.qx.username=15077901670 | ||
| 945 | +emp-sync.qx.password=000000 | ||
| 946 | +emp-sync.qx.corp-code=hfca | ||
| 947 | +emp-sync.qx.app-id=qrpUxHu55xJ3eQWFqEU | ||
| 948 | +emp-sync.qx.page-code=j47lx0e4Page | ||
| 949 | +emp-sync.qx.update-code=53e93Update | ||
| 950 | +emp-sync.qx.add-code=53e93Add | ||
| 951 | + | ||
| 952 | +emp-sync.limit=0 |
| @@ -119,6 +119,20 @@ | @@ -119,6 +119,20 @@ | ||
| 119 | <version>${poi.version}</version> | 119 | <version>${poi.version}</version> |
| 120 | </dependency> | 120 | </dependency> |
| 121 | 121 | ||
| 122 | + <!-- 人大金仓(KingbaseES) JDBC 驱动(读员工信息) --> | ||
| 123 | + <dependency> | ||
| 124 | + <groupId>cn.com.kingbase</groupId> | ||
| 125 | + <artifactId>kingbase8</artifactId> | ||
| 126 | + <version>8.6.0.jre7</version> | ||
| 127 | + </dependency> | ||
| 128 | + | ||
| 129 | + <!-- Oracle JDBC 驱动(场景28 对接客户 MES 中间库) --> | ||
| 130 | + <dependency> | ||
| 131 | + <groupId>com.oracle.database.jdbc</groupId> | ||
| 132 | + <artifactId>ojdbc8</artifactId> | ||
| 133 | + <version>19.22.0.0</version> | ||
| 134 | + </dependency> | ||
| 135 | + | ||
| 122 | <!-- 简化代码 --> | 136 | <!-- 简化代码 --> |
| 123 | <dependency> | 137 | <dependency> |
| 124 | <groupId>org.projectlombok</groupId> | 138 | <groupId>org.projectlombok</groupId> |
run.bat
0 → 100644
| 1 | +@echo off | ||
| 2 | +chcp 65001 >nul | ||
| 3 | +rem ============================================================ | ||
| 4 | +rem qx-apaas-sync 前台启动:日志实时刷新到本窗口 | ||
| 5 | +rem Ctrl+C 停止应用 | ||
| 6 | +rem ============================================================ | ||
| 7 | +set "JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-8.0.504.1-hotspot" | ||
| 8 | +set "JAR=target\qx-apaas-sync-1.0.0-SNAPSHOT.jar" | ||
| 9 | +cd /d "%~dp0" | ||
| 10 | + | ||
| 11 | +echo ============================================================ | ||
| 12 | +echo 启动 qx-apaas-sync(前台运行,日志实时刷新) | ||
| 13 | +echo Ctrl+C 停止应用 | ||
| 14 | +echo ============================================================ | ||
| 15 | +"%JAVA_HOME%\bin\java.exe" -Dfile.encoding=UTF-8 -jar "%JAR%" | ||
| 16 | + | ||
| 17 | +echo. | ||
| 18 | +echo [exit] 应用已退出,按任意键关闭窗口... | ||
| 19 | +pause >nul |
| @@ -301,6 +301,18 @@ public class QxApi { | @@ -301,6 +301,18 @@ public class QxApi { | ||
| 301 | log.info("更新成功: id={}", dataId); | 301 | log.info("更新成功: id={}", dataId); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | + /** 新增一条业务数据(新增接口,body 即字段)。 */ | ||
| 305 | + public String addData(String token, String appId, String code, JSONObject body) { | ||
| 306 | + log.info("新增业务数据: {}", code); | ||
| 307 | + JSONObject resp = JsonHttpUtils.postJson2Obj( | ||
| 308 | + baseUrl + "/qx-api/qx-apaas-run/ar/" + appId + "/" + code, | ||
| 309 | + JsonHttpUtils.token(token), body); | ||
| 310 | + if (!Boolean.TRUE.equals(resp.getBoolean("success"))) { | ||
| 311 | + throw new IllegalStateException("新增数据失败: " + resp); | ||
| 312 | + } | ||
| 313 | + return resp.getString("data"); | ||
| 314 | + } | ||
| 315 | + | ||
| 304 | private static String urlEncode(String s) { | 316 | private static String urlEncode(String s) { |
| 305 | try { | 317 | try { |
| 306 | return java.net.URLEncoder.encode(s == null ? "" : s, "UTF-8"); | 318 | return java.net.URLEncoder.encode(s == null ? "" : s, "UTF-8"); |
| @@ -321,7 +333,25 @@ public class QxApi { | @@ -321,7 +333,25 @@ public class QxApi { | ||
| 321 | ? fileName.substring(fileName.lastIndexOf('.')) : ""; | 333 | ? fileName.substring(fileName.lastIndexOf('.')) : ""; |
| 322 | String checkUrl = baseUrl + "/qx-api/qgyun-service-fs-manager/file/checkFile" | 334 | String checkUrl = baseUrl + "/qx-api/qgyun-service-fs-manager/file/checkFile" |
| 323 | + "?fileMd5=" + md5 + "&publicFile=false&fileExt=" + urlEncode(ext); | 335 | + "?fileMd5=" + md5 + "&publicFile=false&fileExt=" + urlEncode(ext); |
| 324 | - JSONObject check = JsonHttpUtils.getJson2Obj(checkUrl, JsonHttpUtils.token(token)); | 336 | + JSONObject check = null; |
| 337 | + RuntimeException lastEx = null; | ||
| 338 | + for (int attempt = 1; attempt <= 5; attempt++) { | ||
| 339 | + try { | ||
| 340 | + check = JsonHttpUtils.getJson2Obj(checkUrl, JsonHttpUtils.token(token)); | ||
| 341 | + break; | ||
| 342 | + } catch (RuntimeException ex) { | ||
| 343 | + lastEx = ex; | ||
| 344 | + log.warn("checkFile 异常({}),{}ms 后重试(第{}次)", ex.getMessage(), 3000L * attempt, attempt); | ||
| 345 | + try { | ||
| 346 | + Thread.sleep(3000L * attempt); | ||
| 347 | + } catch (InterruptedException ignored) { | ||
| 348 | + Thread.currentThread().interrupt(); | ||
| 349 | + } | ||
| 350 | + } | ||
| 351 | + } | ||
| 352 | + if (check == null) { | ||
| 353 | + throw lastEx != null ? lastEx : new IllegalStateException("checkFile 失败"); | ||
| 354 | + } | ||
| 325 | if (Boolean.TRUE.equals(check.getBoolean("success"))) { | 355 | if (Boolean.TRUE.equals(check.getBoolean("success"))) { |
| 326 | String existId = check.getString("msg"); | 356 | String existId = check.getString("msg"); |
| 327 | if (existId != null && !existId.isEmpty()) { | 357 | if (existId != null && !existId.isEmpty()) { |
| 1 | +package com.qgutech.qgyun.apaas.sync.jdy.config; | ||
| 2 | + | ||
| 3 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 员工信息同步配置(人大金仓 biphr_ddm_empinfo_v -> 启效员工信息表单)。 | ||
| 7 | + * <p> | ||
| 8 | + * 对应 application.properties 的 emp-sync 段。 | ||
| 9 | + * 用途:把人大金仓的员工信息,按「员工编号(gh)」同步到启效员工信息表单(存在则更新、不存在则新增)。 | ||
| 10 | + */ | ||
| 11 | +@ConfigurationProperties(prefix = "emp-sync") | ||
| 12 | +public class EmpSyncProperties { | ||
| 13 | + | ||
| 14 | + /** 人大金仓(Kingbase)数据源配置。 */ | ||
| 15 | + private Kb kb = new Kb(); | ||
| 16 | + | ||
| 17 | + /** 启效(QX)目标配置。 */ | ||
| 18 | + private Qx qx = new Qx(); | ||
| 19 | + | ||
| 20 | + /** 单次同步最多处理多少条(0=不限制,用于全量)。 */ | ||
| 21 | + private int limit = 0; | ||
| 22 | + | ||
| 23 | + /** 是否 dry-run(true=只打印不写入)。 */ | ||
| 24 | + private boolean dryRun = false; | ||
| 25 | + | ||
| 26 | + public Kb getKb() { | ||
| 27 | + return kb; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public void setKb(Kb kb) { | ||
| 31 | + this.kb = kb; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public Qx getQx() { | ||
| 35 | + return qx; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void setQx(Qx qx) { | ||
| 39 | + this.qx = qx; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public int getLimit() { | ||
| 43 | + return limit; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public void setLimit(int limit) { | ||
| 47 | + this.limit = limit; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public boolean isDryRun() { | ||
| 51 | + return dryRun; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setDryRun(boolean dryRun) { | ||
| 55 | + this.dryRun = dryRun; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** 人大金仓连接配置。 */ | ||
| 59 | + public static class Kb { | ||
| 60 | + private String host = "10.144.201.35"; | ||
| 61 | + private int port = 54321; | ||
| 62 | + private String database; | ||
| 63 | + private String username; | ||
| 64 | + private String password; | ||
| 65 | + /** 员工信息表名 */ | ||
| 66 | + private String table = "biphr_ddm_empinfo_v"; | ||
| 67 | + /** 可选 WHERE 过滤条件(不含 WHERE 关键字),只同步命中的行 */ | ||
| 68 | + private String filter; | ||
| 69 | + /** JDBC 驱动类 */ | ||
| 70 | + private String driverClass = "com.kingbase8.Driver"; | ||
| 71 | + /** 可选:直接指定完整 JDBC url(填了则忽略 host/port/database) */ | ||
| 72 | + private String url; | ||
| 73 | + | ||
| 74 | + public String jdbcUrl() { | ||
| 75 | + if (url != null && !url.isEmpty()) { | ||
| 76 | + return url; | ||
| 77 | + } | ||
| 78 | + return "jdbc:kingbase8://" + host + ":" + port + "/" + database; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public String getHost() { | ||
| 82 | + return host; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void setHost(String host) { | ||
| 86 | + this.host = host; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public int getPort() { | ||
| 90 | + return port; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void setPort(int port) { | ||
| 94 | + this.port = port; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public String getDatabase() { | ||
| 98 | + return database; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void setDatabase(String database) { | ||
| 102 | + this.database = database; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public String getUsername() { | ||
| 106 | + return username; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void setUsername(String username) { | ||
| 110 | + this.username = username; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public String getPassword() { | ||
| 114 | + return password; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public void setPassword(String password) { | ||
| 118 | + this.password = password; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public String getTable() { | ||
| 122 | + return table; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public void setTable(String table) { | ||
| 126 | + this.table = table; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public String getFilter() { | ||
| 130 | + return filter; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public void setFilter(String filter) { | ||
| 134 | + this.filter = filter; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public String getDriverClass() { | ||
| 138 | + return driverClass; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public void setDriverClass(String driverClass) { | ||
| 142 | + this.driverClass = driverClass; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public String getUrl() { | ||
| 146 | + return url; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public void setUrl(String url) { | ||
| 150 | + this.url = url; | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + /** 启效(QX)员工信息表单配置。 */ | ||
| 155 | + public static class Qx { | ||
| 156 | + private String baseUrl; | ||
| 157 | + private String username; | ||
| 158 | + private String password; | ||
| 159 | + private String corpCode = "hfca"; | ||
| 160 | + /** 员工信息所在应用 appId */ | ||
| 161 | + private String appId; | ||
| 162 | + /** 分页查询接口 code */ | ||
| 163 | + private String pageCode = "j47lx0e4Page"; | ||
| 164 | + /** 更新接口 code */ | ||
| 165 | + private String updateCode = "53e93Update"; | ||
| 166 | + /** 新增接口 code */ | ||
| 167 | + private String addCode = "53e93Add"; | ||
| 168 | + | ||
| 169 | + public String getBaseUrl() { | ||
| 170 | + return baseUrl; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public void setBaseUrl(String baseUrl) { | ||
| 174 | + this.baseUrl = baseUrl; | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + public String getUsername() { | ||
| 178 | + return username; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + public void setUsername(String username) { | ||
| 182 | + this.username = username; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + public String getPassword() { | ||
| 186 | + return password; | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + public void setPassword(String password) { | ||
| 190 | + this.password = password; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + public String getCorpCode() { | ||
| 194 | + return corpCode; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + public void setCorpCode(String corpCode) { | ||
| 198 | + this.corpCode = corpCode; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + public String getAppId() { | ||
| 202 | + return appId; | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + public void setAppId(String appId) { | ||
| 206 | + this.appId = appId; | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + public String getPageCode() { | ||
| 210 | + return pageCode; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + public void setPageCode(String pageCode) { | ||
| 214 | + this.pageCode = pageCode; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + public String getUpdateCode() { | ||
| 218 | + return updateCode; | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + public void setUpdateCode(String updateCode) { | ||
| 222 | + this.updateCode = updateCode; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + public String getAddCode() { | ||
| 226 | + return addCode; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + public void setAddCode(String addCode) { | ||
| 230 | + this.addCode = addCode; | ||
| 231 | + } | ||
| 232 | + } | ||
| 233 | +} |
| @@ -3,7 +3,9 @@ package com.qgutech.qgyun.apaas.sync.jdy.config; | @@ -3,7 +3,9 @@ package com.qgutech.qgyun.apaas.sync.jdy.config; | ||
| 3 | import org.springframework.boot.context.properties.ConfigurationProperties; | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; |
| 4 | 4 | ||
| 5 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
| 6 | +import java.util.LinkedHashMap; | ||
| 6 | import java.util.List; | 7 | import java.util.List; |
| 8 | +import java.util.Map; | ||
| 7 | 9 | ||
| 8 | /** | 10 | /** |
| 9 | * 风险场景统计配置。 | 11 | * 风险场景统计配置。 |
| @@ -23,9 +25,18 @@ public class JdyRiskProperties { | @@ -23,9 +25,18 @@ public class JdyRiskProperties { | ||
| 23 | /** 启效(QX)写回配置(把统计结果更新到目标应用表单) */ | 25 | /** 启效(QX)写回配置(把统计结果更新到目标应用表单) */ |
| 24 | private Qx qx = new Qx(); | 26 | private Qx qx = new Qx(); |
| 25 | 27 | ||
| 28 | + /** 客户 MES 中间库(Oracle,场景28) */ | ||
| 29 | + private Mes mes = new Mes(); | ||
| 30 | + | ||
| 31 | + /** 客户内网人大金仓(KingbaseES)数据库(设备域场景20/21/22) */ | ||
| 32 | + private Kingbase kingbase = new Kingbase(); | ||
| 33 | + | ||
| 26 | /** 场景清单 */ | 34 | /** 场景清单 */ |
| 27 | private List<Scenario> scenarios = new ArrayList<>(); | 35 | private List<Scenario> scenarios = new ArrayList<>(); |
| 28 | 36 | ||
| 37 | + /** 定时任务(设备域场景12/13 按月抓取) */ | ||
| 38 | + private Schedule schedule = new Schedule(); | ||
| 39 | + | ||
| 29 | public String getHost() { | 40 | public String getHost() { |
| 30 | return host; | 41 | return host; |
| 31 | } | 42 | } |
| @@ -58,6 +69,328 @@ public class JdyRiskProperties { | @@ -58,6 +69,328 @@ public class JdyRiskProperties { | ||
| 58 | this.scenarios = scenarios; | 69 | this.scenarios = scenarios; |
| 59 | } | 70 | } |
| 60 | 71 | ||
| 72 | + public Mes getMes() { | ||
| 73 | + return mes; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setMes(Mes mes) { | ||
| 77 | + this.mes = mes; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public Kingbase getKingbase() { | ||
| 81 | + return kingbase; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public void setKingbase(Kingbase kingbase) { | ||
| 85 | + this.kingbase = kingbase; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public Schedule getSchedule() { | ||
| 89 | + return schedule; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public void setSchedule(Schedule schedule) { | ||
| 93 | + this.schedule = schedule; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + /** 定时任务配置。 */ | ||
| 97 | + public static class Schedule { | ||
| 98 | + /** 是否启用设备域场景12/13定时任务 */ | ||
| 99 | + private boolean enabled = false; | ||
| 100 | + /** 场景1(SYNC0001)抓取 cron:默认每月20号 03:00,抓上月数据 */ | ||
| 101 | + private String s1Cron = "0 0 3 20 * ?"; | ||
| 102 | + /** 质量域场景2/3(SYNC0002/0003):每月5号抓上月 */ | ||
| 103 | + private String s2Cron = "0 0 3 5 * ?"; | ||
| 104 | + private String s3Cron = "0 0 3 5 * ?"; | ||
| 105 | + /** 质量域场景4/5(SYNC0004/0005):1/4/7/10月5号抓上一季度 */ | ||
| 106 | + private String s4Cron = "0 0 3 5 1,4,7,10 ?"; | ||
| 107 | + private String s5Cron = "0 0 3 5 1,4,7,10 ?"; | ||
| 108 | + /** 质量域场景6(SYNC0006):每月最后一天23点抓当月(每天23点触发,月末执行) */ | ||
| 109 | + private String s6Cron = "0 0 23 * * ?"; | ||
| 110 | + /** 质量域场景7(SYNC0007):每月5号抓上月 */ | ||
| 111 | + private String s7Cron = "0 0 3 5 * ?"; | ||
| 112 | + /** 质量域场景8(SYNC0008):每月5号,按上月末增量统计超期 */ | ||
| 113 | + private String s8Cron = "0 0 3 5 * ?"; | ||
| 114 | + /** 质量域场景9/10(SYNC0010/0011):每月5号抓上月 */ | ||
| 115 | + private String s9Cron = "0 0 3 5 * ?"; | ||
| 116 | + private String s10Cron = "0 0 3 5 * ?"; | ||
| 117 | + /** 场景12(SYNC0034)抓取 cron:默认每月1号 03:00 */ | ||
| 118 | + private String s12Cron = "0 0 3 1 * ?"; | ||
| 119 | + /** 场景13(SYNC0042)抓取 cron:默认每月10号 03:00 */ | ||
| 120 | + private String s13Cron = "0 0 3 10 * ?"; | ||
| 121 | + /** 场景14(SYNC0048)抓取 cron:默认每年12月20日 03:00 */ | ||
| 122 | + private String s14Cron = "0 0 3 20 12 ?"; | ||
| 123 | + /** 场景15(SYNC0044)抓取 cron:默认每月1号 03:00 */ | ||
| 124 | + private String s15Cron = "0 0 3 1 * ?"; | ||
| 125 | + /** 场景16(SYNC0045)抓取 cron:默认每天 23:00(方法内判断「月末」才执行) */ | ||
| 126 | + private String s16Cron = "0 0 23 * * ?"; | ||
| 127 | + /** 场景17(SYNC0046)抓取 cron:默认每月1号 03:00 */ | ||
| 128 | + private String s17Cron = "0 0 3 1 * ?"; | ||
| 129 | + /** 场景18(SYNC0047)抓取 cron:默认每天 23:00(方法内判断「月末」才执行) */ | ||
| 130 | + private String s18Cron = "0 0 23 * * ?"; | ||
| 131 | + /** 场景19(SYNC0043)抓取 cron:默认每月1号 01:00 */ | ||
| 132 | + private String s19Cron = "0 0 1 1 * ?"; | ||
| 133 | + /** 场景20(SYNC0039 废料预警,人大金仓):默认每月12号 01:00 抓上月 */ | ||
| 134 | + private String s20Cron = "0 0 1 12 * ?"; | ||
| 135 | + /** 场景21(SYNC0040 过磅记录,人大金仓):每月11号 01:00 抓1-10号 */ | ||
| 136 | + private String s21aCron = "0 0 1 11 * ?"; | ||
| 137 | + /** 场景21:每月21号 01:00 抓11-20号 */ | ||
| 138 | + private String s21bCron = "0 0 1 21 * ?"; | ||
| 139 | + /** 场景21:每月最后一天 23:00 抓21号-月底(每天23点触发,月末执行) */ | ||
| 140 | + private String s21cCron = "0 0 23 * * ?"; | ||
| 141 | + /** 场景22(SYNC0041 运输异常,人大金仓):默认每月1号 01:00 抓上月 */ | ||
| 142 | + private String s22Cron = "0 0 1 1 * ?"; | ||
| 143 | + /** 场景23(SYNC0013)抓取 cron:默认每月1号 01:00 */ | ||
| 144 | + private String s23Cron = "0 0 1 1 * ?"; | ||
| 145 | + /** 场景24(SYNC0014)抓取 cron:默认每月1号 01:00 */ | ||
| 146 | + private String s24Cron = "0 0 1 1 * ?"; | ||
| 147 | + /** 场景25(SYNC0015)抓取 cron:默认每月1号 01:00 */ | ||
| 148 | + private String s25Cron = "0 0 1 1 * ?"; | ||
| 149 | + /** 场景26(SYNC0016)抓取 cron:默认每月1号 01:00 */ | ||
| 150 | + private String s26Cron = "0 0 1 1 * ?"; | ||
| 151 | + /** 场景28/29/30:每月最后一天23点(每天23点触发,月末执行) */ | ||
| 152 | + private String s28Cron = "0 0 23 * * ?"; | ||
| 153 | + private String s29Cron = "0 0 23 * * ?"; | ||
| 154 | + private String s30Cron = "0 0 23 * * ?"; | ||
| 155 | + /** 场景31~36:每季度首月1号01:00(1/4/7/10月) */ | ||
| 156 | + private String s31Cron = "0 0 1 1 1,4,7,10 ?"; | ||
| 157 | + private String s32Cron = "0 0 1 1 1,4,7,10 ?"; | ||
| 158 | + private String s33Cron = "0 0 1 1 1,4,7,10 ?"; | ||
| 159 | + private String s34Cron = "0 0 1 1 1,4,7,10 ?"; | ||
| 160 | + private String s35Cron = "0 0 1 1 1,4,7,10 ?"; | ||
| 161 | + private String s36Cron = "0 0 1 1 1,4,7,10 ?"; | ||
| 162 | + /** 场景37:每年12月31日23:00 */ | ||
| 163 | + private String s37Cron = "0 0 23 31 12 ?"; | ||
| 164 | + /** 场景38(SYNC0036):每月10号抓上月 */ | ||
| 165 | + private String s38Cron = "0 0 3 10 * ?"; | ||
| 166 | + /** 场景39(SYNC0027):每月5号抓上月 */ | ||
| 167 | + private String s39Cron = "0 0 3 5 * ?"; | ||
| 168 | + /** 场景40(SYNC0028):每月5号抓上月 */ | ||
| 169 | + private String s40Cron = "0 0 3 5 * ?"; | ||
| 170 | + /** 场景41~47(SYNC0029~SYNC0035):每月5号抓上月 */ | ||
| 171 | + private String s41Cron = "0 0 3 5 * ?"; | ||
| 172 | + private String s42Cron = "0 0 3 5 * ?"; | ||
| 173 | + private String s43Cron = "0 0 3 5 * ?"; | ||
| 174 | + private String s44Cron = "0 0 3 5 * ?"; | ||
| 175 | + private String s45Cron = "0 0 3 5 * ?"; | ||
| 176 | + private String s46Cron = "0 0 3 5 * ?"; | ||
| 177 | + private String s47Cron = "0 0 3 5 * ?"; | ||
| 178 | + | ||
| 179 | + public boolean isEnabled() { | ||
| 180 | + return enabled; | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + public void setEnabled(boolean enabled) { | ||
| 184 | + this.enabled = enabled; | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + public String getS1Cron() { | ||
| 188 | + return s1Cron; | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + public void setS1Cron(String s1Cron) { | ||
| 192 | + this.s1Cron = s1Cron; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + public String getS2Cron() { return s2Cron; } | ||
| 196 | + public void setS2Cron(String v) { this.s2Cron = v; } | ||
| 197 | + public String getS3Cron() { return s3Cron; } | ||
| 198 | + public void setS3Cron(String v) { this.s3Cron = v; } | ||
| 199 | + public String getS4Cron() { return s4Cron; } | ||
| 200 | + public void setS4Cron(String v) { this.s4Cron = v; } | ||
| 201 | + public String getS5Cron() { return s5Cron; } | ||
| 202 | + public void setS5Cron(String v) { this.s5Cron = v; } | ||
| 203 | + public String getS6Cron() { return s6Cron; } | ||
| 204 | + public void setS6Cron(String v) { this.s6Cron = v; } | ||
| 205 | + public String getS7Cron() { return s7Cron; } | ||
| 206 | + public void setS7Cron(String v) { this.s7Cron = v; } | ||
| 207 | + public String getS8Cron() { return s8Cron; } | ||
| 208 | + public void setS8Cron(String v) { this.s8Cron = v; } | ||
| 209 | + public String getS9Cron() { return s9Cron; } | ||
| 210 | + public void setS9Cron(String v) { this.s9Cron = v; } | ||
| 211 | + public String getS10Cron() { return s10Cron; } | ||
| 212 | + public void setS10Cron(String v) { this.s10Cron = v; } | ||
| 213 | + | ||
| 214 | + public String getS12Cron() { | ||
| 215 | + return s12Cron; | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + public void setS12Cron(String s12Cron) { | ||
| 219 | + this.s12Cron = s12Cron; | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + public String getS13Cron() { | ||
| 223 | + return s13Cron; | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + public void setS13Cron(String s13Cron) { | ||
| 227 | + this.s13Cron = s13Cron; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + public String getS14Cron() { | ||
| 231 | + return s14Cron; | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + public void setS14Cron(String s14Cron) { | ||
| 235 | + this.s14Cron = s14Cron; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + public String getS15Cron() { | ||
| 239 | + return s15Cron; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + public void setS15Cron(String s15Cron) { | ||
| 243 | + this.s15Cron = s15Cron; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + public String getS16Cron() { | ||
| 247 | + return s16Cron; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + public void setS16Cron(String s16Cron) { | ||
| 251 | + this.s16Cron = s16Cron; | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + public String getS17Cron() { | ||
| 255 | + return s17Cron; | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + public void setS17Cron(String s17Cron) { | ||
| 259 | + this.s17Cron = s17Cron; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + public String getS18Cron() { | ||
| 263 | + return s18Cron; | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + public void setS18Cron(String s18Cron) { | ||
| 267 | + this.s18Cron = s18Cron; | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + public String getS19Cron() { | ||
| 271 | + return s19Cron; | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + public void setS19Cron(String s19Cron) { | ||
| 275 | + this.s19Cron = s19Cron; | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + public String getS20Cron() { return s20Cron; } | ||
| 279 | + public void setS20Cron(String v) { this.s20Cron = v; } | ||
| 280 | + public String getS21aCron() { return s21aCron; } | ||
| 281 | + public void setS21aCron(String v) { this.s21aCron = v; } | ||
| 282 | + public String getS21bCron() { return s21bCron; } | ||
| 283 | + public void setS21bCron(String v) { this.s21bCron = v; } | ||
| 284 | + public String getS21cCron() { return s21cCron; } | ||
| 285 | + public void setS21cCron(String v) { this.s21cCron = v; } | ||
| 286 | + public String getS22Cron() { return s22Cron; } | ||
| 287 | + public void setS22Cron(String v) { this.s22Cron = v; } | ||
| 288 | + | ||
| 289 | + public String getS23Cron() { | ||
| 290 | + return s23Cron; | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + public void setS23Cron(String s23Cron) { | ||
| 294 | + this.s23Cron = s23Cron; | ||
| 295 | + } | ||
| 296 | + | ||
| 297 | + public String getS24Cron() { | ||
| 298 | + return s24Cron; | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + public void setS24Cron(String s24Cron) { | ||
| 302 | + this.s24Cron = s24Cron; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + public String getS25Cron() { | ||
| 306 | + return s25Cron; | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + public void setS25Cron(String s25Cron) { | ||
| 310 | + this.s25Cron = s25Cron; | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + public String getS26Cron() { | ||
| 314 | + return s26Cron; | ||
| 315 | + } | ||
| 316 | + | ||
| 317 | + public void setS26Cron(String s26Cron) { | ||
| 318 | + this.s26Cron = s26Cron; | ||
| 319 | + } | ||
| 320 | + | ||
| 321 | + public String getS28Cron() { return s28Cron; } | ||
| 322 | + public void setS28Cron(String v) { this.s28Cron = v; } | ||
| 323 | + public String getS29Cron() { return s29Cron; } | ||
| 324 | + public void setS29Cron(String v) { this.s29Cron = v; } | ||
| 325 | + public String getS30Cron() { return s30Cron; } | ||
| 326 | + public void setS30Cron(String v) { this.s30Cron = v; } | ||
| 327 | + public String getS31Cron() { return s31Cron; } | ||
| 328 | + public void setS31Cron(String v) { this.s31Cron = v; } | ||
| 329 | + public String getS32Cron() { return s32Cron; } | ||
| 330 | + public void setS32Cron(String v) { this.s32Cron = v; } | ||
| 331 | + public String getS33Cron() { return s33Cron; } | ||
| 332 | + public void setS33Cron(String v) { this.s33Cron = v; } | ||
| 333 | + public String getS34Cron() { return s34Cron; } | ||
| 334 | + public void setS34Cron(String v) { this.s34Cron = v; } | ||
| 335 | + public String getS35Cron() { return s35Cron; } | ||
| 336 | + public void setS35Cron(String v) { this.s35Cron = v; } | ||
| 337 | + public String getS36Cron() { return s36Cron; } | ||
| 338 | + public void setS36Cron(String v) { this.s36Cron = v; } | ||
| 339 | + public String getS37Cron() { return s37Cron; } | ||
| 340 | + public void setS37Cron(String v) { this.s37Cron = v; } | ||
| 341 | + public String getS38Cron() { return s38Cron; } | ||
| 342 | + public void setS38Cron(String v) { this.s38Cron = v; } | ||
| 343 | + public String getS39Cron() { return s39Cron; } | ||
| 344 | + public void setS39Cron(String v) { this.s39Cron = v; } | ||
| 345 | + public String getS40Cron() { return s40Cron; } | ||
| 346 | + public void setS40Cron(String v) { this.s40Cron = v; } | ||
| 347 | + public String getS41Cron() { return s41Cron; } | ||
| 348 | + public void setS41Cron(String v) { this.s41Cron = v; } | ||
| 349 | + public String getS42Cron() { return s42Cron; } | ||
| 350 | + public void setS42Cron(String v) { this.s42Cron = v; } | ||
| 351 | + public String getS43Cron() { return s43Cron; } | ||
| 352 | + public void setS43Cron(String v) { this.s43Cron = v; } | ||
| 353 | + public String getS44Cron() { return s44Cron; } | ||
| 354 | + public void setS44Cron(String v) { this.s44Cron = v; } | ||
| 355 | + public String getS45Cron() { return s45Cron; } | ||
| 356 | + public void setS45Cron(String v) { this.s45Cron = v; } | ||
| 357 | + public String getS46Cron() { return s46Cron; } | ||
| 358 | + public void setS46Cron(String v) { this.s46Cron = v; } | ||
| 359 | + public String getS47Cron() { return s47Cron; } | ||
| 360 | + public void setS47Cron(String v) { this.s47Cron = v; } | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + /** 客户 MES 中间库连接配置(Oracle)。 */ | ||
| 364 | + public static class Mes { | ||
| 365 | + private String url; | ||
| 366 | + private String username; | ||
| 367 | + private String password; | ||
| 368 | + | ||
| 369 | + public String getUrl() { return url; } | ||
| 370 | + public void setUrl(String url) { this.url = url; } | ||
| 371 | + public String getUsername() { return username; } | ||
| 372 | + public void setUsername(String username) { this.username = username; } | ||
| 373 | + public String getPassword() { return password; } | ||
| 374 | + public void setPassword(String password) { this.password = password; } | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + /** 客户内网人大金仓(KingbaseES)数据库连接配置(设备域场景20/21/22)。 */ | ||
| 378 | + public static class Kingbase { | ||
| 379 | + private String url = "jdbc:kingbase8://10.144.201.35:54321/qixiao-apaas"; | ||
| 380 | + private String username = "qixiaoadmin"; | ||
| 381 | + private String password = "Qx@20260821.com"; | ||
| 382 | + private String driverClass = "com.kingbase8.Driver"; | ||
| 383 | + | ||
| 384 | + public String getUrl() { return url; } | ||
| 385 | + public void setUrl(String url) { this.url = url; } | ||
| 386 | + public String getUsername() { return username; } | ||
| 387 | + public void setUsername(String username) { this.username = username; } | ||
| 388 | + public String getPassword() { return password; } | ||
| 389 | + public void setPassword(String password) { this.password = password; } | ||
| 390 | + public String getDriverClass() { return driverClass; } | ||
| 391 | + public void setDriverClass(String driverClass) { this.driverClass = driverClass; } | ||
| 392 | + } | ||
| 393 | + | ||
| 61 | /** 启效(QX)写回目标配置。 */ | 394 | /** 启效(QX)写回目标配置。 */ |
| 62 | public static class Qx { | 395 | public static class Qx { |
| 63 | /** 启效环境地址,如 https://hfca.uat3.qgutech.com */ | 396 | /** 启效环境地址,如 https://hfca.uat3.qgutech.com */ |
| @@ -73,10 +406,18 @@ public class JdyRiskProperties { | @@ -73,10 +406,18 @@ public class JdyRiskProperties { | ||
| 73 | private String syncQueryParam; | 406 | private String syncQueryParam; |
| 74 | /** 更新接口 code(如 11a41Update) */ | 407 | /** 更新接口 code(如 11a41Update) */ |
| 75 | private String updateCode; | 408 | private String updateCode; |
| 409 | + /** 新增接口 code(如 11a41Add) */ | ||
| 410 | + private String addCode; | ||
| 411 | + /** 删除接口 code(如 ilr3ne7bDel,历史回补清库用) */ | ||
| 412 | + private String deleteCode; | ||
| 76 | /** 写回数量的字段编号(如 chcbxt) */ | 413 | /** 写回数量的字段编号(如 chcbxt) */ |
| 77 | private String countField; | 414 | private String countField; |
| 78 | /** 附件字段编号(如 hciwkz);配置了则把简道云数据 Excel 作为附件写入(关联ID字段自动取 {attachField}Id) */ | 415 | /** 附件字段编号(如 hciwkz);配置了则把简道云数据 Excel 作为附件写入(关联ID字段自动取 {attachField}Id) */ |
| 79 | private String attachField; | 416 | private String attachField; |
| 417 | + /** 预警时间字段编号(如 bswivu);配置了则每次同步写入「当次跑任务的系统时间」 */ | ||
| 418 | + private String timeField; | ||
| 419 | + /** 第二个随预警时间一起更新的日期字段(如 dgqshv,可为空) */ | ||
| 420 | + private String timeField2; | ||
| 80 | 421 | ||
| 81 | public String getBaseUrl() { | 422 | public String getBaseUrl() { |
| 82 | return baseUrl; | 423 | return baseUrl; |
| @@ -142,6 +483,22 @@ public class JdyRiskProperties { | @@ -142,6 +483,22 @@ public class JdyRiskProperties { | ||
| 142 | this.updateCode = updateCode; | 483 | this.updateCode = updateCode; |
| 143 | } | 484 | } |
| 144 | 485 | ||
| 486 | + public String getAddCode() { | ||
| 487 | + return addCode; | ||
| 488 | + } | ||
| 489 | + | ||
| 490 | + public void setAddCode(String addCode) { | ||
| 491 | + this.addCode = addCode; | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + public String getDeleteCode() { | ||
| 495 | + return deleteCode; | ||
| 496 | + } | ||
| 497 | + | ||
| 498 | + public void setDeleteCode(String deleteCode) { | ||
| 499 | + this.deleteCode = deleteCode; | ||
| 500 | + } | ||
| 501 | + | ||
| 145 | public String getCountField() { | 502 | public String getCountField() { |
| 146 | return countField; | 503 | return countField; |
| 147 | } | 504 | } |
| @@ -157,6 +514,22 @@ public class JdyRiskProperties { | @@ -157,6 +514,22 @@ public class JdyRiskProperties { | ||
| 157 | public void setAttachField(String attachField) { | 514 | public void setAttachField(String attachField) { |
| 158 | this.attachField = attachField; | 515 | this.attachField = attachField; |
| 159 | } | 516 | } |
| 517 | + | ||
| 518 | + public String getTimeField() { | ||
| 519 | + return timeField; | ||
| 520 | + } | ||
| 521 | + | ||
| 522 | + public void setTimeField(String timeField) { | ||
| 523 | + this.timeField = timeField; | ||
| 524 | + } | ||
| 525 | + | ||
| 526 | + public String getTimeField2() { | ||
| 527 | + return timeField2; | ||
| 528 | + } | ||
| 529 | + | ||
| 530 | + public void setTimeField2(String timeField2) { | ||
| 531 | + this.timeField2 = timeField2; | ||
| 532 | + } | ||
| 160 | } | 533 | } |
| 161 | 534 | ||
| 162 | /** | 535 | /** |
| @@ -200,10 +573,17 @@ public class JdyRiskProperties { | @@ -200,10 +573,17 @@ public class JdyRiskProperties { | ||
| 200 | private boolean monthOnly = false; | 573 | private boolean monthOnly = false; |
| 201 | /** 是否仅统计当季度数据(scenario4/5) */ | 574 | /** 是否仅统计当季度数据(scenario4/5) */ |
| 202 | private boolean quarterOnly = false; | 575 | private boolean quarterOnly = false; |
| 576 | + /** 是否仅统计上一季度数据 */ | ||
| 577 | + private boolean prevQuarterOnly = false; | ||
| 203 | /** 是否仅统计当前年份(1月1日至今,scenario6) */ | 578 | /** 是否仅统计当前年份(1月1日至今,scenario6) */ |
| 204 | private boolean yearOnly = false; | 579 | private boolean yearOnly = false; |
| 205 | /** 是否仅统计上个月(scenario8/9) */ | 580 | /** 是否仅统计上个月(scenario8/9) */ |
| 206 | private boolean prevMonthOnly = false; | 581 | private boolean prevMonthOnly = false; |
| 582 | + /** | ||
| 583 | + * 是否按半月统计(scenario20): | ||
| 584 | + * 16号执行=当月1号~15号;1号执行=上月16号~上月底。 | ||
| 585 | + */ | ||
| 586 | + private boolean halfMonthOnly = false; | ||
| 207 | /** 「升级」字段 code(scenario4/5) */ | 587 | /** 「升级」字段 code(scenario4/5) */ |
| 208 | private String upField; | 588 | private String upField; |
| 209 | /** 「升级」需排除的取值(scenario4/5,空白始终排除);如 [QR] */ | 589 | /** 「升级」需排除的取值(scenario4/5,空白始终排除);如 [QR] */ |
| @@ -216,19 +596,505 @@ public class JdyRiskProperties { | @@ -216,19 +596,505 @@ public class JdyRiskProperties { | ||
| 216 | private String flagValue; | 596 | private String flagValue; |
| 217 | /** 比率阈值(scenario8/9,默认 0.7) */ | 597 | /** 比率阈值(scenario8/9,默认 0.7) */ |
| 218 | private double ratioThreshold = 0.7; | 598 | private double ratioThreshold = 0.7; |
| 219 | - /** 条码字段 code(scenario7,主表) */ | 599 | + /** 绝对值阈值(scenario10:|字段| > absThreshold 才算命中,默认 0.05=5%) */ |
| 600 | + private double absThreshold = 0.05; | ||
| 601 | + /** 条码字段 code(scenario7 主表 / scenario11 表A:系统库存明细) */ | ||
| 220 | private String barcodeField; | 602 | private String barcodeField; |
| 603 | + /** 需对比的表 B(scenario11:三包库房实际盘点数量)entry_id */ | ||
| 604 | + private String compareEntryId; | ||
| 605 | + /** 表 B 条码字段 code */ | ||
| 606 | + private String compareBarcodeField; | ||
| 607 | + /** 表 B 展示字段 list */ | ||
| 608 | + private List<String> compareFields = new ArrayList<>(); | ||
| 221 | /** 需要排除的条码来源表单(scenario7) */ | 609 | /** 需要排除的条码来源表单(scenario7) */ |
| 222 | private List<ExcludeForm> excludeForms = new ArrayList<>(); | 610 | private List<ExcludeForm> excludeForms = new ArrayList<>(); |
| 223 | /** 超期天数(scenario7:入库时间距今超过该天数才保留,默认 180) */ | 611 | /** 超期天数(scenario7:入库时间距今超过该天数才保留,默认 180) */ |
| 224 | private int maxAgeDays = 180; | 612 | private int maxAgeDays = 180; |
| 613 | + /** | ||
| 614 | + * scenario7:按月增量统计超期。参考「上个月最后一天」,保留入库时间距其超过 maxAgeDays 天、 | ||
| 615 | + * 且不在上次运行窗口内的数据(避免每月重复预警)。 | ||
| 616 | + */ | ||
| 617 | + private boolean monthlyOverdueIncremental = false; | ||
| 225 | /** 只取这些字段列(scenario7:主表只拉需要的列,减小传输;空=全字段) */ | 618 | /** 只取这些字段列(scenario7:主表只拉需要的列,减小传输;空=全字段) */ |
| 226 | private List<String> fields = new ArrayList<>(); | 619 | private List<String> fields = new ArrayList<>(); |
| 227 | /** Excel 附加列取值的字段 code(为空时 scenario1 默认写「命中」) */ | 620 | /** Excel 附加列取值的字段 code(为空时 scenario1 默认写「命中」) */ |
| 228 | private String extraField; | 621 | private String extraField; |
| 622 | + /** Excel 中需按百分数(1位小数)显示的字段 code 列表 */ | ||
| 623 | + private List<String> percentFields = new ArrayList<>(); | ||
| 624 | + /** Excel 是否只保留「命中/预警」的行(其他行不导出) */ | ||
| 625 | + private boolean onlyWarnRows = false; | ||
| 626 | + /** 关联字段 code(其值为关联表的 _id,需映射成名称) */ | ||
| 627 | + private String lookupField; | ||
| 628 | + /** 关联表 entry_id(用于取 id->名称 映射) */ | ||
| 629 | + private String lookupEntryId; | ||
| 630 | + /** 关联表里存名称的字段 code */ | ||
| 631 | + private String lookupNameField; | ||
| 229 | /** 写回启效目标记录的 syncCode(如 SYNC0001) */ | 632 | /** 写回启效目标记录的 syncCode(如 SYNC0001) */ |
| 230 | private String syncCode; | 633 | private String syncCode; |
| 231 | 634 | ||
| 635 | + /** 停留时长字段 code(scenario13) */ | ||
| 636 | + private String durationField; | ||
| 637 | + /** 停留时长阈值(分钟,scenario13:> 该值才算异常,默认 10) */ | ||
| 638 | + private double durationThreshold = 10; | ||
| 639 | + /** 是否存在异常出门字段 code(scenario13) */ | ||
| 640 | + private String abnormalField; | ||
| 641 | + /** 是否存在异常出门的命中取值(scenario13,如「存在异常」) */ | ||
| 642 | + private String abnormalValue; | ||
| 643 | + /** 异常原因说明字段 code(scenario13,为空也算异常) */ | ||
| 644 | + private String reasonField; | ||
| 645 | + /** | ||
| 646 | + * 人员/签字配对列表(scenario12):人员字段有值但对应签字字段为空则命中。 | ||
| 647 | + * 原因列文案按顺序生成「参与人员N未签字确认」(N 从 1 开始)。 | ||
| 648 | + */ | ||
| 649 | + private List<Pair> pairs = new ArrayList<>(); | ||
| 650 | + /** 流程状态命中值(scenario15/17,「流转完成」对应的 flowState,如 1) */ | ||
| 651 | + private Integer flowStateValue; | ||
| 652 | + /** 条件照片校验规则列表(scenario15) */ | ||
| 653 | + private List<PhotoRule> photoRules = new ArrayList<>(); | ||
| 654 | + /** 命中取值集合(scenario16/18,如 高预算/低预算 或 未提交) */ | ||
| 655 | + private List<String> flagValues = new ArrayList<>(); | ||
| 656 | + /** 计划完成时间字段 code(scenario17) */ | ||
| 657 | + private String planField; | ||
| 658 | + /** 施工完成日期字段 code(scenario17) */ | ||
| 659 | + private String actualField; | ||
| 660 | + /** 逾期天数阈值(scenario17,实际-计划 > 该天数则命中,默认 15) */ | ||
| 661 | + private int overdueDays = 15; | ||
| 662 | + /** 加油量字段 code(scenario20,百公里油耗) */ | ||
| 663 | + private String fuelAmountField; | ||
| 664 | + /** 起始公里数字段 code(scenario20) */ | ||
| 665 | + private String startKmField; | ||
| 666 | + /** 结束公里数字段 code(scenario20,油耗=加油量/(本次结束-上次结束)*100) */ | ||
| 667 | + private String endKmField; | ||
| 668 | + /** 非连续用车子表单字段 code(scenario20,主字段为空时取子表单起始公里数最大值) */ | ||
| 669 | + private String subformField; | ||
| 670 | + /** 子表单内起始公里数字段 code(scenario20) */ | ||
| 671 | + private String subformStartField; | ||
| 672 | + /** 正常范围下限(scenario20,含) */ | ||
| 673 | + private double minValue; | ||
| 674 | + /** 正常范围上限(scenario20,含) */ | ||
| 675 | + private double maxValue; | ||
| 676 | + /** Excel 是否同时导出「上次用车」对比行(scenario25 全顺) */ | ||
| 677 | + private boolean includePreviousRow = false; | ||
| 678 | + /** 是否统计「本月前三个月」(不含本月,scenario21) */ | ||
| 679 | + private boolean prevThreeMonths = false; | ||
| 680 | + /** 参评公司列字段 code 列表(scenario21,每月按这些列汇总得分) */ | ||
| 681 | + private List<String> companyFields = new ArrayList<>(); | ||
| 682 | + /** 倒数取前 N 名(scenario21,默认 3) */ | ||
| 683 | + private int bottomCount = 3; | ||
| 684 | + /** 评价得分字段 code(scenario23) */ | ||
| 685 | + private String scoreField; | ||
| 686 | + /** 平均分阈值(scenario23,低于该值为异常,默认 70) */ | ||
| 687 | + private double avgThreshold = 70; | ||
| 688 | + /** 月度项目数下限(含,scenario24) */ | ||
| 689 | + private int minMonthCount; | ||
| 690 | + /** 月度项目数上限(含,scenario24) */ | ||
| 691 | + private int maxMonthCount; | ||
| 692 | + /** 滞后项目数阈值(scenario24,>= 该值为异常) */ | ||
| 693 | + private int minLagCount; | ||
| 694 | + /** 滞后判定天数(scenario24/25:实际-计划 > 该天数,默认 31) */ | ||
| 695 | + private int lagDays = 31; | ||
| 696 | + /** 预算字段 code(scenario25) */ | ||
| 697 | + private String budgetField; | ||
| 698 | + /** 中选价格字段 code(scenario25) */ | ||
| 699 | + private String priceField; | ||
| 700 | + /** 偏离率阈值(scenario25,默认 0.4=40%) */ | ||
| 701 | + private double deviationThreshold = 0.4; | ||
| 702 | + | ||
| 703 | + public String getScoreField() { | ||
| 704 | + return scoreField; | ||
| 705 | + } | ||
| 706 | + | ||
| 707 | + public void setScoreField(String scoreField) { | ||
| 708 | + this.scoreField = scoreField; | ||
| 709 | + } | ||
| 710 | + | ||
| 711 | + public double getAvgThreshold() { | ||
| 712 | + return avgThreshold; | ||
| 713 | + } | ||
| 714 | + | ||
| 715 | + public void setAvgThreshold(double avgThreshold) { | ||
| 716 | + this.avgThreshold = avgThreshold; | ||
| 717 | + } | ||
| 718 | + | ||
| 719 | + public int getMinMonthCount() { | ||
| 720 | + return minMonthCount; | ||
| 721 | + } | ||
| 722 | + | ||
| 723 | + public void setMinMonthCount(int minMonthCount) { | ||
| 724 | + this.minMonthCount = minMonthCount; | ||
| 725 | + } | ||
| 726 | + | ||
| 727 | + public int getMaxMonthCount() { | ||
| 728 | + return maxMonthCount; | ||
| 729 | + } | ||
| 730 | + | ||
| 731 | + public void setMaxMonthCount(int maxMonthCount) { | ||
| 732 | + this.maxMonthCount = maxMonthCount; | ||
| 733 | + } | ||
| 734 | + | ||
| 735 | + public int getMinLagCount() { | ||
| 736 | + return minLagCount; | ||
| 737 | + } | ||
| 738 | + | ||
| 739 | + public void setMinLagCount(int minLagCount) { | ||
| 740 | + this.minLagCount = minLagCount; | ||
| 741 | + } | ||
| 742 | + | ||
| 743 | + public int getLagDays() { | ||
| 744 | + return lagDays; | ||
| 745 | + } | ||
| 746 | + | ||
| 747 | + public void setLagDays(int lagDays) { | ||
| 748 | + this.lagDays = lagDays; | ||
| 749 | + } | ||
| 750 | + | ||
| 751 | + public String getBudgetField() { | ||
| 752 | + return budgetField; | ||
| 753 | + } | ||
| 754 | + | ||
| 755 | + public void setBudgetField(String budgetField) { | ||
| 756 | + this.budgetField = budgetField; | ||
| 757 | + } | ||
| 758 | + | ||
| 759 | + public String getPriceField() { | ||
| 760 | + return priceField; | ||
| 761 | + } | ||
| 762 | + | ||
| 763 | + public void setPriceField(String priceField) { | ||
| 764 | + this.priceField = priceField; | ||
| 765 | + } | ||
| 766 | + | ||
| 767 | + public double getDeviationThreshold() { | ||
| 768 | + return deviationThreshold; | ||
| 769 | + } | ||
| 770 | + | ||
| 771 | + public void setDeviationThreshold(double deviationThreshold) { | ||
| 772 | + this.deviationThreshold = deviationThreshold; | ||
| 773 | + } | ||
| 774 | + | ||
| 775 | + /** 第二个简道云表单 entry_id(scenario22/28:散件/电泳表) */ | ||
| 776 | + private String secondEntryId; | ||
| 777 | + /** 第二表单日期字段(scenario22:生产月份;scenario28:结算账期) */ | ||
| 778 | + private String secondDateField; | ||
| 779 | + /** 第二表单数量字段(scenario22/28) */ | ||
| 780 | + private String secondQtyField; | ||
| 781 | + /** 第二表单账期开始日期字段(scenario28) */ | ||
| 782 | + private String periodStartField; | ||
| 783 | + /** 第二表单账期结束日期字段(scenario28) */ | ||
| 784 | + private String periodEndField; | ||
| 785 | + | ||
| 786 | + /** 流程开始时间字段(scenario29,如“提出时间”) */ | ||
| 787 | + private String startField; | ||
| 788 | + /** 超时天数阈值(scenario29,默认30天) */ | ||
| 789 | + private int thresholdDays = 30; | ||
| 790 | + /** 退货明细子表单字段(scenario30/31) */ | ||
| 791 | + private String subPartField; | ||
| 792 | + private String subQtyField; | ||
| 793 | + private String subDateField; | ||
| 794 | + /** 零件供应商关系表(scenario30/31) */ | ||
| 795 | + private String relEntryId; | ||
| 796 | + private String relPartField; | ||
| 797 | + private String relSupplierField; | ||
| 798 | + private String relEnableField; | ||
| 799 | + private String relTimeField; | ||
| 800 | + /** 已冻结标准成本表(scenario30/32) */ | ||
| 801 | + private String costEntryId; | ||
| 802 | + private String costCodeField; | ||
| 803 | + private String costValueField; | ||
| 804 | + /** 取前N名(scenario30/31,默认3) */ | ||
| 805 | + private int topCount = 3; | ||
| 806 | + /** 库存指标划分表字段(scenario32) */ | ||
| 807 | + private String indicatorCodeField; | ||
| 808 | + private String indicatorTargetField; | ||
| 809 | + /** 库存现有量表(scenario32) */ | ||
| 810 | + private String stockEntryId; | ||
| 811 | + private String stockMonthField; | ||
| 812 | + private String stockPartField; | ||
| 813 | + private String stockQtyField; | ||
| 814 | + private String stockWarehouseField; | ||
| 815 | + /** 指标外爱信库存表(scenario32,可选) */ | ||
| 816 | + private String aixinEntryId; | ||
| 817 | + private String aixinPartField; | ||
| 818 | + /** 库房编码(scenario32) */ | ||
| 819 | + private String warehouseCode; | ||
| 820 | + | ||
| 821 | + /** 人大金仓表名(scenario33/34/35,如 biz_waste_warn_stat) */ | ||
| 822 | + private String table; | ||
| 823 | + /** 处理状态字段(scenario33/34/35,如 handle_status / is_handled) */ | ||
| 824 | + private String handleField; | ||
| 825 | + /** 视为「未处理」的状态取值(scenario33/34/35) */ | ||
| 826 | + private List<String> handleValues = new ArrayList<>(); | ||
| 827 | + /** 状态码 -> 中文显示(scenario34:3=未处理) */ | ||
| 828 | + private Map<String, String> handleValueLabels = new LinkedHashMap<>(); | ||
| 829 | + /** 统计年份字段(scenario33,如 stat_year) */ | ||
| 830 | + private String statYearField; | ||
| 831 | + /** 统计月份字段(scenario33,如 stat_month) */ | ||
| 832 | + private String statMonthField; | ||
| 833 | + /** Excel 导出列(按配置顺序;空则取表全部列) */ | ||
| 834 | + private List<String> columns = new ArrayList<>(); | ||
| 835 | + /** Excel 列中文表头:列名 -> 标题 */ | ||
| 836 | + private Map<String, String> columnLabels = new LinkedHashMap<>(); | ||
| 837 | + | ||
| 838 | + public String getStartField() { return startField; } | ||
| 839 | + public void setStartField(String v) { this.startField = v; } | ||
| 840 | + public int getThresholdDays() { return thresholdDays; } | ||
| 841 | + public void setThresholdDays(int v) { this.thresholdDays = v; } | ||
| 842 | + public String getSubPartField() { return subPartField; } | ||
| 843 | + public void setSubPartField(String v) { this.subPartField = v; } | ||
| 844 | + public String getSubQtyField() { return subQtyField; } | ||
| 845 | + public void setSubQtyField(String v) { this.subQtyField = v; } | ||
| 846 | + public String getSubDateField() { return subDateField; } | ||
| 847 | + public void setSubDateField(String v) { this.subDateField = v; } | ||
| 848 | + public String getRelEntryId() { return relEntryId; } | ||
| 849 | + public void setRelEntryId(String v) { this.relEntryId = v; } | ||
| 850 | + public String getRelPartField() { return relPartField; } | ||
| 851 | + public void setRelPartField(String v) { this.relPartField = v; } | ||
| 852 | + public String getRelSupplierField() { return relSupplierField; } | ||
| 853 | + public void setRelSupplierField(String v) { this.relSupplierField = v; } | ||
| 854 | + public String getRelEnableField() { return relEnableField; } | ||
| 855 | + public void setRelEnableField(String v) { this.relEnableField = v; } | ||
| 856 | + public String getRelTimeField() { return relTimeField; } | ||
| 857 | + public void setRelTimeField(String v) { this.relTimeField = v; } | ||
| 858 | + public String getCostEntryId() { return costEntryId; } | ||
| 859 | + public void setCostEntryId(String v) { this.costEntryId = v; } | ||
| 860 | + public String getCostCodeField() { return costCodeField; } | ||
| 861 | + public void setCostCodeField(String v) { this.costCodeField = v; } | ||
| 862 | + public String getCostValueField() { return costValueField; } | ||
| 863 | + public void setCostValueField(String v) { this.costValueField = v; } | ||
| 864 | + public int getTopCount() { return topCount; } | ||
| 865 | + public void setTopCount(int v) { this.topCount = v; } | ||
| 866 | + public String getIndicatorCodeField() { return indicatorCodeField; } | ||
| 867 | + public void setIndicatorCodeField(String v) { this.indicatorCodeField = v; } | ||
| 868 | + public String getIndicatorTargetField() { return indicatorTargetField; } | ||
| 869 | + public void setIndicatorTargetField(String v) { this.indicatorTargetField = v; } | ||
| 870 | + public String getStockEntryId() { return stockEntryId; } | ||
| 871 | + public void setStockEntryId(String v) { this.stockEntryId = v; } | ||
| 872 | + public String getStockMonthField() { return stockMonthField; } | ||
| 873 | + public void setStockMonthField(String v) { this.stockMonthField = v; } | ||
| 874 | + public String getStockPartField() { return stockPartField; } | ||
| 875 | + public void setStockPartField(String v) { this.stockPartField = v; } | ||
| 876 | + public String getStockQtyField() { return stockQtyField; } | ||
| 877 | + public void setStockQtyField(String v) { this.stockQtyField = v; } | ||
| 878 | + public String getStockWarehouseField() { return stockWarehouseField; } | ||
| 879 | + public void setStockWarehouseField(String v) { this.stockWarehouseField = v; } | ||
| 880 | + public String getAixinEntryId() { return aixinEntryId; } | ||
| 881 | + public void setAixinEntryId(String v) { this.aixinEntryId = v; } | ||
| 882 | + public String getAixinPartField() { return aixinPartField; } | ||
| 883 | + public void setAixinPartField(String v) { this.aixinPartField = v; } | ||
| 884 | + public String getWarehouseCode() { return warehouseCode; } | ||
| 885 | + public void setWarehouseCode(String v) { this.warehouseCode = v; } | ||
| 886 | + public String getTable() { return table; } | ||
| 887 | + public void setTable(String v) { this.table = v; } | ||
| 888 | + public String getHandleField() { return handleField; } | ||
| 889 | + public void setHandleField(String v) { this.handleField = v; } | ||
| 890 | + public List<String> getHandleValues() { return handleValues; } | ||
| 891 | + public void setHandleValues(List<String> v) { this.handleValues = v; } | ||
| 892 | + public Map<String, String> getHandleValueLabels() { return handleValueLabels; } | ||
| 893 | + public void setHandleValueLabels(Map<String, String> v) { this.handleValueLabels = v; } | ||
| 894 | + public String getStatYearField() { return statYearField; } | ||
| 895 | + public void setStatYearField(String v) { this.statYearField = v; } | ||
| 896 | + public String getStatMonthField() { return statMonthField; } | ||
| 897 | + public void setStatMonthField(String v) { this.statMonthField = v; } | ||
| 898 | + public List<String> getColumns() { return columns; } | ||
| 899 | + public void setColumns(List<String> v) { this.columns = v; } | ||
| 900 | + public Map<String, String> getColumnLabels() { return columnLabels; } | ||
| 901 | + public void setColumnLabels(Map<String, String> v) { this.columnLabels = v; } | ||
| 902 | + | ||
| 903 | + public String getSecondEntryId() { return secondEntryId; } | ||
| 904 | + public void setSecondEntryId(String v) { this.secondEntryId = v; } | ||
| 905 | + public String getSecondDateField() { return secondDateField; } | ||
| 906 | + public void setSecondDateField(String v) { this.secondDateField = v; } | ||
| 907 | + public String getSecondQtyField() { return secondQtyField; } | ||
| 908 | + public void setSecondQtyField(String v) { this.secondQtyField = v; } | ||
| 909 | + public String getPeriodStartField() { return periodStartField; } | ||
| 910 | + public void setPeriodStartField(String v) { this.periodStartField = v; } | ||
| 911 | + public String getPeriodEndField() { return periodEndField; } | ||
| 912 | + public void setPeriodEndField(String v) { this.periodEndField = v; } | ||
| 913 | + | ||
| 914 | + public boolean isPrevThreeMonths() { | ||
| 915 | + return prevThreeMonths; | ||
| 916 | + } | ||
| 917 | + | ||
| 918 | + public void setPrevThreeMonths(boolean prevThreeMonths) { | ||
| 919 | + this.prevThreeMonths = prevThreeMonths; | ||
| 920 | + } | ||
| 921 | + | ||
| 922 | + public List<String> getCompanyFields() { | ||
| 923 | + return companyFields; | ||
| 924 | + } | ||
| 925 | + | ||
| 926 | + public void setCompanyFields(List<String> companyFields) { | ||
| 927 | + this.companyFields = companyFields; | ||
| 928 | + } | ||
| 929 | + | ||
| 930 | + public int getBottomCount() { | ||
| 931 | + return bottomCount; | ||
| 932 | + } | ||
| 933 | + | ||
| 934 | + public void setBottomCount(int bottomCount) { | ||
| 935 | + this.bottomCount = bottomCount; | ||
| 936 | + } | ||
| 937 | + | ||
| 938 | + public String getFuelAmountField() { | ||
| 939 | + return fuelAmountField; | ||
| 940 | + } | ||
| 941 | + | ||
| 942 | + public void setFuelAmountField(String fuelAmountField) { | ||
| 943 | + this.fuelAmountField = fuelAmountField; | ||
| 944 | + } | ||
| 945 | + | ||
| 946 | + public String getStartKmField() { | ||
| 947 | + return startKmField; | ||
| 948 | + } | ||
| 949 | + | ||
| 950 | + public void setStartKmField(String startKmField) { | ||
| 951 | + this.startKmField = startKmField; | ||
| 952 | + } | ||
| 953 | + | ||
| 954 | + public String getEndKmField() { | ||
| 955 | + return endKmField; | ||
| 956 | + } | ||
| 957 | + | ||
| 958 | + public void setEndKmField(String endKmField) { | ||
| 959 | + this.endKmField = endKmField; | ||
| 960 | + } | ||
| 961 | + | ||
| 962 | + public String getSubformField() { | ||
| 963 | + return subformField; | ||
| 964 | + } | ||
| 965 | + | ||
| 966 | + public void setSubformField(String subformField) { | ||
| 967 | + this.subformField = subformField; | ||
| 968 | + } | ||
| 969 | + | ||
| 970 | + public String getSubformStartField() { | ||
| 971 | + return subformStartField; | ||
| 972 | + } | ||
| 973 | + | ||
| 974 | + public void setSubformStartField(String subformStartField) { | ||
| 975 | + this.subformStartField = subformStartField; | ||
| 976 | + } | ||
| 977 | + | ||
| 978 | + public double getMinValue() { | ||
| 979 | + return minValue; | ||
| 980 | + } | ||
| 981 | + | ||
| 982 | + public void setMinValue(double minValue) { | ||
| 983 | + this.minValue = minValue; | ||
| 984 | + } | ||
| 985 | + | ||
| 986 | + public double getMaxValue() { | ||
| 987 | + return maxValue; | ||
| 988 | + } | ||
| 989 | + | ||
| 990 | + public void setMaxValue(double maxValue) { | ||
| 991 | + this.maxValue = maxValue; | ||
| 992 | + } | ||
| 993 | + | ||
| 994 | + public boolean isIncludePreviousRow() { | ||
| 995 | + return includePreviousRow; | ||
| 996 | + } | ||
| 997 | + | ||
| 998 | + public void setIncludePreviousRow(boolean includePreviousRow) { | ||
| 999 | + this.includePreviousRow = includePreviousRow; | ||
| 1000 | + } | ||
| 1001 | + | ||
| 1002 | + public Integer getFlowStateValue() { | ||
| 1003 | + return flowStateValue; | ||
| 1004 | + } | ||
| 1005 | + | ||
| 1006 | + public void setFlowStateValue(Integer flowStateValue) { | ||
| 1007 | + this.flowStateValue = flowStateValue; | ||
| 1008 | + } | ||
| 1009 | + | ||
| 1010 | + public List<PhotoRule> getPhotoRules() { | ||
| 1011 | + return photoRules; | ||
| 1012 | + } | ||
| 1013 | + | ||
| 1014 | + public void setPhotoRules(List<PhotoRule> photoRules) { | ||
| 1015 | + this.photoRules = photoRules; | ||
| 1016 | + } | ||
| 1017 | + | ||
| 1018 | + public List<String> getFlagValues() { | ||
| 1019 | + return flagValues; | ||
| 1020 | + } | ||
| 1021 | + | ||
| 1022 | + public void setFlagValues(List<String> flagValues) { | ||
| 1023 | + this.flagValues = flagValues; | ||
| 1024 | + } | ||
| 1025 | + | ||
| 1026 | + public String getPlanField() { | ||
| 1027 | + return planField; | ||
| 1028 | + } | ||
| 1029 | + | ||
| 1030 | + public void setPlanField(String planField) { | ||
| 1031 | + this.planField = planField; | ||
| 1032 | + } | ||
| 1033 | + | ||
| 1034 | + public String getActualField() { | ||
| 1035 | + return actualField; | ||
| 1036 | + } | ||
| 1037 | + | ||
| 1038 | + public void setActualField(String actualField) { | ||
| 1039 | + this.actualField = actualField; | ||
| 1040 | + } | ||
| 1041 | + | ||
| 1042 | + public int getOverdueDays() { | ||
| 1043 | + return overdueDays; | ||
| 1044 | + } | ||
| 1045 | + | ||
| 1046 | + public void setOverdueDays(int overdueDays) { | ||
| 1047 | + this.overdueDays = overdueDays; | ||
| 1048 | + } | ||
| 1049 | + | ||
| 1050 | + public String getDurationField() { | ||
| 1051 | + return durationField; | ||
| 1052 | + } | ||
| 1053 | + | ||
| 1054 | + public void setDurationField(String durationField) { | ||
| 1055 | + this.durationField = durationField; | ||
| 1056 | + } | ||
| 1057 | + | ||
| 1058 | + public double getDurationThreshold() { | ||
| 1059 | + return durationThreshold; | ||
| 1060 | + } | ||
| 1061 | + | ||
| 1062 | + public void setDurationThreshold(double durationThreshold) { | ||
| 1063 | + this.durationThreshold = durationThreshold; | ||
| 1064 | + } | ||
| 1065 | + | ||
| 1066 | + public String getAbnormalField() { | ||
| 1067 | + return abnormalField; | ||
| 1068 | + } | ||
| 1069 | + | ||
| 1070 | + public void setAbnormalField(String abnormalField) { | ||
| 1071 | + this.abnormalField = abnormalField; | ||
| 1072 | + } | ||
| 1073 | + | ||
| 1074 | + public String getAbnormalValue() { | ||
| 1075 | + return abnormalValue; | ||
| 1076 | + } | ||
| 1077 | + | ||
| 1078 | + public void setAbnormalValue(String abnormalValue) { | ||
| 1079 | + this.abnormalValue = abnormalValue; | ||
| 1080 | + } | ||
| 1081 | + | ||
| 1082 | + public String getReasonField() { | ||
| 1083 | + return reasonField; | ||
| 1084 | + } | ||
| 1085 | + | ||
| 1086 | + public void setReasonField(String reasonField) { | ||
| 1087 | + this.reasonField = reasonField; | ||
| 1088 | + } | ||
| 1089 | + | ||
| 1090 | + public List<Pair> getPairs() { | ||
| 1091 | + return pairs; | ||
| 1092 | + } | ||
| 1093 | + | ||
| 1094 | + public void setPairs(List<Pair> pairs) { | ||
| 1095 | + this.pairs = pairs; | ||
| 1096 | + } | ||
| 1097 | + | ||
| 232 | public String getId() { | 1098 | public String getId() { |
| 233 | return id; | 1099 | return id; |
| 234 | } | 1100 | } |
| @@ -349,6 +1215,14 @@ public class JdyRiskProperties { | @@ -349,6 +1215,14 @@ public class JdyRiskProperties { | ||
| 349 | this.quarterOnly = quarterOnly; | 1215 | this.quarterOnly = quarterOnly; |
| 350 | } | 1216 | } |
| 351 | 1217 | ||
| 1218 | + public boolean isPrevQuarterOnly() { | ||
| 1219 | + return prevQuarterOnly; | ||
| 1220 | + } | ||
| 1221 | + | ||
| 1222 | + public void setPrevQuarterOnly(boolean prevQuarterOnly) { | ||
| 1223 | + this.prevQuarterOnly = prevQuarterOnly; | ||
| 1224 | + } | ||
| 1225 | + | ||
| 352 | public boolean isYearOnly() { | 1226 | public boolean isYearOnly() { |
| 353 | return yearOnly; | 1227 | return yearOnly; |
| 354 | } | 1228 | } |
| @@ -365,6 +1239,14 @@ public class JdyRiskProperties { | @@ -365,6 +1239,14 @@ public class JdyRiskProperties { | ||
| 365 | this.prevMonthOnly = prevMonthOnly; | 1239 | this.prevMonthOnly = prevMonthOnly; |
| 366 | } | 1240 | } |
| 367 | 1241 | ||
| 1242 | + public boolean isHalfMonthOnly() { | ||
| 1243 | + return halfMonthOnly; | ||
| 1244 | + } | ||
| 1245 | + | ||
| 1246 | + public void setHalfMonthOnly(boolean halfMonthOnly) { | ||
| 1247 | + this.halfMonthOnly = halfMonthOnly; | ||
| 1248 | + } | ||
| 1249 | + | ||
| 368 | public String getFlagField() { | 1250 | public String getFlagField() { |
| 369 | return flagField; | 1251 | return flagField; |
| 370 | } | 1252 | } |
| @@ -389,6 +1271,14 @@ public class JdyRiskProperties { | @@ -389,6 +1271,14 @@ public class JdyRiskProperties { | ||
| 389 | this.ratioThreshold = ratioThreshold; | 1271 | this.ratioThreshold = ratioThreshold; |
| 390 | } | 1272 | } |
| 391 | 1273 | ||
| 1274 | + public double getAbsThreshold() { | ||
| 1275 | + return absThreshold; | ||
| 1276 | + } | ||
| 1277 | + | ||
| 1278 | + public void setAbsThreshold(double absThreshold) { | ||
| 1279 | + this.absThreshold = absThreshold; | ||
| 1280 | + } | ||
| 1281 | + | ||
| 392 | public String getBarcodeField() { | 1282 | public String getBarcodeField() { |
| 393 | return barcodeField; | 1283 | return barcodeField; |
| 394 | } | 1284 | } |
| @@ -397,6 +1287,30 @@ public class JdyRiskProperties { | @@ -397,6 +1287,30 @@ public class JdyRiskProperties { | ||
| 397 | this.barcodeField = barcodeField; | 1287 | this.barcodeField = barcodeField; |
| 398 | } | 1288 | } |
| 399 | 1289 | ||
| 1290 | + public String getCompareEntryId() { | ||
| 1291 | + return compareEntryId; | ||
| 1292 | + } | ||
| 1293 | + | ||
| 1294 | + public void setCompareEntryId(String compareEntryId) { | ||
| 1295 | + this.compareEntryId = compareEntryId; | ||
| 1296 | + } | ||
| 1297 | + | ||
| 1298 | + public String getCompareBarcodeField() { | ||
| 1299 | + return compareBarcodeField; | ||
| 1300 | + } | ||
| 1301 | + | ||
| 1302 | + public void setCompareBarcodeField(String compareBarcodeField) { | ||
| 1303 | + this.compareBarcodeField = compareBarcodeField; | ||
| 1304 | + } | ||
| 1305 | + | ||
| 1306 | + public List<String> getCompareFields() { | ||
| 1307 | + return compareFields; | ||
| 1308 | + } | ||
| 1309 | + | ||
| 1310 | + public void setCompareFields(List<String> compareFields) { | ||
| 1311 | + this.compareFields = compareFields; | ||
| 1312 | + } | ||
| 1313 | + | ||
| 400 | public List<ExcludeForm> getExcludeForms() { | 1314 | public List<ExcludeForm> getExcludeForms() { |
| 401 | return excludeForms; | 1315 | return excludeForms; |
| 402 | } | 1316 | } |
| @@ -413,6 +1327,14 @@ public class JdyRiskProperties { | @@ -413,6 +1327,14 @@ public class JdyRiskProperties { | ||
| 413 | this.maxAgeDays = maxAgeDays; | 1327 | this.maxAgeDays = maxAgeDays; |
| 414 | } | 1328 | } |
| 415 | 1329 | ||
| 1330 | + public boolean isMonthlyOverdueIncremental() { | ||
| 1331 | + return monthlyOverdueIncremental; | ||
| 1332 | + } | ||
| 1333 | + | ||
| 1334 | + public void setMonthlyOverdueIncremental(boolean monthlyOverdueIncremental) { | ||
| 1335 | + this.monthlyOverdueIncremental = monthlyOverdueIncremental; | ||
| 1336 | + } | ||
| 1337 | + | ||
| 416 | public List<String> getFields() { | 1338 | public List<String> getFields() { |
| 417 | return fields; | 1339 | return fields; |
| 418 | } | 1340 | } |
| @@ -453,6 +1375,46 @@ public class JdyRiskProperties { | @@ -453,6 +1375,46 @@ public class JdyRiskProperties { | ||
| 453 | this.extraField = extraField; | 1375 | this.extraField = extraField; |
| 454 | } | 1376 | } |
| 455 | 1377 | ||
| 1378 | + public List<String> getPercentFields() { | ||
| 1379 | + return percentFields; | ||
| 1380 | + } | ||
| 1381 | + | ||
| 1382 | + public void setPercentFields(List<String> percentFields) { | ||
| 1383 | + this.percentFields = percentFields; | ||
| 1384 | + } | ||
| 1385 | + | ||
| 1386 | + public boolean isOnlyWarnRows() { | ||
| 1387 | + return onlyWarnRows; | ||
| 1388 | + } | ||
| 1389 | + | ||
| 1390 | + public void setOnlyWarnRows(boolean onlyWarnRows) { | ||
| 1391 | + this.onlyWarnRows = onlyWarnRows; | ||
| 1392 | + } | ||
| 1393 | + | ||
| 1394 | + public String getLookupField() { | ||
| 1395 | + return lookupField; | ||
| 1396 | + } | ||
| 1397 | + | ||
| 1398 | + public void setLookupField(String lookupField) { | ||
| 1399 | + this.lookupField = lookupField; | ||
| 1400 | + } | ||
| 1401 | + | ||
| 1402 | + public String getLookupEntryId() { | ||
| 1403 | + return lookupEntryId; | ||
| 1404 | + } | ||
| 1405 | + | ||
| 1406 | + public void setLookupEntryId(String lookupEntryId) { | ||
| 1407 | + this.lookupEntryId = lookupEntryId; | ||
| 1408 | + } | ||
| 1409 | + | ||
| 1410 | + public String getLookupNameField() { | ||
| 1411 | + return lookupNameField; | ||
| 1412 | + } | ||
| 1413 | + | ||
| 1414 | + public void setLookupNameField(String lookupNameField) { | ||
| 1415 | + this.lookupNameField = lookupNameField; | ||
| 1416 | + } | ||
| 1417 | + | ||
| 456 | public String getSyncCode() { | 1418 | public String getSyncCode() { |
| 457 | return syncCode; | 1419 | return syncCode; |
| 458 | } | 1420 | } |
| @@ -485,4 +1447,72 @@ public class JdyRiskProperties { | @@ -485,4 +1447,72 @@ public class JdyRiskProperties { | ||
| 485 | this.barcodeField = barcodeField; | 1447 | this.barcodeField = barcodeField; |
| 486 | } | 1448 | } |
| 487 | } | 1449 | } |
| 1450 | + | ||
| 1451 | + /** scenario15:条件照片校验规则(条件字段命中 flagValue 时,照片字段不能为空)。 */ | ||
| 1452 | + public static class PhotoRule { | ||
| 1453 | + /** 条件字段 code(如 是否有隐蔽工程) */ | ||
| 1454 | + private String flagField; | ||
| 1455 | + /** 条件命中值(默认「是」) */ | ||
| 1456 | + private String flagValue = "是"; | ||
| 1457 | + /** 需为非空的照片字段 code */ | ||
| 1458 | + private String photoField; | ||
| 1459 | + /** 原因文案(为空时自动取照片字段的表单标题 + 「为空」) */ | ||
| 1460 | + private String label; | ||
| 1461 | + | ||
| 1462 | + public String getFlagField() { | ||
| 1463 | + return flagField; | ||
| 1464 | + } | ||
| 1465 | + | ||
| 1466 | + public void setFlagField(String flagField) { | ||
| 1467 | + this.flagField = flagField; | ||
| 1468 | + } | ||
| 1469 | + | ||
| 1470 | + public String getFlagValue() { | ||
| 1471 | + return flagValue; | ||
| 1472 | + } | ||
| 1473 | + | ||
| 1474 | + public void setFlagValue(String flagValue) { | ||
| 1475 | + this.flagValue = flagValue; | ||
| 1476 | + } | ||
| 1477 | + | ||
| 1478 | + public String getPhotoField() { | ||
| 1479 | + return photoField; | ||
| 1480 | + } | ||
| 1481 | + | ||
| 1482 | + public void setPhotoField(String photoField) { | ||
| 1483 | + this.photoField = photoField; | ||
| 1484 | + } | ||
| 1485 | + | ||
| 1486 | + public String getLabel() { | ||
| 1487 | + return label; | ||
| 1488 | + } | ||
| 1489 | + | ||
| 1490 | + public void setLabel(String label) { | ||
| 1491 | + this.label = label; | ||
| 1492 | + } | ||
| 1493 | + } | ||
| 1494 | + | ||
| 1495 | + /** scenario12:人员字段与对应的手写签字确认字段配对。 */ | ||
| 1496 | + public static class Pair { | ||
| 1497 | + /** 参与人员字段 code */ | ||
| 1498 | + private String personField; | ||
| 1499 | + /** 对应的手写签字确认字段 code */ | ||
| 1500 | + private String signField; | ||
| 1501 | + | ||
| 1502 | + public String getPersonField() { | ||
| 1503 | + return personField; | ||
| 1504 | + } | ||
| 1505 | + | ||
| 1506 | + public void setPersonField(String personField) { | ||
| 1507 | + this.personField = personField; | ||
| 1508 | + } | ||
| 1509 | + | ||
| 1510 | + public String getSignField() { | ||
| 1511 | + return signField; | ||
| 1512 | + } | ||
| 1513 | + | ||
| 1514 | + public void setSignField(String signField) { | ||
| 1515 | + this.signField = signField; | ||
| 1516 | + } | ||
| 1517 | + } | ||
| 488 | } | 1518 | } |
| @@ -9,6 +9,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; | @@ -9,6 +9,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; | ||
| 9 | */ | 9 | */ |
| 10 | @Configuration | 10 | @Configuration |
| 11 | @EnableScheduling | 11 | @EnableScheduling |
| 12 | -@EnableConfigurationProperties({JdySyncProperties.class, JdyRiskProperties.class, JdyFormSyncProperties.class}) | 12 | +@EnableConfigurationProperties({JdySyncProperties.class, JdyRiskProperties.class, JdyFormSyncProperties.class, EmpSyncProperties.class}) |
| 13 | public class JdySyncConfig { | 13 | public class JdySyncConfig { |
| 14 | } | 14 | } |
| 1 | +package com.qgutech.qgyun.apaas.sync.jdy.controller; | ||
| 2 | + | ||
| 3 | +import com.qgutech.qgyun.apaas.sync.jdy.service.EmpSyncService; | ||
| 4 | +import lombok.extern.slf4j.Slf4j; | ||
| 5 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 8 | +import org.springframework.web.bind.annotation.RestController; | ||
| 9 | + | ||
| 10 | +import javax.annotation.Resource; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 员工信息同步接口(人大金仓 -> 启效员工信息表单)。 | ||
| 14 | + */ | ||
| 15 | +@Slf4j | ||
| 16 | +@RestController | ||
| 17 | +@RequestMapping("/api/emp") | ||
| 18 | +public class EmpSyncController { | ||
| 19 | + | ||
| 20 | + @Resource | ||
| 21 | + private EmpSyncService empSyncService; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 第一步:启效已存在人员按姓名匹配人大金仓,回填员工编号(gh)。 | ||
| 25 | + * 例:POST /api/emp/sync/gh?dryRun=true | ||
| 26 | + */ | ||
| 27 | + @PostMapping("/sync/gh") | ||
| 28 | + public String syncGh(@RequestParam(required = false) Boolean dryRun) { | ||
| 29 | + return empSyncService.syncGhByName(Boolean.TRUE.equals(dryRun)); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 第二步:按员工编号(gh)全量同步,已存在更新、不存在新增。 | ||
| 34 | + * 例:POST /api/emp/sync/all?dryRun=true&limit=100&offset=0 | ||
| 35 | + */ | ||
| 36 | + @PostMapping("/sync/all") | ||
| 37 | + public String syncAll(@RequestParam(required = false) Boolean dryRun, | ||
| 38 | + @RequestParam(required = false) Integer limit, | ||
| 39 | + @RequestParam(required = false) Integer offset) { | ||
| 40 | + boolean dr = dryRun != null ? dryRun : false; | ||
| 41 | + int lim = limit != null ? limit : 0; | ||
| 42 | + int off = offset != null ? offset : 0; | ||
| 43 | + return empSyncService.syncAll(dr, lim, off); | ||
| 44 | + } | ||
| 45 | +} |
| @@ -6,9 +6,13 @@ import org.springframework.web.bind.annotation.GetMapping; | @@ -6,9 +6,13 @@ import org.springframework.web.bind.annotation.GetMapping; | ||
| 6 | import org.springframework.web.bind.annotation.PathVariable; | 6 | import org.springframework.web.bind.annotation.PathVariable; |
| 7 | import org.springframework.web.bind.annotation.PostMapping; | 7 | import org.springframework.web.bind.annotation.PostMapping; |
| 8 | import org.springframework.web.bind.annotation.RequestMapping; | 8 | import org.springframework.web.bind.annotation.RequestMapping; |
| 9 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | import org.springframework.web.bind.annotation.RestController; | 10 | import org.springframework.web.bind.annotation.RestController; |
| 10 | 11 | ||
| 11 | import javax.annotation.Resource; | 12 | import javax.annotation.Resource; |
| 13 | +import java.util.Arrays; | ||
| 14 | +import java.util.ArrayList; | ||
| 15 | +import java.util.List; | ||
| 12 | import java.util.Map; | 16 | import java.util.Map; |
| 13 | 17 | ||
| 14 | /** | 18 | /** |
| @@ -69,4 +73,63 @@ public class JdyRiskController { | @@ -69,4 +73,63 @@ public class JdyRiskController { | ||
| 69 | public Map<String, Object> syncOneGet(@PathVariable String scenarioId) { | 73 | public Map<String, Object> syncOneGet(@PathVariable String scenarioId) { |
| 70 | return riskService.countAndSyncOne(scenarioId); | 74 | return riskService.countAndSyncOne(scenarioId); |
| 71 | } | 75 | } |
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 一次性历史回补。参数:from/to=数据月份(yyyy-MM);scenarioIds=逗号分隔的 count_x/syncCode(空=全部); | ||
| 79 | + * dryRun=true 只统计不写回;wipe=true 先清掉本次范围内的旧记录。 | ||
| 80 | + * 例:/api/jdy/risk/backfill?from=2026-01&to=2026-10&dryRun=true | ||
| 81 | + */ | ||
| 82 | + @PostMapping("/backfill") | ||
| 83 | + public Map<String, Object> backfill(@RequestParam(required = false, defaultValue = "2026-01") String from, | ||
| 84 | + @RequestParam(required = false, defaultValue = "2026-10") String to, | ||
| 85 | + @RequestParam(required = false) String scenarioIds, | ||
| 86 | + @RequestParam(required = false, defaultValue = "true") boolean dryRun, | ||
| 87 | + @RequestParam(required = false, defaultValue = "false") boolean wipe, | ||
| 88 | + @RequestParam(required = false) String toDate) { | ||
| 89 | + return riskService.backfill(from, to, parseIds(scenarioIds), dryRun, wipe, toDate); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @GetMapping("/backfill") | ||
| 93 | + public Map<String, Object> backfillGet(@RequestParam(required = false, defaultValue = "2026-01") String from, | ||
| 94 | + @RequestParam(required = false, defaultValue = "2026-10") String to, | ||
| 95 | + @RequestParam(required = false) String scenarioIds, | ||
| 96 | + @RequestParam(required = false, defaultValue = "true") boolean dryRun, | ||
| 97 | + @RequestParam(required = false, defaultValue = "false") boolean wipe, | ||
| 98 | + @RequestParam(required = false) String toDate) { | ||
| 99 | + return riskService.backfill(from, to, parseIds(scenarioIds), dryRun, wipe, toDate); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * 设备域场景20/21/22(人大金仓)一键历史回补:默认同步 2026-01-01 ~ 2026-10-30。 | ||
| 104 | + * 例:/api/jdy/risk/backfill-db?fromDate=2026-01-01&toDate=2026-10-30&dryRun=false | ||
| 105 | + */ | ||
| 106 | + @PostMapping("/backfill-db") | ||
| 107 | + public Map<String, Object> backfillDb(@RequestParam(required = false, defaultValue = "2026-01-01") String fromDate, | ||
| 108 | + @RequestParam(required = false, defaultValue = "2026-10-30") String toDate, | ||
| 109 | + @RequestParam(required = false, defaultValue = "true") boolean dryRun, | ||
| 110 | + @RequestParam(required = false, defaultValue = "false") boolean wipe) { | ||
| 111 | + return riskService.backfillDb(fromDate, toDate, dryRun, wipe); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + @GetMapping("/backfill-db") | ||
| 115 | + public Map<String, Object> backfillDbGet(@RequestParam(required = false, defaultValue = "2026-01-01") String fromDate, | ||
| 116 | + @RequestParam(required = false, defaultValue = "2026-10-30") String toDate, | ||
| 117 | + @RequestParam(required = false, defaultValue = "true") boolean dryRun, | ||
| 118 | + @RequestParam(required = false, defaultValue = "false") boolean wipe) { | ||
| 119 | + return riskService.backfillDb(fromDate, toDate, dryRun, wipe); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + private static List<String> parseIds(String scenarioIds) { | ||
| 123 | + List<String> ids = new ArrayList<>(); | ||
| 124 | + if (scenarioIds == null || scenarioIds.trim().isEmpty()) { | ||
| 125 | + return ids; | ||
| 126 | + } | ||
| 127 | + for (String id : Arrays.asList(scenarioIds.split(","))) { | ||
| 128 | + String v = id.trim(); | ||
| 129 | + if (!v.isEmpty()) { | ||
| 130 | + ids.add(v); | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + return ids; | ||
| 134 | + } | ||
| 72 | } | 135 | } |
| 1 | +package com.qgutech.qgyun.apaas.sync.jdy.db; | ||
| 2 | + | ||
| 3 | +import lombok.extern.slf4j.Slf4j; | ||
| 4 | + | ||
| 5 | +import java.sql.Connection; | ||
| 6 | +import java.sql.DriverManager; | ||
| 7 | +import java.sql.ResultSet; | ||
| 8 | +import java.sql.ResultSetMetaData; | ||
| 9 | +import java.sql.SQLException; | ||
| 10 | +import java.sql.Statement; | ||
| 11 | +import java.util.ArrayList; | ||
| 12 | +import java.util.LinkedHashMap; | ||
| 13 | +import java.util.List; | ||
| 14 | +import java.util.Map; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * 人大金仓(KingbaseES)员工信息读取 DAO(JDBC 直连,无中间件依赖)。 | ||
| 18 | + * <p> | ||
| 19 | + * KingbaseES 兼容 PostgreSQL 协议,使用官方 kingbase8 驱动。 | ||
| 20 | + */ | ||
| 21 | +@Slf4j | ||
| 22 | +public class KingbaseEmpDao { | ||
| 23 | + | ||
| 24 | + private final String url; | ||
| 25 | + private final String username; | ||
| 26 | + private final String password; | ||
| 27 | + private final String table; | ||
| 28 | + private final String filter; | ||
| 29 | + private final String driverClass; | ||
| 30 | + | ||
| 31 | + public KingbaseEmpDao(String url, String username, String password, String table, String filter, String driverClass) { | ||
| 32 | + this.url = url; | ||
| 33 | + this.username = username; | ||
| 34 | + this.password = password; | ||
| 35 | + this.table = table; | ||
| 36 | + this.filter = filter; | ||
| 37 | + this.driverClass = driverClass; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 读取整表指定列,返回每行一个 Map(列名 -> 原始值,未做类型转换)。 | ||
| 42 | + * | ||
| 43 | + * @param columns 需要读取的列(小写,固定常量,不做用户输入) | ||
| 44 | + */ | ||
| 45 | + public List<Map<String, Object>> findAll(List<String> columns) { | ||
| 46 | + if (columns == null || columns.isEmpty()) { | ||
| 47 | + throw new IllegalArgumentException("columns 不能为空"); | ||
| 48 | + } | ||
| 49 | + StringBuilder select = new StringBuilder(); | ||
| 50 | + for (int i = 0; i < columns.size(); i++) { | ||
| 51 | + if (i > 0) { | ||
| 52 | + select.append(", "); | ||
| 53 | + } | ||
| 54 | + select.append(columns.get(i)); | ||
| 55 | + } | ||
| 56 | + String sql = "SELECT " + select + " FROM " + table | ||
| 57 | + + (filter != null && !filter.trim().isEmpty() ? " WHERE " + filter : ""); | ||
| 58 | + log.info("人大金仓查询: {}", sql); | ||
| 59 | + List<Map<String, Object>> rows = new ArrayList<>(); | ||
| 60 | + try { | ||
| 61 | + Class.forName(driverClass); | ||
| 62 | + } catch (ClassNotFoundException e) { | ||
| 63 | + throw new IllegalStateException("加载 Kingbase JDBC 驱动失败: " + driverClass, e); | ||
| 64 | + } | ||
| 65 | + try (Connection conn = DriverManager.getConnection(url, username, password); | ||
| 66 | + Statement st = conn.createStatement(); | ||
| 67 | + ResultSet rs = st.executeQuery(sql)) { | ||
| 68 | + ResultSetMetaData md = rs.getMetaData(); | ||
| 69 | + int n = md.getColumnCount(); | ||
| 70 | + while (rs.next()) { | ||
| 71 | + Map<String, Object> row = new LinkedHashMap<>(n * 2); | ||
| 72 | + for (int i = 1; i <= n; i++) { | ||
| 73 | + row.put(md.getColumnLabel(i).toLowerCase(), rs.getObject(i)); | ||
| 74 | + } | ||
| 75 | + rows.add(row); | ||
| 76 | + } | ||
| 77 | + log.info("人大金仓读取完成: {} 行 (表={})", rows.size(), table); | ||
| 78 | + return rows; | ||
| 79 | + } catch (SQLException e) { | ||
| 80 | + throw new RuntimeException("读取人大金仓失败: " + e.getMessage(), e); | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | +} |
| 1 | +package com.qgutech.qgyun.apaas.sync.jdy.db; | ||
| 2 | + | ||
| 3 | +import lombok.extern.slf4j.Slf4j; | ||
| 4 | + | ||
| 5 | +import java.sql.Connection; | ||
| 6 | +import java.sql.DriverManager; | ||
| 7 | +import java.sql.PreparedStatement; | ||
| 8 | +import java.sql.ResultSet; | ||
| 9 | +import java.sql.ResultSetMetaData; | ||
| 10 | +import java.sql.SQLException; | ||
| 11 | +import java.util.ArrayList; | ||
| 12 | +import java.util.LinkedHashMap; | ||
| 13 | +import java.util.List; | ||
| 14 | +import java.util.Map; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * 人大金仓(KingbaseES)风险场景数据读取 DAO(JDBC 直连)。 | ||
| 18 | + * <p>用于设备域场景20/21/22:直接查询客户内网金仓库(KingbaseES 兼容 PostgreSQL 协议)。</p> | ||
| 19 | + */ | ||
| 20 | +@Slf4j | ||
| 21 | +public class KingbaseRiskDao { | ||
| 22 | + | ||
| 23 | + private final String url; | ||
| 24 | + private final String username; | ||
| 25 | + private final String password; | ||
| 26 | + private final String driverClass; | ||
| 27 | + | ||
| 28 | + public KingbaseRiskDao(String url, String username, String password, String driverClass) { | ||
| 29 | + this.url = url; | ||
| 30 | + this.username = username; | ||
| 31 | + this.password = password; | ||
| 32 | + this.driverClass = driverClass == null || driverClass.trim().isEmpty() | ||
| 33 | + ? "com.kingbase8.Driver" : driverClass.trim(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 执行查询,返回每行一个 Map(列名小写 -> 原始值)。 | ||
| 38 | + * | ||
| 39 | + * @param sql 已拼装好的 SQL(表名/列名来自配置,值走占位符) | ||
| 40 | + * @param params 占位符参数 | ||
| 41 | + */ | ||
| 42 | + public List<Map<String, Object>> query(String sql, List<Object> params) { | ||
| 43 | + log.info("人大金仓场景查询: {}", sql); | ||
| 44 | + List<Map<String, Object>> rows = new ArrayList<>(); | ||
| 45 | + try { | ||
| 46 | + Class.forName(driverClass); | ||
| 47 | + } catch (ClassNotFoundException e) { | ||
| 48 | + throw new IllegalStateException("加载 Kingbase JDBC 驱动失败: " + driverClass, e); | ||
| 49 | + } | ||
| 50 | + try (Connection conn = DriverManager.getConnection(url, username, password); | ||
| 51 | + PreparedStatement ps = conn.prepareStatement(sql)) { | ||
| 52 | + if (params != null) { | ||
| 53 | + for (int i = 0; i < params.size(); i++) { | ||
| 54 | + ps.setObject(i + 1, params.get(i)); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + try (ResultSet rs = ps.executeQuery()) { | ||
| 58 | + ResultSetMetaData md = rs.getMetaData(); | ||
| 59 | + int n = md.getColumnCount(); | ||
| 60 | + while (rs.next()) { | ||
| 61 | + Map<String, Object> row = new LinkedHashMap<>(n * 2); | ||
| 62 | + for (int i = 1; i <= n; i++) { | ||
| 63 | + row.put(md.getColumnLabel(i).toLowerCase(), rs.getObject(i)); | ||
| 64 | + } | ||
| 65 | + rows.add(row); | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + log.info("人大金仓读取完成: {} 条", rows.size()); | ||
| 69 | + return rows; | ||
| 70 | + } catch (SQLException e) { | ||
| 71 | + throw new RuntimeException("查询人大金仓失败: " + e.getMessage(), e); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | +} |
| 1 | +package com.qgutech.qgyun.apaas.sync.jdy.service; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONArray; | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | +import com.qgutech.qgyun.apaas.sync.jdy.api.QxApi; | ||
| 6 | +import com.qgutech.qgyun.apaas.sync.jdy.config.EmpSyncProperties; | ||
| 7 | +import com.qgutech.qgyun.apaas.sync.jdy.db.KingbaseEmpDao; | ||
| 8 | +import lombok.extern.slf4j.Slf4j; | ||
| 9 | +import org.springframework.stereotype.Service; | ||
| 10 | + | ||
| 11 | +import java.util.ArrayList; | ||
| 12 | +import java.util.Arrays; | ||
| 13 | +import java.util.HashMap; | ||
| 14 | +import java.util.HashSet; | ||
| 15 | +import java.util.LinkedHashMap; | ||
| 16 | +import java.util.LinkedHashSet; | ||
| 17 | +import java.util.List; | ||
| 18 | +import java.util.Map; | ||
| 19 | +import java.util.Set; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 员工信息同步(人大金仓 biphr_ddm_empinfo_v -> 启效员工信息表单)。 | ||
| 23 | + * <p> | ||
| 24 | + * 第一步 {@link #syncGhByName}:查出启效已存在人员,按姓名匹配人大金仓员工,回填员工编号(gh); | ||
| 25 | + * 第二步 {@link #syncAll}:按员工编号(gh)同步全部字段,已存在则更新、不存在则新增。 | ||
| 26 | + * <p> | ||
| 27 | + * 字段映射与值转换:日期转毫秒时间戳;性别/政治面貌按数据字典转文本码;平台单位(dw)、平台用户(zzyh)暂不同步。 | ||
| 28 | + */ | ||
| 29 | +@Slf4j | ||
| 30 | +@Service | ||
| 31 | +public class EmpSyncService { | ||
| 32 | + | ||
| 33 | + /** 字段映射:{启效 fieldKey, 人大金仓列, 转换类型}。 */ | ||
| 34 | + private static final String[][] FIELD_MAP = { | ||
| 35 | + {"xm", "emp_name", "STR"}, // 姓名 | ||
| 36 | + {"gh", "emp_id", "STR"}, // 员工编号 | ||
| 37 | + {"xb", "gender", "GENDER"}, // 性别 | ||
| 38 | + {"xjziqy", "employment_type", "STR"}, // 用工形式 | ||
| 39 | + {"gzsj", "work_start_date", "DATE"}, // 参加工作日期 | ||
| 40 | + {"cchycx", "hire_date", "DATE"}, // 入职日期 | ||
| 41 | + {"kiflui", "years_of_service", "NUM"}, // 服务年限 | ||
| 42 | + {"zzmm", "political_status", "POL"}, // 政治面貌 | ||
| 43 | + {"dpksnb", "entry_reason", "STR"}, // 进厂原因 | ||
| 44 | + {"fevepq", "highest_technical_title", "STR"}, // 最高技术职称 | ||
| 45 | + {"fllqfd", "title_level", "STR"}, // 职称级别 | ||
| 46 | + {"kahdlq", "company_seniority_start_date", "DATE"}, // 本企业司龄开始时间 | ||
| 47 | + {"jholak", "skill_level", "STR"}, // 技能等级 | ||
| 48 | + {"zw", "job_grade", "STR"}, // 职级 | ||
| 49 | + {"jnafyx", "professional_level", "STR"}, // 专业等级 | ||
| 50 | + {"cfbzme", "certified_major", "STR"}, // 认证专业 | ||
| 51 | + {"csny", "birth_date", "DATE"}, // 出生日期 | ||
| 52 | + {"iibeao", "age", "NUM"}, // 年龄 | ||
| 53 | + {"ihkmfw", "birth_place", "STR"}, // 出生地 | ||
| 54 | + {"wywvtj", "ancestral_home", "STR"}, // 祖籍 | ||
| 55 | + {"fmogfx", "marital_status", "STR"}, // 婚姻状况 | ||
| 56 | + {"vijlcl", "nationality", "STR"}, // 国籍 | ||
| 57 | + {"oflpgg", "ethnic_group", "STR"}, // 民族 | ||
| 58 | + {"vnzxms", "former_name", "STR"}, // 曾用名 | ||
| 59 | + {"qajljq", "household_type", "STR"}, // 户口性质 | ||
| 60 | + {"iplaqo", "household_location", "STR"}, // 户籍所在地 | ||
| 61 | + {"zgxl", "highest_education", "STR"}, // 最高学历 | ||
| 62 | + {"mzguwx", "school_name", "STR"}, // 学校 | ||
| 63 | + {"bnovfe", "first_major", "STR"}, // 第一专业 | ||
| 64 | + {"zwxpwy", "second_major", "STR"}, // 第二专业 | ||
| 65 | + {"mvmiiu", "children_count", "NUM"}, // 子女数量 | ||
| 66 | + {"ujpifj", "job_start_date", "DATE"}, // 岗位开始日期 | ||
| 67 | + {"quampb", "level_1_dept", "STR"}, // 一级部门 | ||
| 68 | + {"cwjkjf", "level_2_dept", "STR"}, // 二级部门 | ||
| 69 | + {"tcsxvn", "level_3_dept", "STR"}, // 三级部门 | ||
| 70 | + {"llgyiw", "level_4_dept", "STR"}, // 四级部门 | ||
| 71 | + {"iiokqq", "level_5_dept", "STR"}, // 五级部门 | ||
| 72 | + {"tseiyg", "level_6_dept", "STR"}, // 六级部门 | ||
| 73 | + {"syihaj", "level_7_dept", "STR"}, // 七级部门 | ||
| 74 | + {"nsamnf", "position_family", "STR"}, // 岗位族 | ||
| 75 | + {"vbfdeh", "position_full_name", "STR"}, // 岗位全称 | ||
| 76 | + {"pqauhs", "position_value", "STR"}, // 岗位价值 | ||
| 77 | + {"sjaugh", "position_category", "STR"}, // 岗类 | ||
| 78 | + {"judvdv", "position_name", "STR"}, // 岗位名称 | ||
| 79 | + {"wivkxo", "duty_full_name", "STR"}, // 职务全称 | ||
| 80 | + {"egiikb", "duty_type", "STR"}, // 职务类型 | ||
| 81 | + {"ywtyqd", "job_title", "STR"}, // 职务 | ||
| 82 | + {"vnlwsa", "position_level", "STR"} // 岗级 | ||
| 83 | + }; | ||
| 84 | + | ||
| 85 | + private final EmpSyncProperties props; | ||
| 86 | + | ||
| 87 | + public EmpSyncService(EmpSyncProperties props) { | ||
| 88 | + this.props = props; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** 第一步:启效已存在人员按姓名匹配,回填员工编号(gh)。 */ | ||
| 92 | + public String syncGhByName(boolean dryRun) { | ||
| 93 | + QxApi qx = new QxApi(props.getQx().getBaseUrl()); | ||
| 94 | + String token = login(qx); | ||
| 95 | + List<Map<String, Object>> kbRows = dao().findAll(Arrays.asList("emp_id", "emp_name")); | ||
| 96 | + | ||
| 97 | + Map<String, Set<String>> nameToEmpIds = new HashMap<>(); | ||
| 98 | + for (Map<String, Object> row : kbRows) { | ||
| 99 | + String name = str(row.get("emp_name")); | ||
| 100 | + String empId = str(row.get("emp_id")); | ||
| 101 | + if (name == null || empId == null) { | ||
| 102 | + continue; | ||
| 103 | + } | ||
| 104 | + nameToEmpIds.computeIfAbsent(name, k -> new LinkedHashSet<>()).add(empId); | ||
| 105 | + } | ||
| 106 | + log.info("人大金仓员工 {} 条, 不同姓名 {} 个", kbRows.size(), nameToEmpIds.size()); | ||
| 107 | + | ||
| 108 | + JSONArray qxAll = qx.pageAll(token, props.getQx().getAppId(), props.getQx().getPageCode()); | ||
| 109 | + log.info("启效现有员工 {} 条", qxAll.size()); | ||
| 110 | + | ||
| 111 | + int updated = 0; | ||
| 112 | + int skipHasGh = 0; | ||
| 113 | + int skipNotFound = 0; | ||
| 114 | + int skipAmbiguous = 0; | ||
| 115 | + int fail = 0; | ||
| 116 | + List<String> ambiguousSamples = new ArrayList<>(); | ||
| 117 | + for (int i = 0; i < qxAll.size(); i++) { | ||
| 118 | + JSONObject rec = qxAll.getJSONObject(i); | ||
| 119 | + String xm = str(rec.getString("xm")); | ||
| 120 | + String gh = str(rec.getString("gh")); | ||
| 121 | + if (gh != null) { | ||
| 122 | + skipHasGh++; | ||
| 123 | + continue; | ||
| 124 | + } | ||
| 125 | + Set<String> ids = xm == null ? null : nameToEmpIds.get(xm); | ||
| 126 | + if (ids == null || ids.isEmpty()) { | ||
| 127 | + skipNotFound++; | ||
| 128 | + continue; | ||
| 129 | + } | ||
| 130 | + if (ids.size() > 1) { | ||
| 131 | + skipAmbiguous++; | ||
| 132 | + if (ambiguousSamples.size() < 20) { | ||
| 133 | + ambiguousSamples.add(xm + "(" + ids.size() + "人)"); | ||
| 134 | + } | ||
| 135 | + continue; | ||
| 136 | + } | ||
| 137 | + String empId = ids.iterator().next(); | ||
| 138 | + rec.put("gh", empId); | ||
| 139 | + if (!dryRun) { | ||
| 140 | + try { | ||
| 141 | + qx.updateData(token, props.getQx().getAppId(), props.getQx().getUpdateCode(), rec); | ||
| 142 | + } catch (Exception e) { | ||
| 143 | + fail++; | ||
| 144 | + log.error("回填 gh 失败: xm={} gh={} err={}", xm, empId, e.getMessage()); | ||
| 145 | + continue; | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + updated++; | ||
| 149 | + } | ||
| 150 | + String summary = "第一步(按姓名回填gh) ok=" + updated + " 已有gh跳过=" + skipHasGh | ||
| 151 | + + " 未匹配=" + skipNotFound + " 重名歧义跳过=" + skipAmbiguous + " 失败=" + fail | ||
| 152 | + + (dryRun ? " [dry-run]" : ""); | ||
| 153 | + log.info("{}", summary); | ||
| 154 | + if (!ambiguousSamples.isEmpty()) { | ||
| 155 | + log.warn("重名歧义示例: {}", ambiguousSamples); | ||
| 156 | + } | ||
| 157 | + return summary; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + /** 第二步:按员工编号(gh) 全量同步,已存在更新、不存在新增。offset/limit 用于分批与断点续跑。 */ | ||
| 161 | + public String syncAll(boolean dryRun, int limit, int offset) { | ||
| 162 | + QxApi qx = new QxApi(props.getQx().getBaseUrl()); | ||
| 163 | + String token = login(qx); | ||
| 164 | + | ||
| 165 | + JSONArray qxAll = qx.pageAll(token, props.getQx().getAppId(), props.getQx().getPageCode()); | ||
| 166 | + Map<String, JSONObject> ghToRec = new HashMap<>(); | ||
| 167 | + int dupGh = 0; | ||
| 168 | + for (int i = 0; i < qxAll.size(); i++) { | ||
| 169 | + JSONObject rec = qxAll.getJSONObject(i); | ||
| 170 | + String gh = str(rec.getString("gh")); | ||
| 171 | + if (gh == null) { | ||
| 172 | + continue; | ||
| 173 | + } | ||
| 174 | + JSONObject prev = ghToRec.put(gh, rec); | ||
| 175 | + if (prev != null) { | ||
| 176 | + dupGh++; | ||
| 177 | + log.warn("启效存在重复员工编号 gh={} (id={},{})", gh, prev.getString("id"), rec.getString("id")); | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + log.info("启效现有员工 {} 条, 有工号 {} 条", qxAll.size(), ghToRec.size()); | ||
| 181 | + | ||
| 182 | + List<Map<String, Object>> kbRows = dao().findAll(kbColumns()); | ||
| 183 | + log.info("人大金仓员工 {} 条", kbRows.size()); | ||
| 184 | + | ||
| 185 | + int updated = 0; | ||
| 186 | + int added = 0; | ||
| 187 | + int skipNoGh = 0; | ||
| 188 | + int fail = 0; | ||
| 189 | + int idx = 0; | ||
| 190 | + for (Map<String, Object> row : kbRows) { | ||
| 191 | + if (idx++ < offset) { | ||
| 192 | + continue; | ||
| 193 | + } | ||
| 194 | + String empId = str(row.get("emp_id")); | ||
| 195 | + if (empId == null) { | ||
| 196 | + skipNoGh++; | ||
| 197 | + continue; | ||
| 198 | + } | ||
| 199 | + if (limit > 0 && updated + added >= limit) { | ||
| 200 | + log.info("达到 limit={},停止", limit); | ||
| 201 | + break; | ||
| 202 | + } | ||
| 203 | + Map<String, Object> mapped = buildMapped(row); | ||
| 204 | + JSONObject existing = ghToRec.get(empId); | ||
| 205 | + try { | ||
| 206 | + if (existing != null) { | ||
| 207 | + JSONObject body = new JSONObject(); | ||
| 208 | + body.putAll(existing); | ||
| 209 | + body.putAll(mapped); | ||
| 210 | + if (!dryRun) { | ||
| 211 | + qx.updateData(token, props.getQx().getAppId(), props.getQx().getUpdateCode(), body); | ||
| 212 | + } | ||
| 213 | + updated++; | ||
| 214 | + } else { | ||
| 215 | + JSONObject body = new JSONObject(); | ||
| 216 | + body.putAll(mapped); | ||
| 217 | + if (!dryRun) { | ||
| 218 | + qx.addData(token, props.getQx().getAppId(), props.getQx().getAddCode(), body); | ||
| 219 | + } | ||
| 220 | + added++; | ||
| 221 | + } | ||
| 222 | + } catch (Exception e) { | ||
| 223 | + fail++; | ||
| 224 | + log.error("同步失败: gh={} xm={} err={}", empId, mapped.get("xm"), e.getMessage()); | ||
| 225 | + continue; | ||
| 226 | + } | ||
| 227 | + if ((updated + added) % 500 == 0) { | ||
| 228 | + log.info("进度: 更新={} 新增={} 失败={}", updated, added, fail); | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + String summary = "第二步(按gh全量同步) 更新=" + updated + " 新增=" + added | ||
| 232 | + + " 无工号跳过=" + skipNoGh + " 启效重复工号=" + dupGh + " 失败=" + fail | ||
| 233 | + + (dryRun ? " [dry-run]" : ""); | ||
| 234 | + log.info("{}", summary); | ||
| 235 | + return summary; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + private String login(QxApi qx) { | ||
| 239 | + return qx.login(props.getQx().getUsername(), props.getQx().getPassword(), props.getQx().getCorpCode()); | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + private KingbaseEmpDao dao() { | ||
| 243 | + EmpSyncProperties.Kb kb = props.getKb(); | ||
| 244 | + return new KingbaseEmpDao(kb.jdbcUrl(), kb.getUsername(), kb.getPassword(), kb.getTable(), | ||
| 245 | + kb.getFilter(), kb.getDriverClass()); | ||
| 246 | + } | ||
| 247 | + | ||
| 248 | + /** 按映射把一行人大金仓数据转为启效字段(fieldKey -> 值)。 */ | ||
| 249 | + private Map<String, Object> buildMapped(Map<String, Object> row) { | ||
| 250 | + Map<String, Object> body = new LinkedHashMap<>(); | ||
| 251 | + for (String[] f : FIELD_MAP) { | ||
| 252 | + body.put(f[0], transform(f[2], row.get(f[1]))); | ||
| 253 | + } | ||
| 254 | + return body; | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + /** 收集需要从人大金仓读取的列(去重)。 */ | ||
| 258 | + private List<String> kbColumns() { | ||
| 259 | + List<String> cols = new ArrayList<>(); | ||
| 260 | + for (String[] f : FIELD_MAP) { | ||
| 261 | + if (!cols.contains(f[1])) { | ||
| 262 | + cols.add(f[1]); | ||
| 263 | + } | ||
| 264 | + } | ||
| 265 | + return cols; | ||
| 266 | + } | ||
| 267 | + | ||
| 268 | + private Object transform(String kind, Object v) { | ||
| 269 | + switch (kind) { | ||
| 270 | + case "DATE": | ||
| 271 | + return toEpochMs(v); | ||
| 272 | + case "NUM": | ||
| 273 | + return toNumber(v); | ||
| 274 | + case "GENDER": | ||
| 275 | + return mapGender(v); | ||
| 276 | + case "POL": | ||
| 277 | + return mapPolitics(v); | ||
| 278 | + default: | ||
| 279 | + return str(v); | ||
| 280 | + } | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + private static String str(Object v) { | ||
| 284 | + if (v == null) { | ||
| 285 | + return null; | ||
| 286 | + } | ||
| 287 | + String s = String.valueOf(v).trim(); | ||
| 288 | + return s.isEmpty() ? null : s; | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + private static Object toEpochMs(Object v) { | ||
| 292 | + if (v == null) { | ||
| 293 | + return null; | ||
| 294 | + } | ||
| 295 | + if (v instanceof java.util.Date) { | ||
| 296 | + return ((java.util.Date) v).getTime(); | ||
| 297 | + } | ||
| 298 | + if (v instanceof Number) { | ||
| 299 | + return ((Number) v).longValue(); | ||
| 300 | + } | ||
| 301 | + String s = str(v); | ||
| 302 | + if (s == null) { | ||
| 303 | + return null; | ||
| 304 | + } | ||
| 305 | + try { | ||
| 306 | + return java.time.LocalDate.parse(s.length() > 10 ? s.substring(0, 10) : s) | ||
| 307 | + .atStartOfDay(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli(); | ||
| 308 | + } catch (Exception e) { | ||
| 309 | + return null; | ||
| 310 | + } | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + private static Object toNumber(Object v) { | ||
| 314 | + if (v == null) { | ||
| 315 | + return null; | ||
| 316 | + } | ||
| 317 | + if (v instanceof Number) { | ||
| 318 | + return v; | ||
| 319 | + } | ||
| 320 | + String s = str(v); | ||
| 321 | + if (s == null) { | ||
| 322 | + return null; | ||
| 323 | + } | ||
| 324 | + try { | ||
| 325 | + return Long.valueOf(s); | ||
| 326 | + } catch (NumberFormatException e) { | ||
| 327 | + try { | ||
| 328 | + return Double.valueOf(s); | ||
| 329 | + } catch (NumberFormatException ex) { | ||
| 330 | + return null; | ||
| 331 | + } | ||
| 332 | + } | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + /** 性别:文本 1=男 2=女 3=未知。 */ | ||
| 336 | + private static String mapGender(Object v) { | ||
| 337 | + String s = str(v); | ||
| 338 | + if (s == null) { | ||
| 339 | + return null; | ||
| 340 | + } | ||
| 341 | + if ("1".equals(s) || "男".equals(s)) { | ||
| 342 | + return "1"; | ||
| 343 | + } | ||
| 344 | + if ("2".equals(s) || "女".equals(s)) { | ||
| 345 | + return "2"; | ||
| 346 | + } | ||
| 347 | + return "3"; | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + /** 政治面貌:文本 1=党员 2=中国共产党预备党员 3=群众。 */ | ||
| 351 | + private static String mapPolitics(Object v) { | ||
| 352 | + String s = str(v); | ||
| 353 | + if (s == null) { | ||
| 354 | + return null; | ||
| 355 | + } | ||
| 356 | + if (s.contains("预备")) { | ||
| 357 | + return "2"; | ||
| 358 | + } | ||
| 359 | + if (s.contains("党员")) { | ||
| 360 | + return "1"; | ||
| 361 | + } | ||
| 362 | + if (s.contains("群众")) { | ||
| 363 | + return "3"; | ||
| 364 | + } | ||
| 365 | + return s; | ||
| 366 | + } | ||
| 367 | +} |
| @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; | @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; | ||
| 8 | import org.apache.poi.ss.usermodel.Cell; | 8 | import org.apache.poi.ss.usermodel.Cell; |
| 9 | import org.apache.poi.ss.usermodel.CellStyle; | 9 | import org.apache.poi.ss.usermodel.CellStyle; |
| 10 | import org.apache.poi.ss.usermodel.Font; | 10 | import org.apache.poi.ss.usermodel.Font; |
| 11 | +import org.apache.poi.ss.usermodel.IndexedColors; | ||
| 11 | import org.apache.poi.ss.usermodel.Row; | 12 | import org.apache.poi.ss.usermodel.Row; |
| 12 | import org.apache.poi.ss.usermodel.Sheet; | 13 | import org.apache.poi.ss.usermodel.Sheet; |
| 13 | import org.apache.poi.ss.usermodel.Workbook; | 14 | import org.apache.poi.ss.usermodel.Workbook; |
| @@ -35,6 +36,21 @@ public class JdyExcelExportService { | @@ -35,6 +36,21 @@ public class JdyExcelExportService { | ||
| 35 | private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai"); | 36 | private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai"); |
| 36 | private static final DateTimeFormatter TS = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); | 37 | private static final DateTimeFormatter TS = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
| 37 | 38 | ||
| 39 | + /** 当前线程的关联映射(关联字段值 id -> 中文名称);由风险服务在导出前设置。 */ | ||
| 40 | + private static final ThreadLocal<java.util.Map<String, String>> LOOKUP = new ThreadLocal<>(); | ||
| 41 | + | ||
| 42 | + public static void setLookup(java.util.Map<String, String> map) { | ||
| 43 | + if (map == null || map.isEmpty()) { | ||
| 44 | + LOOKUP.remove(); | ||
| 45 | + } else { | ||
| 46 | + LOOKUP.set(map); | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public static java.util.Map<String, String> currentLookup() { | ||
| 51 | + return LOOKUP.get(); | ||
| 52 | + } | ||
| 53 | + | ||
| 38 | private final JdyFormSyncProperties props; | 54 | private final JdyFormSyncProperties props; |
| 39 | 55 | ||
| 40 | public JdyExcelExportService(JdyFormSyncProperties props) { | 56 | public JdyExcelExportService(JdyFormSyncProperties props) { |
| @@ -110,10 +126,27 @@ public class JdyExcelExportService { | @@ -110,10 +126,27 @@ public class JdyExcelExportService { | ||
| 110 | */ | 126 | */ |
| 111 | public String exportRows(JSONArray widgets, JSONArray rows, String extraHeader, | 127 | public String exportRows(JSONArray widgets, JSONArray rows, String extraHeader, |
| 112 | List<String> extraValues, String fileName) { | 128 | List<String> extraValues, String fileName) { |
| 129 | + return exportRows(widgets, rows, extraHeader, extraValues, fileName, null); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * 导出指定行到 Excel(供风险场景附件用),可在最右增加一列,并指定 sheet 名。 | ||
| 134 | + */ | ||
| 135 | + public String exportRows(JSONArray widgets, JSONArray rows, String extraHeader, | ||
| 136 | + List<String> extraValues, String fileName, String sheetName) { | ||
| 137 | + return exportRows(widgets, rows, extraHeader, extraValues, fileName, sheetName, null); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + /** | ||
| 141 | + * 导出指定行到 Excel(供风险场景附件用),可在最右增加一列,并指定 sheet 名与百分数列。 | ||
| 142 | + */ | ||
| 143 | + public String exportRows(JSONArray widgets, JSONArray rows, String extraHeader, | ||
| 144 | + List<String> extraValues, String fileName, String sheetName, | ||
| 145 | + java.util.Set<String> percentFields) { | ||
| 113 | try { | 146 | try { |
| 114 | File dir = exportDir(); | 147 | File dir = exportDir(); |
| 115 | File outFile = new File(dir, fileName); | 148 | File outFile = new File(dir, fileName); |
| 116 | - writeWorkbook(widgets, rows, extraHeader, extraValues, outFile); | 149 | + writeWorkbook(widgets, rows, extraHeader, extraValues, outFile, sheetName, percentFields); |
| 117 | log.info("导出 Excel: {} ({} 条)", outFile.getAbsolutePath(), rows.size()); | 150 | log.info("导出 Excel: {} ({} 条)", outFile.getAbsolutePath(), rows.size()); |
| 118 | return outFile.getAbsolutePath(); | 151 | return outFile.getAbsolutePath(); |
| 119 | } catch (Exception e) { | 152 | } catch (Exception e) { |
| @@ -122,47 +155,168 @@ public class JdyExcelExportService { | @@ -122,47 +155,168 @@ public class JdyExcelExportService { | ||
| 122 | } | 155 | } |
| 123 | } | 156 | } |
| 124 | 157 | ||
| 158 | + /** 多 Sheet 导出规格。 */ | ||
| 159 | + public static class SheetSpec { | ||
| 160 | + public String sheetName; | ||
| 161 | + public String topText; | ||
| 162 | + public JSONArray widgets; | ||
| 163 | + public JSONArray rows; | ||
| 164 | + public String extraHeader; | ||
| 165 | + public List<String> extraValues; | ||
| 166 | + public java.util.Set<String> percentFields; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + /** 导出多个 Sheet 到同一个 xlsx;每个 Sheet 可在首行放一段说明文字(topText)。 */ | ||
| 170 | + public String exportSheets(String fileName, List<SheetSpec> sheets) { | ||
| 171 | + try { | ||
| 172 | + File dir = exportDir(); | ||
| 173 | + File outFile = new File(dir, fileName); | ||
| 174 | + try (Workbook wb = new XSSFWorkbook()) { | ||
| 175 | + for (SheetSpec spec : sheets) { | ||
| 176 | + writeOneSheet(wb, spec == null ? new SheetSpec() : spec); | ||
| 177 | + } | ||
| 178 | + try (OutputStream os = new FileOutputStream(outFile)) { | ||
| 179 | + wb.write(os); | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + log.info("导出 Excel(多sheet): {} ({} sheet)", outFile.getAbsolutePath(), sheets.size()); | ||
| 183 | + return outFile.getAbsolutePath(); | ||
| 184 | + } catch (Exception e) { | ||
| 185 | + log.error("导出 Excel(多sheet) 失败: {}", fileName, e); | ||
| 186 | + return "FAIL " + fileName + " : " + e.getMessage(); | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + private void writeOneSheet(Workbook wb, SheetSpec spec) { | ||
| 191 | + Sheet sheet = wb.createSheet(safeSheetName(spec.sheetName)); | ||
| 192 | + int rowIdx = 0; | ||
| 193 | + if (spec.topText != null && !spec.topText.isEmpty()) { | ||
| 194 | + Row top = sheet.createRow(0); | ||
| 195 | + top.createCell(0).setCellValue(spec.topText); | ||
| 196 | + rowIdx = 1; | ||
| 197 | + } | ||
| 198 | + CellStyle headerStyle = wb.createCellStyle(); | ||
| 199 | + Font bold = wb.createFont(); | ||
| 200 | + bold.setBold(true); | ||
| 201 | + headerStyle.setFont(bold); | ||
| 202 | + Font redFont = wb.createFont(); | ||
| 203 | + redFont.setBold(true); | ||
| 204 | + redFont.setColor(IndexedColors.RED.getIndex()); | ||
| 205 | + CellStyle extraHeaderStyle = wb.createCellStyle(); | ||
| 206 | + extraHeaderStyle.setFont(redFont); | ||
| 207 | + | ||
| 208 | + JSONArray widgets = spec.widgets == null ? new JSONArray() : spec.widgets; | ||
| 209 | + JSONArray rows = spec.rows == null ? new JSONArray() : spec.rows; | ||
| 210 | + int offset = 0; | ||
| 211 | + Row header = sheet.createRow(rowIdx); | ||
| 212 | + if (spec.extraHeader != null && !spec.extraHeader.isEmpty()) { | ||
| 213 | + Cell cell = header.createCell(0); | ||
| 214 | + cell.setCellValue(spec.extraHeader); | ||
| 215 | + cell.setCellStyle(extraHeaderStyle); | ||
| 216 | + offset = 1; | ||
| 217 | + } | ||
| 218 | + for (int c = 0; c < widgets.size(); c++) { | ||
| 219 | + JSONObject w = widgets.getJSONObject(c); | ||
| 220 | + String label = w.getString("label"); | ||
| 221 | + if (label == null || label.isEmpty()) { | ||
| 222 | + label = w.getString("widgetName"); | ||
| 223 | + } | ||
| 224 | + Cell cell = header.createCell(c + offset); | ||
| 225 | + cell.setCellValue(label); | ||
| 226 | + cell.setCellStyle(headerStyle); | ||
| 227 | + } | ||
| 228 | + rowIdx++; | ||
| 229 | + for (int r = 0; r < rows.size(); r++) { | ||
| 230 | + JSONObject rec = rows.getJSONObject(r); | ||
| 231 | + Row row = sheet.createRow(rowIdx + r); | ||
| 232 | + if (offset == 1) { | ||
| 233 | + String ev = (spec.extraValues != null && r < spec.extraValues.size() && spec.extraValues.get(r) != null) | ||
| 234 | + ? spec.extraValues.get(r) : ""; | ||
| 235 | + row.createCell(0).setCellValue(ev); | ||
| 236 | + } | ||
| 237 | + for (int c = 0; c < widgets.size(); c++) { | ||
| 238 | + String code = widgets.getJSONObject(c).getString("name"); | ||
| 239 | + Object v = rec.get(code); | ||
| 240 | + String val; | ||
| 241 | + if (spec.percentFields != null && spec.percentFields.contains(code) && v instanceof Number) { | ||
| 242 | + val = String.format("%.1f%%", ((Number) v).doubleValue() * 100); | ||
| 243 | + } else { | ||
| 244 | + val = formatValue(v); | ||
| 245 | + } | ||
| 246 | + row.createCell(c + offset).setCellValue(val); | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + for (int c = 0; c < widgets.size() + offset; c++) { | ||
| 250 | + sheet.setColumnWidth(c, 20 * 256); | ||
| 251 | + } | ||
| 252 | + } | ||
| 253 | + | ||
| 125 | private void writeWorkbook(JSONArray widgets, JSONArray data, String extraHeader, | 254 | private void writeWorkbook(JSONArray widgets, JSONArray data, String extraHeader, |
| 126 | List<String> extraValues, File outFile) throws Exception { | 255 | List<String> extraValues, File outFile) throws Exception { |
| 256 | + writeWorkbook(widgets, data, extraHeader, extraValues, outFile, null, null); | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + private void writeWorkbook(JSONArray widgets, JSONArray data, String extraHeader, | ||
| 260 | + List<String> extraValues, File outFile, String sheetName) throws Exception { | ||
| 261 | + writeWorkbook(widgets, data, extraHeader, extraValues, outFile, sheetName, null); | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + private void writeWorkbook(JSONArray widgets, JSONArray data, String extraHeader, | ||
| 265 | + List<String> extraValues, File outFile, String sheetName, | ||
| 266 | + java.util.Set<String> percentFields) throws Exception { | ||
| 127 | try (Workbook wb = new XSSFWorkbook()) { | 267 | try (Workbook wb = new XSSFWorkbook()) { |
| 128 | - Sheet sheet = wb.createSheet("数据"); | 268 | + Sheet sheet = wb.createSheet(safeSheetName(sheetName)); |
| 129 | CellStyle headerStyle = wb.createCellStyle(); | 269 | CellStyle headerStyle = wb.createCellStyle(); |
| 130 | Font bold = wb.createFont(); | 270 | Font bold = wb.createFont(); |
| 131 | bold.setBold(true); | 271 | bold.setBold(true); |
| 132 | headerStyle.setFont(bold); | 272 | headerStyle.setFont(bold); |
| 133 | 273 | ||
| 134 | Row header = sheet.createRow(0); | 274 | Row header = sheet.createRow(0); |
| 275 | + boolean hasExtra = extraHeader != null && !extraHeader.isEmpty(); | ||
| 276 | + Font redFont = wb.createFont(); | ||
| 277 | + redFont.setBold(true); | ||
| 278 | + redFont.setColor(IndexedColors.RED.getIndex()); | ||
| 279 | + CellStyle extraHeaderStyle = wb.createCellStyle(); | ||
| 280 | + extraHeaderStyle.setFont(redFont); | ||
| 281 | + int offset = 0; | ||
| 282 | + if (hasExtra) { | ||
| 283 | + Cell cell = header.createCell(0); | ||
| 284 | + cell.setCellValue(extraHeader); | ||
| 285 | + cell.setCellStyle(extraHeaderStyle); | ||
| 286 | + offset = 1; | ||
| 287 | + } | ||
| 135 | for (int c = 0; c < widgets.size(); c++) { | 288 | for (int c = 0; c < widgets.size(); c++) { |
| 136 | JSONObject w = widgets.getJSONObject(c); | 289 | JSONObject w = widgets.getJSONObject(c); |
| 137 | String label = w.getString("label"); | 290 | String label = w.getString("label"); |
| 138 | if (label == null || label.isEmpty()) { | 291 | if (label == null || label.isEmpty()) { |
| 139 | label = w.getString("widgetName"); | 292 | label = w.getString("widgetName"); |
| 140 | } | 293 | } |
| 141 | - Cell cell = header.createCell(c); | 294 | + Cell cell = header.createCell(c + offset); |
| 142 | cell.setCellValue(label); | 295 | cell.setCellValue(label); |
| 143 | cell.setCellStyle(headerStyle); | 296 | cell.setCellStyle(headerStyle); |
| 144 | } | 297 | } |
| 145 | - boolean hasExtra = extraHeader != null && !extraHeader.isEmpty(); | ||
| 146 | - if (hasExtra) { | ||
| 147 | - Cell cell = header.createCell(widgets.size()); | ||
| 148 | - cell.setCellValue(extraHeader); | ||
| 149 | - cell.setCellStyle(headerStyle); | ||
| 150 | - } | ||
| 151 | 298 | ||
| 152 | for (int r = 0; r < data.size(); r++) { | 299 | for (int r = 0; r < data.size(); r++) { |
| 153 | JSONObject rec = data.getJSONObject(r); | 300 | JSONObject rec = data.getJSONObject(r); |
| 154 | Row row = sheet.createRow(r + 1); | 301 | Row row = sheet.createRow(r + 1); |
| 155 | - for (int c = 0; c < widgets.size(); c++) { | ||
| 156 | - String code = widgets.getJSONObject(c).getString("name"); | ||
| 157 | - row.createCell(c).setCellValue(formatValue(rec.get(code))); | ||
| 158 | - } | ||
| 159 | if (hasExtra) { | 302 | if (hasExtra) { |
| 160 | - String v = (extraValues != null && r < extraValues.size() && extraValues.get(r) != null) | 303 | + String ev = (extraValues != null && r < extraValues.size() && extraValues.get(r) != null) |
| 161 | ? extraValues.get(r) : ""; | 304 | ? extraValues.get(r) : ""; |
| 162 | - row.createCell(widgets.size()).setCellValue(v); | 305 | + row.createCell(0).setCellValue(ev); |
| 306 | + } | ||
| 307 | + for (int c = 0; c < widgets.size(); c++) { | ||
| 308 | + String code = widgets.getJSONObject(c).getString("name"); | ||
| 309 | + Object v = rec.get(code); | ||
| 310 | + String val; | ||
| 311 | + if (percentFields != null && percentFields.contains(code) && v instanceof Number) { | ||
| 312 | + val = String.format("%.1f%%", ((Number) v).doubleValue() * 100); | ||
| 313 | + } else { | ||
| 314 | + val = formatValue(v); | ||
| 315 | + } | ||
| 316 | + row.createCell(c + offset).setCellValue(val); | ||
| 163 | } | 317 | } |
| 164 | } | 318 | } |
| 165 | - for (int c = 0; c <= widgets.size(); c++) { | 319 | + for (int c = 0; c < widgets.size() + offset; c++) { |
| 166 | sheet.setColumnWidth(c, 20 * 256); | 320 | sheet.setColumnWidth(c, 20 * 256); |
| 167 | } | 321 | } |
| 168 | try (OutputStream os = new FileOutputStream(outFile)) { | 322 | try (OutputStream os = new FileOutputStream(outFile)) { |
| @@ -202,6 +356,18 @@ public class JdyExcelExportService { | @@ -202,6 +356,18 @@ public class JdyExcelExportService { | ||
| 202 | return null; | 356 | return null; |
| 203 | } | 357 | } |
| 204 | 358 | ||
| 359 | + /** Excel sheet 名:非法字符替换、去空、限 31 字符,默认「数据」。 */ | ||
| 360 | + private static String safeSheetName(String name) { | ||
| 361 | + if (name == null || name.trim().isEmpty()) { | ||
| 362 | + return "数据"; | ||
| 363 | + } | ||
| 364 | + String s = name.replaceAll("[\\\\/:*?\\[\\]]", "_").trim(); | ||
| 365 | + if (s.length() > 31) { | ||
| 366 | + s = s.substring(0, 31); | ||
| 367 | + } | ||
| 368 | + return s; | ||
| 369 | + } | ||
| 370 | + | ||
| 205 | /** 值格式化:时间->北京时间字符串;用户对象->name;数组->逗号连接。 */ | 371 | /** 值格式化:时间->北京时间字符串;用户对象->name;数组->逗号连接。 */ |
| 206 | private String formatValue(Object v) { | 372 | private String formatValue(Object v) { |
| 207 | if (v == null) { | 373 | if (v == null) { |
| @@ -231,6 +397,10 @@ public class JdyExcelExportService { | @@ -231,6 +397,10 @@ public class JdyExcelExportService { | ||
| 231 | return sb.toString(); | 397 | return sb.toString(); |
| 232 | } | 398 | } |
| 233 | String s = String.valueOf(v); | 399 | String s = String.valueOf(v); |
| 400 | + java.util.Map<String, String> lk = LOOKUP.get(); | ||
| 401 | + if (lk != null && lk.containsKey(s)) { | ||
| 402 | + return lk.get(s); | ||
| 403 | + } | ||
| 234 | if (s.matches("\\d{4}-\\d{2}-\\d{2}T.*")) { | 404 | if (s.matches("\\d{4}-\\d{2}-\\d{2}T.*")) { |
| 235 | try { | 405 | try { |
| 236 | return Instant.parse(s).atZone(ZONE).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); | 406 | return Instant.parse(s).atZone(ZONE).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| 1 | +/* | ||
| 2 | + * Decompiled with CFR 0.152. | ||
| 3 | + * | ||
| 4 | + * Could not load the following classes: | ||
| 5 | + * com.alibaba.fastjson.JSONArray | ||
| 6 | + * com.alibaba.fastjson.JSONObject | ||
| 7 | + * org.slf4j.Logger | ||
| 8 | + * org.slf4j.LoggerFactory | ||
| 9 | + * org.springframework.stereotype.Service | ||
| 10 | + */ | ||
| 1 | package com.qgutech.qgyun.apaas.sync.jdy.service; | 11 | package com.qgutech.qgyun.apaas.sync.jdy.service; |
| 2 | 12 | ||
| 3 | import com.alibaba.fastjson.JSONArray; | 13 | import com.alibaba.fastjson.JSONArray; |
| @@ -5,523 +15,2426 @@ import com.alibaba.fastjson.JSONObject; | @@ -5,523 +15,2426 @@ import com.alibaba.fastjson.JSONObject; | ||
| 5 | import com.qgutech.qgyun.apaas.sync.jdy.api.JiandaoYunApi; | 15 | import com.qgutech.qgyun.apaas.sync.jdy.api.JiandaoYunApi; |
| 6 | import com.qgutech.qgyun.apaas.sync.jdy.api.QxApi; | 16 | import com.qgutech.qgyun.apaas.sync.jdy.api.QxApi; |
| 7 | import com.qgutech.qgyun.apaas.sync.jdy.config.JdyRiskProperties; | 17 | import com.qgutech.qgyun.apaas.sync.jdy.config.JdyRiskProperties; |
| 8 | -import lombok.extern.slf4j.Slf4j; | ||
| 9 | -import org.springframework.stereotype.Service; | ||
| 10 | - | 18 | +import com.qgutech.qgyun.apaas.sync.jdy.db.KingbaseRiskDao; |
| 19 | +import com.qgutech.qgyun.apaas.sync.jdy.service.JdyExcelExportService; | ||
| 11 | import java.io.File; | 20 | import java.io.File; |
| 21 | +import java.sql.Connection; | ||
| 22 | +import java.sql.Date; | ||
| 23 | +import java.sql.DriverManager; | ||
| 24 | +import java.sql.PreparedStatement; | ||
| 25 | +import java.sql.ResultSet; | ||
| 12 | import java.time.Instant; | 26 | import java.time.Instant; |
| 27 | +import java.time.LocalDate; | ||
| 28 | +import java.time.LocalTime; | ||
| 29 | +import java.time.YearMonth; | ||
| 13 | import java.time.ZoneId; | 30 | import java.time.ZoneId; |
| 14 | import java.time.ZonedDateTime; | 31 | import java.time.ZonedDateTime; |
| 15 | import java.time.format.DateTimeFormatter; | 32 | import java.time.format.DateTimeFormatter; |
| 16 | import java.time.temporal.ChronoUnit; | 33 | import java.time.temporal.ChronoUnit; |
| 17 | import java.util.ArrayList; | 34 | import java.util.ArrayList; |
| 35 | +import java.util.Arrays; | ||
| 36 | +import java.util.Collections; | ||
| 37 | +import java.util.HashMap; | ||
| 38 | +import java.util.HashSet; | ||
| 39 | +import java.util.Iterator; | ||
| 18 | import java.util.LinkedHashMap; | 40 | import java.util.LinkedHashMap; |
| 19 | import java.util.LinkedHashSet; | 41 | import java.util.LinkedHashSet; |
| 20 | import java.util.List; | 42 | import java.util.List; |
| 43 | +import java.util.Locale; | ||
| 21 | import java.util.Map; | 44 | import java.util.Map; |
| 22 | import java.util.Set; | 45 | import java.util.Set; |
| 46 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 47 | +import java.util.function.Supplier; | ||
| 48 | +import org.slf4j.Logger; | ||
| 49 | +import org.slf4j.LoggerFactory; | ||
| 50 | +import org.springframework.stereotype.Service; | ||
| 23 | 51 | ||
| 24 | -/** | ||
| 25 | - * 风险场景统计:调用长安简道云开放 API 读取表单数据,按规则过滤并输出命中计数; | ||
| 26 | - * 并可按 syncCode 把「计数 + 简道云原始数据 Excel 附件」写回启效表单。 | ||
| 27 | - */ | ||
| 28 | -@Slf4j | ||
| 29 | @Service | 52 | @Service |
| 30 | public class JdyRiskStatisticsService { | 53 | public class JdyRiskStatisticsService { |
| 31 | - | 54 | + private static final Logger log = LoggerFactory.getLogger(JdyRiskStatisticsService.class); |
| 32 | private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai"); | 55 | private static final ZoneId ZONE = ZoneId.of("Asia/Shanghai"); |
| 33 | private static final DateTimeFormatter MONTH_FMT = DateTimeFormatter.ofPattern("yyyy-MM"); | 56 | private static final DateTimeFormatter MONTH_FMT = DateTimeFormatter.ofPattern("yyyy-MM"); |
| 34 | - | 57 | + private static final DateTimeFormatter DAY_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| 58 | + private static final Map<String, Biz> BIZ = new LinkedHashMap<String, Biz>(); | ||
| 59 | + private static final Map<String, Biz> BIZ_BY_SCENARIO = new LinkedHashMap<String, Biz>(); | ||
| 35 | private final JdyRiskProperties props; | 60 | private final JdyRiskProperties props; |
| 36 | private final JdyExcelExportService excelExportService; | 61 | private final JdyExcelExportService excelExportService; |
| 62 | + private static final long CACHE_TTL_MS = 21600000L; | ||
| 63 | + private final Map<String, CacheEntry> cacheMap = new ConcurrentHashMap<String, CacheEntry>(); | ||
| 64 | + private final ThreadLocal<ZonedDateTime> referenceNow = new ThreadLocal(); | ||
| 65 | + private final ThreadLocal<Map<String, JSONArray>> backfillData = new ThreadLocal(); | ||
| 66 | + private final ThreadLocal<Map<String, JSONArray>> backfillPages = new ThreadLocal(); | ||
| 67 | + /** 历史回补的数据截止日(含),用于把最后一个统计区间截到指定日期(如 2026-10-30)。 */ | ||
| 68 | + private final ThreadLocal<LocalDate> backfillEndDate = new ThreadLocal(); | ||
| 69 | + | ||
| 70 | + private JSONArray listAllDataCached(JiandaoYunApi jdy, String appId, String entryId) { | ||
| 71 | + Map<String, JSONArray> cache = this.backfillData.get(); | ||
| 72 | + if (cache == null) { | ||
| 73 | + return jdy.listAllData(this.props.getApiKey(), appId, entryId); | ||
| 74 | + } | ||
| 75 | + String key = appId + "|" + entryId; | ||
| 76 | + JSONArray v = cache.get(key); | ||
| 77 | + if (v == null) { | ||
| 78 | + v = jdy.listAllData(this.props.getApiKey(), appId, entryId); | ||
| 79 | + cache.put(key, v); | ||
| 80 | + } | ||
| 81 | + return v; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + private void forEachPageCached(JiandaoYunApi jdy, String appId, String entryId, List<String> fields, | ||
| 85 | + java.util.function.Consumer<JSONArray> consumer) { | ||
| 86 | + Map<String, JSONArray> cache = this.backfillPages.get(); | ||
| 87 | + if (cache == null) { | ||
| 88 | + jdy.forEachPage(this.props.getApiKey(), appId, entryId, fields, consumer); | ||
| 89 | + return; | ||
| 90 | + } | ||
| 91 | + String fs = fields == null ? "" : String.join(",", fields); | ||
| 92 | + String key = appId + "|" + entryId + "|" + fs; | ||
| 93 | + JSONArray all = cache.get(key); | ||
| 94 | + if (all == null) { | ||
| 95 | + final JSONArray target = new JSONArray(); | ||
| 96 | + jdy.forEachPage(this.props.getApiKey(), appId, entryId, fields, page -> { | ||
| 97 | + for (int i = 0; i < page.size(); ++i) { | ||
| 98 | + target.add((Object)page.getJSONObject(i)); | ||
| 99 | + } | ||
| 100 | + }); | ||
| 101 | + cache.put(key, target); | ||
| 102 | + all = target; | ||
| 103 | + } | ||
| 104 | + consumer.accept(all); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + private static Biz invBiz(String sceneTitle, String sceneId, String sivnbu, String ilecyn) { | ||
| 108 | + Biz b = new Biz("4", "\u5b58\u8d27\u7ba1\u7406", "R6LrkJ9nwIPWLoAbj9t", "\u7269\u6d41\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", sceneId, sceneTitle); | ||
| 109 | + b.sceneMemberId = "UAAXYEx5XV0HnEomYxp"; | ||
| 110 | + b.sceneMemberTitle = "\u90ed\u656c\u4eea"; | ||
| 111 | + b.jetcalId = "UAAXYEx5XV0HnEomYxp"; | ||
| 112 | + b.jetcalTitle = "\u90ed\u656c\u4eea"; | ||
| 113 | + b.sivnbu = sivnbu; | ||
| 114 | + b.ilecyn = ilecyn; | ||
| 115 | + return b; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + private static Biz claimBiz(String sceneTitle, String sceneId, String sivnbu, String ilecyn) { | ||
| 119 | + Biz b = new Biz("4", "\u751f\u4ea7\u8fc7\u7a0b\u4f9b\u5e94\u5546\u635f\u5931\u7d22\u8d54", "ahUsBuZJ92r9B0qa394", "\u5236\u9020\u8fd0\u8425\u5904", "xbV3UUbZMtQrKJXOeuq", "\u5f20\u5f3a", sceneId, sceneTitle); | ||
| 120 | + b.sceneMemberId = "0BLwHBhr1ulchOtGiBm"; | ||
| 121 | + b.sceneMemberTitle = "\u7ae0\u57ce\u4e61"; | ||
| 122 | + b.jetcalId = "0BLwHBhr1ulchOtGiBm"; | ||
| 123 | + b.jetcalTitle = "\u7ae0\u57ce\u4e61"; | ||
| 124 | + b.sivnbu = sivnbu; | ||
| 125 | + b.ilecyn = ilecyn; | ||
| 126 | + return b; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + private static Biz bizOf(JdyRiskProperties.Scenario s) { | ||
| 130 | + Biz b = BIZ_BY_SCENARIO.get(s.getId()); | ||
| 131 | + return b != null ? b : BIZ.get(s.getSyncCode()); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + private static Biz projectBiz(String businessLine, String sceneId, String sceneTitle) { | ||
| 135 | + Biz b; | ||
| 136 | + if ("\u5de5\u5e8f\u59d4\u5916\u4e1a\u52a1".equals(businessLine)) { | ||
| 137 | + b = new Biz("3", businessLine, "ahUsBuZJ92r9B0qa394", "\u5236\u9020\u8fd0\u8425\u5904", "xbV3UUbZMtQrKJXOeuq", "\u5f20\u5f3a", sceneId, sceneTitle); | ||
| 138 | + b.sceneMemberId = "0BLwHBhr1ulchOtGiBm"; | ||
| 139 | + b.sceneMemberTitle = "\u7ae0\u57ce\u4e61"; | ||
| 140 | + } else { | ||
| 141 | + b = new Biz("3", businessLine, "hFfriNVYr51k7kygFST", "\u5408\u80a5\u957f\u5b89\u91c7\u8d2d\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", sceneId, sceneTitle); | ||
| 142 | + b.sceneMemberId = "wh8J34cBYHayy79SFFQ"; | ||
| 143 | + b.sceneMemberTitle = "\u66fe\u5ff5\u5149"; | ||
| 144 | + } | ||
| 145 | + return b; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + private ZonedDateTime now() { | ||
| 149 | + ZonedDateTime r = this.referenceNow.get(); | ||
| 150 | + return r != null ? r : ZonedDateTime.now(ZONE); | ||
| 151 | + } | ||
| 37 | 152 | ||
| 38 | public JdyRiskStatisticsService(JdyRiskProperties props, JdyExcelExportService excelExportService) { | 153 | public JdyRiskStatisticsService(JdyRiskProperties props, JdyExcelExportService excelExportService) { |
| 39 | this.props = props; | 154 | this.props = props; |
| 40 | this.excelExportService = excelExportService; | 155 | this.excelExportService = excelExportService; |
| 41 | } | 156 | } |
| 42 | 157 | ||
| 43 | - /** 只统计,返回 {count_1:.., count_2:.., ...}。 */ | 158 | + private <T> T cached(String key, Supplier<T> loader) { |
| 159 | + long now = System.currentTimeMillis(); | ||
| 160 | + CacheEntry e = this.cacheMap.get(key); | ||
| 161 | + if (e != null && e.expireAt > now) { | ||
| 162 | + return (T)e.value; | ||
| 163 | + } | ||
| 164 | + T v = loader.get(); | ||
| 165 | + this.cacheMap.put(key, new CacheEntry(v, now + 21600000L)); | ||
| 166 | + return v; | ||
| 167 | + } | ||
| 168 | + | ||
| 44 | public Map<String, Object> countAll() { | 169 | public Map<String, Object> countAll() { |
| 45 | - Map<String, Object> result = new LinkedHashMap<>(); | ||
| 46 | - JiandaoYunApi jdy = new JiandaoYunApi(props.getHost()); | ||
| 47 | - for (JdyRiskProperties.Scenario s : props.getScenarios()) { | 170 | + LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); |
| 171 | + JiandaoYunApi jdy = new JiandaoYunApi(this.props.getHost()); | ||
| 172 | + for (JdyRiskProperties.Scenario s : this.props.getScenarios()) { | ||
| 48 | try { | 173 | try { |
| 49 | - String type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 50 | - if ("scenario7".equals(type)) { | ||
| 51 | - result.put(s.getId(), buildScenario7Rows(jdy, s).size()); | ||
| 52 | - } else { | ||
| 53 | - JSONArray all = jdy.listAllData(props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 54 | - JSONArray rows = filterScope(all, s); | ||
| 55 | - result.put(s.getId(), count(s, rows)); | ||
| 56 | - } | ||
| 57 | - } catch (Exception e) { | ||
| 58 | - log.error("场景[{}] 统计失败", s.getId(), e); | 174 | + result.put(s.getId(), this.countOneInternal(jdy, s)); |
| 175 | + } | ||
| 176 | + catch (Exception e) { | ||
| 177 | + log.error("\u573a\u666f[{}] \u7edf\u8ba1\u5931\u8d25", (Object)s.getId(), (Object)e); | ||
| 59 | result.put(s.getId(), "ERROR: " + e.getMessage()); | 178 | result.put(s.getId(), "ERROR: " + e.getMessage()); |
| 60 | } | 179 | } |
| 61 | } | 180 | } |
| 62 | return result; | 181 | return result; |
| 63 | } | 182 | } |
| 64 | 183 | ||
| 65 | - /** 统计全部场景并按 syncCode 把计数 + Excel 附件写回启效。 */ | ||
| 66 | public Map<String, Object> countAndSync() { | 184 | public Map<String, Object> countAndSync() { |
| 67 | - log.info("========== 开始风险场景统计并写回启效(全部 {} 个场景) ==========", props.getScenarios().size()); | ||
| 68 | - Map<String, Object> result = new LinkedHashMap<>(); | ||
| 69 | - Context ctx = context(); | ||
| 70 | - for (JdyRiskProperties.Scenario s : props.getScenarios()) { | ||
| 71 | - syncOneScenario(s, ctx, result); | 185 | + log.info("========== \u5f00\u59cb\u98ce\u9669\u573a\u666f\u7edf\u8ba1\u5e76\u5199\u56de\u542f\u6548\uff08\u5168\u90e8 {} \u4e2a\u573a\u666f\uff09 ==========", (Object)this.props.getScenarios().size()); |
| 186 | + LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); | ||
| 187 | + Context ctx = this.context(); | ||
| 188 | + for (JdyRiskProperties.Scenario s : this.props.getScenarios()) { | ||
| 189 | + this.syncOneScenario(s, ctx, result); | ||
| 72 | } | 190 | } |
| 73 | - log.info("========== 风险场景统计并写回完成 =========="); | 191 | + log.info("========== \u98ce\u9669\u573a\u666f\u7edf\u8ba1\u5e76\u5199\u56de\u5b8c\u6210 =========="); |
| 74 | return result; | 192 | return result; |
| 75 | } | 193 | } |
| 76 | 194 | ||
| 77 | - /** 只处理单个场景(参数为场景 id 如 count_1,或 syncCode 如 SYNC0001)。 */ | ||
| 78 | public Map<String, Object> countAndSyncOne(String scenarioId) { | 195 | public Map<String, Object> countAndSyncOne(String scenarioId) { |
| 79 | - Map<String, Object> result = new LinkedHashMap<>(); | ||
| 80 | - JdyRiskProperties.Scenario s = findScenario(scenarioId); | 196 | + LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); |
| 197 | + JdyRiskProperties.Scenario s = this.findScenario(scenarioId); | ||
| 81 | if (s == null) { | 198 | if (s == null) { |
| 82 | - result.put("error", "场景不存在: " + scenarioId); | 199 | + result.put("error", "\u573a\u666f\u4e0d\u5b58\u5728: " + scenarioId); |
| 83 | return result; | 200 | return result; |
| 84 | } | 201 | } |
| 85 | - log.info("========== 开始单场景统计并写回: {} ==========", scenarioId); | ||
| 86 | - syncOneScenario(s, context(), result); | 202 | + log.info("========== \u5f00\u59cb\u5355\u573a\u666f\u7edf\u8ba1\u5e76\u5199\u56de: {} ==========", (Object)scenarioId); |
| 203 | + this.syncOneScenario(s, this.context(), result); | ||
| 87 | return result; | 204 | return result; |
| 88 | } | 205 | } |
| 89 | 206 | ||
| 90 | - /** 只统计单个场景(不写回)。 */ | ||
| 91 | public Map<String, Object> countOne(String scenarioId) { | 207 | public Map<String, Object> countOne(String scenarioId) { |
| 92 | - Map<String, Object> result = new LinkedHashMap<>(); | ||
| 93 | - JdyRiskProperties.Scenario s = findScenario(scenarioId); | 208 | + LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); |
| 209 | + JdyRiskProperties.Scenario s = this.findScenario(scenarioId); | ||
| 94 | if (s == null) { | 210 | if (s == null) { |
| 95 | - result.put("error", "场景不存在: " + scenarioId); | 211 | + result.put("error", "\u573a\u666f\u4e0d\u5b58\u5728: " + scenarioId); |
| 96 | return result; | 212 | return result; |
| 97 | } | 213 | } |
| 98 | - JiandaoYunApi jdy = new JiandaoYunApi(props.getHost()); | 214 | + JiandaoYunApi jdy = new JiandaoYunApi(this.props.getHost()); |
| 99 | try { | 215 | try { |
| 100 | - String type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 101 | - if ("scenario7".equals(type)) { | ||
| 102 | - result.put(s.getId(), buildScenario7Rows(jdy, s).size()); | ||
| 103 | - } else { | ||
| 104 | - JSONArray all = jdy.listAllData(props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 105 | - result.put(s.getId(), count(s, filterScope(all, s))); | ||
| 106 | - } | ||
| 107 | - } catch (Exception e) { | 216 | + result.put(s.getId(), this.countOneInternal(jdy, s)); |
| 217 | + } | ||
| 218 | + catch (Exception e) { | ||
| 108 | result.put(s.getId(), "ERROR: " + e.getMessage()); | 219 | result.put(s.getId(), "ERROR: " + e.getMessage()); |
| 109 | } | 220 | } |
| 110 | return result; | 221 | return result; |
| 111 | } | 222 | } |
| 112 | 223 | ||
| 224 | + /* | ||
| 225 | + * WARNING - Removed try catching itself - possible behaviour change. | ||
| 226 | + */ | ||
| 227 | + public Map<String, Object> backfill(String fromMonth, String toMonth, List<String> scenarioIds, boolean dryRun, boolean wipe) { | ||
| 228 | + return backfill(fromMonth, toMonth, scenarioIds, dryRun, wipe, null); | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + /* | ||
| 232 | + * WARNING - Removed try catching itself - possible behaviour change. | ||
| 233 | + */ | ||
| 234 | + public Map<String, Object> backfill(String fromMonth, String toMonth, List<String> scenarioIds, boolean dryRun, boolean wipe, String toDate) { | ||
| 235 | + YearMonth to; | ||
| 236 | + YearMonth from; | ||
| 237 | + LocalDate endDate = null; | ||
| 238 | + LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); | ||
| 239 | + try { | ||
| 240 | + from = YearMonth.parse(fromMonth); | ||
| 241 | + to = YearMonth.parse(toMonth); | ||
| 242 | + if (toDate != null && !toDate.trim().isEmpty()) { | ||
| 243 | + endDate = LocalDate.parse(toDate.trim()); | ||
| 244 | + } | ||
| 245 | + } | ||
| 246 | + catch (Exception e) { | ||
| 247 | + result.put("error", "月份格式应为 yyyy-MM,截止日应为 yyyy-MM-dd: " + fromMonth + "~" + toMonth + " / " + toDate); | ||
| 248 | + return result; | ||
| 249 | + } | ||
| 250 | + if (to.isBefore(from)) { | ||
| 251 | + result.put("error", "to \u4e0d\u80fd\u65e9\u4e8e from"); | ||
| 252 | + return result; | ||
| 253 | + } | ||
| 254 | + ArrayList<JdyRiskProperties.Scenario> targets = new ArrayList<JdyRiskProperties.Scenario>(); | ||
| 255 | + for (JdyRiskProperties.Scenario s : this.props.getScenarios()) { | ||
| 256 | + if (!JdyRiskStatisticsService.matchesTarget(s, scenarioIds)) continue; | ||
| 257 | + if (!JdyRiskStatisticsService.isBackfillSupported(s)) { | ||
| 258 | + result.put(s.getId(), "SKIP: \u5468\u671f\u7c7b\u578b\u4e0d\u786e\u5b9a(" + s.getType() + ")"); | ||
| 259 | + continue; | ||
| 260 | + } | ||
| 261 | + targets.add(s); | ||
| 262 | + } | ||
| 263 | + if (targets.isEmpty()) { | ||
| 264 | + result.put("error", "\u6ca1\u6709\u53ef\u56de\u8865\u7684\u573a\u666f"); | ||
| 265 | + return result; | ||
| 266 | + } | ||
| 267 | + log.info("========== \u5386\u53f2\u56de\u8865 {} ~ {}\uff0c\u573a\u666f={}\uff0cdryRun={}\uff0cwipe={} ==========", new Object[]{fromMonth, toMonth, targets.size(), dryRun, wipe}); | ||
| 268 | + Context ctx = this.context(); | ||
| 269 | + LinkedHashMap<String, JSONObject> templates = new LinkedHashMap<String, JSONObject>(); | ||
| 270 | + for (JdyRiskProperties.Scenario s : targets) { | ||
| 271 | + JSONObject t = this.findRecordBySyncCode(ctx.allRecords, s, JdyRiskStatisticsService.bizOf(s)); | ||
| 272 | + if (t == null) continue; | ||
| 273 | + templates.put(s.getId(), t); | ||
| 274 | + } | ||
| 275 | + if (wipe && !dryRun) { | ||
| 276 | + int deleted = this.wipeTargets(ctx, targets); | ||
| 277 | + result.put("_deleted", deleted); | ||
| 278 | + JSONArray kept = new JSONArray(); | ||
| 279 | + JdyRiskProperties.Qx qx = this.props.getQx(); | ||
| 280 | + for (JSONObject t : templates.values()) { | ||
| 281 | + // 模板仅用于克隆业务字段,清掉预警时间避免 findTodayRecord 误命中已删除记录 | ||
| 282 | + if (qx.getTimeField() != null && !qx.getTimeField().isEmpty()) { | ||
| 283 | + t.remove(qx.getTimeField()); | ||
| 284 | + } | ||
| 285 | + if (qx.getTimeField2() != null && !qx.getTimeField2().isEmpty()) { | ||
| 286 | + t.remove(qx.getTimeField2()); | ||
| 287 | + } | ||
| 288 | + kept.add((Object)t); | ||
| 289 | + } | ||
| 290 | + ctx = new Context(ctx.qxApi, ctx.token, ctx.jdy, kept); | ||
| 291 | + } | ||
| 292 | + this.backfillData.set(new HashMap<String, JSONArray>()); | ||
| 293 | + this.backfillPages.set(new HashMap<String, JSONArray>()); | ||
| 294 | + if (endDate != null) { | ||
| 295 | + this.backfillEndDate.set(endDate); | ||
| 296 | + } | ||
| 297 | + try { | ||
| 298 | + for (JdyRiskProperties.Scenario s : targets) { | ||
| 299 | + List<ZonedDateTime> runDates = this.runDatesFor(s, from, to); | ||
| 300 | + for (ZonedDateTime runDate : runDates) { | ||
| 301 | + String key = s.getId() + "@" + runDate.toLocalDate(); | ||
| 302 | + this.referenceNow.set(runDate); | ||
| 303 | + try { | ||
| 304 | + if (dryRun) { | ||
| 305 | + result.put(key, this.countOneInternal(ctx.jdy, s)); | ||
| 306 | + continue; | ||
| 307 | + } | ||
| 308 | + LinkedHashMap<String, Object> one = new LinkedHashMap<String, Object>(); | ||
| 309 | + this.syncOneScenario(s, ctx, one); | ||
| 310 | + Object v = one.get(s.getId()); | ||
| 311 | + result.put(key, v != null ? v : one); | ||
| 312 | + } | ||
| 313 | + catch (Exception e) { | ||
| 314 | + log.error("\u5386\u53f2\u56de\u8865\u5931\u8d25: {} {}", new Object[]{s.getId(), runDate, e}); | ||
| 315 | + result.put(key, "ERROR: " + e.getMessage()); | ||
| 316 | + } | ||
| 317 | + finally { | ||
| 318 | + this.referenceNow.remove(); | ||
| 319 | + } | ||
| 320 | + } | ||
| 321 | + } | ||
| 322 | + } finally { | ||
| 323 | + this.backfillData.remove(); | ||
| 324 | + this.backfillPages.remove(); | ||
| 325 | + this.backfillEndDate.remove(); | ||
| 326 | + } | ||
| 327 | + log.info("========== \u5386\u53f2\u56de\u8865\u5b8c\u6210 =========="); | ||
| 328 | + return result; | ||
| 329 | + } | ||
| 330 | + | ||
| 331 | + /** | ||
| 332 | + * 设备域场景20/21/22 一键历史回补(人大金仓)。 | ||
| 333 | + * <p>默认区间 2026-01-01 ~ 2026-10-30:按月生成启效记录; | ||
| 334 | + * 场景21按每月 1-10、11-20、21-月底 三个区间生成。</p> | ||
| 335 | + */ | ||
| 336 | + public Map<String, Object> backfillDb(String fromDate, String toDate, boolean dryRun, boolean wipe) { | ||
| 337 | + try { | ||
| 338 | + LocalDate from = LocalDate.parse(fromDate); | ||
| 339 | + LocalDate to = LocalDate.parse(toDate); | ||
| 340 | + return this.backfill(YearMonth.from(from).toString(), YearMonth.from(to).toString(), | ||
| 341 | + Arrays.asList("count_20", "count_21", "count_22"), dryRun, wipe, to.toString()); | ||
| 342 | + } catch (Exception e) { | ||
| 343 | + LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); | ||
| 344 | + result.put("error", "\u65e5\u671f\u683c\u5f0f\u5e94\u4e3a yyyy-MM-dd: " + fromDate + " ~ " + toDate); | ||
| 345 | + return result; | ||
| 346 | + } | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + private static boolean matchesTarget(JdyRiskProperties.Scenario s, List<String> ids) { if (ids == null || ids.isEmpty()) { | ||
| 350 | + return true; | ||
| 351 | + } | ||
| 352 | + for (String id : ids) { | ||
| 353 | + if (id == null || !id.equals(s.getId()) && !id.equals(s.getSyncCode())) continue; | ||
| 354 | + return true; | ||
| 355 | + } | ||
| 356 | + return false; | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + private static boolean isBackfillSupported(JdyRiskProperties.Scenario s) { | ||
| 360 | + String type; | ||
| 361 | + String string = type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 362 | + if ("scenario11".equals(type)) { | ||
| 363 | + return false; | ||
| 364 | + } | ||
| 365 | + if (JdyRiskStatisticsService.isDbType(type)) { | ||
| 366 | + return true; | ||
| 367 | + } | ||
| 368 | + if (s.isMonthOnly() || s.isPrevMonthOnly() || s.isPrevQuarterOnly() || s.isQuarterOnly() | ||
| 369 | + || s.isYearOnly() || s.isHalfMonthOnly() || s.isPrevThreeMonths() | ||
| 370 | + || s.isMonthlyOverdueIncremental()) { | ||
| 371 | + return true; | ||
| 372 | + } | ||
| 373 | + return "scenario22".equals(type) || "scenario28".equals(type) || "scenario30".equals(type) || "scenario31".equals(type) || "scenario32".equals(type); | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + private List<ZonedDateTime> runDatesFor(JdyRiskProperties.Scenario s, YearMonth from, YearMonth to) { | ||
| 377 | + ArrayList<ZonedDateTime> dates = new ArrayList<ZonedDateTime>(); | ||
| 378 | + LinkedHashSet<LocalDate> seen = new LinkedHashSet<LocalDate>(); | ||
| 379 | + String runType = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 380 | + if (JdyRiskStatisticsService.isDbType(runType)) { | ||
| 381 | + return this.dbRunDates(runType, from, to); | ||
| 382 | + } | ||
| 383 | + if (s.isYearOnly()) { | ||
| 384 | + dates.add(ZonedDateTime.now(ZONE)); | ||
| 385 | + return dates; | ||
| 386 | + } | ||
| 387 | + if (s.isHalfMonthOnly()) { | ||
| 388 | + YearMonth m = from; | ||
| 389 | + while (!m.isAfter(to)) { | ||
| 390 | + LocalDate first = m.atDay(16); | ||
| 391 | + LocalDate nextFirst = m.plusMonths(1L).atDay(1); | ||
| 392 | + if (seen.add(first)) { | ||
| 393 | + dates.add(ZonedDateTime.of(first, LocalTime.of(1, 0), ZONE)); | ||
| 394 | + } | ||
| 395 | + if (seen.add(nextFirst)) { | ||
| 396 | + dates.add(ZonedDateTime.of(nextFirst, LocalTime.of(1, 0), ZONE)); | ||
| 397 | + } | ||
| 398 | + m = m.plusMonths(1L); | ||
| 399 | + } | ||
| 400 | + return dates; | ||
| 401 | + } | ||
| 402 | + if (s.isPrevThreeMonths()) { | ||
| 403 | + YearMonth m = from.plusMonths(3L); | ||
| 404 | + YearMonth end = to.plusMonths(1L); | ||
| 405 | + while (!m.isAfter(end)) { | ||
| 406 | + LocalDate rd = m.atDay(1); | ||
| 407 | + if (seen.add(rd)) { | ||
| 408 | + dates.add(ZonedDateTime.of(rd, LocalTime.of(1, 0), ZONE)); | ||
| 409 | + } | ||
| 410 | + m = m.plusMonths(1L); | ||
| 411 | + } | ||
| 412 | + return dates; | ||
| 413 | + } | ||
| 414 | + boolean quarter = s.isPrevQuarterOnly() || s.isQuarterOnly(); | ||
| 415 | + YearMonth ym = from; | ||
| 416 | + while (!ym.isAfter(to)) { | ||
| 417 | + LocalDate runDate = null; | ||
| 418 | + LocalTime runTime = LocalTime.of(3, 0); | ||
| 419 | + if (quarter) { | ||
| 420 | + int m = ym.getMonthValue(); | ||
| 421 | + if (m == 3 || m == 6 || m == 9 || m == 12) { | ||
| 422 | + runDate = ym.plusMonths(1L).atDay(5); | ||
| 423 | + } | ||
| 424 | + } else if (s.isMonthOnly()) { | ||
| 425 | + runDate = ym.atEndOfMonth(); | ||
| 426 | + runTime = LocalTime.of(23, 0); | ||
| 427 | + } else { | ||
| 428 | + int day = "count_1".equals(s.getId()) ? 20 : 5; | ||
| 429 | + runDate = ym.plusMonths(1L).atDay(day); | ||
| 430 | + } | ||
| 431 | + if (runDate != null && seen.add(runDate)) { | ||
| 432 | + dates.add(ZonedDateTime.of(runDate, runTime, ZONE)); | ||
| 433 | + } | ||
| 434 | + ym = ym.plusMonths(1L); | ||
| 435 | + } | ||
| 436 | + return dates; | ||
| 437 | + } | ||
| 438 | + | ||
| 439 | + /** | ||
| 440 | + * 人大金仓场景的历史回补运行日期: | ||
| 441 | + * <ul> | ||
| 442 | + * <li>scenario33(废料预警):数据月 m 的记录在 m+1 月 12 号 01:00 生成</li> | ||
| 443 | + * <li>scenario34(过磅记录):数据月内 11 号 01:00(1-10)、21 号 01:00(11-20)、月末 23:00(21-月底)</li> | ||
| 444 | + * <li>scenario35(运输异常):数据月 m 的记录在 m+1 月 1 号 01:00 生成</li> | ||
| 445 | + * </ul> | ||
| 446 | + */ | ||
| 447 | + private List<ZonedDateTime> dbRunDates(String type, YearMonth from, YearMonth to) { | ||
| 448 | + ArrayList<ZonedDateTime> dates = new ArrayList<ZonedDateTime>(); | ||
| 449 | + LocalDate cap = this.backfillEndDate.get(); | ||
| 450 | + YearMonth ym = from; | ||
| 451 | + while (!ym.isAfter(to)) { | ||
| 452 | + if ("scenario33".equals(type)) { | ||
| 453 | + dates.add(ZonedDateTime.of(ym.plusMonths(1L).atDay(12), LocalTime.of(1, 0), ZONE)); | ||
| 454 | + } else if ("scenario35".equals(type)) { | ||
| 455 | + dates.add(ZonedDateTime.of(ym.plusMonths(1L).atDay(1), LocalTime.of(1, 0), ZONE)); | ||
| 456 | + } else if ("scenario34".equals(type)) { | ||
| 457 | + dates.add(ZonedDateTime.of(ym.atDay(11), LocalTime.of(1, 0), ZONE)); | ||
| 458 | + dates.add(ZonedDateTime.of(ym.atDay(21), LocalTime.of(1, 0), ZONE)); | ||
| 459 | + LocalDate last = ym.atEndOfMonth(); | ||
| 460 | + if (cap != null && !cap.isBefore(ym.atDay(21)) && cap.isBefore(last)) { | ||
| 461 | + last = cap; | ||
| 462 | + } | ||
| 463 | + if (!last.isBefore(ym.atDay(21)) && last.getMonthValue() == ym.getMonthValue()) { | ||
| 464 | + dates.add(ZonedDateTime.of(last, LocalTime.of(23, 0), ZONE)); | ||
| 465 | + } | ||
| 466 | + } | ||
| 467 | + ym = ym.plusMonths(1L); | ||
| 468 | + } | ||
| 469 | + return dates; | ||
| 470 | + } | ||
| 471 | + | ||
| 472 | + private int wipeTargets(Context ctx, List<JdyRiskProperties.Scenario> targets) { | ||
| 473 | + JdyRiskProperties.Qx qx = this.props.getQx(); | ||
| 474 | + String deleteCode = qx.getDeleteCode(); | ||
| 475 | + if (deleteCode == null || deleteCode.isEmpty()) { | ||
| 476 | + deleteCode = "ilr3ne7bDel"; | ||
| 477 | + } | ||
| 478 | + int deleted = 0; | ||
| 479 | + for (int i = 0; i < ctx.allRecords.size(); ++i) { | ||
| 480 | + String id; | ||
| 481 | + JSONObject r = ctx.allRecords.getJSONObject(i); | ||
| 482 | + if (!JdyRiskStatisticsService.belongsToAny(r, targets) || (id = r.getString("id")) == null || id.isEmpty()) continue; | ||
| 483 | + try { | ||
| 484 | + ctx.qxApi.deleteData(ctx.token, qx.getAppId(), deleteCode, id); | ||
| 485 | + ++deleted; | ||
| 486 | + continue; | ||
| 487 | + } | ||
| 488 | + catch (Exception e) { | ||
| 489 | + log.error("\u56de\u8865\u6e05\u5e93\u5220\u9664\u5931\u8d25 id={}: {}", (Object)id, (Object)e.getMessage()); | ||
| 490 | + } | ||
| 491 | + } | ||
| 492 | + log.info("\u56de\u8865\u6e05\u5e93\u5b8c\u6210\uff0c\u5220\u9664 {} \u6761\uff08\u4ec5\u9650\u672c\u6b21\u56de\u8865\u573a\u666f\uff09", (Object)deleted); | ||
| 493 | + return deleted; | ||
| 494 | + } | ||
| 495 | + | ||
| 496 | + private static boolean belongsToAny(JSONObject r, List<JdyRiskProperties.Scenario> targets) { | ||
| 497 | + String sc = r.getString("syncCode"); | ||
| 498 | + if (sc == null) { | ||
| 499 | + return false; | ||
| 500 | + } | ||
| 501 | + JSONObject scene = r.getJSONObject("miidqb"); | ||
| 502 | + String sceneId = scene != null ? scene.getString("id") : r.getString("miidqbId"); | ||
| 503 | + for (JdyRiskProperties.Scenario s : targets) { | ||
| 504 | + if (!sc.equals(s.getSyncCode())) continue; | ||
| 505 | + Biz biz = JdyRiskStatisticsService.bizOf(s); | ||
| 506 | + if (biz != null && biz.sceneId != null) { | ||
| 507 | + if (!biz.sceneId.equals(sceneId)) continue; | ||
| 508 | + return true; | ||
| 509 | + } | ||
| 510 | + return true; | ||
| 511 | + } | ||
| 512 | + return false; | ||
| 513 | + } | ||
| 514 | + | ||
| 515 | + private long countOneInternal(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 516 | + String type; | ||
| 517 | + String string = type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 518 | + if ("scenario7".equals(type)) { | ||
| 519 | + return this.buildScenario7Rows(jdy, s).size(); | ||
| 520 | + } | ||
| 521 | + if ("scenario11".equals(type)) { | ||
| 522 | + return this.buildScenario11((JiandaoYunApi)jdy, (JdyRiskProperties.Scenario)s).count; | ||
| 523 | + } | ||
| 524 | + if ("scenario30".equals(type) || "scenario31".equals(type) || "scenario32".equals(type)) { | ||
| 525 | + return this.customSheets((JiandaoYunApi)jdy, (JdyRiskProperties.Scenario)s).count; | ||
| 526 | + } | ||
| 527 | + if ("scenario22".equals(type)) { | ||
| 528 | + return this.buildS28((JiandaoYunApi)jdy, (JdyRiskProperties.Scenario)s).count; | ||
| 529 | + } | ||
| 530 | + if ("scenario28".equals(type)) { | ||
| 531 | + return this.buildS29((JiandaoYunApi)jdy, (JdyRiskProperties.Scenario)s).count; | ||
| 532 | + } | ||
| 533 | + if (JdyRiskStatisticsService.isDbType(type)) { | ||
| 534 | + return this.buildDbRows((JdyRiskProperties.Scenario)s).count; | ||
| 535 | + } | ||
| 536 | + if (JdyRiskStatisticsService.isReasonType(type)) { | ||
| 537 | + return this.buildReasonRows((JiandaoYunApi)jdy, (JdyRiskProperties.Scenario)s).count; | ||
| 538 | + } | ||
| 539 | + return this.count(s, this.buildScopeRows(jdy, s)); | ||
| 540 | + } | ||
| 541 | + | ||
| 113 | private JdyRiskProperties.Scenario findScenario(String scenarioId) { | 542 | private JdyRiskProperties.Scenario findScenario(String scenarioId) { |
| 114 | if (scenarioId == null) { | 543 | if (scenarioId == null) { |
| 115 | return null; | 544 | return null; |
| 116 | } | 545 | } |
| 117 | - for (JdyRiskProperties.Scenario s : props.getScenarios()) { | ||
| 118 | - if (scenarioId.equals(s.getId()) || scenarioId.equals(s.getSyncCode())) { | ||
| 119 | - return s; | ||
| 120 | - } | 546 | + for (JdyRiskProperties.Scenario s : this.props.getScenarios()) { |
| 547 | + if (!scenarioId.equals(s.getId()) && !scenarioId.equals(s.getSyncCode())) continue; | ||
| 548 | + return s; | ||
| 121 | } | 549 | } |
| 122 | return null; | 550 | return null; |
| 123 | } | 551 | } |
| 124 | 552 | ||
| 125 | - /** 登录启效并一次性拉取全部记录(本地按 syncCode 匹配)。 */ | ||
| 126 | private Context context() { | 553 | private Context context() { |
| 127 | - JdyRiskProperties.Qx qx = props.getQx(); | 554 | + JdyRiskProperties.Qx qx = this.props.getQx(); |
| 128 | QxApi qxApi = new QxApi(qx.getBaseUrl()); | 555 | QxApi qxApi = new QxApi(qx.getBaseUrl()); |
| 129 | String token = qxApi.login(qx.getUsername(), qx.getPassword(), qx.getCorpCode()); | 556 | String token = qxApi.login(qx.getUsername(), qx.getPassword(), qx.getCorpCode()); |
| 130 | - JiandaoYunApi jdy = new JiandaoYunApi(props.getHost()); | 557 | + JiandaoYunApi jdy = new JiandaoYunApi(this.props.getHost()); |
| 131 | JSONArray allRecords = qxApi.pageAll(token, qx.getAppId(), qx.getQueryCode()); | 558 | JSONArray allRecords = qxApi.pageAll(token, qx.getAppId(), qx.getQueryCode()); |
| 132 | - log.info("启效记录总数={}(按 syncCode 本地匹配)", allRecords.size()); | 559 | + log.info("\u542f\u6548\u8bb0\u5f55\u603b\u6570={}\uff08\u6309 syncCode \u672c\u5730\u5339\u914d\uff09", (Object)allRecords.size()); |
| 133 | return new Context(qxApi, token, jdy, allRecords); | 560 | return new Context(qxApi, token, jdy, allRecords); |
| 134 | } | 561 | } |
| 135 | 562 | ||
| 136 | - private static class Context { | ||
| 137 | - final QxApi qxApi; | ||
| 138 | - final String token; | ||
| 139 | - final JiandaoYunApi jdy; | ||
| 140 | - final JSONArray allRecords; | ||
| 141 | - | ||
| 142 | - Context(QxApi qxApi, String token, JiandaoYunApi jdy, JSONArray allRecords) { | ||
| 143 | - this.qxApi = qxApi; | ||
| 144 | - this.token = token; | ||
| 145 | - this.jdy = jdy; | ||
| 146 | - this.allRecords = allRecords; | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - /** 单场景:统计 -> 生成 Excel -> 上传附件 -> 更新记录。 */ | ||
| 151 | private void syncOneScenario(JdyRiskProperties.Scenario s, Context ctx, Map<String, Object> result) { | 563 | private void syncOneScenario(JdyRiskProperties.Scenario s, Context ctx, Map<String, Object> result) { |
| 152 | - JdyRiskProperties.Qx qx = props.getQx(); | 564 | + JdyRiskProperties.Qx qx = this.props.getQx(); |
| 153 | QxApi qxApi = ctx.qxApi; | 565 | QxApi qxApi = ctx.qxApi; |
| 154 | String token = ctx.token; | 566 | String token = ctx.token; |
| 155 | JiandaoYunApi jdy = ctx.jdy; | 567 | JiandaoYunApi jdy = ctx.jdy; |
| 156 | JSONArray allRecords = ctx.allRecords; | 568 | JSONArray allRecords = ctx.allRecords; |
| 157 | try { | 569 | try { |
| 158 | - String type = s.getType() == null ? "" : s.getType().toLowerCase(); | 570 | + JSONArray widgets; |
| 159 | JSONArray rows; | 571 | JSONArray rows; |
| 160 | long count; | 572 | long count; |
| 161 | - if ("scenario7".equals(type)) { | ||
| 162 | - rows = buildScenario7Rows(jdy, s); | 573 | + String type = s.getType() == null ? "" : s.getType().toLowerCase(); |
| 574 | + Biz sceneBiz = JdyRiskStatisticsService.bizOf(s); | ||
| 575 | + JdyExcelExportService.setLookup(this.buildLookupMap(jdy, s)); | ||
| 576 | + String extraHeader = null; | ||
| 577 | + List<String> extraValues = null; | ||
| 578 | + List<JdyExcelExportService.SheetSpec> customSheets = null; | ||
| 579 | + if (JdyRiskStatisticsService.isCustomSheetType(type)) { | ||
| 580 | + MultiResult mr = this.customSheets(jdy, s); | ||
| 581 | + count = mr.count; | ||
| 582 | + customSheets = mr.sheets; | ||
| 583 | + rows = new JSONArray(); | ||
| 584 | + widgets = new JSONArray(); | ||
| 585 | + } else if ("scenario7".equals(type)) { | ||
| 586 | + rows = this.buildScenario7Rows(jdy, s); | ||
| 163 | count = rows.size(); | 587 | count = rows.size(); |
| 588 | + widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 589 | + } else if ("scenario11".equals(type)) { | ||
| 590 | + Built11 b = this.buildScenario11(jdy, s); | ||
| 591 | + rows = b.excelRows; | ||
| 592 | + count = b.count; | ||
| 593 | + widgets = b.excelWidgets; | ||
| 594 | + } else if (JdyRiskStatisticsService.isDbType(type)) { | ||
| 595 | + BuiltDb db = this.buildDbRows(s); | ||
| 596 | + rows = db.rows; | ||
| 597 | + count = db.count; | ||
| 598 | + widgets = db.widgets; | ||
| 599 | + extraHeader = "\u539f\u56e0"; | ||
| 600 | + extraValues = db.reasons; | ||
| 601 | + } else if (JdyRiskStatisticsService.isReasonType(type)) { | ||
| 602 | + BuiltReason br = this.buildReasonRows(jdy, s); | ||
| 603 | + rows = br.rows; | ||
| 604 | + count = br.count; | ||
| 605 | + widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 606 | + extraHeader = "\u539f\u56e0"; | ||
| 607 | + extraValues = br.reasons; | ||
| 164 | } else { | 608 | } else { |
| 165 | - JSONArray all = jdy.listAllData(props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 166 | - rows = filterScope(all, s); | ||
| 167 | - count = count(s, rows); | 609 | + String sortField; |
| 610 | + rows = this.buildScopeRows(jdy, s); | ||
| 611 | + count = this.count(s, rows); | ||
| 612 | + widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 613 | + if (!"scenario10".equals(type)) { | ||
| 614 | + extraHeader = "scenario4".equals(type) || "scenario6".equals(type) || "scenario8".equals(type) ? "\u9884\u8b66\u4f9b\u5e94\u5546" : ("scenario5".equals(type) || "scenario9".equals(type) ? "\u9884\u8b66\u5de5\u7a0b\u5e08" : "\u7b5b\u9009\u7ed3\u679c"); | ||
| 615 | + extraValues = this.buildExtraValues(s, rows); | ||
| 616 | + } | ||
| 617 | + if (s.isOnlyWarnRows()) { | ||
| 618 | + rows = this.filterWarnRows(s, rows); | ||
| 619 | + extraValues = this.buildExtraValues(s, rows); | ||
| 620 | + } | ||
| 621 | + String string = sortField = s.getGroupField() != null && !s.getGroupField().isEmpty() ? s.getGroupField() : s.getExtraField(); | ||
| 622 | + if (sortField != null && !sortField.isEmpty()) { | ||
| 623 | + JdyRiskStatisticsService.sortRows(rows, sortField); | ||
| 624 | + if (extraHeader != null) { | ||
| 625 | + extraValues = this.buildExtraValues(s, rows); | ||
| 626 | + } | ||
| 627 | + } | ||
| 168 | } | 628 | } |
| 169 | result.put(s.getId(), count); | 629 | result.put(s.getId(), count); |
| 170 | - log.info("场景[{}] 命中={} (参与统计{}条)", s.getId(), count, rows.size()); | ||
| 171 | - | ||
| 172 | - JSONArray widgets = jdy.listWidgets(props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 173 | - String extraHeader = null; | ||
| 174 | - List<String> extraValues = null; | ||
| 175 | - if (!"scenario7".equals(type)) { | ||
| 176 | - if ("scenario4".equals(type) || "scenario6".equals(type) || "scenario8".equals(type)) { | ||
| 177 | - extraHeader = "预警供应商"; | ||
| 178 | - } else if ("scenario5".equals(type) || "scenario9".equals(type)) { | ||
| 179 | - extraHeader = "预警工程师"; | 630 | + log.info("\u573a\u666f[{}] \u547d\u4e2d={} (\u53c2\u4e0e\u7edf\u8ba1{}\u6761)", new Object[]{s.getId(), count, rows.size()}); |
| 631 | + boolean skipAttach = (JdyRiskStatisticsService.isReasonType(type) || JdyRiskStatisticsService.isCustomSheetType(type) || JdyRiskStatisticsService.isDbType(type)) && count == 0L; | ||
| 632 | + String fileId = null; | ||
| 633 | + String fileName = null; | ||
| 634 | + long size = 0L; | ||
| 635 | + if (skipAttach) { | ||
| 636 | + log.info("\u573a\u666f[{}] \u547d\u4e2d0\u6761\uff0c\u8df3\u8fc7 Excel \u751f\u6210\u4e0e\u9644\u4ef6\u4e0a\u4f20\uff0c\u4ec5\u56de\u5199\u8ba1\u6570", (Object)s.getId()); | ||
| 637 | + } else { | ||
| 638 | + String path; | ||
| 639 | + fileName = JdyExcelExportService.nowFileName(); | ||
| 640 | + if (customSheets != null) { | ||
| 641 | + path = this.excelExportService.exportSheets(fileName, customSheets); | ||
| 180 | } else { | 642 | } else { |
| 181 | - extraHeader = "筛选结果"; | 643 | + HashSet<String> percentFields = s.getPercentFields().isEmpty() ? null : new HashSet<String>(s.getPercentFields()); |
| 644 | + Biz sheetBiz = sceneBiz; | ||
| 645 | + String sheetName = sheetBiz != null ? sheetBiz.sceneTitle : s.getName(); | ||
| 646 | + path = this.excelExportService.exportRows(widgets, rows, extraHeader, extraValues, fileName, sheetName, percentFields); | ||
| 182 | } | 647 | } |
| 183 | - extraValues = buildExtraValues(s, rows); | ||
| 184 | - } | ||
| 185 | - String fileName = JdyExcelExportService.nowFileName(); | ||
| 186 | - String path = excelExportService.exportRows(widgets, rows, extraHeader, extraValues, fileName); | ||
| 187 | - if (path == null || path.startsWith("FAIL")) { | ||
| 188 | - throw new IllegalStateException("Excel 导出失败: " + path); | 648 | + if (path == null || path.startsWith("FAIL")) { |
| 649 | + throw new IllegalStateException("Excel \u5bfc\u51fa\u5931\u8d25: " + path); | ||
| 650 | + } | ||
| 651 | + fileId = qxApi.uploadFile(token, new File(path), fileName); | ||
| 652 | + size = new File(path).length(); | ||
| 189 | } | 653 | } |
| 190 | - | ||
| 191 | - String fileId = qxApi.uploadFile(token, new File(path), fileName); | ||
| 192 | - | 654 | + long now = this.now().toInstant().toEpochMilli(); |
| 193 | String syncCode = s.getSyncCode(); | 655 | String syncCode = s.getSyncCode(); |
| 194 | - JSONObject rec = findRecordBySyncCode(allRecords, syncCode); | ||
| 195 | - if (rec == null) { | ||
| 196 | - log.warn("按 syncCode={} 未查到记录,跳过写回", syncCode); | ||
| 197 | - return; | ||
| 198 | - } | ||
| 199 | - rec.put(qx.getCountField(), count); | ||
| 200 | - if (qx.getAttachField() != null && !qx.getAttachField().isEmpty()) { | ||
| 201 | - JSONObject rel = new JSONObject(); | ||
| 202 | - rel.put("id", fileId); | ||
| 203 | - rel.put("dataTitle", fileName); | ||
| 204 | - rec.put(qx.getAttachField(), rel); | ||
| 205 | - rec.put(qx.getAttachField() + "Id", fileId); | ||
| 206 | - } | ||
| 207 | - qxApi.updateData(token, qx.getAppId(), qx.getUpdateCode(), rec); | ||
| 208 | - log.info("写回成功: syncCode={} id={} {}={} 附件={}", syncCode, rec.getString("id"), | ||
| 209 | - qx.getCountField(), count, fileName); | ||
| 210 | - } catch (Exception e) { | ||
| 211 | - log.error("场景[{}] 写回失败", s.getId(), e); | 656 | + JSONObject todayRec = this.findTodayRecord(allRecords, s, sceneBiz, qx.getTimeField()); |
| 657 | + if (todayRec != null) { | ||
| 658 | + todayRec.put(qx.getCountField(), (Object)count); | ||
| 659 | + JdyRiskStatisticsService.setTimeFields(todayRec, qx, now); | ||
| 660 | + if (!skipAttach && qx.getAttachField() != null && !qx.getAttachField().isEmpty()) { | ||
| 661 | + todayRec.put(qx.getAttachField(), (Object)this.buildAttach(fileId, fileName, size)); | ||
| 662 | + todayRec.put(qx.getAttachField() + "Id", (Object)fileId); | ||
| 663 | + } | ||
| 664 | + qxApi.updateData(token, qx.getAppId(), qx.getUpdateCode(), todayRec); | ||
| 665 | + log.info("\u5f53\u5929\u5df2\u5b58\u5728\u2192\u66f4\u65b0\u6210\u529f: syncCode={} id={} {}={} \u9644\u4ef6={}", new Object[]{syncCode, todayRec.getString("id"), qx.getCountField(), count, fileName}); | ||
| 666 | + } else { | ||
| 667 | + JSONObject addBody; | ||
| 668 | + JSONObject template = this.findRecordBySyncCode(allRecords, s, sceneBiz); | ||
| 669 | + if (template != null) { | ||
| 670 | + addBody = this.cloneTemplate(template, qx, syncCode, count, now, fileId, fileName, size, skipAttach); | ||
| 671 | + log.info("\u5f53\u5929\u65e0\u6570\u636e\u2192\u4ee5[{}]\u73b0\u6709\u8bb0\u5f55\u4e3a\u6a21\u677f\u65b0\u589e", (Object)syncCode); | ||
| 672 | + } else { | ||
| 673 | + Biz biz = sceneBiz; | ||
| 674 | + if (biz == null) { | ||
| 675 | + throw new IllegalStateException("\u672a\u914d\u7f6e\u8be5\u573a\u666f\u7684\u65b0\u589e\u4e1a\u52a1\u6570\u636e(\u6a21\u677f): " + syncCode); | ||
| 676 | + } | ||
| 677 | + addBody = this.buildAddBody(biz, qx, syncCode, count, now, fileId, fileName, size); | ||
| 678 | + } | ||
| 679 | + String newId = qxApi.addData(token, qx.getAppId(), qx.getAddCode(), addBody); | ||
| 680 | + log.info("\u5f53\u5929\u65e0\u6570\u636e\u2192\u65b0\u589e\u6210\u529f: syncCode={} newId={} {}={} \u9644\u4ef6={}", new Object[]{syncCode, newId, qx.getCountField(), count, fileName}); | ||
| 681 | + } | ||
| 682 | + } | ||
| 683 | + catch (Exception e) { | ||
| 684 | + log.error("\u573a\u666f[{}] \u5199\u56de\u5931\u8d25", (Object)s.getId(), (Object)e); | ||
| 212 | result.put(s.getId() + "_error", e.getMessage()); | 685 | result.put(s.getId() + "_error", e.getMessage()); |
| 213 | } | 686 | } |
| 214 | } | 687 | } |
| 215 | 688 | ||
| 216 | - /* ==================== 范围过滤 ==================== */ | ||
| 217 | - | ||
| 218 | - /** 按场景统计周期过滤数据:全量 / 当月 / 当季度 / 当年 / 上月。 */ | ||
| 219 | private JSONArray filterScope(JSONArray all, JdyRiskProperties.Scenario s) { | 689 | private JSONArray filterScope(JSONArray all, JdyRiskProperties.Scenario s) { |
| 220 | - if (!s.isMonthOnly() && !s.isQuarterOnly() && !s.isYearOnly() && !s.isPrevMonthOnly()) { | 690 | + ZonedDateTime hmEnd; |
| 691 | + ZonedDateTime hmStart; | ||
| 692 | + if (!(s.isMonthOnly() || s.isQuarterOnly() || s.isPrevQuarterOnly() || s.isYearOnly() || s.isPrevMonthOnly() || s.isPrevThreeMonths() || s.isHalfMonthOnly())) { | ||
| 221 | return all; | 693 | return all; |
| 222 | } | 694 | } |
| 223 | - ZonedDateTime now = ZonedDateTime.now(ZONE); | ||
| 224 | - ZonedDateTime qStart = quarterStart(now); | ||
| 225 | - ZonedDateTime qEnd = qStart.plusMonths(3); | 695 | + ZonedDateTime now = this.now(); |
| 696 | + ZonedDateTime qStart = JdyRiskStatisticsService.quarterStart(now); | ||
| 697 | + ZonedDateTime qEnd = qStart.plusMonths(3L); | ||
| 698 | + ZonedDateTime pqStart = qStart.minusMonths(3L); | ||
| 226 | ZonedDateTime yStart = now.withDayOfYear(1).truncatedTo(ChronoUnit.DAYS); | 699 | ZonedDateTime yStart = now.withDayOfYear(1).truncatedTo(ChronoUnit.DAYS); |
| 227 | - ZonedDateTime pmStart = now.minusMonths(1).withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | 700 | + ZonedDateTime pmStart = now.minusMonths(1L).withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); |
| 228 | ZonedDateTime pmEnd = now.withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | 701 | ZonedDateTime pmEnd = now.withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); |
| 702 | + ZonedDateTime p3Start = now.minusMonths(3L).withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | ||
| 703 | + ZonedDateTime monthStart = now.withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | ||
| 704 | + if (now.getDayOfMonth() < 16) { | ||
| 705 | + hmStart = monthStart.minusMonths(1L).plusDays(15L); | ||
| 706 | + hmEnd = monthStart; | ||
| 707 | + } else { | ||
| 708 | + hmStart = monthStart; | ||
| 709 | + hmEnd = monthStart.plusDays(15L); | ||
| 710 | + } | ||
| 229 | String month = now.format(MONTH_FMT); | 711 | String month = now.format(MONTH_FMT); |
| 230 | JSONArray out = new JSONArray(); | 712 | JSONArray out = new JSONArray(); |
| 231 | - for (int i = 0; i < all.size(); i++) { | 713 | + for (int i = 0; i < all.size(); ++i) { |
| 232 | JSONObject row = all.getJSONObject(i); | 714 | JSONObject row = all.getJSONObject(i); |
| 233 | - ZonedDateTime dt = parseTime(row.getString(s.getDateField())); | ||
| 234 | - if (dt == null) { | ||
| 235 | - continue; | ||
| 236 | - } | 715 | + ZonedDateTime dt = JdyRiskStatisticsService.parseTime(row.getString(s.getDateField())); |
| 716 | + if (dt == null) continue; | ||
| 237 | boolean keep = false; | 717 | boolean keep = false; |
| 238 | if (s.isQuarterOnly()) { | 718 | if (s.isQuarterOnly()) { |
| 239 | keep = !dt.isBefore(qStart) && dt.isBefore(qEnd); | 719 | keep = !dt.isBefore(qStart) && dt.isBefore(qEnd); |
| 720 | + } else if (s.isPrevQuarterOnly()) { | ||
| 721 | + keep = !dt.isBefore(pqStart) && dt.isBefore(qStart); | ||
| 240 | } else if (s.isYearOnly()) { | 722 | } else if (s.isYearOnly()) { |
| 241 | keep = !dt.isBefore(yStart) && !dt.isAfter(now); | 723 | keep = !dt.isBefore(yStart) && !dt.isAfter(now); |
| 724 | + } else if (s.isHalfMonthOnly()) { | ||
| 725 | + keep = !dt.isBefore(hmStart) && dt.isBefore(hmEnd); | ||
| 242 | } else if (s.isPrevMonthOnly()) { | 726 | } else if (s.isPrevMonthOnly()) { |
| 243 | keep = !dt.isBefore(pmStart) && dt.isBefore(pmEnd); | 727 | keep = !dt.isBefore(pmStart) && dt.isBefore(pmEnd); |
| 728 | + } else if (s.isPrevThreeMonths()) { | ||
| 729 | + keep = !dt.isBefore(p3Start) && dt.isBefore(pmEnd); | ||
| 244 | } else if (s.isMonthOnly()) { | 730 | } else if (s.isMonthOnly()) { |
| 245 | keep = month.equals(dt.format(MONTH_FMT)); | 731 | keep = month.equals(dt.format(MONTH_FMT)); |
| 246 | } | 732 | } |
| 247 | - if (keep) { | ||
| 248 | - out.add(row); | ||
| 249 | - } | 733 | + if (!keep) continue; |
| 734 | + out.add((Object)row); | ||
| 250 | } | 735 | } |
| 251 | return out; | 736 | return out; |
| 252 | } | 737 | } |
| 253 | 738 | ||
| 254 | - /* ==================== 计数 ==================== */ | ||
| 255 | - | ||
| 256 | private long count(JdyRiskProperties.Scenario s, JSONArray rows) { | 739 | private long count(JdyRiskProperties.Scenario s, JSONArray rows) { |
| 257 | - String type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 258 | - switch (type) { | ||
| 259 | - case "scenario1": | ||
| 260 | - return countScenario1(s, rows); | ||
| 261 | - case "scenario2": | ||
| 262 | - return countScenario2(s, rows); | ||
| 263 | - case "scenario3": | ||
| 264 | - return countScenario3(s, rows); | ||
| 265 | - case "scenario4": | ||
| 266 | - case "scenario5": | ||
| 267 | - return countGroupByUp(s, rows); | ||
| 268 | - case "scenario6": | ||
| 269 | - return warningGroupsByCount(s, rows).size(); | ||
| 270 | - case "scenario8": | ||
| 271 | - case "scenario9": | ||
| 272 | - return warningGroupsByRatio(s, rows).size(); | ||
| 273 | - default: | ||
| 274 | - throw new IllegalStateException("未知场景类型: " + s.getType()); | ||
| 275 | - } | ||
| 276 | - } | ||
| 277 | - | ||
| 278 | - /** 场景1:总计>=5 且 差值>=1 且 flowState=进行中。 */ | 740 | + String type; |
| 741 | + switch (type = s.getType() == null ? "" : s.getType().toLowerCase()) { | ||
| 742 | + case "scenario1": { | ||
| 743 | + return this.countScenario1(s, rows); | ||
| 744 | + } | ||
| 745 | + case "scenario2": { | ||
| 746 | + return this.countScenario2(s, rows); | ||
| 747 | + } | ||
| 748 | + case "scenario3": { | ||
| 749 | + return this.countScenario3(s, rows); | ||
| 750 | + } | ||
| 751 | + case "scenario4": | ||
| 752 | + case "scenario5": { | ||
| 753 | + return this.countGroupByUp(s, rows); | ||
| 754 | + } | ||
| 755 | + case "scenario6": { | ||
| 756 | + return this.warningGroupsByCount(s, rows).size(); | ||
| 757 | + } | ||
| 758 | + case "scenario8": | ||
| 759 | + case "scenario9": { | ||
| 760 | + return this.warningGroupsByRatio(s, rows).size(); | ||
| 761 | + } | ||
| 762 | + case "scenario10": { | ||
| 763 | + return rows.size(); | ||
| 764 | + } | ||
| 765 | + } | ||
| 766 | + throw new IllegalStateException("\u672a\u77e5\u573a\u666f\u7c7b\u578b: " + s.getType()); | ||
| 767 | + } | ||
| 768 | + | ||
| 279 | private long countScenario1(JdyRiskProperties.Scenario s, JSONArray data) { | 769 | private long countScenario1(JdyRiskProperties.Scenario s, JSONArray data) { |
| 280 | - long hit = 0; | ||
| 281 | - for (int i = 0; i < data.size(); i++) { | 770 | + long hit = 0L; |
| 771 | + for (int i = 0; i < data.size(); ++i) { | ||
| 282 | JSONObject row = data.getJSONObject(i); | 772 | JSONObject row = data.getJSONObject(i); |
| 283 | - double total = num(row, s.getTotalField()); | ||
| 284 | - double diff = num(row, s.getDiffField()); | 773 | + double total = JdyRiskStatisticsService.num(row, s.getTotalField()); |
| 774 | + double diff = JdyRiskStatisticsService.num(row, s.getDiffField()); | ||
| 285 | Integer flow = row.getInteger("flowState"); | 775 | Integer flow = row.getInteger("flowState"); |
| 286 | - if (total >= 5 && diff >= 1 && flow != null && flow == s.getInProgressState()) { | ||
| 287 | - hit++; | ||
| 288 | - } | 776 | + if (!(total >= 5.0) || !(diff >= 1.0) || flow == null || flow.intValue() != s.getInProgressState()) continue; |
| 777 | + ++hit; | ||
| 289 | } | 778 | } |
| 290 | return hit; | 779 | return hit; |
| 291 | } | 780 | } |
| 292 | 781 | ||
| 293 | - /** 场景2:按供应商分组,SI数量/问题数量合计>60% 且 合计>=5 的供应商个数。 */ | ||
| 294 | private long countScenario2(JdyRiskProperties.Scenario s, JSONArray data) { | 782 | private long countScenario2(JdyRiskProperties.Scenario s, JSONArray data) { |
| 295 | - Map<String, double[]> byGroup = new LinkedHashMap<>(); | ||
| 296 | - for (int i = 0; i < data.size(); i++) { | 783 | + LinkedHashMap<String, double[]> byGroup = new LinkedHashMap<String, double[]>(); |
| 784 | + for (int i = 0; i < data.size(); ++i) { | ||
| 297 | JSONObject row = data.getJSONObject(i); | 785 | JSONObject row = data.getJSONObject(i); |
| 298 | - String group = orEmpty(row.getString(s.getGroupField())); | ||
| 299 | - double qty = num(row, s.getQtyField()); | 786 | + String group = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); |
| 787 | + double qty = JdyRiskStatisticsService.num(row, s.getQtyField()); | ||
| 300 | double[] agg = byGroup.computeIfAbsent(group, k -> new double[2]); | 788 | double[] agg = byGroup.computeIfAbsent(group, k -> new double[2]); |
| 301 | - agg[0] += qty; | ||
| 302 | - if ("SI".equalsIgnoreCase(row.getString(s.getSiField()))) { | ||
| 303 | - agg[1] += qty; | ||
| 304 | - } | 789 | + agg[0] = agg[0] + qty; |
| 790 | + if (!"SI".equalsIgnoreCase(row.getString(s.getSiField()))) continue; | ||
| 791 | + agg[1] = agg[1] + qty; | ||
| 305 | } | 792 | } |
| 306 | - long hit = 0; | 793 | + long hit = 0L; |
| 307 | for (double[] agg : byGroup.values()) { | 794 | for (double[] agg : byGroup.values()) { |
| 308 | - if (agg[0] >= 5 && (agg[1] / agg[0]) > 0.6) { | ||
| 309 | - hit++; | ||
| 310 | - } | 795 | + if (!(agg[0] >= 5.0) || !(agg[1] / agg[0] > 0.6)) continue; |
| 796 | + ++hit; | ||
| 311 | } | 797 | } |
| 312 | return hit; | 798 | return hit; |
| 313 | } | 799 | } |
| 314 | 800 | ||
| 315 | - /** 场景3:SI占比>60% 且 总问题数>=5 的行数(工程师个数)。 */ | ||
| 316 | private long countScenario3(JdyRiskProperties.Scenario s, JSONArray data) { | 801 | private long countScenario3(JdyRiskProperties.Scenario s, JSONArray data) { |
| 317 | - long hit = 0; | ||
| 318 | - for (int i = 0; i < data.size(); i++) { | 802 | + long hit = 0L; |
| 803 | + for (int i = 0; i < data.size(); ++i) { | ||
| 319 | JSONObject row = data.getJSONObject(i); | 804 | JSONObject row = data.getJSONObject(i); |
| 320 | - double total = num(row, s.getTotalField()); | ||
| 321 | - double ratio = num(row, s.getRatioField()); | ||
| 322 | - if (total >= 5 && ratio > 0.6) { | ||
| 323 | - hit++; | ||
| 324 | - } | 805 | + double total = JdyRiskStatisticsService.num(row, s.getTotalField()); |
| 806 | + double ratio = JdyRiskStatisticsService.num(row, s.getRatioField()); | ||
| 807 | + if (!(total >= 5.0) || !(ratio > 0.6)) continue; | ||
| 808 | + ++hit; | ||
| 325 | } | 809 | } |
| 326 | return hit; | 810 | return hit; |
| 327 | } | 811 | } |
| 328 | 812 | ||
| 329 | - /** 场景4/5:升级不含排除值且非空,按分组计数,分组次数 >= minCount 的命中分组个数。 */ | ||
| 330 | private long countGroupByUp(JdyRiskProperties.Scenario s, JSONArray data) { | 813 | private long countGroupByUp(JdyRiskProperties.Scenario s, JSONArray data) { |
| 331 | - return warningGroupsByUp(s, data).size(); | 814 | + return this.warningGroupsByUp(s, data).size(); |
| 332 | } | 815 | } |
| 333 | 816 | ||
| 334 | - /** 场景4/5:命中分组集合(升级不含排除值且非空,分组计数 >= minCount)。 */ | ||
| 335 | private Set<String> warningGroupsByUp(JdyRiskProperties.Scenario s, JSONArray data) { | 817 | private Set<String> warningGroupsByUp(JdyRiskProperties.Scenario s, JSONArray data) { |
| 336 | - Map<String, Integer> counts = new LinkedHashMap<>(); | ||
| 337 | - for (int i = 0; i < data.size(); i++) { | 818 | + LinkedHashMap<String, Integer> counts = new LinkedHashMap<String, Integer>(); |
| 819 | + for (int i = 0; i < data.size(); ++i) { | ||
| 338 | JSONObject row = data.getJSONObject(i); | 820 | JSONObject row = data.getJSONObject(i); |
| 339 | - if (isUpHit(s, row)) { | ||
| 340 | - String g = orEmpty(row.getString(s.getGroupField())); | ||
| 341 | - counts.merge(g, 1, Integer::sum); | ||
| 342 | - } | 821 | + if (!this.isUpHit(s, row)) continue; |
| 822 | + String g = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); | ||
| 823 | + counts.merge(g, 1, Integer::sum); | ||
| 343 | } | 824 | } |
| 344 | int threshold = Math.max(1, s.getMinCount()); | 825 | int threshold = Math.max(1, s.getMinCount()); |
| 345 | - Set<String> warn = new LinkedHashSet<>(); | ||
| 346 | - for (Map.Entry<String, Integer> e : counts.entrySet()) { | ||
| 347 | - if (e.getValue() >= threshold) { | ||
| 348 | - warn.add(e.getKey()); | ||
| 349 | - } | 826 | + LinkedHashSet<String> warn = new LinkedHashSet<String>(); |
| 827 | + for (Map.Entry e : counts.entrySet()) { | ||
| 828 | + if ((Integer)e.getValue() < threshold) continue; | ||
| 829 | + warn.add((String)e.getKey()); | ||
| 350 | } | 830 | } |
| 351 | return warn; | 831 | return warn; |
| 352 | } | 832 | } |
| 353 | 833 | ||
| 354 | - /** 场景6:按分组字段计数,分组次数 >= minCount 的命中分组集合。 */ | ||
| 355 | private Set<String> warningGroupsByCount(JdyRiskProperties.Scenario s, JSONArray data) { | 834 | private Set<String> warningGroupsByCount(JdyRiskProperties.Scenario s, JSONArray data) { |
| 356 | - Map<String, Integer> counts = new LinkedHashMap<>(); | ||
| 357 | - for (int i = 0; i < data.size(); i++) { | 835 | + LinkedHashMap<String, Integer> counts = new LinkedHashMap<String, Integer>(); |
| 836 | + for (int i = 0; i < data.size(); ++i) { | ||
| 358 | JSONObject row = data.getJSONObject(i); | 837 | JSONObject row = data.getJSONObject(i); |
| 359 | - String g = orEmpty(row.getString(s.getGroupField())); | 838 | + String g = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); |
| 360 | counts.merge(g, 1, Integer::sum); | 839 | counts.merge(g, 1, Integer::sum); |
| 361 | } | 840 | } |
| 362 | int threshold = Math.max(1, s.getMinCount()); | 841 | int threshold = Math.max(1, s.getMinCount()); |
| 363 | - Set<String> warn = new LinkedHashSet<>(); | ||
| 364 | - for (Map.Entry<String, Integer> e : counts.entrySet()) { | ||
| 365 | - if (e.getValue() >= threshold) { | ||
| 366 | - warn.add(e.getKey()); | ||
| 367 | - } | 842 | + LinkedHashSet<String> warn = new LinkedHashSet<String>(); |
| 843 | + for (Map.Entry e : counts.entrySet()) { | ||
| 844 | + if ((Integer)e.getValue() < threshold) continue; | ||
| 845 | + warn.add((String)e.getKey()); | ||
| 368 | } | 846 | } |
| 369 | return warn; | 847 | return warn; |
| 370 | } | 848 | } |
| 371 | 849 | ||
| 372 | - /** 场景8/9:按分组字段,flagField==flagValue 的条数 / 总条数 > ratioThreshold 的命中分组集合。 */ | ||
| 373 | private Set<String> warningGroupsByRatio(JdyRiskProperties.Scenario s, JSONArray data) { | 850 | private Set<String> warningGroupsByRatio(JdyRiskProperties.Scenario s, JSONArray data) { |
| 374 | - Map<String, int[]> byGroup = new LinkedHashMap<>(); // [总数, 命中数] | ||
| 375 | - for (int i = 0; i < data.size(); i++) { | 851 | + LinkedHashMap<String, int[]> byGroup = new LinkedHashMap<String, int[]>(); |
| 852 | + for (int i = 0; i < data.size(); ++i) { | ||
| 376 | JSONObject row = data.getJSONObject(i); | 853 | JSONObject row = data.getJSONObject(i); |
| 377 | - String g = orEmpty(row.getString(s.getGroupField())); | 854 | + String g = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); |
| 378 | int[] agg = byGroup.computeIfAbsent(g, k -> new int[2]); | 855 | int[] agg = byGroup.computeIfAbsent(g, k -> new int[2]); |
| 379 | - agg[0]++; | ||
| 380 | - if (s.getFlagValue() != null && s.getFlagValue().equalsIgnoreCase(row.getString(s.getFlagField()))) { | ||
| 381 | - agg[1]++; | ||
| 382 | - } | 856 | + agg[0] = agg[0] + 1; |
| 857 | + if (s.getFlagValue() == null || !s.getFlagValue().equalsIgnoreCase(row.getString(s.getFlagField()))) continue; | ||
| 858 | + agg[1] = agg[1] + 1; | ||
| 383 | } | 859 | } |
| 384 | - Set<String> warn = new LinkedHashSet<>(); | 860 | + LinkedHashSet<String> warn = new LinkedHashSet<String>(); |
| 385 | double th = s.getRatioThreshold(); | 861 | double th = s.getRatioThreshold(); |
| 386 | - for (Map.Entry<String, int[]> e : byGroup.entrySet()) { | ||
| 387 | - int[] agg = e.getValue(); | ||
| 388 | - if (agg[0] > 0 && ((double) agg[1] / agg[0]) > th) { | ||
| 389 | - warn.add(e.getKey()); | ||
| 390 | - } | 862 | + for (Map.Entry e : byGroup.entrySet()) { |
| 863 | + int[] agg = (int[])e.getValue(); | ||
| 864 | + if (agg[0] <= 0 || !((double)agg[1] / (double)agg[0] > th)) continue; | ||
| 865 | + warn.add((String)e.getKey()); | ||
| 391 | } | 866 | } |
| 392 | return warn; | 867 | return warn; |
| 393 | } | 868 | } |
| 394 | 869 | ||
| 395 | - /** | ||
| 396 | - * 场景7:多表关联 + 超期过滤(分批流式,防大表 OOM)。 | ||
| 397 | - * <p>① 收集排除表单的条码集合;② 流式遍历主表:条码命中排除集合则丢弃;③ 剩余按入库时间超过 maxAgeDays 天保留。 | ||
| 398 | - */ | ||
| 399 | private JSONArray buildScenario7Rows(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | 870 | private JSONArray buildScenario7Rows(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { |
| 400 | - Set<String> exclude = new LinkedHashSet<>(); | 871 | + Instant lowerCutoff; |
| 872 | + Instant cutoff; | ||
| 873 | + LinkedHashSet exclude = new LinkedHashSet(); | ||
| 401 | for (JdyRiskProperties.ExcludeForm ef : s.getExcludeForms()) { | 874 | for (JdyRiskProperties.ExcludeForm ef : s.getExcludeForms()) { |
| 402 | - if (ef == null || ef.getEntryId() == null || ef.getBarcodeField() == null) { | ||
| 403 | - continue; | ||
| 404 | - } | ||
| 405 | - final JdyRiskProperties.ExcludeForm cur = ef; | ||
| 406 | - jdy.forEachPage(props.getApiKey(), s.getAppId(), cur.getEntryId(), | ||
| 407 | - java.util.Collections.singletonList(cur.getBarcodeField()), page -> { | ||
| 408 | - for (int i = 0; i < page.size(); i++) { | 875 | + if (ef == null || ef.getEntryId() == null || ef.getBarcodeField() == null) continue; |
| 876 | + JdyRiskProperties.ExcludeForm cur = ef; | ||
| 877 | + this.forEachPageCached(jdy, s.getAppId(), cur.getEntryId(), Collections.singletonList(cur.getBarcodeField()), page -> { | ||
| 878 | + for (int i = 0; i < page.size(); ++i) { | ||
| 409 | String b = page.getJSONObject(i).getString(cur.getBarcodeField()); | 879 | String b = page.getJSONObject(i).getString(cur.getBarcodeField()); |
| 410 | - if (b != null && !b.trim().isEmpty()) { | ||
| 411 | - exclude.add(b.trim()); | ||
| 412 | - } | 880 | + if (b == null || b.trim().isEmpty()) continue; |
| 881 | + exclude.add(b.trim()); | ||
| 413 | } | 882 | } |
| 414 | }); | 883 | }); |
| 415 | - log.info("场景7 排除来源 entry={} 累计条码={}", ef.getEntryId(), exclude.size()); | 884 | + log.info("\u573a\u666f7 \u6392\u9664\u6765\u6e90 entry={} \u7d2f\u8ba1\u6761\u7801={}", (Object)ef.getEntryId(), (Object)exclude.size()); |
| 885 | + } | ||
| 886 | + if (s.isMonthlyOverdueIncremental()) { | ||
| 887 | + ZonedDateTime prevMonthEnd = this.now().withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS).minusDays(1L); | ||
| 888 | + ZonedDateTime prevRef = prevMonthEnd.minusMonths(1L); | ||
| 889 | + cutoff = prevMonthEnd.minusDays(Math.max(0, s.getMaxAgeDays())).toInstant(); | ||
| 890 | + lowerCutoff = prevRef.minusDays(Math.max(0, s.getMaxAgeDays())).toInstant(); | ||
| 891 | + log.info("\u573a\u666f7 \u6309\u6708\u589e\u91cf\uff1a\u53c2\u8003\u4e0a\u6708\u672b={} cutoff={} \u4e0a\u6b21\u7a97\u53e3\u8d77\u70b9={}", new Object[]{prevMonthEnd.format(DAY_FMT), cutoff, lowerCutoff}); | ||
| 892 | + } else { | ||
| 893 | + cutoff = this.now().minusDays(Math.max(0, s.getMaxAgeDays())).toInstant(); | ||
| 894 | + lowerCutoff = null; | ||
| 416 | } | 895 | } |
| 417 | - | ||
| 418 | - java.time.Instant cutoff = ZonedDateTime.now(ZONE) | ||
| 419 | - .minusDays(Math.max(0, s.getMaxAgeDays())).toInstant(); | ||
| 420 | JSONArray kept = new JSONArray(); | 896 | JSONArray kept = new JSONArray(); |
| 421 | - final int[] scanned = {0}; | ||
| 422 | - jdy.forEachPage(props.getApiKey(), s.getAppId(), s.getEntryId(), s.getFields(), page -> { | ||
| 423 | - for (int i = 0; i < page.size(); i++) { | ||
| 424 | - scanned[0]++; | 897 | + int[] scanned = new int[]{0}; |
| 898 | + this.forEachPageCached(jdy, s.getAppId(), s.getEntryId(), s.getFields(), page -> { | ||
| 899 | + for (int i = 0; i < page.size(); ++i) { | ||
| 900 | + Instant in; | ||
| 901 | + ZonedDateTime inTime; | ||
| 902 | + scanned[0] = scanned[0] + 1; | ||
| 425 | JSONObject row = page.getJSONObject(i); | 903 | JSONObject row = page.getJSONObject(i); |
| 426 | String barcode = row.getString(s.getBarcodeField()); | 904 | String barcode = row.getString(s.getBarcodeField()); |
| 427 | - if (barcode != null && exclude.contains(barcode.trim())) { | ||
| 428 | - continue; // 条码在出库/抵扣表中出现 → 过滤掉 | ||
| 429 | - } | ||
| 430 | - ZonedDateTime inTime = parseTime(row.getString(s.getDateField())); | ||
| 431 | - if (inTime == null) { | ||
| 432 | - continue; | ||
| 433 | - } | ||
| 434 | - if (inTime.toInstant().isBefore(cutoff)) { | ||
| 435 | - kept.add(row); // 入库时间超过 maxAgeDays 天 | ||
| 436 | - } | 905 | + if (barcode != null && exclude.contains(barcode.trim()) || (inTime = JdyRiskStatisticsService.parseTime(row.getString(s.getDateField()))) == null || !(in = inTime.toInstant()).isBefore(cutoff) || lowerCutoff != null && in.isBefore(lowerCutoff)) continue; |
| 906 | + kept.add((Object)row); | ||
| 437 | } | 907 | } |
| 438 | }); | 908 | }); |
| 439 | - log.info("场景7 主表扫描={}条, 过滤后保留={}条 (排除条码={}, 超期阈值={}天)", | ||
| 440 | - scanned[0], kept.size(), exclude.size(), s.getMaxAgeDays()); | 909 | + log.info("\u573a\u666f7 \u4e3b\u8868\u626b\u63cf={}\u6761, \u8fc7\u6ee4\u540e\u4fdd\u7559={}\u6761 (\u6392\u9664\u6761\u7801={}, \u8d85\u671f\u9608\u503c={}\u5929)", new Object[]{scanned[0], kept.size(), exclude.size(), s.getMaxAgeDays()}); |
| 441 | return kept; | 910 | return kept; |
| 442 | } | 911 | } |
| 443 | 912 | ||
| 444 | - /** 场景2:命中供应商集合(SI数量/问题数量合计>60% 且 合计>=5)。 */ | ||
| 445 | - private Set<String> warningSuppliers2(JdyRiskProperties.Scenario s, JSONArray data) { | ||
| 446 | - Map<String, double[]> byGroup = new LinkedHashMap<>(); | ||
| 447 | - for (int i = 0; i < data.size(); i++) { | ||
| 448 | - JSONObject row = data.getJSONObject(i); | ||
| 449 | - String group = orEmpty(row.getString(s.getGroupField())); | ||
| 450 | - double qty = num(row, s.getQtyField()); | ||
| 451 | - double[] agg = byGroup.computeIfAbsent(group, k -> new double[2]); | ||
| 452 | - agg[0] += qty; | ||
| 453 | - if ("SI".equalsIgnoreCase(row.getString(s.getSiField()))) { | ||
| 454 | - agg[1] += qty; | 913 | + private JSONArray filterByAbsThreshold(JdyRiskProperties.Scenario s, JSONArray rows) { |
| 914 | + JSONArray out = new JSONArray(); | ||
| 915 | + for (int i = 0; i < rows.size(); ++i) { | ||
| 916 | + JSONObject row = rows.getJSONObject(i); | ||
| 917 | + if (!(Math.abs(JdyRiskStatisticsService.num(row, s.getDiffField())) > s.getAbsThreshold())) continue; | ||
| 918 | + out.add((Object)row); | ||
| 919 | + } | ||
| 920 | + return out; | ||
| 921 | + } | ||
| 922 | + | ||
| 923 | + private JSONArray buildScopeRows(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 924 | + String type; | ||
| 925 | + JSONArray all = this.listAllDataCached(jdy, s.getAppId(), s.getEntryId()); | ||
| 926 | + JSONArray scoped = this.filterScope(all, s); | ||
| 927 | + String string = type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 928 | + if ("scenario10".equals(type)) { | ||
| 929 | + return this.filterByAbsThreshold(s, scoped); | ||
| 930 | + } | ||
| 931 | + return scoped; | ||
| 932 | + } | ||
| 933 | + | ||
| 934 | + private Built11 buildScenario11(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 935 | + JSONArray aWidgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 936 | + JSONArray aRows = this.listAllDataCached(jdy, s.getAppId(), s.getEntryId()); | ||
| 937 | + JSONArray bWidgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getCompareEntryId()); | ||
| 938 | + JSONArray bRows = this.listAllDataCached(jdy, s.getAppId(), s.getCompareEntryId()); | ||
| 939 | + Set<String> cSet = new LinkedHashSet<String>(); | ||
| 940 | + for (JdyRiskProperties.ExcludeForm ef : s.getExcludeForms()) { | ||
| 941 | + if (ef == null || ef.getEntryId() == null || ef.getBarcodeField() == null) continue; | ||
| 942 | + final JdyRiskProperties.ExcludeForm cur = ef; | ||
| 943 | + jdy.forEachPage(this.props.getApiKey(), s.getAppId(), ((JdyRiskProperties.ExcludeForm)((Object)cur)).getEntryId(), Collections.singletonList(((JdyRiskProperties.ExcludeForm)((Object)cur)).getBarcodeField()), page -> { | ||
| 944 | + for (int i = 0; i < page.size(); ++i) { | ||
| 945 | + String b = page.getJSONObject(i).getString(cur.getBarcodeField()); | ||
| 946 | + if (b == null || b.trim().isEmpty()) continue; | ||
| 947 | + cSet.add(b.trim()); | ||
| 948 | + } | ||
| 949 | + }); | ||
| 950 | + } | ||
| 951 | + Map<String, List<JSONObject>> aMap = JdyRiskStatisticsService.groupByBarcode(aRows, s.getBarcodeField()); | ||
| 952 | + Map<String, List<JSONObject>> bMap = JdyRiskStatisticsService.groupByBarcode(bRows, s.getCompareBarcodeField()); | ||
| 953 | + for (String k : cSet) { | ||
| 954 | + aMap.remove(k); | ||
| 955 | + bMap.remove(k); | ||
| 956 | + } | ||
| 957 | + for (String k : new ArrayList<String>(aMap.keySet())) { | ||
| 958 | + List<JSONObject> bl = bMap.get(k); | ||
| 959 | + if (bl == null) continue; | ||
| 960 | + List<JSONObject> al = aMap.get(k); | ||
| 961 | + int common = Math.min(al.size(), bl.size()); | ||
| 962 | + for (int i2 = 0; i2 < common; ++i2) { | ||
| 963 | + al.remove(al.size() - 1); | ||
| 964 | + bl.remove(bl.size() - 1); | ||
| 455 | } | 965 | } |
| 966 | + if (al.isEmpty()) { | ||
| 967 | + aMap.remove(k); | ||
| 968 | + } | ||
| 969 | + if (!bl.isEmpty()) continue; | ||
| 970 | + bMap.remove(k); | ||
| 456 | } | 971 | } |
| 457 | - Set<String> warn = new LinkedHashSet<>(); | ||
| 458 | - for (Map.Entry<String, double[]> e : byGroup.entrySet()) { | ||
| 459 | - double[] agg = e.getValue(); | ||
| 460 | - if (agg[0] >= 5 && (agg[1] / agg[0]) > 0.6) { | ||
| 461 | - warn.add(e.getKey()); | 972 | + JSONArray excelRows = new JSONArray(); |
| 973 | + long pos = 0L; | ||
| 974 | + long neg = 0L; | ||
| 975 | + for (Map.Entry<String, List<JSONObject>> e : aMap.entrySet()) { | ||
| 976 | + for (JSONObject row : e.getValue()) { | ||
| 977 | + row.put("__type", (Object)"\u6b63"); | ||
| 978 | + excelRows.add((Object)row); | ||
| 979 | + ++pos; | ||
| 462 | } | 980 | } |
| 463 | } | 981 | } |
| 464 | - return warn; | 982 | + for (Map.Entry<String, List<JSONObject>> e : bMap.entrySet()) { |
| 983 | + for (JSONObject row : e.getValue()) { | ||
| 984 | + row.put("__type", (Object)"\u8d1f"); | ||
| 985 | + excelRows.add((Object)row); | ||
| 986 | + ++neg; | ||
| 987 | + } | ||
| 988 | + } | ||
| 989 | + JSONArray widgets = new JSONArray(); | ||
| 990 | + widgets.add((Object)JdyRiskStatisticsService.syntheticWidget("__type", "\u7c7b\u578b(\u6b63/\u8d1f)")); | ||
| 991 | + for (int i = 0; i < aWidgets.size(); ++i) { | ||
| 992 | + widgets.add((Object)aWidgets.getJSONObject(i)); | ||
| 993 | + } | ||
| 994 | + for (int i = 0; i < bWidgets.size(); ++i) { | ||
| 995 | + widgets.add((Object)bWidgets.getJSONObject(i)); | ||
| 996 | + } | ||
| 997 | + Built11 built = new Built11(); | ||
| 998 | + built.count = pos + neg; | ||
| 999 | + built.excelRows = excelRows; | ||
| 1000 | + built.excelWidgets = widgets; | ||
| 1001 | + log.info("\u573a\u666f11 A={}\u6761 B={}\u6761 C\u6761\u7801={} -> \u6b63={} \u8d1f={} \u9884\u8b66\u6570\u91cf={}", new Object[]{aRows.size(), bRows.size(), cSet.size(), pos, neg, built.count}); | ||
| 1002 | + return built; | ||
| 1003 | + } | ||
| 1004 | + | ||
| 1005 | + private static boolean isDbType(String type) { | ||
| 1006 | + return "scenario33".equals(type) || "scenario34".equals(type) || "scenario35".equals(type); | ||
| 1007 | + } | ||
| 1008 | + | ||
| 1009 | + private static boolean isReasonType(String type) { | ||
| 1010 | + return "scenario12".equals(type) || "scenario13".equals(type) || "scenario14".equals(type) || "scenario15".equals(type) || "scenario16".equals(type) || "scenario17".equals(type) || "scenario18".equals(type) || "scenario19".equals(type) || "scenario20".equals(type) || "scenario21".equals(type) || "scenario23".equals(type) || "scenario24".equals(type) || "scenario25".equals(type) || "scenario26".equals(type) || "scenario27".equals(type) || "scenario29".equals(type); | ||
| 465 | } | 1011 | } |
| 466 | 1012 | ||
| 467 | /** | 1013 | /** |
| 468 | - * Excel 最右附加列的值(各场景统一): | ||
| 469 | - * 命中/预警的行显示对应名称,其余为空。 | ||
| 470 | - * 取值优先级:extra-field > group-field > 「命中」。 | 1014 | + * 设备域场景20/21/22:直接查询人大金仓表,取「未处理/未处置」数据。 |
| 1015 | + * <p>Excel 首列固定为「原因」(表头红色),内容为「处理状态为未处理/未处置」。</p> | ||
| 471 | */ | 1016 | */ |
| 472 | - private List<String> buildExtraValues(JdyRiskProperties.Scenario s, JSONArray data) { | 1017 | + private BuiltDb buildDbRows(JdyRiskProperties.Scenario s) { |
| 473 | String type = s.getType() == null ? "" : s.getType().toLowerCase(); | 1018 | String type = s.getType() == null ? "" : s.getType().toLowerCase(); |
| 474 | - Set<String> warnGroups = null; | ||
| 475 | - if ("scenario2".equals(type)) { | ||
| 476 | - warnGroups = warningSuppliers2(s, data); | ||
| 477 | - } else if ("scenario4".equals(type) || "scenario5".equals(type)) { | ||
| 478 | - warnGroups = warningGroupsByUp(s, data); | ||
| 479 | - } else if ("scenario6".equals(type)) { | ||
| 480 | - warnGroups = warningGroupsByCount(s, data); | ||
| 481 | - } else if ("scenario8".equals(type) || "scenario9".equals(type)) { | ||
| 482 | - warnGroups = warningGroupsByRatio(s, data); | 1019 | + JdyRiskProperties.Kingbase kb = this.props.getKingbase(); |
| 1020 | + KingbaseRiskDao dao = new KingbaseRiskDao(kb.getUrl(), kb.getUsername(), kb.getPassword(), kb.getDriverClass()); | ||
| 1021 | + String table = requireIdent(s.getTable(), "table"); | ||
| 1022 | + String handleField = requireIdent(s.getHandleField(), "handle-field"); | ||
| 1023 | + | ||
| 1024 | + List<String> columns = new ArrayList<String>(); | ||
| 1025 | + if (s.getColumns() != null) { | ||
| 1026 | + for (String c : s.getColumns()) { | ||
| 1027 | + if (c != null && !c.trim().isEmpty()) { | ||
| 1028 | + columns.add(requireIdent(c, "columns")); | ||
| 1029 | + } | ||
| 1030 | + } | ||
| 483 | } | 1031 | } |
| 484 | - List<String> values = new ArrayList<>(); | ||
| 485 | - for (int i = 0; i < data.size(); i++) { | ||
| 486 | - JSONObject row = data.getJSONObject(i); | 1032 | + String select = columns.isEmpty() ? "*" : String.join(", ", columns); |
| 1033 | + StringBuilder sql = new StringBuilder("SELECT ").append(select).append(" FROM ").append(table).append(" WHERE "); | ||
| 1034 | + List<Object> params = new ArrayList<Object>(); | ||
| 1035 | + | ||
| 1036 | + List<String> handleValues = s.getHandleValues(); | ||
| 1037 | + if (handleValues == null || handleValues.isEmpty()) { | ||
| 1038 | + handleValues = Arrays.asList("\u672a\u5904\u7406", "\u672a\u5904\u7f6e"); | ||
| 1039 | + } | ||
| 1040 | + sql.append(handleField).append(" IN ("); | ||
| 1041 | + for (int i = 0; i < handleValues.size(); i++) { | ||
| 1042 | + if (i > 0) { | ||
| 1043 | + sql.append(","); | ||
| 1044 | + } | ||
| 1045 | + sql.append("?"); | ||
| 1046 | + params.add(handleValues.get(i)); | ||
| 1047 | + } | ||
| 1048 | + sql.append(")"); | ||
| 1049 | + | ||
| 1050 | + String periodDesc; | ||
| 1051 | + if ("scenario33".equals(type)) { | ||
| 1052 | + YearMonth dataMonth = YearMonth.from(this.now()).minusMonths(1L); | ||
| 1053 | + String yf = requireIdent(s.getStatYearField(), "stat-year-field"); | ||
| 1054 | + String mf = requireIdent(s.getStatMonthField(), "stat-month-field"); | ||
| 1055 | + sql.append(" AND ").append(yf).append(" = ? AND ").append(mf).append(" = ?"); | ||
| 1056 | + params.add(String.valueOf(dataMonth.getYear())); | ||
| 1057 | + params.add(String.format(Locale.ROOT, "%02d", dataMonth.getMonthValue())); | ||
| 1058 | + sql.append(" ORDER BY ").append(yf).append(" DESC, ").append(mf).append(" DESC"); | ||
| 1059 | + periodDesc = dataMonth.toString(); | ||
| 1060 | + } else { | ||
| 1061 | + String timeField = requireIdent(s.getDateField(), "date-field"); | ||
| 1062 | + ZonedDateTime n = this.now(); | ||
| 1063 | + ZonedDateTime start; | ||
| 1064 | + ZonedDateTime end; | ||
| 1065 | + if ("scenario34".equals(type)) { | ||
| 1066 | + ZonedDateTime monthStart = n.withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | ||
| 1067 | + int day = n.getDayOfMonth(); | ||
| 1068 | + if (day == 11 || day <= 10) { | ||
| 1069 | + start = monthStart; | ||
| 1070 | + end = monthStart.plusDays(10L); | ||
| 1071 | + periodDesc = "1-10"; | ||
| 1072 | + } else if (day == 21 || day <= 20) { | ||
| 1073 | + start = monthStart.plusDays(10L); | ||
| 1074 | + end = monthStart.plusDays(20L); | ||
| 1075 | + periodDesc = "11-20"; | ||
| 1076 | + } else { | ||
| 1077 | + start = monthStart.plusDays(20L); | ||
| 1078 | + end = monthStart.plusMonths(1L); | ||
| 1079 | + periodDesc = "21-end"; | ||
| 1080 | + } | ||
| 1081 | + } else { | ||
| 1082 | + ZonedDateTime currentMonthStart = n.withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | ||
| 1083 | + start = currentMonthStart.minusMonths(1L); | ||
| 1084 | + end = currentMonthStart; | ||
| 1085 | + periodDesc = YearMonth.from(start).toString(); | ||
| 1086 | + } | ||
| 1087 | + LocalDate capDate = this.backfillEndDate.get(); | ||
| 1088 | + if (capDate != null) { | ||
| 1089 | + ZonedDateTime capEnd = ZonedDateTime.of(capDate.plusDays(1L), LocalTime.MIDNIGHT, ZONE); | ||
| 1090 | + if (end.isAfter(capEnd)) { | ||
| 1091 | + end = capEnd; | ||
| 1092 | + } | ||
| 1093 | + } | ||
| 1094 | + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||
| 1095 | + sql.append(" AND ").append(timeField).append(" >= ? AND ").append(timeField).append(" < ?"); | ||
| 1096 | + params.add(start.format(fmt)); | ||
| 1097 | + params.add(end.format(fmt)); | ||
| 1098 | + sql.append(" ORDER BY ").append(timeField).append(" DESC"); | ||
| 1099 | + periodDesc = start.format(DAY_FMT) + " ~ " + end.minusSeconds(1L).format(DAY_FMT); | ||
| 1100 | + } | ||
| 1101 | + | ||
| 1102 | + List<Map<String, Object>> data = dao.query(sql.toString(), params); | ||
| 1103 | + BuiltDb built = new BuiltDb(); | ||
| 1104 | + List<String> displayColumns = new ArrayList<String>(columns); | ||
| 1105 | + for (Map<String, Object> r : data) { | ||
| 1106 | + JSONObject row = new JSONObject(); | ||
| 1107 | + row.putAll(r); | ||
| 1108 | + built.rows.add(row); | ||
| 1109 | + if (displayColumns.isEmpty()) { | ||
| 1110 | + displayColumns.addAll(r.keySet()); | ||
| 1111 | + } | ||
| 1112 | + built.reasons.add("\u5904\u7406\u72b6\u6001\u4e3a" + statusLabel(s, r.get(handleField.toLowerCase()))); | ||
| 1113 | + } | ||
| 1114 | + JSONArray widgets = new JSONArray(); | ||
| 1115 | + for (String c : displayColumns) { | ||
| 1116 | + String label = s.getColumnLabels() == null ? null : s.getColumnLabels().get(c); | ||
| 1117 | + if (label == null || label.isEmpty()) { | ||
| 1118 | + label = c; | ||
| 1119 | + } | ||
| 1120 | + widgets.add(syntheticWidget(c, label)); | ||
| 1121 | + } | ||
| 1122 | + built.widgets = widgets; | ||
| 1123 | + built.count = built.rows.size(); | ||
| 1124 | + log.info("\u573a\u666f[{}] \u91d1\u4ed3\u67e5\u8be2 table={} \u7edf\u8ba1\u671f={} \u672a\u5904\u7406\u547d\u4e2d={}\u6761", | ||
| 1125 | + new Object[]{s.getId(), table, periodDesc, built.count}); | ||
| 1126 | + return built; | ||
| 1127 | + } | ||
| 1128 | + | ||
| 1129 | + /** 状态码转中文:如过磅表 is_handled=3 -> 未处理。 */ | ||
| 1130 | + private static String statusLabel(JdyRiskProperties.Scenario s, Object raw) { | ||
| 1131 | + if (raw == null) { | ||
| 1132 | + return ""; | ||
| 1133 | + } | ||
| 1134 | + String v = String.valueOf(raw).trim(); | ||
| 1135 | + Map<String, String> labels = s.getHandleValueLabels(); | ||
| 1136 | + if (labels != null) { | ||
| 1137 | + String lb = labels.get(v); | ||
| 1138 | + if (lb != null && !lb.isEmpty()) { | ||
| 1139 | + return lb; | ||
| 1140 | + } | ||
| 1141 | + } | ||
| 1142 | + return v; | ||
| 1143 | + } | ||
| 1144 | + | ||
| 1145 | + /** 校验 SQL 标识符(表名/列名只能来自配置,禁止拼接任意字符串)。 */ | ||
| 1146 | + private static String requireIdent(String value, String name) { | ||
| 1147 | + if (value == null || value.trim().isEmpty()) { | ||
| 1148 | + throw new IllegalStateException("\u573a\u666f\u7f3a\u5c11\u914d\u7f6e: " + name); | ||
| 1149 | + } | ||
| 1150 | + String v = value.trim(); | ||
| 1151 | + if (!v.matches("[A-Za-z_][A-Za-z0-9_]*")) { | ||
| 1152 | + throw new IllegalStateException("\u975e\u6cd5\u7684\u6570\u636e\u5e93\u6807\u8bc6\u7b26(" + name + "): " + v); | ||
| 1153 | + } | ||
| 1154 | + return v; | ||
| 1155 | + } | ||
| 1156 | + | ||
| 1157 | + /* | ||
| 1158 | + * WARNING - void declaration | ||
| 1159 | + */ | ||
| 1160 | + private BuiltReason buildReasonRows(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1161 | + JSONArray all = this.listAllDataCached(jdy, s.getAppId(), s.getEntryId()); | ||
| 1162 | + JSONArray scoped = this.filterScope(all, s); | ||
| 1163 | + String type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 1164 | + BuiltReason built = new BuiltReason(); | ||
| 1165 | + long explicitCount = -1L; | ||
| 1166 | + if ("scenario12".equals(type)) { | ||
| 1167 | + int n = 0; | ||
| 1168 | + for (JdyRiskProperties.Pair p : s.getPairs()) { | ||
| 1169 | + ++n; | ||
| 1170 | + if (p == null || p.getPersonField() == null || p.getSignField() == null) continue; | ||
| 1171 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1172 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1173 | + if (!JdyRiskStatisticsService.hasValue(row, p.getPersonField()) || JdyRiskStatisticsService.hasValue(row, p.getSignField())) continue; | ||
| 1174 | + row.put("__reason_" + n, (Object)("\u53c2\u4e0e\u4eba\u5458" + n + "\u672a\u7b7e\u5b57\u786e\u8ba4")); | ||
| 1175 | + } | ||
| 1176 | + } | ||
| 1177 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1178 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1179 | + ArrayList<String> arrayList = new ArrayList<String>(); | ||
| 1180 | + for (int k2 = 1; k2 <= n; ++k2) { | ||
| 1181 | + Object r = row.get((Object)("__reason_" + k2)); | ||
| 1182 | + if (r == null) continue; | ||
| 1183 | + arrayList.add(String.valueOf(r)); | ||
| 1184 | + row.remove((Object)("__reason_" + k2)); | ||
| 1185 | + } | ||
| 1186 | + if (arrayList.isEmpty()) continue; | ||
| 1187 | + built.rows.add((Object)row); | ||
| 1188 | + built.reasons.add(String.join((CharSequence)"\u3001", arrayList)); | ||
| 1189 | + } | ||
| 1190 | + } else if ("scenario13".equals(type)) { | ||
| 1191 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1192 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1193 | + if (JdyRiskStatisticsService.num(row, s.getDurationField()) <= s.getDurationThreshold()) continue; | ||
| 1194 | + ArrayList<String> reasons = new ArrayList<String>(); | ||
| 1195 | + if (s.getAbnormalValue() != null && s.getAbnormalValue().equals(row.getString(s.getAbnormalField()))) { | ||
| 1196 | + reasons.add("\u5b58\u5728\u5f02\u5e38\u51fa\u95e8"); | ||
| 1197 | + } | ||
| 1198 | + if (!JdyRiskStatisticsService.hasValue(row, s.getReasonField())) { | ||
| 1199 | + reasons.add("\u5f02\u5e38\u539f\u56e0\u8bf4\u660e\u4e3a\u7a7a"); | ||
| 1200 | + } | ||
| 1201 | + if (reasons.isEmpty()) continue; | ||
| 1202 | + built.rows.add((Object)row); | ||
| 1203 | + built.reasons.add(String.join((CharSequence)"\u3001", reasons)); | ||
| 1204 | + } | ||
| 1205 | + } else if ("scenario14".equals(type)) { | ||
| 1206 | + LinkedHashMap<String, Integer> counts = new LinkedHashMap<String, Integer>(); | ||
| 1207 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1208 | + String g = JdyRiskStatisticsService.orEmpty(scoped.getJSONObject(i).getString(s.getGroupField())); | ||
| 1209 | + counts.merge(g, 1, Integer::sum); | ||
| 1210 | + } | ||
| 1211 | + int threshold = Math.max(1, s.getMinCount()); | ||
| 1212 | + long hitGroups = 0L; | ||
| 1213 | + for (Map.Entry e : counts.entrySet()) { | ||
| 1214 | + if ((Integer)e.getValue() < threshold) continue; | ||
| 1215 | + ++hitGroups; | ||
| 1216 | + } | ||
| 1217 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1218 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1219 | + String string = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); | ||
| 1220 | + Integer c = (Integer)counts.get(string); | ||
| 1221 | + if (c == null || c < threshold) continue; | ||
| 1222 | + built.rows.add((Object)row); | ||
| 1223 | + built.reasons.add("\u540c\u4e00\u4f9b\u5e94\u5546[" + string + "]\u51fa\u73b0" + c + "\u6b21"); | ||
| 1224 | + } | ||
| 1225 | + explicitCount = hitGroups; | ||
| 1226 | + } else if ("scenario15".equals(type)) { | ||
| 1227 | + Map<String, String> labels = this.widgetLabels(jdy, s); | ||
| 1228 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1229 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1230 | + if (!JdyRiskStatisticsService.flowStateMatches(s, row)) continue; | ||
| 1231 | + ArrayList<String> arrayList = new ArrayList<String>(); | ||
| 1232 | + for (JdyRiskProperties.PhotoRule r : s.getPhotoRules()) { | ||
| 1233 | + if (r == null || r.getFlagField() == null || r.getPhotoField() == null || r.getFlagValue() == null || !r.getFlagValue().equals(row.getString(r.getFlagField())) || JdyRiskStatisticsService.hasValue(row, r.getPhotoField())) continue; | ||
| 1234 | + String lb = r.getLabel(); | ||
| 1235 | + if (lb == null || lb.isEmpty()) { | ||
| 1236 | + lb = labels.getOrDefault(r.getPhotoField(), r.getPhotoField()); | ||
| 1237 | + } | ||
| 1238 | + arrayList.add(lb + "\u4e3a\u7a7a"); | ||
| 1239 | + } | ||
| 1240 | + if (arrayList.isEmpty()) continue; | ||
| 1241 | + built.rows.add((Object)row); | ||
| 1242 | + built.reasons.add(String.join((CharSequence)"\u3001", arrayList)); | ||
| 1243 | + } | ||
| 1244 | + } else if ("scenario16".equals(type)) { | ||
| 1245 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1246 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1247 | + String v = row.getString(s.getFlagField()); | ||
| 1248 | + if (v == null || !s.getFlagValues().contains(v) || JdyRiskStatisticsService.hasValue(row, s.getReasonField())) continue; | ||
| 1249 | + built.rows.add((Object)row); | ||
| 1250 | + built.reasons.add(v + "\u4e14\u672a\u586b\u5199\u8d85\u9884\u7b97\u539f\u56e0"); | ||
| 1251 | + } | ||
| 1252 | + } else if ("scenario17".equals(type)) { | ||
| 1253 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1254 | + long days; | ||
| 1255 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1256 | + if (!JdyRiskStatisticsService.flowStateMatches(s, row) || !JdyRiskStatisticsService.hasValue(row, s.getPlanField()) || !JdyRiskStatisticsService.hasValue(row, s.getActualField())) continue; | ||
| 1257 | + ZonedDateTime plan = JdyRiskStatisticsService.parseTime(row.getString(s.getPlanField())); | ||
| 1258 | + ZonedDateTime zonedDateTime = JdyRiskStatisticsService.parseTime(row.getString(s.getActualField())); | ||
| 1259 | + if (plan == null || zonedDateTime == null || (days = ChronoUnit.DAYS.between(plan.toLocalDate(), zonedDateTime.toLocalDate())) <= (long)s.getOverdueDays()) continue; | ||
| 1260 | + built.rows.add((Object)row); | ||
| 1261 | + built.reasons.add("\u65bd\u5de5\u5b8c\u6210\u65e5\u671f\u8d85\u8fc7\u8ba1\u5212\u5b8c\u6210\u65f6\u95f4" + days + "\u5929"); | ||
| 1262 | + } | ||
| 1263 | + } else if ("scenario18".equals(type)) { | ||
| 1264 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1265 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1266 | + String v = row.getString(s.getFlagField()); | ||
| 1267 | + if (v == null || !s.getFlagValues().contains(v) || JdyRiskStatisticsService.hasValue(row, s.getReasonField())) continue; | ||
| 1268 | + built.rows.add((Object)row); | ||
| 1269 | + built.reasons.add("\u5f53\u6708\u65bd\u5de5\u5355\u4f4d\u672a\u63d0\u4ea4\u5ba1\u8ba1\u8d44\u6599\u4e14\u539f\u56e0\u8bf4\u660e\u4e3a\u7a7a"); | ||
| 1270 | + } | ||
| 1271 | + } else if ("scenario19".equals(type)) { | ||
| 1272 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1273 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1274 | + String v = row.getString(s.getFlagField()); | ||
| 1275 | + if (v == null || !s.getFlagValues().contains(v)) continue; | ||
| 1276 | + built.rows.add((Object)row); | ||
| 1277 | + built.reasons.add("\u4e09\u4e2a\u6708\u5185\u5df2\u63d0\u62a5\u76f8\u4f3c\u9879\u76ee"); | ||
| 1278 | + } | ||
| 1279 | + } else if ("scenario20".equals(type)) { | ||
| 1280 | + JSONArray flagged = JdyRiskStatisticsService.filterByFlag(scoped, s); | ||
| 1281 | + ArrayList<JSONObject> ordered = new ArrayList<JSONObject>(); | ||
| 1282 | + for (int i = 0; i < flagged.size(); ++i) { | ||
| 1283 | + ordered.add(flagged.getJSONObject(i)); | ||
| 1284 | + } | ||
| 1285 | + JdyRiskStatisticsService.sortByDateDesc(ordered, s.getDateField()); | ||
| 1286 | + long hits = 0L; | ||
| 1287 | + for (JSONObject current : ordered) { | ||
| 1288 | + ZonedDateTime zonedDateTime = JdyRiskStatisticsService.parseTime(current.getString(s.getDateField())); | ||
| 1289 | + JSONObject prev = this.findPreviousRefuel(all, s, current, zonedDateTime); | ||
| 1290 | + double d = JdyRiskStatisticsService.num(current, s.getEndKmField()); | ||
| 1291 | + double d2 = prev != null ? JdyRiskStatisticsService.num(prev, s.getEndKmField()) : 0.0; | ||
| 1292 | + double fuel = JdyRiskStatisticsService.num(current, s.getFuelAmountField()); | ||
| 1293 | + if (prev == null || d <= 0.0 || d2 <= 0.0 || fuel <= 0.0 || d <= d2) { | ||
| 1294 | + log.warn("\u573a\u666f[{}] \u8df3\u8fc7\u4e00\u6761\uff1a\u4e0a\u6b21\u8bb0\u5f55\u7f3a\u5931\u6216\u7ed3\u675f\u516c\u91cc\u6570/\u91cc\u7a0b\u5dee\u65e0\u6548", (Object)s.getId()); | ||
| 1295 | + continue; | ||
| 1296 | + } | ||
| 1297 | + double cons = fuel / (d - d2) * 100.0; | ||
| 1298 | + if (!(cons < s.getMinValue()) && !(cons > s.getMaxValue())) continue; | ||
| 1299 | + built.rows.add((Object)current); | ||
| 1300 | + built.reasons.add(String.format(Locale.ROOT, "\u767e\u516c\u91cc\u6cb9\u8017%.2fL\uff0c\u8d85\u51fa\u6b63\u5e38\u8303\u56f4[%.0f,%.0f]\uff08\u672c\u6b21\u7ec8%.0f/\u4e0a\u6b21\u7ec8%.0f\uff09", cons, s.getMinValue(), s.getMaxValue(), d, d2)); | ||
| 1301 | + if (s.isIncludePreviousRow()) { | ||
| 1302 | + built.rows.add((Object)prev); | ||
| 1303 | + built.reasons.add("\u4e0a\u6b21\u7528\u8f66\uff08\u5bf9\u6bd4\uff09"); | ||
| 1304 | + } | ||
| 1305 | + ++hits; | ||
| 1306 | + } | ||
| 1307 | + explicitCount = hits; | ||
| 1308 | + } else if ("scenario21".equals(type)) { | ||
| 1309 | + JSONArray flagged = JdyRiskStatisticsService.filterByFlag(scoped, s); | ||
| 1310 | + Map<String, Map<String, Double>> monthTotals = new LinkedHashMap<String, Map<String, Double>>(); | ||
| 1311 | + Map<String, JSONArray> monthRows = new LinkedHashMap<String, JSONArray>(); | ||
| 1312 | + int i0 = 0; | ||
| 1313 | + while (i0 < flagged.size()) { | ||
| 1314 | + JSONObject row = flagged.getJSONObject(i0); | ||
| 1315 | + ZonedDateTime t = JdyRiskStatisticsService.parseTime(row.getString(s.getDateField())); | ||
| 1316 | + if (t != null) { | ||
| 1317 | + String string = t.format(MONTH_FMT); | ||
| 1318 | + monthRows.computeIfAbsent(string, k -> new JSONArray()).add((Object)row); | ||
| 1319 | + Map<String, Double> totals = monthTotals.computeIfAbsent(string, k -> new LinkedHashMap<String, Double>()); | ||
| 1320 | + for (String string3 : s.getCompanyFields()) { | ||
| 1321 | + totals.merge(string3, JdyRiskStatisticsService.num(row, string3), Double::sum); | ||
| 1322 | + } | ||
| 1323 | + } | ||
| 1324 | + ++i0; | ||
| 1325 | + } | ||
| 1326 | + if (monthTotals.size() >= 3) { | ||
| 1327 | + List<String> months = new ArrayList<String>(monthTotals.keySet()); | ||
| 1328 | + months.sort(null); | ||
| 1329 | + if (months.size() > 3) { | ||
| 1330 | + months = months.subList(months.size() - 3, months.size()); | ||
| 1331 | + } | ||
| 1332 | + Set<String> common = null; | ||
| 1333 | + for (String string : months) { | ||
| 1334 | + Set<String> bottom = JdyRiskStatisticsService.bottomCompanyFields(monthTotals.get(string), s.getBottomCount()); | ||
| 1335 | + if (common == null) { | ||
| 1336 | + common = new LinkedHashSet<String>(bottom); | ||
| 1337 | + continue; | ||
| 1338 | + } | ||
| 1339 | + common.retainAll(bottom); | ||
| 1340 | + } | ||
| 1341 | + if (common == null) { | ||
| 1342 | + common = new LinkedHashSet<String>(); | ||
| 1343 | + } | ||
| 1344 | + if (!common.isEmpty()) { | ||
| 1345 | + Map<String, String> labels = this.widgetLabels(jdy, s); | ||
| 1346 | + ArrayList<String> arrayList2 = new ArrayList<String>(); | ||
| 1347 | + for (String string : common) { | ||
| 1348 | + arrayList2.add(labels.getOrDefault(string, string)); | ||
| 1349 | + } | ||
| 1350 | + String reason = "\u8fde\u7eed" + months.size() + "\u4e2a\u6708\u6392\u540d\u5012\u6570\u524d" + s.getBottomCount() + "\uff1a" + String.join((CharSequence)"\u3001", arrayList2); | ||
| 1351 | + ArrayList<JSONObject> arrayList3 = new ArrayList<JSONObject>(); | ||
| 1352 | + for (String string : months) { | ||
| 1353 | + JSONArray arr = (JSONArray)monthRows.get(string); | ||
| 1354 | + if (arr == null) continue; | ||
| 1355 | + for (int i = 0; i < arr.size(); ++i) { | ||
| 1356 | + arrayList3.add(arr.getJSONObject(i)); | ||
| 1357 | + } | ||
| 1358 | + } | ||
| 1359 | + JdyRiskStatisticsService.sortByDateDesc(arrayList3, s.getDateField()); | ||
| 1360 | + for (JSONObject jSONObject : arrayList3) { | ||
| 1361 | + built.rows.add((Object)jSONObject); | ||
| 1362 | + built.reasons.add(reason); | ||
| 1363 | + } | ||
| 1364 | + explicitCount = common.size(); | ||
| 1365 | + } | ||
| 1366 | + } else { | ||
| 1367 | + log.warn("\u573a\u666f[{}] \u8fd1\u4e09\u4e2a\u6708\u6570\u636e\u4e0d\u8db3\uff08{}\u4e2a\u6708\uff09\uff0c\u8df3\u8fc7", (Object)s.getId(), (Object)monthTotals.size()); | ||
| 1368 | + } | ||
| 1369 | + } else if ("scenario23".equals(type)) { | ||
| 1370 | + LinkedHashMap<String, double[]> agg = new LinkedHashMap<String, double[]>(); | ||
| 1371 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1372 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1373 | + String string = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); | ||
| 1374 | + double[] a = agg.computeIfAbsent(string, k -> new double[2]); | ||
| 1375 | + a[0] = a[0] + JdyRiskStatisticsService.num(row, s.getScoreField()); | ||
| 1376 | + a[1] = a[1] + 1.0; | ||
| 1377 | + } | ||
| 1378 | + LinkedHashSet hit = new LinkedHashSet(); | ||
| 1379 | + for (Map.Entry entry : agg.entrySet()) { | ||
| 1380 | + if (!(((double[])entry.getValue())[1] > 0.0) || !(((double[])entry.getValue())[0] / ((double[])entry.getValue())[1] < s.getAvgThreshold())) continue; | ||
| 1381 | + hit.add(entry.getKey()); | ||
| 1382 | + } | ||
| 1383 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1384 | + JSONObject jSONObject = scoped.getJSONObject(i); | ||
| 1385 | + String g = JdyRiskStatisticsService.orEmpty(jSONObject.getString(s.getGroupField())); | ||
| 1386 | + if (!hit.contains(g)) continue; | ||
| 1387 | + double[] a = (double[])agg.get(g); | ||
| 1388 | + built.rows.add((Object)jSONObject); | ||
| 1389 | + built.reasons.add("\u4f9b\u5e94\u5546[" + g + "]\u5e73\u5747\u5206" + String.format(Locale.ROOT, "%.2f", a[0] / a[1]) + "<" + s.getAvgThreshold()); | ||
| 1390 | + } | ||
| 1391 | + explicitCount = hit.size(); | ||
| 1392 | + } else if ("scenario24".equals(type)) { | ||
| 1393 | + Map<String, List<JSONObject>> byMonth = new LinkedHashMap<String, List<JSONObject>>(); | ||
| 1394 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1395 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1396 | + ZonedDateTime zonedDateTime = JdyRiskStatisticsService.parseTime(row.getString(s.getDateField())); | ||
| 1397 | + if (zonedDateTime == null) continue; | ||
| 1398 | + byMonth.computeIfAbsent(zonedDateTime.format(MONTH_FMT), k -> new ArrayList<JSONObject>()).add(row); | ||
| 1399 | + } | ||
| 1400 | + List<String> months = new ArrayList<String>(byMonth.keySet()); | ||
| 1401 | + months.sort(null); | ||
| 1402 | + long hitMonths = 0L; | ||
| 1403 | + for (String m : months) { | ||
| 1404 | + List<JSONObject> list = byMonth.get(m); | ||
| 1405 | + int total = list.size(); | ||
| 1406 | + int n = 0; | ||
| 1407 | + for (JSONObject jSONObject : list) { | ||
| 1408 | + ZonedDateTime plan = JdyRiskStatisticsService.parseTime(jSONObject.getString(s.getPlanField())); | ||
| 1409 | + ZonedDateTime act = JdyRiskStatisticsService.parseTime(jSONObject.getString(s.getActualField())); | ||
| 1410 | + if (plan == null || act == null || ChronoUnit.DAYS.between(plan.toLocalDate(), act.toLocalDate()) <= (long)s.getLagDays()) continue; | ||
| 1411 | + ++n; | ||
| 1412 | + } | ||
| 1413 | + if (total < s.getMinMonthCount() || total > s.getMaxMonthCount() || n < s.getMinLagCount()) continue; | ||
| 1414 | + String string = m + " \u6708\u5ea6\u9879\u76ee\u6570" + total + "\uff08\u8303\u56f4" + s.getMinMonthCount() + "-" + s.getMaxMonthCount() + "\uff09\uff0c\u6ede\u540e\u9879\u76ee" + n + "\u4e2a\u2265" + s.getMinLagCount(); | ||
| 1415 | + for (JSONObject r : list) { | ||
| 1416 | + built.rows.add((Object)r); | ||
| 1417 | + built.reasons.add(string); | ||
| 1418 | + } | ||
| 1419 | + ++hitMonths; | ||
| 1420 | + } | ||
| 1421 | + explicitCount = hitMonths; | ||
| 1422 | + } else if ("scenario25".equals(type)) { | ||
| 1423 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1424 | + double price; | ||
| 1425 | + double d; | ||
| 1426 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1427 | + double budget = JdyRiskStatisticsService.num(row, s.getBudgetField()); | ||
| 1428 | + if (budget <= 0.0 || !JdyRiskStatisticsService.hasValue(row, s.getPriceField()) || !((d = (budget - (price = JdyRiskStatisticsService.num(row, s.getPriceField()))) / budget) >= s.getDeviationThreshold())) continue; | ||
| 1429 | + built.rows.add((Object)row); | ||
| 1430 | + built.reasons.add(String.format(Locale.ROOT, "\u504f\u79bb\u7387%.2f%%\u2265%.0f%%\uff08\u9884\u7b97%.2f/\u4e2d\u9009%.2f\uff09", d * 100.0, s.getDeviationThreshold() * 100.0, budget, price)); | ||
| 1431 | + } | ||
| 1432 | + explicitCount = built.rows.size(); | ||
| 1433 | + } else if ("scenario26".equals(type)) { | ||
| 1434 | + JSONArray flagged = JdyRiskStatisticsService.filterByFlag(scoped, s); | ||
| 1435 | + int threshold = Math.max(1, s.getMinCount()); | ||
| 1436 | + if (flagged.size() >= threshold) { | ||
| 1437 | + String reason = "\u672c\u5b63\u5ea6\u7d27\u6025\u91c7\u8d2d" + flagged.size() + "\u6b21\u2265" + threshold; | ||
| 1438 | + int i0 = 0; | ||
| 1439 | + while (i0 < flagged.size()) { | ||
| 1440 | + built.rows.add((Object)flagged.getJSONObject(i0)); | ||
| 1441 | + built.reasons.add(reason); | ||
| 1442 | + ++i0; | ||
| 1443 | + } | ||
| 1444 | + } | ||
| 1445 | + explicitCount = flagged.size(); | ||
| 1446 | + } else if ("scenario27".equals(type)) { | ||
| 1447 | + int[] a; | ||
| 1448 | + LinkedHashMap<String, int[]> byDept = new LinkedHashMap<String, int[]>(); | ||
| 1449 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1450 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1451 | + String string = JdyRiskStatisticsService.toDisplayName(row.get((Object)s.getGroupField())); | ||
| 1452 | + if (string == null || string.isEmpty()) { | ||
| 1453 | + string = "(\u7a7a)"; | ||
| 1454 | + } | ||
| 1455 | + a = byDept.computeIfAbsent(string, k -> new int[2]); | ||
| 1456 | + a[0] = a[0] + 1; | ||
| 1457 | + if (s.getFlagValues().isEmpty() || !s.getFlagValues().contains(row.getString(s.getFlagField()))) continue; | ||
| 1458 | + a[1] = a[1] + 1; | ||
| 1459 | + } | ||
| 1460 | + LinkedHashSet hitDept = new LinkedHashSet(); | ||
| 1461 | + for (Map.Entry entry : byDept.entrySet()) { | ||
| 1462 | + a = (int[])entry.getValue(); | ||
| 1463 | + if (a[0] <= 0 || !((double)a[1] / (double)a[0] >= s.getRatioThreshold())) continue; | ||
| 1464 | + hitDept.add(entry.getKey()); | ||
| 1465 | + } | ||
| 1466 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1467 | + JSONObject jSONObject = scoped.getJSONObject(i); | ||
| 1468 | + String dept = JdyRiskStatisticsService.toDisplayName(jSONObject.get((Object)s.getGroupField())); | ||
| 1469 | + if (dept == null || dept.isEmpty()) { | ||
| 1470 | + dept = "(\u7a7a)"; | ||
| 1471 | + } | ||
| 1472 | + if (!hitDept.contains(dept) || s.getFlagValues().isEmpty() || !s.getFlagValues().contains(jSONObject.getString(s.getFlagField()))) continue; | ||
| 1473 | + int[] a2 = (int[])byDept.get(dept); | ||
| 1474 | + built.rows.add((Object)jSONObject); | ||
| 1475 | + built.reasons.add(String.format(Locale.ROOT, "\u90e8\u95e8[%s]\u5408\u540c\u5f02\u5e38\u53d8\u66f4\u7387=%.1f%%\u2265%.0f%%\uff08%d/%d\uff09", dept, (double)a2[1] / (double)a2[0] * 100.0, s.getRatioThreshold() * 100.0, a2[1], a2[0])); | ||
| 1476 | + } | ||
| 1477 | + explicitCount = hitDept.size(); | ||
| 1478 | + } else if ("scenario29".equals(type)) { | ||
| 1479 | + for (int i = 0; i < scoped.size(); ++i) { | ||
| 1480 | + long days; | ||
| 1481 | + JSONObject row = scoped.getJSONObject(i); | ||
| 1482 | + if (!JdyRiskStatisticsService.hasValue(row, s.getDateField()) || !JdyRiskStatisticsService.hasValue(row, s.getStartField())) continue; | ||
| 1483 | + ZonedDateTime start = JdyRiskStatisticsService.parseTime(row.getString(s.getStartField())); | ||
| 1484 | + ZonedDateTime zonedDateTime = JdyRiskStatisticsService.parseTime(row.getString(s.getDateField())); | ||
| 1485 | + if (start == null || zonedDateTime == null || (days = ChronoUnit.DAYS.between(start.toLocalDate(), zonedDateTime.toLocalDate())) <= (long)s.getThresholdDays()) continue; | ||
| 1486 | + built.rows.add((Object)row); | ||
| 1487 | + built.reasons.add("\u6d41\u7a0b\u7ed3\u675f\u65f6\u95f4-\u6d41\u7a0b\u5f00\u59cb\u65f6\u95f4=" + days + "\u5929"); | ||
| 1488 | + } | ||
| 1489 | + explicitCount = built.rows.size(); | ||
| 1490 | + } | ||
| 1491 | + built.count = explicitCount >= 0L ? explicitCount : (long)built.rows.size(); | ||
| 1492 | + log.info("\u573a\u666f[{}] \u5468\u671f\u5185={}\u6761, \u547d\u4e2d={}\u6761", new Object[]{s.getId(), scoped.size(), built.count}); | ||
| 1493 | + return built; | ||
| 1494 | + } | ||
| 1495 | + | ||
| 1496 | + private static boolean isCustomSheetType(String type) { | ||
| 1497 | + return "scenario22".equals(type) || "scenario28".equals(type) || "scenario30".equals(type) || "scenario31".equals(type) || "scenario32".equals(type); | ||
| 1498 | + } | ||
| 1499 | + | ||
| 1500 | + private MultiResult customSheets(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1501 | + String type; | ||
| 1502 | + String string = type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 1503 | + if ("scenario22".equals(type)) { | ||
| 1504 | + return this.buildS28(jdy, s); | ||
| 1505 | + } | ||
| 1506 | + if ("scenario28".equals(type)) { | ||
| 1507 | + return this.buildS29(jdy, s); | ||
| 1508 | + } | ||
| 1509 | + if ("scenario30".equals(type)) { | ||
| 1510 | + return this.buildTopSupplier(jdy, s, true); | ||
| 1511 | + } | ||
| 1512 | + if ("scenario31".equals(type)) { | ||
| 1513 | + return this.buildTopSupplier(jdy, s, false); | ||
| 1514 | + } | ||
| 1515 | + if ("scenario32".equals(type)) { | ||
| 1516 | + return this.buildS32(jdy, s); | ||
| 1517 | + } | ||
| 1518 | + throw new IllegalStateException("\u672a\u77e5\u591aSheet\u573a\u666f\u7c7b\u578b: " + type); | ||
| 1519 | + } | ||
| 1520 | + | ||
| 1521 | + private static JSONArray filterByMonth(JSONArray rows, String dateField, String month) { | ||
| 1522 | + JSONArray out = new JSONArray(); | ||
| 1523 | + for (int i = 0; i < rows.size(); ++i) { | ||
| 1524 | + JSONObject row = rows.getJSONObject(i); | ||
| 1525 | + ZonedDateTime t = JdyRiskStatisticsService.parseTime(row.getString(dateField)); | ||
| 1526 | + if (t == null || !month.equals(t.format(MONTH_FMT))) continue; | ||
| 1527 | + out.add((Object)row); | ||
| 1528 | + } | ||
| 1529 | + return out; | ||
| 1530 | + } | ||
| 1531 | + | ||
| 1532 | + private static double sumNum(JSONArray rows, String field) { | ||
| 1533 | + double s = 0.0; | ||
| 1534 | + for (int i = 0; i < rows.size(); ++i) { | ||
| 1535 | + s += JdyRiskStatisticsService.num(rows.getJSONObject(i), field); | ||
| 1536 | + } | ||
| 1537 | + return s; | ||
| 1538 | + } | ||
| 1539 | + | ||
| 1540 | + private static List<String> repeat(String v, int n) { | ||
| 1541 | + ArrayList<String> list = new ArrayList<String>(); | ||
| 1542 | + for (int i = 0; i < n; ++i) { | ||
| 1543 | + list.add(v); | ||
| 1544 | + } | ||
| 1545 | + return list; | ||
| 1546 | + } | ||
| 1547 | + | ||
| 1548 | + private static String fmtNum(double v) { | ||
| 1549 | + if (Math.abs(v - Math.rint(v)) < 1.0E-9) { | ||
| 1550 | + return String.valueOf((long)Math.rint(v)); | ||
| 1551 | + } | ||
| 1552 | + return String.format(Locale.ROOT, "%.2f", v); | ||
| 1553 | + } | ||
| 1554 | + | ||
| 1555 | + private long[] queryMes(String startDate, String endDate) { | ||
| 1556 | + long[] out = new long[2]; | ||
| 1557 | + JdyRiskProperties.Mes mes = this.props.getMes(); | ||
| 1558 | + if (mes == null || mes.getUrl() == null || mes.getUrl().isEmpty()) { | ||
| 1559 | + log.warn("\u672a\u914d\u7f6e jdy-risk.mes.*\uff0cMES \u6570\u91cf\u6309 0 \u5904\u7406"); | ||
| 1560 | + return out; | ||
| 1561 | + } | ||
| 1562 | + String sql = "SELECT CASE NVL(c.SITES_CODE,'')||NVL(c.SITES_SUB_SEQ,'') WHEN 'HA1781' THEN 'YQ' WHEN 'HA2781' THEN 'EQ' END AS K, COUNT(DISTINCT c.VIN_CODE) AS VINCNT FROM MESHFMID.CAR_PRC_SEQ_V c WHERE c.SITES_DT >= ? AND c.SITES_DT < ? AND NVL(c.SITES_CODE,'')||NVL(c.SITES_SUB_SEQ,'') IN ('HA1781','HA2781') GROUP BY CASE NVL(c.SITES_CODE,'')||NVL(c.SITES_SUB_SEQ,'') WHEN 'HA1781' THEN 'YQ' WHEN 'HA2781' THEN 'EQ' END"; | ||
| 1563 | + try { | ||
| 1564 | + Class.forName("oracle.jdbc.OracleDriver"); | ||
| 1565 | + try (Connection conn = DriverManager.getConnection(mes.getUrl(), mes.getUsername(), mes.getPassword()); | ||
| 1566 | + PreparedStatement ps = conn.prepareStatement(sql);){ | ||
| 1567 | + ps.setDate(1, Date.valueOf(startDate)); | ||
| 1568 | + ps.setDate(2, Date.valueOf(endDate)); | ||
| 1569 | + try (ResultSet rs = ps.executeQuery();){ | ||
| 1570 | + while (rs.next()) { | ||
| 1571 | + String k = rs.getString(1); | ||
| 1572 | + long v = rs.getLong(2); | ||
| 1573 | + if ("YQ".equals(k)) { | ||
| 1574 | + out[0] = v; | ||
| 1575 | + continue; | ||
| 1576 | + } | ||
| 1577 | + if (!"EQ".equals(k)) continue; | ||
| 1578 | + out[1] = v; | ||
| 1579 | + } | ||
| 1580 | + } | ||
| 1581 | + } | ||
| 1582 | + log.info("MES \u67e5\u8be2 {}~{} : \u4e00\u671f={} \u4e8c\u671f={}", new Object[]{startDate, endDate, out[0], out[1]}); | ||
| 1583 | + } | ||
| 1584 | + catch (Exception e) { | ||
| 1585 | + log.error("MES \u67e5\u8be2\u5931\u8d25: {}", (Object)e.getMessage(), (Object)e); | ||
| 1586 | + } | ||
| 1587 | + return out; | ||
| 1588 | + } | ||
| 1589 | + | ||
| 1590 | + private MultiResult buildS28(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1591 | + ZonedDateTime now = this.now(); | ||
| 1592 | + ZonedDateTime start = now.minusMonths(1L).withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | ||
| 1593 | + String month = start.format(MONTH_FMT); | ||
| 1594 | + String startDate = start.toLocalDate().toString(); | ||
| 1595 | + String endDate = now.withDayOfMonth(1).toLocalDate().toString(); | ||
| 1596 | + JSONArray settleRows = JdyRiskStatisticsService.filterByMonth(this.listAllDataCached(jdy, s.getAppId(), s.getEntryId()), s.getDateField(), month); | ||
| 1597 | + double settle = JdyRiskStatisticsService.sumNum(settleRows, s.getQtyField()); | ||
| 1598 | + JSONArray partsRows = JdyRiskStatisticsService.filterByMonth(this.listAllDataCached(jdy, s.getAppId(), s.getSecondEntryId()), s.getSecondDateField(), month); | ||
| 1599 | + double parts = JdyRiskStatisticsService.sumNum(partsRows, s.getSecondQtyField()); | ||
| 1600 | + long[] mes = this.queryMes(startDate, endDate); | ||
| 1601 | + long down = mes[0] + mes[1]; | ||
| 1602 | + double diff = settle - (double)down - parts; | ||
| 1603 | + MultiResult r = new MultiResult(); | ||
| 1604 | + long l = r.count = Math.abs(diff) > 1.0E-6 ? 1L : 0L; | ||
| 1605 | + if (r.count > 0L) { | ||
| 1606 | + String reason = "\u6708\u5ea6\u7ed3\u7b97\u6570\u91cf" + JdyRiskStatisticsService.fmtNum(settle) + "-\u4e0b\u7ebf\u8f66\u8f86\u6570\u91cf" + down + "-\u6563\u4ef6\u6570\u91cf" + JdyRiskStatisticsService.fmtNum(parts) + "=" + JdyRiskStatisticsService.fmtNum(diff) + "\u22600"; | ||
| 1607 | + JdyExcelExportService.SheetSpec sh1 = new JdyExcelExportService.SheetSpec(); | ||
| 1608 | + sh1.sheetName = "\u6708\u5ea6\u7ed3\u7b97\u6570\u91cf"; | ||
| 1609 | + sh1.topText = "\u901a\u8fc7MES\u7cfb\u7edf\u67e5\u8be2\u5230\u7684\u4e00\u671f-\u603b\u88c5\u51fa\u53e3\u70b9\u6570\u91cf\uff1a" + mes[0] + "\u548c\u4e8c\u671f-\u603b\u88c5\u6700\u7ec8\u4e8c\u51fa\u53e3\u70b9\u6570\u91cf\uff1a" + mes[1]; | ||
| 1610 | + sh1.widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 1611 | + sh1.rows = settleRows; | ||
| 1612 | + sh1.extraHeader = "\u539f\u56e0"; | ||
| 1613 | + sh1.extraValues = JdyRiskStatisticsService.repeat(reason, settleRows.size()); | ||
| 1614 | + JdyExcelExportService.SheetSpec sh2 = new JdyExcelExportService.SheetSpec(); | ||
| 1615 | + sh2.sheetName = "\u6708\u5ea6\u6563\u4ef6\u6570\u91cf"; | ||
| 1616 | + sh2.widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getSecondEntryId()); | ||
| 1617 | + sh2.rows = partsRows; | ||
| 1618 | + sh2.extraHeader = "\u539f\u56e0"; | ||
| 1619 | + sh2.extraValues = JdyRiskStatisticsService.repeat("\u6563\u4ef6\u6570\u91cf\u5408\u8ba1" + JdyRiskStatisticsService.fmtNum(parts), partsRows.size()); | ||
| 1620 | + r.sheets.add(sh1); | ||
| 1621 | + r.sheets.add(sh2); | ||
| 1622 | + } | ||
| 1623 | + log.info("\u573a\u666f28 \u6708\u4efd={} \u7ed3\u7b97={} \u4e0b\u7ebf(MES)={} \u6563\u4ef6={} \u5dee={}", new Object[]{month, JdyRiskStatisticsService.fmtNum(settle), down, JdyRiskStatisticsService.fmtNum(parts), JdyRiskStatisticsService.fmtNum(diff)}); | ||
| 1624 | + return r; | ||
| 1625 | + } | ||
| 1626 | + | ||
| 1627 | + private MultiResult buildS29(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1628 | + ZonedDateTime now = this.now(); | ||
| 1629 | + ZonedDateTime start = now.minusMonths(1L).withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | ||
| 1630 | + String month = start.format(MONTH_FMT); | ||
| 1631 | + JSONArray secondAll = this.listAllDataCached(jdy, s.getAppId(), s.getSecondEntryId()); | ||
| 1632 | + JSONArray secondRows = JdyRiskStatisticsService.filterByMonth(secondAll, s.getSecondDateField(), month); | ||
| 1633 | + double secondSum = JdyRiskStatisticsService.sumNum(secondRows, s.getSecondQtyField()); | ||
| 1634 | + ArrayList<long[]> ranges = new ArrayList<long[]>(); | ||
| 1635 | + for (int i = 0; i < secondRows.size(); ++i) { | ||
| 1636 | + JSONObject row = secondRows.getJSONObject(i); | ||
| 1637 | + ZonedDateTime ps = JdyRiskStatisticsService.parseTime(row.getString(s.getPeriodStartField())); | ||
| 1638 | + ZonedDateTime pe = JdyRiskStatisticsService.parseTime(row.getString(s.getPeriodEndField())); | ||
| 1639 | + if (ps == null || pe == null) continue; | ||
| 1640 | + ranges.add(new long[]{ps.toInstant().toEpochMilli(), pe.toInstant().toEpochMilli()}); | ||
| 1641 | + } | ||
| 1642 | + JSONArray mainAll = this.listAllDataCached(jdy, s.getAppId(), s.getEntryId()); | ||
| 1643 | + JSONArray mainRows = new JSONArray(); | ||
| 1644 | + if (!ranges.isEmpty()) { | ||
| 1645 | + block1: for (int i = 0; i < mainAll.size(); ++i) { | ||
| 1646 | + JSONObject row = mainAll.getJSONObject(i); | ||
| 1647 | + ZonedDateTime t = JdyRiskStatisticsService.parseTime(row.getString(s.getDateField())); | ||
| 1648 | + if (t == null) continue; | ||
| 1649 | + long ms = t.toInstant().toEpochMilli(); | ||
| 1650 | + for (long[] rg : ranges) { | ||
| 1651 | + if (ms < rg[0] || ms > rg[1]) continue; | ||
| 1652 | + mainRows.add((Object)row); | ||
| 1653 | + continue block1; | ||
| 1654 | + } | ||
| 1655 | + } | ||
| 1656 | + } else { | ||
| 1657 | + mainRows = JdyRiskStatisticsService.filterByMonth(mainAll, s.getDateField(), month); | ||
| 1658 | + } | ||
| 1659 | + double mainSum = JdyRiskStatisticsService.sumNum(mainRows, s.getQtyField()); | ||
| 1660 | + double diff = mainSum - secondSum; | ||
| 1661 | + MultiResult r = new MultiResult(); | ||
| 1662 | + long l = r.count = Math.abs(diff) > 1.0E-6 ? 1L : 0L; | ||
| 1663 | + if (r.count > 0L) { | ||
| 1664 | + String reason = "\u5408\u80a5\u5e93\u5b9e\u6536\u6570\u91cf\u5408\u8ba1" + JdyRiskStatisticsService.fmtNum(mainSum) + "\u2260\u59d4\u5916\u7535\u6cf3\u7ed3\u7b97\u6570\u91cf\u5408\u8ba1" + JdyRiskStatisticsService.fmtNum(secondSum); | ||
| 1665 | + JdyExcelExportService.SheetSpec sh1 = new JdyExcelExportService.SheetSpec(); | ||
| 1666 | + sh1.sheetName = "\u5408\u80a5\u5e93\u6bcf\u65e5\u6536\u8d27"; | ||
| 1667 | + sh1.widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 1668 | + sh1.rows = mainRows; | ||
| 1669 | + sh1.extraHeader = "\u539f\u56e0"; | ||
| 1670 | + sh1.extraValues = JdyRiskStatisticsService.repeat(reason, mainRows.size()); | ||
| 1671 | + JdyExcelExportService.SheetSpec sh2 = new JdyExcelExportService.SheetSpec(); | ||
| 1672 | + sh2.sheetName = "\u59d4\u5916\u7535\u6cf3\u6708\u5ea6\u7ed3\u7b97"; | ||
| 1673 | + sh2.widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getSecondEntryId()); | ||
| 1674 | + sh2.rows = secondRows; | ||
| 1675 | + sh2.extraHeader = "\u539f\u56e0"; | ||
| 1676 | + sh2.extraValues = JdyRiskStatisticsService.repeat("\u59d4\u5916\u7535\u6cf3\u7ed3\u7b97\u6570\u91cf\u5408\u8ba1" + JdyRiskStatisticsService.fmtNum(secondSum), secondRows.size()); | ||
| 1677 | + r.sheets.add(sh1); | ||
| 1678 | + r.sheets.add(sh2); | ||
| 1679 | + } | ||
| 1680 | + log.info("\u573a\u666f29 \u6708\u4efd={} \u5b9e\u6536={} \u7535\u6cf3\u7ed3\u7b97={} \u5dee={}", new Object[]{month, JdyRiskStatisticsService.fmtNum(mainSum), JdyRiskStatisticsService.fmtNum(secondSum), JdyRiskStatisticsService.fmtNum(diff)}); | ||
| 1681 | + return r; | ||
| 1682 | + } | ||
| 1683 | + | ||
| 1684 | + private MultiResult buildTopSupplier(JiandaoYunApi jdy, JdyRiskProperties.Scenario s, boolean amountMode) { | ||
| 1685 | + Map<String, Double> sumBySupplier; | ||
| 1686 | + String month = this.prevMonth(); | ||
| 1687 | + Map<String, String> relMap = this.loadRelMap(jdy, s); | ||
| 1688 | + Map<String, Double> qtyBySupplier = new LinkedHashMap<String, Double>(); | ||
| 1689 | + Map<String, Map<String, Double>> qtyBySupplierPart = new LinkedHashMap<String, Map<String, Double>>(); | ||
| 1690 | + int[] scanned = new int[]{0}; | ||
| 1691 | + int[] matched = new int[]{0}; | ||
| 1692 | + int[] unmatched = new int[]{0}; | ||
| 1693 | + this.forEachPageCached(jdy, s.getAppId(), s.getEntryId(), Collections.singletonList(s.getSubformField()), page -> { | ||
| 1694 | + for (int i = 0; i < page.size(); ++i) { | ||
| 1695 | + JSONArray subs = page.getJSONObject(i).getJSONArray(s.getSubformField()); | ||
| 1696 | + if (subs == null || subs.isEmpty()) continue; | ||
| 1697 | + for (int j = 0; j < subs.size(); ++j) { | ||
| 1698 | + JSONObject sub = subs.getJSONObject(j); | ||
| 1699 | + scanned[0] = scanned[0] + 1; | ||
| 1700 | + ZonedDateTime d = JdyRiskStatisticsService.parseTime(sub.getString(s.getSubDateField())); | ||
| 1701 | + if (d == null || !month.equals(d.format(MONTH_FMT))) continue; | ||
| 1702 | + String part = JdyRiskStatisticsService.normalizePart(sub.getString(s.getSubPartField())); | ||
| 1703 | + String supplier = (String)relMap.get(part); | ||
| 1704 | + if (supplier == null || supplier.isEmpty()) { | ||
| 1705 | + unmatched[0] = unmatched[0] + 1; | ||
| 1706 | + continue; | ||
| 1707 | + } | ||
| 1708 | + matched[0] = matched[0] + 1; | ||
| 1709 | + double qty = JdyRiskStatisticsService.num(sub, s.getSubQtyField()); | ||
| 1710 | + qtyBySupplier.merge(supplier, qty, Double::sum); | ||
| 1711 | + if (!amountMode) continue; | ||
| 1712 | + qtyBySupplierPart.computeIfAbsent(supplier, k -> new LinkedHashMap<String, Double>()).merge(part, qty, Double::sum); | ||
| 1713 | + } | ||
| 1714 | + } | ||
| 1715 | + }); | ||
| 1716 | + if (amountMode) { | ||
| 1717 | + sumBySupplier = new LinkedHashMap<String, Double>(); | ||
| 1718 | + if (!qtyBySupplierPart.isEmpty()) { | ||
| 1719 | + Map<String, Double> costMap = this.loadCostMap(jdy, s); | ||
| 1720 | + for (Map.Entry<String, Map<String, Double>> se : qtyBySupplierPart.entrySet()) { | ||
| 1721 | + double amount = 0.0; | ||
| 1722 | + for (Map.Entry<String, Double> pe : se.getValue().entrySet()) { | ||
| 1723 | + Double cost = costMap.get(pe.getKey()); | ||
| 1724 | + amount += (Double)pe.getValue() * (cost == null ? 0.0 : cost); | ||
| 1725 | + } | ||
| 1726 | + sumBySupplier.put(se.getKey(), amount); | ||
| 1727 | + } | ||
| 1728 | + } | ||
| 1729 | + } else { | ||
| 1730 | + sumBySupplier = qtyBySupplier; | ||
| 1731 | + } | ||
| 1732 | + List<Map.Entry<String, Double>> list = new ArrayList<Map.Entry<String, Double>>(sumBySupplier.entrySet()); | ||
| 1733 | + list.sort((a, b) -> Double.compare(b.getValue(), a.getValue())); | ||
| 1734 | + int topN = Math.max(1, s.getTopCount()); | ||
| 1735 | + if (list.size() > topN) { | ||
| 1736 | + list = new ArrayList<Map.Entry<String, Double>>(list.subList(0, topN)); | ||
| 1737 | + } | ||
| 1738 | + MultiResult r = new MultiResult(); | ||
| 1739 | + r.count = list.size(); | ||
| 1740 | + if (!list.isEmpty()) { | ||
| 1741 | + JSONArray rows = new JSONArray(); | ||
| 1742 | + ArrayList<String> reasons = new ArrayList<String>(); | ||
| 1743 | + for (Map.Entry<String, Double> e : list) { | ||
| 1744 | + String reason; | ||
| 1745 | + JSONObject row = new JSONObject(); | ||
| 1746 | + row.put("supplier", e.getKey()); | ||
| 1747 | + if (amountMode) { | ||
| 1748 | + double amt = (Double)e.getValue(); | ||
| 1749 | + row.put("amount", (Object)JdyRiskStatisticsService.fmtAmount(amt)); | ||
| 1750 | + reason = "\u603b\u91d1\u989d" + JdyRiskStatisticsService.fmtAmount(amt) + "\u5143"; | ||
| 1751 | + } else { | ||
| 1752 | + double qty = (Double)e.getValue(); | ||
| 1753 | + row.put("qty", (Object)JdyRiskStatisticsService.fmtNum(qty)); | ||
| 1754 | + reason = "\u9000\u8d27\u603b\u6570\u91cf" + JdyRiskStatisticsService.fmtNum(qty); | ||
| 1755 | + } | ||
| 1756 | + rows.add((Object)row); | ||
| 1757 | + reasons.add(reason); | ||
| 1758 | + } | ||
| 1759 | + JdyExcelExportService.SheetSpec sh = new JdyExcelExportService.SheetSpec(); | ||
| 1760 | + Biz biz = JdyRiskStatisticsService.bizOf(s); | ||
| 1761 | + sh.sheetName = biz != null ? biz.sceneTitle : s.getName(); | ||
| 1762 | + sh.widgets = new JSONArray(); | ||
| 1763 | + sh.widgets.add((Object)JdyRiskStatisticsService.syntheticWidget("supplier", "\u4f9b\u5e94\u5546\u540d\u79f0")); | ||
| 1764 | + if (amountMode) { | ||
| 1765 | + sh.widgets.add((Object)JdyRiskStatisticsService.syntheticWidget("amount", "\u9000\u8d27\u603b\u91d1\u989d(\u5143)")); | ||
| 1766 | + } else { | ||
| 1767 | + sh.widgets.add((Object)JdyRiskStatisticsService.syntheticWidget("qty", "\u9000\u8d27\u603b\u6570\u91cf")); | ||
| 1768 | + } | ||
| 1769 | + sh.rows = rows; | ||
| 1770 | + sh.extraHeader = "\u539f\u56e0"; | ||
| 1771 | + sh.extraValues = reasons; | ||
| 1772 | + r.sheets.add(sh); | ||
| 1773 | + } | ||
| 1774 | + log.info("\u573a\u666f[{}] \u6708\u4efd={} \u9000\u8d27\u660e\u7ec6\u884c={} \u5df2\u5339\u914d\u4f9b\u5e94\u5546={} \u672a\u5339\u914d={} TOP{}=>{}", new Object[]{s.getId(), month, scanned[0], matched[0], unmatched[0], topN, r.count}); | ||
| 1775 | + return r; | ||
| 1776 | + } | ||
| 1777 | + | ||
| 1778 | + private MultiResult buildS32(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1779 | + String month = this.prevMonth(); | ||
| 1780 | + JSONArray indicatorWidgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 1781 | + JSONArray indicatorRows = this.cachedRows(jdy, s.getAppId(), s.getEntryId(), JdyRiskStatisticsService.widgetFieldNames(indicatorWidgets)); | ||
| 1782 | + JSONObject indicator = null; | ||
| 1783 | + String wantCode = JdyRiskStatisticsService.normalizeCode(s.getWarehouseCode()); | ||
| 1784 | + for (int i = 0; i < indicatorRows.size(); ++i) { | ||
| 1785 | + JSONObject row = indicatorRows.getJSONObject(i); | ||
| 1786 | + if (!wantCode.equals(JdyRiskStatisticsService.normalizeCode(row.get((Object)s.getIndicatorCodeField())))) continue; | ||
| 1787 | + if (indicator == null) { | ||
| 1788 | + indicator = row; | ||
| 1789 | + continue; | ||
| 1790 | + } | ||
| 1791 | + log.warn("\u573a\u666f[{}] \u5e93\u623f\u7f16\u7801={} \u5728\u5e93\u5b58\u6307\u6807\u5212\u5206\u4e2d\u5b58\u5728\u591a\u6761\uff0c\u4f7f\u7528\u7b2c\u4e00\u6761", (Object)s.getId(), (Object)wantCode); | ||
| 1792 | + } | ||
| 1793 | + MultiResult r = new MultiResult(); | ||
| 1794 | + if (indicator == null) { | ||
| 1795 | + log.warn("\u573a\u666f[{}] \u5e93\u5b58\u6307\u6807\u5212\u5206\u672a\u627e\u5230\u5e93\u623f\u7f16\u7801={}", (Object)s.getId(), (Object)wantCode); | ||
| 1796 | + return r; | ||
| 1797 | + } | ||
| 1798 | + double target = JdyRiskStatisticsService.num(indicator, s.getIndicatorTargetField()); | ||
| 1799 | + Set<String> aixin = this.loadAixinSet(jdy, s); | ||
| 1800 | + Map<String, Double> costMap = this.loadCostMap(jdy, s); | ||
| 1801 | + JSONArray stockWidgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getStockEntryId()); | ||
| 1802 | + JSONArray stocks = this.loadStockByWarehouse(jdy, s).get(wantCode); | ||
| 1803 | + if (stocks == null) { | ||
| 1804 | + stocks = new JSONArray(); | ||
| 1805 | + } | ||
| 1806 | + JSONArray sheetRows = new JSONArray(); | ||
| 1807 | + double total = 0.0; | ||
| 1808 | + int matchedRows = 0; | ||
| 1809 | + int excludedAixin = 0; | ||
| 1810 | + int missingCost = 0; | ||
| 1811 | + for (int i = 0; i < stocks.size(); ++i) { | ||
| 1812 | + JSONObject row = stocks.getJSONObject(i); | ||
| 1813 | + ZonedDateTime m = JdyRiskStatisticsService.parseTime(row.getString(s.getStockMonthField())); | ||
| 1814 | + if (m == null || !month.equals(m.format(MONTH_FMT)) || !wantCode.equals(JdyRiskStatisticsService.normalizeCode(row.get((Object)s.getStockWarehouseField())))) continue; | ||
| 1815 | + String part = JdyRiskStatisticsService.normalizePart(row.getString(s.getStockPartField())); | ||
| 1816 | + if (!aixin.isEmpty() && aixin.contains(part)) { | ||
| 1817 | + ++excludedAixin; | ||
| 1818 | + continue; | ||
| 1819 | + } | ||
| 1820 | + double qty = JdyRiskStatisticsService.num(row, s.getStockQtyField()); | ||
| 1821 | + Double cost = costMap.get(part); | ||
| 1822 | + if (cost == null) { | ||
| 1823 | + ++missingCost; | ||
| 1824 | + cost = 0.0; | ||
| 1825 | + } | ||
| 1826 | + total += qty * cost; | ||
| 1827 | + ++matchedRows; | ||
| 1828 | + JSONObject copy = new JSONObject(); | ||
| 1829 | + copy.putAll((Map)row); | ||
| 1830 | + copy.put("__cost", costMap.containsKey(part) ? cost : ""); | ||
| 1831 | + sheetRows.add((Object)copy); | ||
| 1832 | + } | ||
| 1833 | + double totalWan = total / 10000.0; | ||
| 1834 | + boolean abnormal = totalWan > target; | ||
| 1835 | + r.count = abnormal ? 1L : 0L; | ||
| 1836 | + log.info("\u573a\u666f[{}] \u6708\u4efd={} \u5e93\u623f={} \u5e93\u5b58\u884c={} \u6392\u9664\u7231\u4fe1={} \u7f3a\u6210\u672c={} \u5408\u8ba1={}\u4e07\u5143 \u6307\u6807={}\u4e07\u5143 \u5f02\u5e38={}", new Object[]{s.getId(), month, wantCode, matchedRows, excludedAixin, missingCost, JdyRiskStatisticsService.fmtAmount(totalWan), JdyRiskStatisticsService.fmtNum(target), abnormal}); | ||
| 1837 | + if (abnormal) { | ||
| 1838 | + String reason = "\u5e93\u5b58\u73b0\u6709\u91cf\u8ba1\u7b97\u603b\u91d1\u989d" + JdyRiskStatisticsService.fmtAmount(totalWan) + "\u4e07\u5143>\u5185\u63a7\u6307\u6807" + JdyRiskStatisticsService.fmtNum(target) + "\u4e07\u5143"; | ||
| 1839 | + JdyExcelExportService.SheetSpec sh1 = new JdyExcelExportService.SheetSpec(); | ||
| 1840 | + sh1.sheetName = "\u5e93\u5b58\u73b0\u6709\u91cf"; | ||
| 1841 | + sh1.widgets = JdyRiskStatisticsService.insertCostWidget(stockWidgets, s.getStockQtyField()); | ||
| 1842 | + sh1.rows = sheetRows; | ||
| 1843 | + sh1.extraHeader = "\u539f\u56e0"; | ||
| 1844 | + sh1.extraValues = JdyRiskStatisticsService.repeat(reason, sheetRows.size()); | ||
| 1845 | + JdyExcelExportService.SheetSpec sh2 = new JdyExcelExportService.SheetSpec(); | ||
| 1846 | + sh2.sheetName = "\u5e93\u5b58\u6307\u6807\u5212\u5206"; | ||
| 1847 | + sh2.widgets = indicatorWidgets; | ||
| 1848 | + JSONArray indRows = new JSONArray(); | ||
| 1849 | + indRows.add((Object)indicator); | ||
| 1850 | + sh2.rows = indRows; | ||
| 1851 | + sh2.extraHeader = "\u539f\u56e0"; | ||
| 1852 | + sh2.extraValues = JdyRiskStatisticsService.repeat(reason, 1); | ||
| 1853 | + r.sheets.add(sh1); | ||
| 1854 | + r.sheets.add(sh2); | ||
| 1855 | + } | ||
| 1856 | + return r; | ||
| 1857 | + } | ||
| 1858 | + | ||
| 1859 | + private JSONArray cachedRows(JiandaoYunApi jdy, String appId, String entryId, List<String> fields) { | ||
| 1860 | + String key = "rows|" + entryId + "|" + (fields == null ? "*" : String.join((CharSequence)",", fields)); | ||
| 1861 | + return this.cached(key, () -> { | ||
| 1862 | + JSONArray arr = new JSONArray(); | ||
| 1863 | + jdy.forEachPage(this.props.getApiKey(), appId, entryId, fields, arg_0 -> ((JSONArray)arr).addAll(arg_0)); | ||
| 1864 | + log.info("\u52a0\u8f7d\u7b80\u9053\u4e91\u8868 {} \u5171 {} \u6761\uff08\u7f13\u5b58{}\u5c0f\u65f6\uff09", new Object[]{entryId, arr.size(), 6L}); | ||
| 1865 | + return arr; | ||
| 1866 | + }); | ||
| 1867 | + } | ||
| 1868 | + | ||
| 1869 | + private Map<String, JSONArray> loadStockByWarehouse(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1870 | + String month = this.prevMonth(); | ||
| 1871 | + LinkedHashSet<String> codes = new LinkedHashSet<String>(); | ||
| 1872 | + for (JdyRiskProperties.Scenario x : this.props.getScenarios()) { | ||
| 1873 | + String type = x.getType() == null ? "" : x.getType().toLowerCase(); | ||
| 1874 | + if (!"scenario32".equals(type) || !JdyRiskStatisticsService.hasText(x.getWarehouseCode())) continue; | ||
| 1875 | + codes.add(JdyRiskStatisticsService.normalizeCode(x.getWarehouseCode())); | ||
| 1876 | + } | ||
| 1877 | + String key = "stock|" + s.getAppId() + "|" + s.getStockEntryId() + "|" + month + "|" + String.join((CharSequence)",", codes); | ||
| 1878 | + return this.cached(key, () -> { | ||
| 1879 | + JSONArray widgets = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getStockEntryId()); | ||
| 1880 | + List<String> fields = JdyRiskStatisticsService.widgetFieldNames(widgets); | ||
| 1881 | + Map<String, JSONArray> map = new HashMap<String, JSONArray>(); | ||
| 1882 | + int[] scanned = new int[]{0}; | ||
| 1883 | + jdy.forEachPage(this.props.getApiKey(), s.getAppId(), s.getStockEntryId(), fields, page -> { | ||
| 1884 | + for (int i = 0; i < page.size(); ++i) { | ||
| 1885 | + String wh; | ||
| 1886 | + scanned[0] = scanned[0] + 1; | ||
| 1887 | + JSONObject row = page.getJSONObject(i); | ||
| 1888 | + ZonedDateTime t = JdyRiskStatisticsService.parseTime(row.getString(s.getStockMonthField())); | ||
| 1889 | + if (t == null || !month.equals(t.format(MONTH_FMT)) || !codes.contains(wh = JdyRiskStatisticsService.normalizeCode(row.get((Object)s.getStockWarehouseField())))) continue; | ||
| 1890 | + map.computeIfAbsent(wh, k -> new JSONArray()).add((Object)row); | ||
| 1891 | + } | ||
| 1892 | + }); | ||
| 1893 | + int kept = 0; | ||
| 1894 | + for (JSONArray arr : map.values()) { | ||
| 1895 | + kept += arr.size(); | ||
| 1896 | + } | ||
| 1897 | + log.info("\u52a0\u8f7d\u5e93\u5b58\u73b0\u6709\u91cf\u8868 \u626b\u63cf={} \u6761\uff0c\u4fdd\u7559\u4e0a\u6708({})\u76ee\u6807\u5e93\u623f={} \u6761\uff08\u7f13\u5b58{}\u5c0f\u65f6\uff09", new Object[]{scanned[0], month, kept, 6L}); | ||
| 1898 | + JdyRiskStatisticsService.logHeap("\u5e93\u5b58\u8868\u73b0\u6709\u91cf\u52a0\u8f7d\u540e"); | ||
| 1899 | + return map; | ||
| 1900 | + }); | ||
| 1901 | + } | ||
| 1902 | + | ||
| 1903 | + private Map<String, Double> loadCostMap(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1904 | + if (!(JdyRiskStatisticsService.hasText(s.getCostEntryId()) && JdyRiskStatisticsService.hasText(s.getCostCodeField()) && JdyRiskStatisticsService.hasText(s.getCostValueField()))) { | ||
| 1905 | + return Collections.emptyMap(); | ||
| 1906 | + } | ||
| 1907 | + String key = "cost|" + s.getCostEntryId() + "|" + s.getCostCodeField() + "|" + s.getCostValueField(); | ||
| 1908 | + return this.cached(key, () -> { | ||
| 1909 | + HashMap map = new HashMap(); | ||
| 1910 | + List<String> fields = Arrays.asList(s.getCostCodeField(), s.getCostValueField()); | ||
| 1911 | + jdy.forEachPage(this.props.getApiKey(), s.getAppId(), s.getCostEntryId(), fields, page -> { | ||
| 1912 | + for (int i = 0; i < page.size(); ++i) { | ||
| 1913 | + JSONObject row = page.getJSONObject(i); | ||
| 1914 | + String code = JdyRiskStatisticsService.normalizePart(row.getString(s.getCostCodeField())); | ||
| 1915 | + Object raw = row.get((Object)s.getCostValueField()); | ||
| 1916 | + if (code.isEmpty() || raw == null) continue; | ||
| 1917 | + double v = JdyRiskStatisticsService.toDouble(raw); | ||
| 1918 | + Double old = (Double)map.get(code); | ||
| 1919 | + if (old != null && !(v > 0.0) && !(old <= 0.0)) continue; | ||
| 1920 | + map.put(code, v); | ||
| 1921 | + } | ||
| 1922 | + }); | ||
| 1923 | + log.info("\u52a0\u8f7d\u5df2\u51bb\u7ed3\u6807\u51c6\u6210\u672c {} \u6761\uff08\u7f13\u5b58{}\u5c0f\u65f6\uff09", (Object)map.size(), (Object)6L); | ||
| 1924 | + JdyRiskStatisticsService.logHeap("\u6210\u672c\u8868\u52a0\u8f7d\u540e"); | ||
| 1925 | + return map; | ||
| 1926 | + }); | ||
| 1927 | + } | ||
| 1928 | + | ||
| 1929 | + private Map<String, String> loadRelMap(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1930 | + if (!JdyRiskStatisticsService.hasText(s.getRelEntryId()) || !JdyRiskStatisticsService.hasText(s.getRelPartField())) { | ||
| 1931 | + return Collections.emptyMap(); | ||
| 1932 | + } | ||
| 1933 | + String key = "rel|" + s.getRelEntryId() + "|" + s.getRelPartField() + "|" + s.getRelSupplierField(); | ||
| 1934 | + return this.cached(key, () -> { | ||
| 1935 | + Map<String, Rel> tmp = new HashMap<String, Rel>(); | ||
| 1936 | + ArrayList<String> fields = new ArrayList<String>(); | ||
| 1937 | + fields.add(s.getRelPartField()); | ||
| 1938 | + if (JdyRiskStatisticsService.hasText(s.getRelSupplierField())) { | ||
| 1939 | + fields.add(s.getRelSupplierField()); | ||
| 1940 | + } | ||
| 1941 | + if (JdyRiskStatisticsService.hasText(s.getRelEnableField())) { | ||
| 1942 | + fields.add(s.getRelEnableField()); | ||
| 1943 | + } | ||
| 1944 | + if (JdyRiskStatisticsService.hasText(s.getRelTimeField())) { | ||
| 1945 | + fields.add(s.getRelTimeField()); | ||
| 1946 | + } | ||
| 1947 | + jdy.forEachPage(this.props.getApiKey(), s.getAppId(), s.getRelEntryId(), fields, page -> { | ||
| 1948 | + for (int i = 0; i < page.size(); ++i) { | ||
| 1949 | + Rel cur; | ||
| 1950 | + ZonedDateTime t; | ||
| 1951 | + JSONObject row = page.getJSONObject(i); | ||
| 1952 | + String part = JdyRiskStatisticsService.normalizePart(row.getString(s.getRelPartField())); | ||
| 1953 | + String supplier = row.getString(s.getRelSupplierField()); | ||
| 1954 | + if (part.isEmpty() || supplier == null || supplier.trim().isEmpty()) continue; | ||
| 1955 | + boolean enabled = !JdyRiskStatisticsService.hasText(s.getRelEnableField()) || JdyRiskStatisticsService.isEnabledValue(row.get((Object)s.getRelEnableField())); | ||
| 1956 | + long time = 0L; | ||
| 1957 | + if (JdyRiskStatisticsService.hasText(s.getRelTimeField()) && (t = JdyRiskStatisticsService.parseTime(row.getString(s.getRelTimeField()))) != null) { | ||
| 1958 | + time = t.toInstant().toEpochMilli(); | ||
| 1959 | + } | ||
| 1960 | + if ((cur = (Rel)tmp.get(part)) == null) { | ||
| 1961 | + tmp.put(part, new Rel(supplier, enabled, time)); | ||
| 1962 | + continue; | ||
| 1963 | + } | ||
| 1964 | + if (enabled && !cur.enabled) { | ||
| 1965 | + tmp.put(part, new Rel(supplier, enabled, time)); | ||
| 1966 | + continue; | ||
| 1967 | + } | ||
| 1968 | + if (enabled != cur.enabled || time <= cur.time) continue; | ||
| 1969 | + tmp.put(part, new Rel(supplier, enabled, time)); | ||
| 1970 | + } | ||
| 1971 | + }); | ||
| 1972 | + HashMap map = new HashMap(); | ||
| 1973 | + for (Map.Entry<String, Rel> e : tmp.entrySet()) { | ||
| 1974 | + if (!e.getValue().enabled) continue; | ||
| 1975 | + map.put(e.getKey(), e.getValue().supplier); | ||
| 1976 | + } | ||
| 1977 | + log.info("\u52a0\u8f7d\u96f6\u4ef6\u4f9b\u5e94\u5546\u5173\u7cfb {} \u6761\u542f\u7528\u8bb0\u5f55\uff08\u7f13\u5b58{}\u5c0f\u65f6\uff09", (Object)map.size(), (Object)6L); | ||
| 1978 | + return map; | ||
| 1979 | + }); | ||
| 1980 | + } | ||
| 1981 | + | ||
| 1982 | + private Set<String> loadAixinSet(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 1983 | + if (!JdyRiskStatisticsService.hasText(s.getAixinEntryId()) || !JdyRiskStatisticsService.hasText(s.getAixinPartField())) { | ||
| 1984 | + return Collections.emptySet(); | ||
| 1985 | + } | ||
| 1986 | + String key = "aixin|" + s.getAixinEntryId() + "|" + s.getAixinPartField(); | ||
| 1987 | + return this.cached(key, () -> { | ||
| 1988 | + HashSet set = new HashSet(); | ||
| 1989 | + jdy.forEachPage(this.props.getApiKey(), s.getAppId(), s.getAixinEntryId(), Collections.singletonList(s.getAixinPartField()), page -> { | ||
| 1990 | + for (int i = 0; i < page.size(); ++i) { | ||
| 1991 | + String part = JdyRiskStatisticsService.normalizePart(page.getJSONObject(i).getString(s.getAixinPartField())); | ||
| 1992 | + if (part.isEmpty()) continue; | ||
| 1993 | + set.add(part); | ||
| 1994 | + } | ||
| 1995 | + }); | ||
| 1996 | + log.info("\u52a0\u8f7d\u6307\u6807\u5916\u7231\u4fe1\u5e93\u5b58 {} \u6761\uff08\u7f13\u5b58{}\u5c0f\u65f6\uff09", (Object)set.size(), (Object)6L); | ||
| 1997 | + return set; | ||
| 1998 | + }); | ||
| 1999 | + } | ||
| 2000 | + | ||
| 2001 | + private static List<String> widgetFieldNames(JSONArray widgets) { | ||
| 2002 | + ArrayList<String> fields = new ArrayList<String>(); | ||
| 2003 | + for (int i = 0; i < widgets.size(); ++i) { | ||
| 2004 | + String name = widgets.getJSONObject(i).getString("name"); | ||
| 2005 | + if (name == null || name.isEmpty()) continue; | ||
| 2006 | + fields.add(name); | ||
| 2007 | + } | ||
| 2008 | + return fields; | ||
| 2009 | + } | ||
| 2010 | + | ||
| 2011 | + private static JSONArray insertCostWidget(JSONArray widgets, String afterField) { | ||
| 2012 | + JSONArray out = new JSONArray(); | ||
| 2013 | + boolean inserted = false; | ||
| 2014 | + for (int i = 0; i < widgets.size(); ++i) { | ||
| 2015 | + JSONObject w = widgets.getJSONObject(i); | ||
| 2016 | + out.add((Object)w); | ||
| 2017 | + if (afterField == null || !afterField.equals(w.getString("name"))) continue; | ||
| 2018 | + out.add((Object)JdyRiskStatisticsService.syntheticWidget("__cost", "\u6210\u672c")); | ||
| 2019 | + inserted = true; | ||
| 2020 | + } | ||
| 2021 | + if (!inserted) { | ||
| 2022 | + out.add((Object)JdyRiskStatisticsService.syntheticWidget("__cost", "\u6210\u672c")); | ||
| 2023 | + } | ||
| 2024 | + return out; | ||
| 2025 | + } | ||
| 2026 | + | ||
| 2027 | + private static boolean hasText(String s) { | ||
| 2028 | + return s != null && !s.trim().isEmpty(); | ||
| 2029 | + } | ||
| 2030 | + | ||
| 2031 | + private String prevMonth() { | ||
| 2032 | + return this.now().minusMonths(1L).format(MONTH_FMT); | ||
| 2033 | + } | ||
| 2034 | + | ||
| 2035 | + private static String normalizePart(String v) { | ||
| 2036 | + return v == null ? "" : v.trim().toUpperCase(Locale.ROOT); | ||
| 2037 | + } | ||
| 2038 | + | ||
| 2039 | + private static String normalizeCode(Object v) { | ||
| 2040 | + double d; | ||
| 2041 | + if (v == null) { | ||
| 2042 | + return ""; | ||
| 2043 | + } | ||
| 2044 | + if (v instanceof Number && (d = ((Number)v).doubleValue()) == Math.rint(d)) { | ||
| 2045 | + return String.valueOf((long)d); | ||
| 2046 | + } | ||
| 2047 | + String s = String.valueOf(v).trim(); | ||
| 2048 | + if (s.endsWith(".0")) { | ||
| 2049 | + s = s.substring(0, s.length() - 2); | ||
| 2050 | + } | ||
| 2051 | + return s; | ||
| 2052 | + } | ||
| 2053 | + | ||
| 2054 | + private static boolean isEnabledValue(Object v) { | ||
| 2055 | + if (v == null) { | ||
| 2056 | + return false; | ||
| 2057 | + } | ||
| 2058 | + String s = String.valueOf(v).trim(); | ||
| 2059 | + return "Y".equalsIgnoreCase(s) || "\u662f".equals(s) || "YES".equalsIgnoreCase(s) || "TRUE".equalsIgnoreCase(s) || "1".equals(s) || "\u542f\u7528".equals(s); | ||
| 2060 | + } | ||
| 2061 | + | ||
| 2062 | + private static double toDouble(Object v) { | ||
| 2063 | + if (v == null) { | ||
| 2064 | + return 0.0; | ||
| 2065 | + } | ||
| 2066 | + if (v instanceof Number) { | ||
| 2067 | + return ((Number)v).doubleValue(); | ||
| 2068 | + } | ||
| 2069 | + try { | ||
| 2070 | + return Double.parseDouble(String.valueOf(v)); | ||
| 2071 | + } | ||
| 2072 | + catch (NumberFormatException e) { | ||
| 2073 | + return 0.0; | ||
| 2074 | + } | ||
| 2075 | + } | ||
| 2076 | + | ||
| 2077 | + private static String fmtAmount(double v) { | ||
| 2078 | + return String.format(Locale.ROOT, "%.2f", v); | ||
| 2079 | + } | ||
| 2080 | + | ||
| 2081 | + private static void logHeap(String tag) { | ||
| 2082 | + Runtime r = Runtime.getRuntime(); | ||
| 2083 | + long used = (r.totalMemory() - r.freeMemory()) / 1024L / 1024L; | ||
| 2084 | + long max = r.maxMemory() / 1024L / 1024L; | ||
| 2085 | + log.info("{} \u5806\u5185\u5b58 used={}MB / max={}MB", new Object[]{tag, used, max}); | ||
| 2086 | + } | ||
| 2087 | + | ||
| 2088 | + private static boolean flowStateMatches(JdyRiskProperties.Scenario s, JSONObject row) { | ||
| 2089 | + Integer want = s.getFlowStateValue(); | ||
| 2090 | + if (want == null) { | ||
| 2091 | + return true; | ||
| 2092 | + } | ||
| 2093 | + Integer f = row.getInteger("flowState"); | ||
| 2094 | + return f != null && f.equals(want); | ||
| 2095 | + } | ||
| 2096 | + | ||
| 2097 | + private Map<String, String> widgetLabels(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 2098 | + LinkedHashMap<String, String> m = new LinkedHashMap<String, String>(); | ||
| 2099 | + JSONArray ws = jdy.listWidgets(this.props.getApiKey(), s.getAppId(), s.getEntryId()); | ||
| 2100 | + for (int i = 0; i < ws.size(); ++i) { | ||
| 2101 | + JSONObject w = ws.getJSONObject(i); | ||
| 2102 | + String n = w.getString("name"); | ||
| 2103 | + String l = w.getString("label"); | ||
| 2104 | + if (n == null || l == null) continue; | ||
| 2105 | + m.put(n, l); | ||
| 2106 | + } | ||
| 2107 | + return m; | ||
| 2108 | + } | ||
| 2109 | + | ||
| 2110 | + private static boolean hasValue(JSONObject row, String field) { | ||
| 2111 | + if (field == null) { | ||
| 2112 | + return false; | ||
| 2113 | + } | ||
| 2114 | + Object v = row.get((Object)field); | ||
| 2115 | + if (v == null) { | ||
| 2116 | + return false; | ||
| 2117 | + } | ||
| 2118 | + if (v instanceof String) { | ||
| 2119 | + return !((String)v).trim().isEmpty(); | ||
| 2120 | + } | ||
| 2121 | + if (v instanceof JSONObject) { | ||
| 2122 | + JSONObject o = (JSONObject)v; | ||
| 2123 | + return !o.isEmpty() && (o.getString("name") == null || !o.getString("name").trim().isEmpty()); | ||
| 2124 | + } | ||
| 2125 | + if (v instanceof JSONArray) { | ||
| 2126 | + return !((JSONArray)v).isEmpty(); | ||
| 2127 | + } | ||
| 2128 | + return true; | ||
| 2129 | + } | ||
| 2130 | + | ||
| 2131 | + private static void sortByDateDesc(List<JSONObject> list, String dateField) { | ||
| 2132 | + list.sort((a, b) -> { | ||
| 2133 | + ZonedDateTime ta = JdyRiskStatisticsService.parseTime(a.getString(dateField)); | ||
| 2134 | + ZonedDateTime tb = JdyRiskStatisticsService.parseTime(b.getString(dateField)); | ||
| 2135 | + if (ta == null && tb == null) { | ||
| 2136 | + return 0; | ||
| 2137 | + } | ||
| 2138 | + if (ta == null) { | ||
| 2139 | + return 1; | ||
| 2140 | + } | ||
| 2141 | + if (tb == null) { | ||
| 2142 | + return -1; | ||
| 2143 | + } | ||
| 2144 | + return tb.compareTo(ta); | ||
| 2145 | + }); | ||
| 2146 | + } | ||
| 2147 | + | ||
| 2148 | + private JSONObject findPreviousRefuel(JSONArray all, JdyRiskProperties.Scenario s, JSONObject current, ZonedDateTime curTime) { | ||
| 2149 | + if (curTime == null) { | ||
| 2150 | + return null; | ||
| 2151 | + } | ||
| 2152 | + String flagVal = s.getFlagValues().isEmpty() ? "\u662f" : s.getFlagValues().get(0); | ||
| 2153 | + Integer wantFlow = s.getFlowStateValue(); | ||
| 2154 | + JSONObject best = null; | ||
| 2155 | + ZonedDateTime bestT = null; | ||
| 2156 | + for (int i = 0; i < all.size(); ++i) { | ||
| 2157 | + ZonedDateTime t; | ||
| 2158 | + Integer f; | ||
| 2159 | + JSONObject row = all.getJSONObject(i); | ||
| 2160 | + if (row == current || !flagVal.equals(row.getString(s.getFlagField())) || wantFlow != null && ((f = row.getInteger("flowState")) == null || !f.equals(wantFlow)) || (t = JdyRiskStatisticsService.parseTime(row.getString(s.getDateField()))) == null || !t.isBefore(curTime) || bestT != null && !t.isAfter(bestT)) continue; | ||
| 2161 | + best = row; | ||
| 2162 | + bestT = t; | ||
| 2163 | + } | ||
| 2164 | + return best; | ||
| 2165 | + } | ||
| 2166 | + | ||
| 2167 | + private static JSONArray filterByFlag(JSONArray rows, JdyRiskProperties.Scenario s) { | ||
| 2168 | + String f = s.getFlagField(); | ||
| 2169 | + if (f == null || f.isEmpty() || s.getFlagValues().isEmpty()) { | ||
| 2170 | + return rows; | ||
| 2171 | + } | ||
| 2172 | + JSONArray out = new JSONArray(); | ||
| 2173 | + for (int i = 0; i < rows.size(); ++i) { | ||
| 2174 | + JSONObject row = rows.getJSONObject(i); | ||
| 2175 | + if (!s.getFlagValues().contains(row.getString(f))) continue; | ||
| 2176 | + out.add((Object)row); | ||
| 2177 | + } | ||
| 2178 | + return out; | ||
| 2179 | + } | ||
| 2180 | + | ||
| 2181 | + private static Set<String> bottomCompanyFields(Map<String, Double> totals, int n) { | ||
| 2182 | + LinkedHashSet<String> bottom = new LinkedHashSet<String>(); | ||
| 2183 | + if (totals == null || totals.isEmpty() || n <= 0) { | ||
| 2184 | + return bottom; | ||
| 2185 | + } | ||
| 2186 | + ArrayList<Map.Entry<String, Double>> list = new ArrayList<Map.Entry<String, Double>>(totals.entrySet()); | ||
| 2187 | + list.sort((a, b) -> Double.compare((Double)a.getValue(), (Double)b.getValue())); | ||
| 2188 | + double cutoff = (Double)((Map.Entry)list.get(Math.min(n, list.size()) - 1)).getValue(); | ||
| 2189 | + for (Map.Entry entry : list) { | ||
| 2190 | + if (!((Double)entry.getValue() <= cutoff)) continue; | ||
| 2191 | + bottom.add((String)entry.getKey()); | ||
| 2192 | + } | ||
| 2193 | + return bottom; | ||
| 2194 | + } | ||
| 2195 | + | ||
| 2196 | + private static double startKm(JSONObject row, JdyRiskProperties.Scenario s) { | ||
| 2197 | + Object o; | ||
| 2198 | + double v = JdyRiskStatisticsService.num(row, s.getStartKmField()); | ||
| 2199 | + if (v > 0.0) { | ||
| 2200 | + return v; | ||
| 2201 | + } | ||
| 2202 | + if (s.getSubformField() != null && s.getSubformStartField() != null && (o = row.get((Object)s.getSubformField())) instanceof JSONArray) { | ||
| 2203 | + JSONArray arr = (JSONArray)o; | ||
| 2204 | + double max = 0.0; | ||
| 2205 | + for (int i = 0; i < arr.size(); ++i) { | ||
| 2206 | + double sv; | ||
| 2207 | + Object it = arr.get(i); | ||
| 2208 | + if (!(it instanceof JSONObject) || !((sv = JdyRiskStatisticsService.num((JSONObject)it, s.getSubformStartField())) > max)) continue; | ||
| 2209 | + max = sv; | ||
| 2210 | + } | ||
| 2211 | + return max; | ||
| 2212 | + } | ||
| 2213 | + return 0.0; | ||
| 2214 | + } | ||
| 2215 | + | ||
| 2216 | + private static JSONObject syntheticWidget(String name, String label) { | ||
| 2217 | + JSONObject w = new JSONObject(); | ||
| 2218 | + w.put("name", (Object)name); | ||
| 2219 | + w.put("label", (Object)label); | ||
| 2220 | + return w; | ||
| 2221 | + } | ||
| 2222 | + | ||
| 2223 | + private static Map<String, List<JSONObject>> groupByBarcode(JSONArray rows, String field) { | ||
| 2224 | + LinkedHashMap<String, List<JSONObject>> map = new LinkedHashMap<String, List<JSONObject>>(); | ||
| 2225 | + for (int i = 0; i < rows.size(); ++i) { | ||
| 2226 | + JSONObject row = rows.getJSONObject(i); | ||
| 2227 | + String b = row.getString(field); | ||
| 2228 | + if (b == null || b.trim().isEmpty()) continue; | ||
| 2229 | + map.computeIfAbsent(b.trim(), k -> new ArrayList()).add(row); | ||
| 2230 | + } | ||
| 2231 | + return map; | ||
| 2232 | + } | ||
| 2233 | + | ||
| 2234 | + private Set<String> warningSuppliers2(JdyRiskProperties.Scenario s, JSONArray data) { | ||
| 2235 | + LinkedHashMap<String, double[]> byGroup = new LinkedHashMap<String, double[]>(); | ||
| 2236 | + for (int i = 0; i < data.size(); ++i) { | ||
| 2237 | + JSONObject row = data.getJSONObject(i); | ||
| 2238 | + String group = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); | ||
| 2239 | + double qty = JdyRiskStatisticsService.num(row, s.getQtyField()); | ||
| 2240 | + double[] agg = byGroup.computeIfAbsent(group, k -> new double[2]); | ||
| 2241 | + agg[0] = agg[0] + qty; | ||
| 2242 | + if (!"SI".equalsIgnoreCase(row.getString(s.getSiField()))) continue; | ||
| 2243 | + agg[1] = agg[1] + qty; | ||
| 2244 | + } | ||
| 2245 | + LinkedHashSet<String> warn = new LinkedHashSet<String>(); | ||
| 2246 | + for (Map.Entry e : byGroup.entrySet()) { | ||
| 2247 | + double[] agg = (double[])e.getValue(); | ||
| 2248 | + if (!(agg[0] >= 5.0) || !(agg[1] / agg[0] > 0.6)) continue; | ||
| 2249 | + warn.add((String)e.getKey()); | ||
| 2250 | + } | ||
| 2251 | + return warn; | ||
| 2252 | + } | ||
| 2253 | + | ||
| 2254 | + private List<String> buildExtraValues(JdyRiskProperties.Scenario s, JSONArray data) { | ||
| 2255 | + String type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 2256 | + Set<String> warnGroups = null; | ||
| 2257 | + Map<String, Double> ratio2 = null; | ||
| 2258 | + if ("scenario2".equals(type)) { | ||
| 2259 | + ratio2 = this.supplierRatio2(s, data); | ||
| 2260 | + warnGroups = ratio2.keySet(); | ||
| 2261 | + } else if ("scenario4".equals(type) || "scenario5".equals(type)) { | ||
| 2262 | + warnGroups = this.warningGroupsByUp(s, data); | ||
| 2263 | + } else if ("scenario6".equals(type)) { | ||
| 2264 | + warnGroups = this.warningGroupsByCount(s, data); | ||
| 2265 | + } else if ("scenario8".equals(type) || "scenario9".equals(type)) { | ||
| 2266 | + ratio2 = this.groupRatioByFlag(s, data); | ||
| 2267 | + warnGroups = ratio2.keySet(); | ||
| 2268 | + } | ||
| 2269 | + ArrayList<String> values = new ArrayList<String>(); | ||
| 2270 | + for (int i = 0; i < data.size(); ++i) { | ||
| 2271 | + JSONObject row = data.getJSONObject(i); | ||
| 487 | String v = ""; | 2272 | String v = ""; |
| 488 | if ("scenario1".equals(type)) { | 2273 | if ("scenario1".equals(type)) { |
| 489 | - v = rowHitScenario1(s, row) ? displayName(s, row) : ""; | 2274 | + v = this.rowHitScenario1(s, row) ? this.displayName(s, row) : ""; |
| 490 | } else if ("scenario3".equals(type)) { | 2275 | } else if ("scenario3".equals(type)) { |
| 491 | - v = rowHitScenario3(s, row) ? displayName(s, row) : ""; | 2276 | + v = this.rowHitScenario3(s, row) ? this.displayName(s, row) : ""; |
| 2277 | + } else if (ratio2 != null) { | ||
| 2278 | + Double rr = ratio2.get(JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField()))); | ||
| 2279 | + v = rr != null ? this.displayName(s, row) + "(" + String.format("%.1f%%", rr * 100.0) + ")" : ""; | ||
| 492 | } else if (warnGroups != null) { | 2280 | } else if (warnGroups != null) { |
| 493 | - String g = orEmpty(row.getString(s.getGroupField())); | ||
| 494 | - v = warnGroups.contains(g) ? displayName(s, row) : ""; | 2281 | + String g = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); |
| 2282 | + v = warnGroups.contains(g) ? this.displayName(s, row) : ""; | ||
| 495 | } | 2283 | } |
| 496 | values.add(v); | 2284 | values.add(v); |
| 497 | } | 2285 | } |
| 498 | return values; | 2286 | return values; |
| 499 | } | 2287 | } |
| 500 | 2288 | ||
| 2289 | + private Map<String, Double> supplierRatio2(JdyRiskProperties.Scenario s, JSONArray data) { | ||
| 2290 | + double[] agg; | ||
| 2291 | + LinkedHashMap<String, double[]> byGroup = new LinkedHashMap<String, double[]>(); | ||
| 2292 | + for (int i = 0; i < data.size(); ++i) { | ||
| 2293 | + JSONObject row = data.getJSONObject(i); | ||
| 2294 | + String group = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); | ||
| 2295 | + agg = byGroup.computeIfAbsent(group, k -> new double[2]); | ||
| 2296 | + double qty = JdyRiskStatisticsService.num(row, s.getQtyField()); | ||
| 2297 | + agg[0] = agg[0] + qty; | ||
| 2298 | + if (!"SI".equalsIgnoreCase(row.getString(s.getSiField()))) continue; | ||
| 2299 | + agg[1] = agg[1] + qty; | ||
| 2300 | + } | ||
| 2301 | + LinkedHashMap<String, Double> out = new LinkedHashMap<String, Double>(); | ||
| 2302 | + for (Map.Entry e : byGroup.entrySet()) { | ||
| 2303 | + agg = (double[])e.getValue(); | ||
| 2304 | + if (!(agg[0] >= 5.0) || !(agg[1] / agg[0] > 0.6)) continue; | ||
| 2305 | + out.put((String)e.getKey(), agg[1] / agg[0]); | ||
| 2306 | + } | ||
| 2307 | + return out; | ||
| 2308 | + } | ||
| 2309 | + | ||
| 2310 | + private Map<String, Double> groupRatioByFlag(JdyRiskProperties.Scenario s, JSONArray data) { | ||
| 2311 | + LinkedHashMap<String, int[]> byGroup = new LinkedHashMap<String, int[]>(); | ||
| 2312 | + for (int i = 0; i < data.size(); ++i) { | ||
| 2313 | + JSONObject row = data.getJSONObject(i); | ||
| 2314 | + String g = JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField())); | ||
| 2315 | + int[] agg = byGroup.computeIfAbsent(g, k -> new int[2]); | ||
| 2316 | + agg[0] = agg[0] + 1; | ||
| 2317 | + if (s.getFlagValue() == null || !s.getFlagValue().equalsIgnoreCase(row.getString(s.getFlagField()))) continue; | ||
| 2318 | + agg[1] = agg[1] + 1; | ||
| 2319 | + } | ||
| 2320 | + LinkedHashMap<String, Double> out = new LinkedHashMap<String, Double>(); | ||
| 2321 | + double th = s.getRatioThreshold(); | ||
| 2322 | + for (Map.Entry e : byGroup.entrySet()) { | ||
| 2323 | + int[] agg = (int[])e.getValue(); | ||
| 2324 | + if (agg[0] <= 0 || !((double)agg[1] / (double)agg[0] > th)) continue; | ||
| 2325 | + out.put((String)e.getKey(), (double)agg[1] / (double)agg[0]); | ||
| 2326 | + } | ||
| 2327 | + return out; | ||
| 2328 | + } | ||
| 2329 | + | ||
| 501 | private String displayName(JdyRiskProperties.Scenario s, JSONObject row) { | 2330 | private String displayName(JdyRiskProperties.Scenario s, JSONObject row) { |
| 2331 | + Map<String, String> lk; | ||
| 2332 | + Object v; | ||
| 502 | if (s.getExtraField() != null && !s.getExtraField().isEmpty()) { | 2333 | if (s.getExtraField() != null && !s.getExtraField().isEmpty()) { |
| 503 | - return orEmpty(row.getString(s.getExtraField())); | 2334 | + v = row.get((Object)s.getExtraField()); |
| 2335 | + } else if (s.getGroupField() != null && !s.getGroupField().isEmpty()) { | ||
| 2336 | + v = row.get((Object)s.getGroupField()); | ||
| 2337 | + } else { | ||
| 2338 | + return "\u547d\u4e2d"; | ||
| 2339 | + } | ||
| 2340 | + if (v instanceof String && (lk = JdyExcelExportService.currentLookup()) != null && lk.containsKey(v)) { | ||
| 2341 | + return lk.get(v); | ||
| 2342 | + } | ||
| 2343 | + return JdyRiskStatisticsService.toDisplayName(v); | ||
| 2344 | + } | ||
| 2345 | + | ||
| 2346 | + private Map<String, String> buildLookupMap(JiandaoYunApi jdy, JdyRiskProperties.Scenario s) { | ||
| 2347 | + LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); | ||
| 2348 | + if (s.getLookupEntryId() == null || s.getLookupEntryId().isEmpty() || s.getLookupNameField() == null || s.getLookupNameField().isEmpty()) { | ||
| 2349 | + return map; | ||
| 2350 | + } | ||
| 2351 | + jdy.forEachPage(this.props.getApiKey(), s.getAppId(), s.getLookupEntryId(), Collections.singletonList(s.getLookupNameField()), page -> { | ||
| 2352 | + for (int i = 0; i < page.size(); ++i) { | ||
| 2353 | + JSONObject r = page.getJSONObject(i); | ||
| 2354 | + String id = r.getString("_id"); | ||
| 2355 | + String name = r.getString(s.getLookupNameField()); | ||
| 2356 | + if (id == null || name == null) continue; | ||
| 2357 | + map.put(id, name); | ||
| 2358 | + } | ||
| 2359 | + }); | ||
| 2360 | + log.info("\u573a\u666f[{}] \u5173\u8054\u8868 {} \u6620\u5c04 {} \u6761", new Object[]{s.getId(), s.getLookupEntryId(), map.size()}); | ||
| 2361 | + return map; | ||
| 2362 | + } | ||
| 2363 | + | ||
| 2364 | + private static void sortRows(JSONArray rows, String field) { | ||
| 2365 | + ArrayList<JSONObject> list = new ArrayList<JSONObject>(); | ||
| 2366 | + for (int i = 0; i < rows.size(); ++i) { | ||
| 2367 | + list.add(rows.getJSONObject(i)); | ||
| 504 | } | 2368 | } |
| 505 | - if (s.getGroupField() != null && !s.getGroupField().isEmpty()) { | ||
| 506 | - return orEmpty(row.getString(s.getGroupField())); | 2369 | + list.sort((a, b) -> JdyRiskStatisticsService.toDisplayName(a.get((Object)field)).compareTo(JdyRiskStatisticsService.toDisplayName(b.get((Object)field)))); |
| 2370 | + rows.clear(); | ||
| 2371 | + for (JSONObject o : list) { | ||
| 2372 | + rows.add((Object)o); | ||
| 507 | } | 2373 | } |
| 508 | - return "命中"; | 2374 | + } |
| 2375 | + | ||
| 2376 | + private static String toDisplayName(Object v) { | ||
| 2377 | + if (v == null) { | ||
| 2378 | + return ""; | ||
| 2379 | + } | ||
| 2380 | + if (v instanceof JSONObject) { | ||
| 2381 | + JSONObject o = (JSONObject)v; | ||
| 2382 | + String n = o.getString("dataTitle"); | ||
| 2383 | + if (n == null || n.isEmpty()) { | ||
| 2384 | + n = o.getString("name"); | ||
| 2385 | + } | ||
| 2386 | + return n == null ? "" : n; | ||
| 2387 | + } | ||
| 2388 | + if (v instanceof JSONArray) { | ||
| 2389 | + JSONArray arr = (JSONArray)v; | ||
| 2390 | + StringBuilder sb = new StringBuilder(); | ||
| 2391 | + for (int i = 0; i < arr.size(); ++i) { | ||
| 2392 | + String n = JdyRiskStatisticsService.toDisplayName(arr.get(i)); | ||
| 2393 | + if (n.isEmpty()) continue; | ||
| 2394 | + if (sb.length() > 0) { | ||
| 2395 | + sb.append(","); | ||
| 2396 | + } | ||
| 2397 | + sb.append(n); | ||
| 2398 | + } | ||
| 2399 | + return sb.toString(); | ||
| 2400 | + } | ||
| 2401 | + String s = String.valueOf(v); | ||
| 2402 | + return "null".equals(s) ? "" : s; | ||
| 2403 | + } | ||
| 2404 | + | ||
| 2405 | + private JSONArray filterWarnRows(JdyRiskProperties.Scenario s, JSONArray rows) { | ||
| 2406 | + String type = s.getType() == null ? "" : s.getType().toLowerCase(); | ||
| 2407 | + Set<String> warnGroups = null; | ||
| 2408 | + if ("scenario2".equals(type)) { | ||
| 2409 | + warnGroups = this.warningSuppliers2(s, rows); | ||
| 2410 | + } else if ("scenario4".equals(type) || "scenario5".equals(type)) { | ||
| 2411 | + warnGroups = this.warningGroupsByUp(s, rows); | ||
| 2412 | + } else if ("scenario8".equals(type) || "scenario9".equals(type)) { | ||
| 2413 | + warnGroups = this.warningGroupsByRatio(s, rows); | ||
| 2414 | + } | ||
| 2415 | + JSONArray out = new JSONArray(); | ||
| 2416 | + for (int i = 0; i < rows.size(); ++i) { | ||
| 2417 | + JSONObject row = rows.getJSONObject(i); | ||
| 2418 | + boolean keep = warnGroups != null ? warnGroups.contains(JdyRiskStatisticsService.orEmpty(row.getString(s.getGroupField()))) : ("scenario3".equals(type) ? this.rowHitScenario3(s, row) : ("scenario1".equals(type) ? this.rowHitScenario1(s, row) : true)); | ||
| 2419 | + if (!keep) continue; | ||
| 2420 | + out.add((Object)row); | ||
| 2421 | + } | ||
| 2422 | + return out; | ||
| 509 | } | 2423 | } |
| 510 | 2424 | ||
| 511 | private boolean rowHitScenario1(JdyRiskProperties.Scenario s, JSONObject row) { | 2425 | private boolean rowHitScenario1(JdyRiskProperties.Scenario s, JSONObject row) { |
| 512 | - double total = num(row, s.getTotalField()); | ||
| 513 | - double diff = num(row, s.getDiffField()); | 2426 | + double total = JdyRiskStatisticsService.num(row, s.getTotalField()); |
| 2427 | + double diff = JdyRiskStatisticsService.num(row, s.getDiffField()); | ||
| 514 | Integer flow = row.getInteger("flowState"); | 2428 | Integer flow = row.getInteger("flowState"); |
| 515 | - return total >= 5 && diff >= 1 && flow != null && flow == s.getInProgressState(); | 2429 | + return total >= 5.0 && diff >= 1.0 && flow != null && flow.intValue() == s.getInProgressState(); |
| 516 | } | 2430 | } |
| 517 | 2431 | ||
| 518 | private boolean rowHitScenario3(JdyRiskProperties.Scenario s, JSONObject row) { | 2432 | private boolean rowHitScenario3(JdyRiskProperties.Scenario s, JSONObject row) { |
| 519 | - double total = num(row, s.getTotalField()); | ||
| 520 | - double ratio = num(row, s.getRatioField()); | ||
| 521 | - return total >= 5 && ratio > 0.6; | 2433 | + double total = JdyRiskStatisticsService.num(row, s.getTotalField()); |
| 2434 | + double ratio = JdyRiskStatisticsService.num(row, s.getRatioField()); | ||
| 2435 | + return total >= 5.0 && ratio > 0.6; | ||
| 522 | } | 2436 | } |
| 523 | 2437 | ||
| 524 | - /** 升级字段是否命中:非空 且 不在排除值内。 */ | ||
| 525 | private boolean isUpHit(JdyRiskProperties.Scenario s, JSONObject row) { | 2438 | private boolean isUpHit(JdyRiskProperties.Scenario s, JSONObject row) { |
| 526 | String up = row.getString(s.getUpField()); | 2439 | String up = row.getString(s.getUpField()); |
| 527 | if (up == null || up.trim().isEmpty()) { | 2440 | if (up == null || up.trim().isEmpty()) { |
| @@ -529,38 +2442,179 @@ public class JdyRiskStatisticsService { | @@ -529,38 +2442,179 @@ public class JdyRiskStatisticsService { | ||
| 529 | } | 2442 | } |
| 530 | if (s.getExcludeValues() != null) { | 2443 | if (s.getExcludeValues() != null) { |
| 531 | for (String ex : s.getExcludeValues()) { | 2444 | for (String ex : s.getExcludeValues()) { |
| 532 | - if (ex != null && ex.equalsIgnoreCase(up.trim())) { | ||
| 533 | - return false; | ||
| 534 | - } | 2445 | + if (ex == null || !ex.equalsIgnoreCase(up.trim())) continue; |
| 2446 | + return false; | ||
| 535 | } | 2447 | } |
| 536 | } | 2448 | } |
| 537 | return true; | 2449 | return true; |
| 538 | } | 2450 | } |
| 539 | 2451 | ||
| 540 | - /* ==================== 工具 ==================== */ | 2452 | + private JSONObject findTodayRecord(JSONArray records, JdyRiskProperties.Scenario s, Biz biz, String timeField) { |
| 2453 | + if (records == null || s == null || timeField == null || timeField.isEmpty()) { | ||
| 2454 | + return null; | ||
| 2455 | + } | ||
| 2456 | + String today = this.now().format(DAY_FMT); | ||
| 2457 | + for (JSONObject r : this.candidates(records, s, biz)) { | ||
| 2458 | + Long t = r.getLong(timeField); | ||
| 2459 | + if (t == null || !Instant.ofEpochMilli(t).atZone(ZONE).format(DAY_FMT).equals(today)) continue; | ||
| 2460 | + return r; | ||
| 2461 | + } | ||
| 2462 | + return null; | ||
| 2463 | + } | ||
| 2464 | + | ||
| 2465 | + private JSONObject buildAttach(String fileId, String fileName, long size) { | ||
| 2466 | + JSONObject rel = new JSONObject(); | ||
| 2467 | + rel.put("uid", (Object)fileId); | ||
| 2468 | + rel.put("name", (Object)fileName); | ||
| 2469 | + rel.put("size", (Object)size); | ||
| 2470 | + rel.put("fileId", (Object)fileId); | ||
| 2471 | + rel.put("status", (Object)"done"); | ||
| 2472 | + rel.put("id", (Object)fileId); | ||
| 2473 | + rel.put("dataTitle", (Object)fileName); | ||
| 2474 | + return rel; | ||
| 2475 | + } | ||
| 2476 | + | ||
| 2477 | + private static void setTimeFields(JSONObject rec, JdyRiskProperties.Qx qx, long now) { | ||
| 2478 | + if (qx.getTimeField() != null && !qx.getTimeField().isEmpty()) { | ||
| 2479 | + rec.put(qx.getTimeField(), (Object)now); | ||
| 2480 | + } | ||
| 2481 | + if (qx.getTimeField2() != null && !qx.getTimeField2().isEmpty()) { | ||
| 2482 | + rec.put(qx.getTimeField2(), (Object)now); | ||
| 2483 | + } | ||
| 2484 | + } | ||
| 2485 | + | ||
| 2486 | + private JSONObject cloneTemplate(JSONObject template, JdyRiskProperties.Qx qx, String syncCode, long count, long now, String fileId, String fileName, long size, boolean skipAttach) { | ||
| 2487 | + JSONObject body = new JSONObject(); | ||
| 2488 | + body.putAll((Map)template); | ||
| 2489 | + body.remove((Object)"id"); | ||
| 2490 | + body.remove((Object)"corpCode"); | ||
| 2491 | + body.remove((Object)"createdBy"); | ||
| 2492 | + body.remove((Object)"updatedBy"); | ||
| 2493 | + body.remove((Object)"createdAt"); | ||
| 2494 | + body.remove((Object)"updatedAt"); | ||
| 2495 | + body.put(qx.getCountField(), (Object)count); | ||
| 2496 | + body.put("syncCode", (Object)syncCode); | ||
| 2497 | + JdyRiskStatisticsService.setTimeFields(body, qx, now); | ||
| 2498 | + String af = qx.getAttachField(); | ||
| 2499 | + if (af != null && !af.isEmpty()) { | ||
| 2500 | + if (skipAttach || fileId == null) { | ||
| 2501 | + body.remove((Object)af); | ||
| 2502 | + body.remove((Object)(af + "Id")); | ||
| 2503 | + } else { | ||
| 2504 | + body.put(af, (Object)this.buildAttach(fileId, fileName, size)); | ||
| 2505 | + body.put(af + "Id", (Object)fileId); | ||
| 2506 | + } | ||
| 2507 | + } | ||
| 2508 | + return body; | ||
| 2509 | + } | ||
| 541 | 2510 | ||
| 542 | - /** 在启效记录中按 syncCode 匹配(重复时取第一条并告警)。 */ | ||
| 543 | - private JSONObject findRecordBySyncCode(JSONArray records, String syncCode) { | ||
| 544 | - if (records == null || syncCode == null || syncCode.isEmpty()) { | 2511 | + private JSONObject buildAddBody(Biz biz, JdyRiskProperties.Qx qx, String syncCode, long count, long now, String fileId, String fileName, long size) { |
| 2512 | + JSONObject unit = new JSONObject(); | ||
| 2513 | + unit.put("dataTitle", (Object)biz.unitTitle); | ||
| 2514 | + unit.put("id", (Object)biz.unitId); | ||
| 2515 | + JSONObject leader = new JSONObject(); | ||
| 2516 | + leader.put("dataTitle", (Object)biz.leaderTitle); | ||
| 2517 | + leader.put("id", (Object)biz.leaderId); | ||
| 2518 | + JSONObject scene = new JSONObject(); | ||
| 2519 | + scene.put("id", (Object)biz.sceneId); | ||
| 2520 | + scene.put("dataTitle", (Object)biz.sceneTitle); | ||
| 2521 | + scene.put("faomis", (Object)biz.domain); | ||
| 2522 | + scene.put("xxwbzf", (Object)biz.businessLine); | ||
| 2523 | + scene.put("qdbuhp", (Object)unit); | ||
| 2524 | + scene.put("pofmup", (Object)leader); | ||
| 2525 | + if (biz.sceneMemberId != null) { | ||
| 2526 | + JSONObject member = new JSONObject(); | ||
| 2527 | + member.put("dataTitle", (Object)biz.sceneMemberTitle); | ||
| 2528 | + member.put("id", (Object)biz.sceneMemberId); | ||
| 2529 | + scene.put("jiaplm", (Object)member); | ||
| 2530 | + } | ||
| 2531 | + if (biz.sivnbu != null) { | ||
| 2532 | + scene.put("lwpfsp", (Object)biz.sivnbu); | ||
| 2533 | + } | ||
| 2534 | + if (biz.ilecyn != null) { | ||
| 2535 | + scene.put("vikuzx", (Object)biz.ilecyn); | ||
| 2536 | + } | ||
| 2537 | + JSONObject body = new JSONObject(); | ||
| 2538 | + body.put("miidqb", (Object)scene); | ||
| 2539 | + body.put("miidqbId", (Object)biz.sceneId); | ||
| 2540 | + body.put("gyxwbd", (Object)biz.domain); | ||
| 2541 | + body.put("wifxkb", (Object)biz.businessLine); | ||
| 2542 | + if (biz.sivnbu != null) { | ||
| 2543 | + body.put("sivnbu", (Object)biz.sivnbu); | ||
| 2544 | + } | ||
| 2545 | + if (biz.ilecyn != null) { | ||
| 2546 | + body.put("ilecyn", (Object)biz.ilecyn); | ||
| 2547 | + } | ||
| 2548 | + body.put("gnzuoi", (Object)unit); | ||
| 2549 | + body.put("gnzuoiId", (Object)biz.unitId); | ||
| 2550 | + body.put("khexbl", (Object)leader); | ||
| 2551 | + body.put("khexblId", (Object)biz.leaderId); | ||
| 2552 | + JdyRiskStatisticsService.setTimeFields(body, qx, now); | ||
| 2553 | + body.put("sxhuzf", (Object)"1"); | ||
| 2554 | + body.put(qx.getCountField(), (Object)count); | ||
| 2555 | + body.put("syncCode", (Object)syncCode); | ||
| 2556 | + if (biz.jetcalId != null) { | ||
| 2557 | + JSONObject jet = new JSONObject(); | ||
| 2558 | + jet.put("dataTitle", (Object)biz.jetcalTitle); | ||
| 2559 | + jet.put("id", (Object)biz.jetcalId); | ||
| 2560 | + body.put("jetcal", (Object)jet); | ||
| 2561 | + body.put("jetcalId", (Object)biz.jetcalId); | ||
| 2562 | + } | ||
| 2563 | + if (biz.zawlah != null) { | ||
| 2564 | + body.put("zawlah", (Object)biz.zawlah); | ||
| 2565 | + } | ||
| 2566 | + if (fileId != null && qx.getAttachField() != null && !qx.getAttachField().isEmpty()) { | ||
| 2567 | + body.put(qx.getAttachField(), (Object)this.buildAttach(fileId, fileName, size)); | ||
| 2568 | + body.put(qx.getAttachField() + "Id", (Object)fileId); | ||
| 2569 | + } | ||
| 2570 | + return body; | ||
| 2571 | + } | ||
| 2572 | + | ||
| 2573 | + private JSONObject findRecordBySyncCode(JSONArray records, JdyRiskProperties.Scenario s, Biz biz) { | ||
| 2574 | + List<JSONObject> list = this.candidates(records, s, biz); | ||
| 2575 | + if (list.isEmpty()) { | ||
| 545 | return null; | 2576 | return null; |
| 546 | } | 2577 | } |
| 547 | - JSONObject found = null; | ||
| 548 | - for (int i = 0; i < records.size(); i++) { | 2578 | + if (list.size() > 1) { |
| 2579 | + log.warn("syncCode={} \u573a\u666f={} \u5b58\u5728\u591a\u6761\u8bb0\u5f55\uff08id={} \u4e0e id={}\uff09\uff0c\u4f7f\u7528\u7b2c\u4e00\u6761", new Object[]{s.getSyncCode(), biz != null ? biz.sceneId : "", list.get(0).getString("id"), list.get(1).getString("id")}); | ||
| 2580 | + } | ||
| 2581 | + return list.get(0); | ||
| 2582 | + } | ||
| 2583 | + | ||
| 2584 | + private List<JSONObject> candidates(JSONArray records, JdyRiskProperties.Scenario s, Biz biz) { | ||
| 2585 | + ArrayList<JSONObject> byCode = new ArrayList<JSONObject>(); | ||
| 2586 | + ArrayList<JSONObject> byScene = new ArrayList<JSONObject>(); | ||
| 2587 | + if (records == null || s == null || s.getSyncCode() == null) { | ||
| 2588 | + return byCode; | ||
| 2589 | + } | ||
| 2590 | + for (int i = 0; i < records.size(); ++i) { | ||
| 549 | JSONObject r = records.getJSONObject(i); | 2591 | JSONObject r = records.getJSONObject(i); |
| 550 | - if (syncCode.equals(r.getString("syncCode"))) { | ||
| 551 | - if (found == null) { | ||
| 552 | - found = r; | ||
| 553 | - } else { | ||
| 554 | - log.warn("syncCode={} 存在多条记录(id={} 与 id={}),使用第一条", | ||
| 555 | - syncCode, found.getString("id"), r.getString("id")); | ||
| 556 | - } | ||
| 557 | - } | 2592 | + if (!s.getSyncCode().equals(r.getString("syncCode"))) continue; |
| 2593 | + byCode.add(r); | ||
| 2594 | + if (!JdyRiskStatisticsService.sceneMatches(r, biz)) continue; | ||
| 2595 | + byScene.add(r); | ||
| 558 | } | 2596 | } |
| 559 | - return found; | 2597 | + if (biz != null && biz.sceneId != null && !byScene.isEmpty()) { |
| 2598 | + return byScene; | ||
| 2599 | + } | ||
| 2600 | + if (byCode.size() > 1 && biz != null && biz.sceneId != null) { | ||
| 2601 | + log.warn("syncCode={} \u5b58\u5728 {} \u6761\u8bb0\u5f55\u4e14\u65e0\u5339\u914d\u573a\u666f {}\uff0c\u4e3a\u907f\u514d\u8bef\u66f4\u65b0\u5c06\u65b0\u589e\u5904\u7406", new Object[]{s.getSyncCode(), byCode.size(), biz.sceneId}); | ||
| 2602 | + return new ArrayList<JSONObject>(); | ||
| 2603 | + } | ||
| 2604 | + return byCode; | ||
| 2605 | + } | ||
| 2606 | + | ||
| 2607 | + private static boolean sceneMatches(JSONObject r, Biz biz) { | ||
| 2608 | + if (biz == null || biz.sceneId == null) { | ||
| 2609 | + return true; | ||
| 2610 | + } | ||
| 2611 | + JSONObject scene = r.getJSONObject("miidqb"); | ||
| 2612 | + String id = scene != null ? scene.getString("id") : r.getString("miidqbId"); | ||
| 2613 | + return biz.sceneId.equals(id); | ||
| 560 | } | 2614 | } |
| 561 | 2615 | ||
| 562 | private static ZonedDateTime quarterStart(ZonedDateTime now) { | 2616 | private static ZonedDateTime quarterStart(ZonedDateTime now) { |
| 563 | - int qStartMonth = ((now.getMonthValue() - 1) / 3) * 3 + 1; | 2617 | + int qStartMonth = (now.getMonthValue() - 1) / 3 * 3 + 1; |
| 564 | return now.withMonth(qStartMonth).withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); | 2618 | return now.withMonth(qStartMonth).withDayOfMonth(1).truncatedTo(ChronoUnit.DAYS); |
| 565 | } | 2619 | } |
| 566 | 2620 | ||
| @@ -570,30 +2624,199 @@ public class JdyRiskStatisticsService { | @@ -570,30 +2624,199 @@ public class JdyRiskStatisticsService { | ||
| 570 | } | 2624 | } |
| 571 | try { | 2625 | try { |
| 572 | return Instant.parse(iso).atZone(ZONE); | 2626 | return Instant.parse(iso).atZone(ZONE); |
| 573 | - } catch (Exception e) { | 2627 | + } |
| 2628 | + catch (Exception e) { | ||
| 574 | return null; | 2629 | return null; |
| 575 | } | 2630 | } |
| 576 | } | 2631 | } |
| 577 | 2632 | ||
| 578 | private static double num(JSONObject row, String field) { | 2633 | private static double num(JSONObject row, String field) { |
| 579 | if (field == null) { | 2634 | if (field == null) { |
| 580 | - return 0d; | 2635 | + return 0.0; |
| 581 | } | 2636 | } |
| 582 | - Object v = row.get(field); | 2637 | + Object v = row.get((Object)field); |
| 583 | if (v == null) { | 2638 | if (v == null) { |
| 584 | - return 0d; | 2639 | + return 0.0; |
| 585 | } | 2640 | } |
| 586 | if (v instanceof Number) { | 2641 | if (v instanceof Number) { |
| 587 | - return ((Number) v).doubleValue(); | 2642 | + return ((Number)v).doubleValue(); |
| 588 | } | 2643 | } |
| 589 | try { | 2644 | try { |
| 590 | return Double.parseDouble(String.valueOf(v)); | 2645 | return Double.parseDouble(String.valueOf(v)); |
| 591 | - } catch (NumberFormatException e) { | ||
| 592 | - return 0d; | 2646 | + } |
| 2647 | + catch (NumberFormatException e) { | ||
| 2648 | + return 0.0; | ||
| 593 | } | 2649 | } |
| 594 | } | 2650 | } |
| 595 | 2651 | ||
| 596 | private static String orEmpty(String s) { | 2652 | private static String orEmpty(String s) { |
| 597 | - return (s == null || s.isEmpty()) ? "(空)" : s; | 2653 | + return s == null || s.isEmpty() ? "(\u7a7a)" : s; |
| 2654 | + } | ||
| 2655 | + | ||
| 2656 | + static { | ||
| 2657 | + BIZ.put("SYNC0001", new Biz("1", "\u4f9b\u5e94\u5546\u7ee9\u6548\u8bc4\u4ef7", "B97s4IjzEBCqYE6162N", "\u6280\u672f\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "ltgYjvQ4Hz4sdq5BA4j", "26MY3mis\u7ef4\u4fee")); | ||
| 2658 | + BIZ.put("SYNC0002", new Biz("1", "\u751f\u4ea7\u8fc7\u7a0b\u8d28\u91cf\u7d22\u8d54\u7ba1\u7406\u4e1a\u52a1\u7ebf", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "ilKV2ucowXkCZLmcRbI", "\u8d23\u4efb\u5224\u5b9aSI-\u4f9b\u5e94\u5546")); | ||
| 2659 | + BIZ.put("SYNC0003", new Biz("1", "\u751f\u4ea7\u8fc7\u7a0b\u8d28\u91cf\u7d22\u8d54\u7ba1\u7406\u4e1a\u52a1\u7ebf", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "Mqn0b2FMTbJPzw5yf2L", "\u8d23\u4efb\u5224\u5b9aSI-\u5de5\u7a0b\u5e08")); | ||
| 2660 | + BIZ.put("SYNC0004", new Biz("1", "\u751f\u4ea7\u8fc7\u7a0b\u8d28\u91cf\u7d22\u8d54\u7ba1\u7406\u4e1a\u52a1\u7ebf", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "JXpTEimiPxT9OyUCdOs", "CR\u7533\u8bc9-\u4f9b\u5e94\u5546")); | ||
| 2661 | + BIZ.put("SYNC0005", new Biz("1", "\u751f\u4ea7\u8fc7\u7a0b\u8d28\u91cf\u7d22\u8d54\u7ba1\u7406\u4e1a\u52a1\u7ebf", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "8UPj3nt0Sx9uZS6dgVF", "CR\u7533\u8bc9-\u5de5\u7a0b\u5e08")); | ||
| 2662 | + BIZ.put("SYNC0006", new Biz("1", "\u4e09\u5305\u7d22\u8d54\u7ba1\u7406", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "J15qNYvHMzMRf9e6RZe", "\u4f9b\u5e94\u5546\u7d22\u8d54\u7387")); | ||
| 2663 | + BIZ.put("SYNC0007", new Biz("1", "\u4e09\u5305\u7d22\u8d54\u7ba1\u7406", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "Utom1MrkvERsdUE6t2z", "\u4e89\u8bae\u7d22\u8d54\u6d41\u7a0b")); | ||
| 2664 | + BIZ.put("SYNC0008", new Biz("1", "\u4e09\u5305\u7d22\u8d54\u7ba1\u7406", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "2Mbjy3qxZuZyLMLZXd7", "\u4e09\u5305\u65e7\u4ef6\u65f6\u957f")); | ||
| 2665 | + BIZ.put("SYNC0010", new Biz("1", "\u5de5\u6599\u5e9f\u7ba1\u7406", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "4obqviBjm3eZqkzcLhp", "CR\u5f00\u542f-\u4f9b\u5e94\u5546")); | ||
| 2666 | + BIZ.put("SYNC0011", new Biz("1", "\u5de5\u6599\u5e9f\u7ba1\u7406", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "WLT9HuAoXw5EAvSvAhR", "CR\u5f00\u542f-\u5de5\u7a0b\u5e08")); | ||
| 2667 | + Biz b9 = new Biz("1", "\u4e09\u5305\u7d22\u8d54\u7ba1\u7406", "qxTEnTMgrphkplbc1ln", "\u8d28\u91cf\u7ba1\u7406\u5904", "h1VpqLbLQBUsGNremKy", "\u5f20\u7389\u6797", "8SUJY8YCGQGNFZ4cy9b", "\u4e09\u5305\u76d8\u70b9"); | ||
| 2668 | + b9.sceneMemberId = "lpbRQ5mmp45qcO2lhce"; | ||
| 2669 | + b9.sceneMemberTitle = "\u9c81\u671d\u51b0"; | ||
| 2670 | + b9.jetcalId = "lpbRQ5mmp45qcO2lhce"; | ||
| 2671 | + b9.jetcalTitle = "\u9c81\u671d\u51b0"; | ||
| 2672 | + b9.zawlah = "1"; | ||
| 2673 | + BIZ.put("SYNC009", b9); | ||
| 2674 | + BIZ.put("SYNC0038", new Biz("5", "\u8d44\u4ea7\u5904\u7f6e\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "9wzxQRZ1UvIl0sByuX0", "\u8d44\u8d28\u5ba1\u6838\u4fe1\u606f\u8ffd\u6eaf")); | ||
| 2675 | + BIZ.put("SYNC0042", new Biz("5", "\u8d44\u4ea7\u5904\u7f6e\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "wTl8JygmpJ6zBzOoHtv", "\u8f66\u8f86\u79bb\u573a\u65f6\u957f\u63a7\u5236")); | ||
| 2676 | + BIZ.put("SYNC0048", new Biz("5", "\u5907\u54c1\u5907\u4ef6\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "DQXs1TRUrrfufZa3HKy", "\u591a\u6b21\u9001\u8d27\u4e0d\u5408\u683c\u6b21\u6570")); | ||
| 2677 | + Biz bx15 = new Biz("5", "\u96f6\u661f\u5de5\u7a0b\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "UbK8GlpSq2eEfmeXLMF", "\u65bd\u5de5\u65b9\u6750\u6599\u6216\u8bb0\u5f55\u4e0d\u7b26"); | ||
| 2678 | + BIZ.put("SYNC0044", bx15); | ||
| 2679 | + BIZ.put("SYNC0045", new Biz("5", "\u96f6\u661f\u5de5\u7a0b\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "z7m71szmZGhyuUFKtUf", "\u9884\u7b97\u91d1\u989d\u4e0e\u7ed3\u7b97\u91d1\u989d\u5dee\u5f02")); | ||
| 2680 | + BIZ.put("SYNC0046", new Biz("5", "\u96f6\u661f\u5de5\u7a0b\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "FtUaPIjcnIT9Yg2U0o3", "\u65bd\u5de5\u5468\u671f\u903e\u671f")); | ||
| 2681 | + BIZ.put("SYNC0047", new Biz("5", "\u96f6\u661f\u5de5\u7a0b\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "V7q6eDgMf1SmzQla1kw", "\u9a8c\u6536\u7ed3\u7b97\u903e\u671f")); | ||
| 2682 | + BIZ.put("SYNC0043", new Biz("5", "\u96f6\u661f\u5de5\u7a0b\u7ba1\u7406", "Ljw92oXLsXrkJsnTBp1", "\u8bbe\u5907\u5de5\u7a0b\u5904", "visMyujHTrS74mR6kaO", "\u5173\u5b58\u5cad", "qSe2WYwCtLJsaNpzDok", "\u540c\u4e00\u4e2a\u7ef4\u4fee\u9879\u76ee\u9891\u6b21")); | ||
| 2683 | + Biz car95 = new Biz("2", "\u7efc\u5408\u4e1a\u52a1\u7ba1\u7406", "5cr2gzxHL2HhgbLVABh", "\u7efc\u5408\u7ba1\u7406\u5904", "hjvIVM2neWcnSWjU22M", "\u5f90\u8000", "K6QPpZ3KZqZoWO3zVG2", "9\u2264\u767e\u516c\u91cc\u6cb9\u8017\u226413L"); | ||
| 2684 | + car95.sceneMemberId = "tWOCv8gguUBWI96ZsLK"; | ||
| 2685 | + car95.sceneMemberTitle = "\u77f3\u96ea\u677e"; | ||
| 2686 | + BIZ.put("SYNC0013", car95); | ||
| 2687 | + Biz car75 = new Biz("2", "\u7efc\u5408\u4e1a\u52a1\u7ba1\u7406", "5cr2gzxHL2HhgbLVABh", "\u7efc\u5408\u7ba1\u7406\u5904", "hjvIVM2neWcnSWjU22M", "\u5f90\u8000", "P9cgaXrq1at8wUS3JbG", "8\u2264\u767e\u516c\u91cc\u6cb9\u8017\u226411L"); | ||
| 2688 | + car75.sceneMemberId = "tWOCv8gguUBWI96ZsLK"; | ||
| 2689 | + car75.sceneMemberTitle = "\u77f3\u96ea\u677e"; | ||
| 2690 | + BIZ.put("SYNC0014", car75); | ||
| 2691 | + Biz carQs = new Biz("2", "\u7efc\u5408\u4e1a\u52a1\u7ba1\u7406", "5cr2gzxHL2HhgbLVABh", "\u7efc\u5408\u7ba1\u7406\u5904", "hjvIVM2neWcnSWjU22M", "\u5f90\u8000", "MmvfUhXphWVkDVbfONP", "9\u2264\u767e\u516c\u91cc\u6cb9\u8017\u226416L"); | ||
| 2692 | + carQs.sceneMemberId = "tWOCv8gguUBWI96ZsLK"; | ||
| 2693 | + carQs.sceneMemberTitle = "\u77f3\u96ea\u677e"; | ||
| 2694 | + BIZ.put("SYNC0015", carQs); | ||
| 2695 | + Biz hr = new Biz("2", "\u4eba\u529b\u8d44\u6e90\u7ba1\u7406", "9csExRXNOnUUsG4yx2I", "\u4eba\u529b\u8d44\u6e90\u5904", "hjvIVM2neWcnSWjU22M", "\u5f90\u8000", "eO1UPvUJF8Zabs2DNUb", "\u52b3\u52a1\u516c\u53f8\u8bc4\u4ef7"); | ||
| 2696 | + hr.sceneMemberId = "nFbc8BKA3U24hSgxYs7"; | ||
| 2697 | + hr.sceneMemberTitle = "\u9f9a\u52cb"; | ||
| 2698 | + BIZ.put("SYNC0016", hr); | ||
| 2699 | + BIZ.put("SYNC0024", JdyRiskStatisticsService.projectBiz("\u5de5\u5e8f\u59d4\u5916\u4e1a\u52a1", "HVJmHWGU9gJrkcQYWb3", "\u59d4\u5916\u4e1a\u52a1\u7ed3\u7b97")); | ||
| 2700 | + BIZ.put("SYNC0025", JdyRiskStatisticsService.projectBiz("\u5de5\u5e8f\u59d4\u5916\u4e1a\u52a1", "A4An2Kg3ix42M9Y7aql", "\u59d4\u5916\u7535\u6cf3\u7ed3\u7b97")); | ||
| 2701 | + BIZ.put("SYNC0026", JdyRiskStatisticsService.projectBiz("\u5de5\u5e8f\u59d4\u5916\u4e1a\u52a1", "CUnoLZZpTDBVQVEZzBZ", "\u59d4\u5916\u4f9b\u5e94\u5546\u7ee9\u6548\u8bc4\u4ef7")); | ||
| 2702 | + BIZ.put("SYNC0017", JdyRiskStatisticsService.projectBiz("\u8d39\u7528\u7c7b\u9879\u76ee\u7ba1\u7406", "wuyC1teVi5cnALPMqQ1", "\u9700\u6c42\u90e8\u95e8\u62a5\u9001\u6ede\u540e3")); | ||
| 2703 | + BIZ.put("SYNC0018", JdyRiskStatisticsService.projectBiz("\u8d39\u7528\u7c7b\u9879\u76ee\u7ba1\u7406", "GHQq0mZk2okvECbVIMY", "\u9700\u6c42\u90e8\u95e8\u62a5\u9001\u6ede\u540e2")); | ||
| 2704 | + BIZ.put("SYNC0019", JdyRiskStatisticsService.projectBiz("\u8d39\u7528\u7c7b\u9879\u76ee\u7ba1\u7406", "YUlLhSKtiTpZ9GfBBZG", "\u9700\u6c42\u90e8\u95e8\u62a5\u9001\u6ede\u540e4")); | ||
| 2705 | + BIZ.put("SYNC0020", JdyRiskStatisticsService.projectBiz("\u8d39\u7528\u7c7b\u9879\u76ee\u7ba1\u7406", "Exo2yffYYWypfAUrHxv", "\u9700\u6c42\u90e8\u95e8\u62a5\u9001\u6ede\u540e1")); | ||
| 2706 | + BIZ.put("SYNC0021", JdyRiskStatisticsService.projectBiz("\u8d39\u7528\u7c7b\u9879\u76ee\u7ba1\u7406", "Csz40PvvroUVxi9SvbR", "\u4e2d\u6807\u4ef7\u504f\u79bb\u7387")); | ||
| 2707 | + BIZ.put("SYNC0022", JdyRiskStatisticsService.projectBiz("\u8d39\u7528\u7c7b\u9879\u76ee\u7ba1\u7406", "SWUrOQSieNbKbDhl443", "\u7d27\u6025\u91c7\u8d2d\u3001\u5f02\u5e38\u76f4\u91c7\u9891\u6b21")); | ||
| 2708 | + BIZ.put("SYNC0023", JdyRiskStatisticsService.projectBiz("\u8d39\u7528\u7c7b\u9879\u76ee\u7ba1\u7406", "hrotOTMz5IzAWQWnONz", "\u5408\u540c\u5f02\u5e38\u53d8\u66f4\u9891\u6b21")); | ||
| 2709 | + BIZ_BY_SCENARIO.put("count_38", JdyRiskStatisticsService.claimBiz("\u7d22\u8d54\u6d41\u7a0b\u8d85\u65f6", "BFYtFTWiEFReBt6dxc4", "\u6d41\u7a0b\u7ed3\u675f\u65f6\u95f4-\u6d41\u7a0b\u5f00\u542f\u65f6\u95f4\u300a=30\u5929", "\u300a=30\u5929")); | ||
| 2710 | + BIZ_BY_SCENARIO.put("count_39", JdyRiskStatisticsService.invBiz("\u4f9b\u5e94\u5546\u7269\u8d44\u9000\u8d27\u91d1\u989dTOP", "RiVJUklIkwHJUVO9xLf", "\u6708\u5ea6\u4f9b\u5e94\u5546\u9000\u8d27\u4e1a\u52a1TOP3\u76d1\u63a7\uff08\u91d1\u989d\uff09\uff08\u9000\u8d27\u91cf*\u5355\u4ef7\uff09\u6c42\u548c", "\u91d1\u989dTOP3\u4f9b\u5e94\u5546")); | ||
| 2711 | + BIZ_BY_SCENARIO.put("count_40", JdyRiskStatisticsService.invBiz("\u4f9b\u5e94\u5546\u7269\u8d44\u9000\u8d27\u6570TOP", "0FXfwGjJ8CYCsFv0CDx", "\u6708\u5ea6\u4f9b\u5e94\u5546\u9000\u8d27\u4e1a\u52a1TOP3\u76d1\u63a7\uff08\u6570\u91cf\uff09", "\u6570\u91cfTOP3\u4f9b\u5e94\u5546")); | ||
| 2712 | + BIZ_BY_SCENARIO.put("count_41", JdyRiskStatisticsService.invBiz("\u5b58\u8d27\u5360\u7528\u8d44\u91d1-\u603b\u88c5A", "wNYg0saI40siQGJicJm", "\u603b\u88c5\u8f66\u95f4A\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528\u8d85\u9608\u503c\n\u5b58\u8d27\u6570\u91cf*\u5355\u4ef7>\u8d44\u91d1\u6307\u6807", "\u603b\u88c5\u8f66\u95f4A\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528<1150\u4e07")); | ||
| 2713 | + BIZ_BY_SCENARIO.put("count_42", JdyRiskStatisticsService.invBiz("\u5b58\u8d27\u5360\u7528\u8d44\u91d1-\u603b\u88c5B", "KXfUZgWng09x5DdvEFi", "\u603b\u88c5\u8f66\u95f4B\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528\u8d85\u9608\u503c\n\u5b58\u8d27\u6570\u91cf*\u5355\u4ef7>\u8d44\u91d1\u6307\u6807", "\u603b\u88c5\u8f66\u95f4B\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528<130\u4e07")); | ||
| 2714 | + BIZ_BY_SCENARIO.put("count_43", JdyRiskStatisticsService.invBiz("\u5b58\u8d27\u5360\u7528\u8d44\u91d1-\u6d82\u88c5A", "7rmQ28Q3P617nxAANyQ", "\u6d82\u88c5\u8f66\u95f4A\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528\u8d85\u9608\u503c\n\u5b58\u8d27\u6570\u91cf*\u5355\u4ef7>\u8d44\u91d1\u6307\u6807", "\u6d82\u88c5\u8f66\u95f4A\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528<6\u4e07")); | ||
| 2715 | + BIZ_BY_SCENARIO.put("count_44", JdyRiskStatisticsService.invBiz("\u5b58\u8d27\u5360\u7528\u8d44\u91d1-\u6d82\u88c5B", "ToQVFlSIDvEIjerQoSY", "\u6d82\u88c5\u8f66\u95f4B\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528\u8d85\u9608\u503c\n\u5b58\u8d27\u6570\u91cf*\u5355\u4ef7>\u8d44\u91d1\u6307\u6807", "\u6d82\u88c5\u8f66\u95f4B\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528<7\u4e07")); | ||
| 2716 | + BIZ_BY_SCENARIO.put("count_45", JdyRiskStatisticsService.invBiz("\u5b58\u8d27\u5360\u7528\u8d44\u91d1-\u710a\u88c5A", "TGfxmTPuPWeGv4B8hfA", "\u710a\u88c5\u8f66\u95f4A\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528\u8d85\u9608\u503c\n\u5b58\u8d27\u6570\u91cf*\u5355\u4ef7>\u8d44\u91d1\u6307\u6807", "\u710a\u88c5\u8f66\u95f4A\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528<150\u4e07")); | ||
| 2717 | + BIZ_BY_SCENARIO.put("count_46", JdyRiskStatisticsService.invBiz("\u5b58\u8d27\u5360\u7528\u8d44\u91d1-\u710a\u88c5B", "BtT3C6zpiMwfzAeQlHO", "\u710a\u88c5\u8f66\u95f4B\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528\u8d85\u9608\u503c\n\u5b58\u8d27\u6570\u91cf*\u5355\u4ef7>\u8d44\u91d1\u6307\u6807", "\u710a\u88c5\u8f66\u95f4B\u7ebf\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528<130\u4e07")); | ||
| 2718 | + BIZ_BY_SCENARIO.put("count_47", JdyRiskStatisticsService.invBiz("\u5b58\u8d27\u5360\u7528\u8d44\u91d1-\u51b2\u538b", "M70TfJpq2Etva4HAegs", "\u51b2\u538b\u8f66\u95f4\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528\u8d85\u9608\u503c\n\u5b58\u8d27\u6570\u91cf*\u5355\u4ef7>\u8d44\u91d1\u6307\u6807", "\u51b2\u538b\u8f66\u95f4\u6750\u6599\u5e93\u5b58\u8d27\u8d44\u91d1\u5360\u7528<170\u4e07")); | ||
| 2719 | + } | ||
| 2720 | + | ||
| 2721 | + private static class Rel { | ||
| 2722 | + final String supplier; | ||
| 2723 | + final boolean enabled; | ||
| 2724 | + final long time; | ||
| 2725 | + | ||
| 2726 | + Rel(String supplier, boolean enabled, long time) { | ||
| 2727 | + this.supplier = supplier; | ||
| 2728 | + this.enabled = enabled; | ||
| 2729 | + this.time = time; | ||
| 2730 | + } | ||
| 2731 | + } | ||
| 2732 | + | ||
| 2733 | + private static class MultiResult { | ||
| 2734 | + long count; | ||
| 2735 | + List<JdyExcelExportService.SheetSpec> sheets = new ArrayList<JdyExcelExportService.SheetSpec>(); | ||
| 2736 | + | ||
| 2737 | + private MultiResult() { | ||
| 2738 | + } | ||
| 2739 | + } | ||
| 2740 | + | ||
| 2741 | + private static class BuiltReason { | ||
| 2742 | + long count; | ||
| 2743 | + JSONArray rows = new JSONArray(); | ||
| 2744 | + List<String> reasons = new ArrayList<String>(); | ||
| 2745 | + | ||
| 2746 | + private BuiltReason() { | ||
| 2747 | + } | ||
| 2748 | + } | ||
| 2749 | + | ||
| 2750 | + private static class BuiltDb { | ||
| 2751 | + long count; | ||
| 2752 | + JSONArray rows = new JSONArray(); | ||
| 2753 | + JSONArray widgets = new JSONArray(); | ||
| 2754 | + List<String> reasons = new ArrayList<String>(); | ||
| 2755 | + | ||
| 2756 | + private BuiltDb() { | ||
| 2757 | + } | ||
| 2758 | + } | ||
| 2759 | + | ||
| 2760 | + private static class Built11 { | ||
| 2761 | + long count; | ||
| 2762 | + JSONArray excelRows; | ||
| 2763 | + JSONArray excelWidgets; | ||
| 2764 | + | ||
| 2765 | + private Built11() { | ||
| 2766 | + } | ||
| 2767 | + } | ||
| 2768 | + | ||
| 2769 | + private static class Context { | ||
| 2770 | + final QxApi qxApi; | ||
| 2771 | + final String token; | ||
| 2772 | + final JiandaoYunApi jdy; | ||
| 2773 | + final JSONArray allRecords; | ||
| 2774 | + | ||
| 2775 | + Context(QxApi qxApi, String token, JiandaoYunApi jdy, JSONArray allRecords) { | ||
| 2776 | + this.qxApi = qxApi; | ||
| 2777 | + this.token = token; | ||
| 2778 | + this.jdy = jdy; | ||
| 2779 | + this.allRecords = allRecords; | ||
| 2780 | + } | ||
| 2781 | + } | ||
| 2782 | + | ||
| 2783 | + private static class CacheEntry { | ||
| 2784 | + final Object value; | ||
| 2785 | + final long expireAt; | ||
| 2786 | + | ||
| 2787 | + CacheEntry(Object value, long expireAt) { | ||
| 2788 | + this.value = value; | ||
| 2789 | + this.expireAt = expireAt; | ||
| 2790 | + } | ||
| 2791 | + } | ||
| 2792 | + | ||
| 2793 | + private static class Biz { | ||
| 2794 | + final String domain; | ||
| 2795 | + final String businessLine; | ||
| 2796 | + final String unitId; | ||
| 2797 | + final String unitTitle; | ||
| 2798 | + final String leaderId; | ||
| 2799 | + final String leaderTitle; | ||
| 2800 | + final String sceneId; | ||
| 2801 | + final String sceneTitle; | ||
| 2802 | + String sceneMemberId; | ||
| 2803 | + String sceneMemberTitle; | ||
| 2804 | + String jetcalId; | ||
| 2805 | + String jetcalTitle; | ||
| 2806 | + String zawlah; | ||
| 2807 | + String sivnbu; | ||
| 2808 | + String ilecyn; | ||
| 2809 | + | ||
| 2810 | + Biz(String domain, String businessLine, String unitId, String unitTitle, String leaderId, String leaderTitle, String sceneId, String sceneTitle) { | ||
| 2811 | + this.domain = domain; | ||
| 2812 | + this.businessLine = businessLine; | ||
| 2813 | + this.unitId = unitId; | ||
| 2814 | + this.unitTitle = unitTitle; | ||
| 2815 | + this.leaderId = leaderId; | ||
| 2816 | + this.leaderTitle = leaderTitle; | ||
| 2817 | + this.sceneId = sceneId; | ||
| 2818 | + this.sceneTitle = sceneTitle; | ||
| 2819 | + } | ||
| 598 | } | 2820 | } |
| 599 | } | 2821 | } |
| 2822 | + |
| 1 | package com.qgutech.qgyun.apaas.sync.jdy.task; | 1 | package com.qgutech.qgyun.apaas.sync.jdy.task; |
| 2 | 2 | ||
| 3 | +import com.qgutech.qgyun.apaas.sync.jdy.config.JdyRiskProperties; | ||
| 3 | import com.qgutech.qgyun.apaas.sync.jdy.config.JdySyncProperties; | 4 | import com.qgutech.qgyun.apaas.sync.jdy.config.JdySyncProperties; |
| 5 | +import com.qgutech.qgyun.apaas.sync.jdy.service.JdyRiskStatisticsService; | ||
| 4 | import com.qgutech.qgyun.apaas.sync.jdy.service.JdyToQxSyncService; | 6 | import com.qgutech.qgyun.apaas.sync.jdy.service.JdyToQxSyncService; |
| 5 | import lombok.extern.slf4j.Slf4j; | 7 | import lombok.extern.slf4j.Slf4j; |
| 6 | import org.springframework.scheduling.annotation.Scheduled; | 8 | import org.springframework.scheduling.annotation.Scheduled; |
| @@ -10,7 +12,8 @@ import javax.annotation.Resource; | @@ -10,7 +12,8 @@ import javax.annotation.Resource; | ||
| 10 | import java.util.List; | 12 | import java.util.List; |
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| 13 | - * 简道云 -> 启效 每日定时同步任务。 | 15 | + * 简道云 -> 启效 定时同步任务。 |
| 16 | + * <p>含:每日表单同步、设备域场景12(每月1号)/场景13(每月10号)风险统计回写。</p> | ||
| 14 | */ | 17 | */ |
| 15 | @Slf4j | 18 | @Slf4j |
| 16 | @Component | 19 | @Component |
| @@ -22,6 +25,12 @@ public class JdySyncScheduledTask { | @@ -22,6 +25,12 @@ public class JdySyncScheduledTask { | ||
| 22 | @Resource | 25 | @Resource |
| 23 | private JdySyncProperties props; | 26 | private JdySyncProperties props; |
| 24 | 27 | ||
| 28 | + @Resource | ||
| 29 | + private JdyRiskStatisticsService riskService; | ||
| 30 | + | ||
| 31 | + @Resource | ||
| 32 | + private JdyRiskProperties riskProps; | ||
| 33 | + | ||
| 25 | @Scheduled(cron = "${jdy-sync.cron:0 0 2 * * ?}") | 34 | @Scheduled(cron = "${jdy-sync.cron:0 0 2 * * ?}") |
| 26 | public void dailySync() { | 35 | public void dailySync() { |
| 27 | if (!props.isEnabled()) { | 36 | if (!props.isEnabled()) { |
| @@ -32,4 +41,267 @@ public class JdySyncScheduledTask { | @@ -32,4 +41,267 @@ public class JdySyncScheduledTask { | ||
| 32 | List<String> result = syncService.syncAll(); | 41 | List<String> result = syncService.syncAll(); |
| 33 | result.forEach(r -> log.info("同步结果: {}", r)); | 42 | result.forEach(r -> log.info("同步结果: {}", r)); |
| 34 | } | 43 | } |
| 44 | + | ||
| 45 | + /** 质量域场景1(SYNC0001 供应商绩效评价-26MY 3mis维修记录):每月20号抓取上月数据。 */ | ||
| 46 | + @Scheduled(cron = "${jdy-risk.schedule.s1-cron:0 0 3 20 * ?}") | ||
| 47 | + public void monthlySyncS1() { | ||
| 48 | + if (!riskProps.getSchedule().isEnabled()) { | ||
| 49 | + log.info("jdy-risk.schedule.enabled=false,跳过场景1定时抓取"); | ||
| 50 | + return; | ||
| 51 | + } | ||
| 52 | + log.info("========== 定时抓取 质量域场景1(SYNC0001) =========="); | ||
| 53 | + log.info("场景1结果: {}", riskService.countAndSyncOne("SYNC0001")); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** 质量域场景2(SYNC0002 供应商 SI 占比):每月5号抓上月。 */ | ||
| 57 | + @Scheduled(cron = "${jdy-risk.schedule.s2-cron:0 0 3 5 * ?}") | ||
| 58 | + public void monthlySyncS2() { runQuality("场景2", "SYNC0002"); } | ||
| 59 | + | ||
| 60 | + /** 质量域场景3(SYNC0003 工程师 SI 占比):每月5号抓上月。 */ | ||
| 61 | + @Scheduled(cron = "${jdy-risk.schedule.s3-cron:0 0 3 5 * ?}") | ||
| 62 | + public void monthlySyncS3() { runQuality("场景3", "SYNC0003"); } | ||
| 63 | + | ||
| 64 | + /** 质量域场景4(SYNC0004 CR升级-供应商):1/4/7/10月5号抓上一季度。 */ | ||
| 65 | + @Scheduled(cron = "${jdy-risk.schedule.s4-cron:0 0 3 5 1,4,7,10 ?}") | ||
| 66 | + public void quarterlySyncS4() { runQuality("场景4", "SYNC0004"); } | ||
| 67 | + | ||
| 68 | + /** 质量域场景5(SYNC0005 CR升级-工程师):1/4/7/10月5号抓上一季度。 */ | ||
| 69 | + @Scheduled(cron = "${jdy-risk.schedule.s5-cron:0 0 3 5 1,4,7,10 ?}") | ||
| 70 | + public void quarterlySyncS5() { runQuality("场景5", "SYNC0005"); } | ||
| 71 | + | ||
| 72 | + /** 质量域场景6(SYNC0006 索赔率差值):每月最后一天23点抓当月(每天23点触发,月末执行)。 */ | ||
| 73 | + @Scheduled(cron = "${jdy-risk.schedule.s6-cron:0 0 23 * * ?}") | ||
| 74 | + public void monthlySyncS6() { | ||
| 75 | + if (!isLastDayOfMonth()) { | ||
| 76 | + log.info("非月末,跳过场景6定时抓取"); | ||
| 77 | + return; | ||
| 78 | + } | ||
| 79 | + runQuality("场景6", "SYNC0006"); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** 质量域场景7(SYNC0007 经销商三包索赔):每月5号抓上月。 */ | ||
| 83 | + @Scheduled(cron = "${jdy-risk.schedule.s7-cron:0 0 3 5 * ?}") | ||
| 84 | + public void monthlySyncS7() { runQuality("场景7", "SYNC0007"); } | ||
| 85 | + | ||
| 86 | + /** 质量域场景8(SYNC0008 三包库房超期未处理):每月5号,按上月末增量统计超期。 */ | ||
| 87 | + @Scheduled(cron = "${jdy-risk.schedule.s8-cron:0 0 3 5 * ?}") | ||
| 88 | + public void monthlySyncS8() { runQuality("场景8", "SYNC0008"); } | ||
| 89 | + | ||
| 90 | + /** 质量域场景9(SYNC0010 供应商未开CR):每月5号抓上月。 */ | ||
| 91 | + @Scheduled(cron = "${jdy-risk.schedule.s9-cron:0 0 3 5 * ?}") | ||
| 92 | + public void monthlySyncS9() { runQuality("场景9", "SYNC0010"); } | ||
| 93 | + | ||
| 94 | + /** 质量域场景10(SYNC0011 工程师未开CR):每月5号抓上月。 */ | ||
| 95 | + @Scheduled(cron = "${jdy-risk.schedule.s10-cron:0 0 3 5 * ?}") | ||
| 96 | + public void monthlySyncS10() { runQuality("场景10", "SYNC0011"); } | ||
| 97 | + | ||
| 98 | + /** 设备域场景12(SYNC0034):每月1号抓取当年数据。 */ | ||
| 99 | + @Scheduled(cron = "${jdy-risk.schedule.s12-cron:0 0 3 1 * ?}") | ||
| 100 | + public void monthlySyncS12() { | ||
| 101 | + if (!riskProps.getSchedule().isEnabled()) { | ||
| 102 | + log.info("jdy-risk.schedule.enabled=false,跳过场景12定时抓取"); | ||
| 103 | + return; | ||
| 104 | + } | ||
| 105 | + log.info("========== 定时抓取 设备域场景12(SYNC0034) =========="); | ||
| 106 | + log.info("场景12结果: {}", riskService.countAndSyncOne("SYNC0034")); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + /** 设备域场景13(SYNC0042):每月10号抓取上月数据。 */ | ||
| 110 | + @Scheduled(cron = "${jdy-risk.schedule.s13-cron:0 0 3 10 * ?}") | ||
| 111 | + public void monthlySyncS13() { | ||
| 112 | + if (!riskProps.getSchedule().isEnabled()) { | ||
| 113 | + log.info("jdy-risk.schedule.enabled=false,跳过场景13定时抓取"); | ||
| 114 | + return; | ||
| 115 | + } | ||
| 116 | + log.info("========== 定时抓取 设备域场景13(SYNC0042) =========="); | ||
| 117 | + log.info("场景13结果: {}", riskService.countAndSyncOne("SYNC0042")); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + /** 设备域场景14(SYNC0048):每年12月20日抓取当年数据。 */ | ||
| 121 | + @Scheduled(cron = "${jdy-risk.schedule.s14-cron:0 0 3 20 12 ?}") | ||
| 122 | + public void yearlySyncS14() { | ||
| 123 | + run("场景14", "SYNC0048"); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** 设备域场景15(SYNC0044):每月1号抓取上月数据。 */ | ||
| 127 | + @Scheduled(cron = "${jdy-risk.schedule.s15-cron:0 0 3 1 * ?}") | ||
| 128 | + public void monthlySyncS15() { | ||
| 129 | + run("场景15", "SYNC0044"); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** 设备域场景16(SYNC0045):每月最后一天23点抓取当月数据(每天23点触发,月末才执行)。 */ | ||
| 133 | + @Scheduled(cron = "${jdy-risk.schedule.s16-cron:0 0 23 * * ?}") | ||
| 134 | + public void monthlySyncS16() { | ||
| 135 | + if (!isLastDayOfMonth()) { | ||
| 136 | + log.info("非月末,跳过场景16定时抓取"); | ||
| 137 | + return; | ||
| 138 | + } | ||
| 139 | + run("场景16", "SYNC0045"); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** 设备域场景17(SYNC0046):每月1号抓取上月数据(以更新日期)。 */ | ||
| 143 | + @Scheduled(cron = "${jdy-risk.schedule.s17-cron:0 0 3 1 * ?}") | ||
| 144 | + public void monthlySyncS17() { | ||
| 145 | + run("场景17", "SYNC0046"); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + /** 设备域场景18(SYNC0047):每月最后一天23点抓取当月数据(每天23点触发,月末才执行)。 */ | ||
| 149 | + @Scheduled(cron = "${jdy-risk.schedule.s18-cron:0 0 23 * * ?}") | ||
| 150 | + public void monthlySyncS18() { | ||
| 151 | + if (!isLastDayOfMonth()) { | ||
| 152 | + log.info("非月末,跳过场景18定时抓取"); | ||
| 153 | + return; | ||
| 154 | + } | ||
| 155 | + run("场景18", "SYNC0047"); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + /** 设备域场景19(SYNC0043):每月1号1点抓取上月数据。 */ | ||
| 159 | + @Scheduled(cron = "${jdy-risk.schedule.s19-cron:0 0 1 1 * ?}") | ||
| 160 | + public void monthlySyncS19() { | ||
| 161 | + run("场景19", "SYNC0043"); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + /** 设备域场景20(SYNC0039 废料预警,人大金仓):每月12号 01:00 抓上月数据。 */ | ||
| 165 | + @Scheduled(cron = "${jdy-risk.schedule.s20-cron:0 0 1 12 * ?}") | ||
| 166 | + public void monthlySyncS20() { | ||
| 167 | + run("场景20", "count_20"); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + /** 设备域场景21(SYNC0040 过磅记录,人大金仓):每月11号 01:00 抓1-10号数据。 */ | ||
| 171 | + @Scheduled(cron = "${jdy-risk.schedule.s21a-cron:0 0 1 11 * ?}") | ||
| 172 | + public void monthlySyncS21a() { | ||
| 173 | + run("场景21", "count_21"); | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + /** 设备域场景21(SYNC0040):每月21号 01:00 抓11-20号数据。 */ | ||
| 177 | + @Scheduled(cron = "${jdy-risk.schedule.s21b-cron:0 0 1 21 * ?}") | ||
| 178 | + public void monthlySyncS21b() { | ||
| 179 | + run("场景21", "count_21"); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + /** 设备域场景21(SYNC0040):每月最后一天 23:00 抓21号至月底数据(每天23点触发,月末执行)。 */ | ||
| 183 | + @Scheduled(cron = "${jdy-risk.schedule.s21c-cron:0 0 23 * * ?}") | ||
| 184 | + public void monthlySyncS21c() { | ||
| 185 | + if (!isLastDayOfMonth()) { | ||
| 186 | + log.info("非月末,跳过场景21(21号至月底)定时抓取"); | ||
| 187 | + return; | ||
| 188 | + } | ||
| 189 | + run("场景21", "count_21"); | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + /** 设备域场景22(SYNC0041 运输异常,人大金仓):每月1号 01:00 抓上月数据。 */ | ||
| 193 | + @Scheduled(cron = "${jdy-risk.schedule.s22-cron:0 0 1 1 * ?}") | ||
| 194 | + public void monthlySyncS22() { | ||
| 195 | + run("场景22", "count_22"); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + /** 管理域场景23(SYNC0013 CS95 油耗):每月1号抓上月16号~月底,16号抓当月1号~15号。 */ | ||
| 199 | + @Scheduled(cron = "${jdy-risk.schedule.s23-cron:0 0 1 1,16 * ?}") | ||
| 200 | + public void monthlySyncS23() { | ||
| 201 | + run("场景23", "SYNC0013"); | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + /** 管理域场景24(SYNC0014 CS75 油耗):每月1号抓上月16号~月底,16号抓当月1号~15号。 */ | ||
| 205 | + @Scheduled(cron = "${jdy-risk.schedule.s24-cron:0 0 1 1,16 * ?}") | ||
| 206 | + public void monthlySyncS24() { | ||
| 207 | + run("场景24", "SYNC0014"); | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + /** 管理域场景25(SYNC0015 全顺 油耗):每月1号抓上月16号~月底,16号抓当月1号~15号。 */ | ||
| 211 | + @Scheduled(cron = "${jdy-risk.schedule.s25-cron:0 0 1 1,16 * ?}") | ||
| 212 | + public void monthlySyncS25() { | ||
| 213 | + run("场景25", "SYNC0015"); | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + /** 场景26(SYNC0016 劳务公司评价):每月1号1点抓本月前三个月数据。 */ | ||
| 217 | + @Scheduled(cron = "${jdy-risk.schedule.s26-cron:0 0 1 1 * ?}") | ||
| 218 | + public void monthlySyncS26() { | ||
| 219 | + run("场景26", "SYNC0016"); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + @Scheduled(cron = "${jdy-risk.schedule.s28-cron:0 0 23 * * ?}") | ||
| 223 | + public void monthlySyncS28() { if (isLastDayOfMonth()) { run("场景28", "SYNC0024"); } } | ||
| 224 | + | ||
| 225 | + @Scheduled(cron = "${jdy-risk.schedule.s29-cron:0 0 23 * * ?}") | ||
| 226 | + public void monthlySyncS29() { if (isLastDayOfMonth()) { run("场景29", "SYNC0025"); } } | ||
| 227 | + | ||
| 228 | + @Scheduled(cron = "${jdy-risk.schedule.s30-cron:0 0 23 * * ?}") | ||
| 229 | + public void monthlySyncS30() { if (isLastDayOfMonth()) { run("场景30", "SYNC0026"); } } | ||
| 230 | + | ||
| 231 | + @Scheduled(cron = "${jdy-risk.schedule.s31-cron:0 0 1 1 1,4,7,10 ?}") | ||
| 232 | + public void quarterlySyncS31() { run("场景31", "SYNC0017"); } | ||
| 233 | + | ||
| 234 | + @Scheduled(cron = "${jdy-risk.schedule.s32-cron:0 0 1 1 1,4,7,10 ?}") | ||
| 235 | + public void quarterlySyncS32() { run("场景32", "SYNC0018"); } | ||
| 236 | + | ||
| 237 | + @Scheduled(cron = "${jdy-risk.schedule.s33-cron:0 0 1 1 1,4,7,10 ?}") | ||
| 238 | + public void quarterlySyncS33() { run("场景33", "SYNC0019"); } | ||
| 239 | + | ||
| 240 | + @Scheduled(cron = "${jdy-risk.schedule.s34-cron:0 0 1 1 1,4,7,10 ?}") | ||
| 241 | + public void quarterlySyncS34() { run("场景34", "SYNC0020"); } | ||
| 242 | + | ||
| 243 | + @Scheduled(cron = "${jdy-risk.schedule.s35-cron:0 0 1 1 1,4,7,10 ?}") | ||
| 244 | + public void quarterlySyncS35() { run("场景35", "SYNC0021"); } | ||
| 245 | + | ||
| 246 | + @Scheduled(cron = "${jdy-risk.schedule.s36-cron:0 0 1 1 1,4,7,10 ?}") | ||
| 247 | + public void quarterlySyncS36() { run("场景36", "SYNC0022"); } | ||
| 248 | + | ||
| 249 | + @Scheduled(cron = "${jdy-risk.schedule.s37-cron:0 0 23 31 12 ?}") | ||
| 250 | + public void yearlySyncS37() { run("场景37", "SYNC0023"); } | ||
| 251 | + | ||
| 252 | + /** 场景38(SYNC0036 索赔流程超时):每月10号抓上月。 */ | ||
| 253 | + @Scheduled(cron = "${jdy-risk.schedule.s38-cron:0 0 3 10 * ?}") | ||
| 254 | + public void monthlySyncS38() { run("场景38", "count_38"); } | ||
| 255 | + | ||
| 256 | + /** 场景39/40(SYNC0027/0028 退货TOP3):每月5号抓上月。 */ | ||
| 257 | + @Scheduled(cron = "${jdy-risk.schedule.s39-cron:0 0 3 5 * ?}") | ||
| 258 | + public void monthlySyncS39() { run("场景39", "count_39"); } | ||
| 259 | + | ||
| 260 | + @Scheduled(cron = "${jdy-risk.schedule.s40-cron:0 0 3 5 * ?}") | ||
| 261 | + public void monthlySyncS40() { run("场景40", "count_40"); } | ||
| 262 | + | ||
| 263 | + /** 场景41~47(SYNC0029~SYNC0035 库存资金占用):每月5号抓上月。 */ | ||
| 264 | + @Scheduled(cron = "${jdy-risk.schedule.s41-cron:0 0 3 5 * ?}") | ||
| 265 | + public void monthlySyncS41() { run("场景41", "count_41"); } | ||
| 266 | + | ||
| 267 | + @Scheduled(cron = "${jdy-risk.schedule.s42-cron:0 0 3 5 * ?}") | ||
| 268 | + public void monthlySyncS42() { run("场景42", "count_42"); } | ||
| 269 | + | ||
| 270 | + @Scheduled(cron = "${jdy-risk.schedule.s43-cron:0 0 3 5 * ?}") | ||
| 271 | + public void monthlySyncS43() { run("场景43", "count_43"); } | ||
| 272 | + | ||
| 273 | + @Scheduled(cron = "${jdy-risk.schedule.s44-cron:0 0 3 5 * ?}") | ||
| 274 | + public void monthlySyncS44() { run("场景44", "count_44"); } | ||
| 275 | + | ||
| 276 | + @Scheduled(cron = "${jdy-risk.schedule.s45-cron:0 0 3 5 * ?}") | ||
| 277 | + public void monthlySyncS45() { run("场景45", "count_45"); } | ||
| 278 | + | ||
| 279 | + @Scheduled(cron = "${jdy-risk.schedule.s46-cron:0 0 3 5 * ?}") | ||
| 280 | + public void monthlySyncS46() { run("场景46", "count_46"); } | ||
| 281 | + | ||
| 282 | + @Scheduled(cron = "${jdy-risk.schedule.s47-cron:0 0 3 5 * ?}") | ||
| 283 | + public void monthlySyncS47() { run("场景47", "count_47"); } | ||
| 284 | + | ||
| 285 | + private static boolean isLastDayOfMonth() { | ||
| 286 | + java.time.LocalDate now = java.time.LocalDate.now(java.time.ZoneId.of("Asia/Shanghai")); | ||
| 287 | + return now.getDayOfMonth() == now.lengthOfMonth(); | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + private void runQuality(String label, String syncCode) { | ||
| 291 | + if (!riskProps.getSchedule().isEnabled()) { | ||
| 292 | + log.info("jdy-risk.schedule.enabled=false,跳过{}定时抓取", label); | ||
| 293 | + return; | ||
| 294 | + } | ||
| 295 | + log.info("========== 定时抓取 质量域{}({}) ==========", label, syncCode); | ||
| 296 | + log.info("{}结果: {}", label, riskService.countAndSyncOne(syncCode)); | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + private void run(String label, String syncCode) { | ||
| 300 | + if (!riskProps.getSchedule().isEnabled()) { | ||
| 301 | + log.info("jdy-risk.schedule.enabled=false,跳过{}定时抓取", label); | ||
| 302 | + return; | ||
| 303 | + } | ||
| 304 | + log.info("========== 定时抓取 设备域{}({}) ==========", label, syncCode); | ||
| 305 | + log.info("{}结果: {}", label, riskService.countAndSyncOne(syncCode)); | ||
| 306 | + } | ||
| 35 | } | 307 | } |
| 1 | package com.qgutech.qgyun.apaas.sync.jdy.util; | 1 | package com.qgutech.qgyun.apaas.sync.jdy.util; |
| 2 | 2 | ||
| 3 | +import org.apache.http.client.config.RequestConfig; | ||
| 3 | import org.apache.http.config.Registry; | 4 | import org.apache.http.config.Registry; |
| 4 | import org.apache.http.config.RegistryBuilder; | 5 | import org.apache.http.config.RegistryBuilder; |
| 5 | import org.apache.http.conn.socket.ConnectionSocketFactory; | 6 | import org.apache.http.conn.socket.ConnectionSocketFactory; |
| @@ -64,9 +65,15 @@ public class SSLClientCustom { | @@ -64,9 +65,15 @@ public class SSLClientCustom { | ||
| 64 | * @throws Exception | 65 | * @throws Exception |
| 65 | */ | 66 | */ |
| 66 | public static CloseableHttpClient getHttpClinet() throws Exception { | 67 | public static CloseableHttpClient getHttpClinet() throws Exception { |
| 68 | + RequestConfig requestConfig = RequestConfig.custom() | ||
| 69 | + .setConnectTimeout(30000) | ||
| 70 | + .setConnectionRequestTimeout(30000) | ||
| 71 | + .setSocketTimeout(120000) | ||
| 72 | + .build(); | ||
| 67 | CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory) | 73 | CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory) |
| 68 | .setConnectionManager(poolingHttpClientConnectionManager) | 74 | .setConnectionManager(poolingHttpClientConnectionManager) |
| 69 | .setConnectionManagerShared(true) | 75 | .setConnectionManagerShared(true) |
| 76 | + .setDefaultRequestConfig(requestConfig) | ||
| 70 | .build(); | 77 | .build(); |
| 71 | return httpClient; | 78 | return httpClient; |
| 72 | } | 79 | } |
start.bat
0 → 100644
stop.bat
0 → 100644
| 1 | +@echo off | ||
| 2 | +chcp 65001 >nul | ||
| 3 | +echo 停止 qx-apaas-sync 应用 ... | ||
| 4 | +powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter \"Name='java.exe'\" | Where-Object { $_.CommandLine -like '*qx-apaas-sync*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force; Write-Output ('已停止 PID=' + $_.ProcessId) }" | ||
| 5 | +echo 完成 | ||
| 6 | +pause |
tail.bat
0 → 100644
| 1 | +@echo off | ||
| 2 | +chcp 65001 >nul | ||
| 3 | +rem 实时查看日志文件(应用已在运行;日志文件为 logs\spring.log) | ||
| 4 | +cd /d "%~dp0" | ||
| 5 | +if not exist "logs\spring.log" ( | ||
| 6 | + echo 未找到 logs\spring.log,请先用 run.bat / start.bat 启动应用 | ||
| 7 | + pause | ||
| 8 | + exit /b 1 | ||
| 9 | +) | ||
| 10 | +powershell -NoProfile -Command "Get-Content -Path '.\logs\spring.log' -Wait -Tail 60 -Encoding UTF8" |