| | |
| | | export function companySync (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/company/syncAll', data) |
| | | } |
| | | export function companySyncDingding (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/company/syncAllDingding', data) |
| | | } |
| | | // å页æ¥è¯¢ |
| | | export function companyGetList (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/company/page', data) |
| | |
| | | trim: true |
| | | }) |
| | | } |
| | | // é¨é¨ä¿¡æ¯åæ¥ |
| | | // ä¿¡æ¯åæ¥ |
| | | export function memberSync (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/member/syncAll', data) |
| | | } |
| | | export function memberSyncDingding (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/member/syncAllDingding', data) |
| | | } |
| | | export function delHkForce (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/member/delHkForce', data) |
| | | } |
| | |
| | | <el-form-item label="æåºç " prop="sortnum"> |
| | | <el-input v-model="form.sortnum" placeholder="请è¾å
¥æåºç " v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="ç»ç»ç±»å" prop="type" v-if="(editType === 'edit' && parentId) || (editType === 'add')"> |
| | | <el-form-item label="ç»ç»ç±»å" prop="type" v-if="(editType === 'edit' && parentId) || (editType === 'add')" > |
| | | <el-radio-group v-model="form.type" :disabled="(editType === 'edit') || (!!(editType === 'add' && parentId))"> |
| | | <el-radio :label="0">ç¸å
³æ¹ç»ç»</el-radio> |
| | | <el-radio :label="1">å
é¨ç»ç»</el-radio> |
| | | <!-- <el-radio :label="1">å
é¨ç»ç»</el-radio>--> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-form> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <TableLayout :permissions="['business:category:query']"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="120px" inline> |
| | | <el-form-item label="广ååç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" clearable placeholder="请è¾å
¥å¹¿ååç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <ul class="toolbar" v-permissions="['business:category:create','business:category:delete']"> |
| | | <li><el-button type="primary" @click="$refs.OperaCategoryFileWindow.open('æ°å»ºå¹¿å')" icon="el-icon-plus" v-permissions="['business:category:create']">æ°å»º</el-button></li> |
| | | <li><el-button type="danger" @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:category:delete']">æ¹éå é¤</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="name" show-overflow-tooltip label="广å" min-width="120px"></el-table-column> |
| | | <el-table-column prop="imgurl" show-overflow-tooltip label="" min-width="120px"> |
| | | <template slot-scope="{row}"> |
| | | <el-image v-if="row.imgurlFull" style="width: 60px; height: 60px" :src="row.imgurlFull" |
| | | :preview-src-list="[row.imgurlFull]"> |
| | | </el-image> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="sortnum" label="æåºç " min-width="70px"></el-table-column> |
| | | <el-table-column prop="editDate" label="æä½æ¶é´" width="160px"></el-table-column> |
| | | <el-table-column |
| | | v-if="containPermissions(['business:category:update', 'business:category:delete' ])" |
| | | label="æä½" |
| | | min-width="140" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" icon="el-icon-edit" @click="$refs.OperaCategoryFileWindow.open('ç¼è¾å¹¿å',row)" v-permissions="['business:category:update']">ç¼è¾</el-button> |
| | | <el-button type="text" icon="el-icon-delete" @click="deleteById(row)" style="color: red" v-permissions="['business:category:delete']">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </template> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaCategoryFileWindow ref="OperaCategoryFileWindow" @success="handlePageChange"/> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaCategoryFileWindow from '@/components/business/OperaCategoryFileWindow' |
| | | export default { |
| | | name: 'areaSet', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaCategoryFileWindow }, |
| | | data () { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | name: '', |
| | | type: 4 |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: '广å', |
| | | api: '/business/category', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | } |
| | | } |
| | | </script> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <TableLayout :permissions="['business:category:query']"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="120px" inline> |
| | | <el-form-item label="主线路åç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" clearable placeholder="请è¾å
¥ä¸»çº¿è·¯åç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <ul class="toolbar" v-permissions="['business:category:create','business:category:delete']"> |
| | | <li><el-button type="primary" @click="$refs.OperaCategoryFileWindow.open('æ°å»ºä¸»çº¿è·¯')" icon="el-icon-plus" v-permissions="['business:category:create']">æ°å»º</el-button></li> |
| | | <li><el-button type="danger" @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:category:delete']">æ¹éå é¤</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="name" show-overflow-tooltip label="主线路" min-width="120px"></el-table-column> |
| | | <el-table-column prop="sortnum" label="æåºç " min-width="70px"></el-table-column> |
| | | <el-table-column prop="editDate" label="æä½æ¶é´" width="160px"></el-table-column> |
| | | <el-table-column |
| | | v-if="containPermissions(['business:category:update', 'business:category:delete' ])" |
| | | label="æä½" |
| | | min-width="140" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" icon="el-icon-edit" @click="$refs.OperaCategoryFileWindow.open('ç¼è¾ä¸»çº¿è·¯',row)" v-permissions="['business:category:update']">ç¼è¾</el-button> |
| | | <el-button type="text" icon="el-icon-delete" @click="deleteById(row)" style="color: red" v-permissions="['business:category:delete']">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </template> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaCategoryFileWindow ref="OperaCategoryFileWindow" @success="handlePageChange"/> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaCategoryFileWindow from '@/components/business/OperaCategoryFileWindow' |
| | | export default { |
| | | name: 'areaSet', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaCategoryFileWindow }, |
| | | data () { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | name: '', |
| | | type: 4 |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: '主线路', |
| | | api: '/business/category', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | } |
| | | } |
| | | </script> |
| | |
| | | { key: 1, name: 'å¤åè¿è¾è½¦è¾' }, |
| | | { key: 2, name: 'å¸å
¬å¸å¸è´§è½¦è¾' }, |
| | | { key: 3, name: 'å å·¥çå¸è´§è½¦è¾' }, |
| | | { key: 4, name: 'ç©æµå
¬å¡ç¨è½¦' }, |
| | | { key: 5, name: 'ç©æµè´§è¿è½¦è¾' }, |
| | | { key: 4, name: 'èªæå
¬å¡è½¦' }, |
| | | { key: 5, name: 'èªæè´§è¿è½¦è¾' }, |
| | | { key: 6, name: 'æªç¥è½¦è¾' } |
| | | ] |
| | | } |
| | |
| | | v-permissions="['business:company:sort']">ä¸ç§»</el-button></li> |
| | | <li><el-button type="primary" v-permissions="['business:company:sync']" :loading="loading" |
| | | @click="synchronous()">忥</el-button></li> |
| | | <li><el-button type="primary" v-permissions="['business:company:create']" :loading="loading" |
| | | @click="synchronousDingding()">忥éé</el-button></li> |
| | | </ul> |
| | | <el-table :max-height="tableHeight" v-loading="isWorking.search" :data="list" stripe |
| | | :tree-props="{ children: 'childList', hasChildren: 'hasChildren' }" row-key="id" |
| | |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" |
| | | @click="$refs.OperaInternalCompanyWindow.open('ç¼è¾ä¼ä¸ä¿¡æ¯', { id: row.parentId, name: row.parentName, type: row.parentType, companyPath: row.parentCompanyPath }, row, 'edit')" |
| | | icon="el-icon-edit" v-permissions="['business:company:update']">ç¼è¾</el-button> |
| | | icon="el-icon-edit" v-permissions="['business:company:update']" v-if="row.type ==0">ç¼è¾</el-button> |
| | | <el-button type="text" @click="$refs.OperaInternalCompanyWindow.open('æ°å»ºå级', row, null, 'add')" |
| | | icon="el-icon-plus">æ°å»ºå级</el-button> |
| | | <el-button type="text" @click="deleteById(row)" style="color: red" icon="el-icon-delete" |
| | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import { companySync, sort } from '@/api/business/company' |
| | | import { companySync,companySyncDingding, sort } from '@/api/business/company' |
| | | import OperaInternalCompanyWindow from '@/components/business/OperaInternalCompanyWindow' |
| | | export default { |
| | | name: 'internalCompany', |
| | |
| | | }) |
| | | .catch(() => { }) |
| | | }, |
| | | async synchronousDingding() { |
| | | this.$dialog.actionConfirm('该æä½å°ç³»ç»æ¸
空已æå
é¨ç»ç»ä¿¡æ¯ï¼æ¨ç¡®è®¤åæ¥å
¨é¨ä¿¡æ¯åï¼', 'æä½ç¡®è®¤æé') |
| | | .then(() => { |
| | | this.loading = true |
| | | companySyncDingding({}) |
| | | .then(res => { |
| | | this.$tip.apiSuccess(res || '忥æå') |
| | | this.search() |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.loading = false |
| | | }) |
| | | }) |
| | | .catch(() => { }) |
| | | }, |
| | | // æåº |
| | | sort(direction) { |
| | | if (this.sorting) { |
| | |
| | | <ul class="toolbar" v-permissions="['business:member:delete', 'business:member:create,business:empower:create']"> |
| | | <li><el-button type="primary" v-permissions="['business:member:sync']" :loading="loading" |
| | | @click="synchronous()">忥</el-button></li> |
| | | <li><el-button type="primary" |
| | | <li><el-button type="primary" v-permissions="['business:member:create']" :loading="loading" |
| | | @click="synchronousDingding()">忥éé</el-button></li> |
| | | <!-- <li><el-button type="primary" |
| | | @click="add" icon="el-icon-plus" |
| | | v-permissions="['business:member:create']">æ°å»ºåå·¥</el-button></li> |
| | | <li><el-button type="primary" @click="$refs.OperaMemberImportWindow.open('人å导å
¥', searchForm.companyType)" |
| | | icon="el-icon-plus" v-permissions="['business:member:create']">人å导å
¥</el-button></li> |
| | | <li><el-button type="danger" @click="deleteByIdInBatch" icon="el-icon-delete" |
| | | v-permissions="['business:member:delete']">æ¹éå é¤</el-button></li> |
| | | v-permissions="['business:member:delete']">æ¹éå é¤</el-button></li>--> |
| | | <li><el-button type="primary" v-permissions="['business:empower:create']" |
| | | @click="startEmpowerBatch()">ä¸åææ</el-button></li> |
| | | <li style="float: right"> |
| | |
| | | v-if="containPermissions(['business:member:update', 'business:member:delete', 'business:empower:create'])" |
| | | label="æä½" min-width="280"> |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" icon="el-icon-edit" @click="edit(row)" |
| | | v-permissions="['business:member:update']">ç¼è¾</el-button> |
| | | <el-button type="text" icon="el-icon-edit" @click="edit(row)" v-permissions="['business:member:update']">ç¼è¾</el-button> |
| | | <el-button type="text" icon="el-icon-plus" @click="empower(row.id)" |
| | | v-permissions="['business:empower:create']">éæ°ææ</el-button> |
| | | <el-button type="text" :loading="heading" style="color: red" icon="el-icon-delete" |
| | |
| | | v-permissions="['business:member:head']">åæ¶ä¸»ç®¡</el-button> |
| | | <el-button type="text" :loading="heading" icon="el-icon-edit" @click="updateHead(row, 1)" |
| | | v-if="row.headStatus == 0" v-permissions="['business:member:head']">设为主管</el-button> |
| | | <el-button type="text" icon="el-icon-delete" @click="deleteById(row)" style="color: red" |
| | | v-permissions="['business:member:delete']">å é¤</el-button> |
| | | <!-- <el-button type="text" icon="el-icon-delete" @click="deleteById(row)" style="color: red" |
| | | v-permissions="['business:member:delete']">å é¤</el-button>--> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | import OperaMemberImportWindow from '@/components/business/OperaMemberImportWindow' |
| | | import { fetchList } from '@/api/business/company' |
| | | import { allList } from '@/api/business/position' |
| | | import { memberSync, roleAuth, updateCanVisit, updateHead, updateWorkStatus } from '@/api/business/member' |
| | | import { memberSync,memberSyncDingding, roleAuth, updateCanVisit, updateHead, updateWorkStatus } from '@/api/business/member' |
| | | export default { |
| | | name: 'internalMember', |
| | | extends: BaseTable, |
| | |
| | | }) |
| | | .catch(() => { }) |
| | | }, |
| | | // åæ¥ä¿¡æ¯ |
| | | async synchronousDingding() { |
| | | this.$dialog.actionConfirm('该æä½é触åå
¨åä¿¡æ¯æ´æ°åéæ°ä¸åï¼è¯·è°¨æ
æä½', 'æ¨ç¡®è®¤å
¨é忥å
é¨äººåä¿¡æ¯åï¼') |
| | | .then(() => { |
| | | this.loading = true |
| | | memberSyncDingding({}) |
| | | .then(res => { |
| | | this.$tip.apiSuccess(res || '忥æå') |
| | | this.search() |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.loading = false |
| | | }) |
| | | }) |
| | | .catch(() => { }) |
| | | }, |
| | | async updateHead(row, type) { |
| | | this.$dialog.actionConfirm('æ¨ç¡®è®¤è¿è¡å½åæä½åï¼', 'é¨é¨ä¸»ç®¡è®¾ç½®æä½æç¤º') |
| | | .then(() => { |
| | |
| | | { label: '访客ç³è¯·', value: '0' }, |
| | | { label: '访客æ¥å¤', value: '1' }, |
| | | { label: 'ç¨è½¦ç³è¯·', value: '2' }, |
| | | { label: '鿣鿿', value: '3' }, |
| | | { label: 'ç©æµè½¦ç³è¯·', value: '6' } |
| | | // { label: '鿣鿿', value: '3' }, |
| | | // { label: 'ç©æµè½¦ç³è¯·', value: '6' } |
| | | ] |
| | | }, |
| | | { |
| | |
| | | { name: '访客ç³è¯·', id: 0 }, |
| | | { name: '访客æ¥å¤', id: 1 }, |
| | | { name: 'ç¨è½¦ç³è¯·', id: 2 }, |
| | | { name: '鿣鿿', id: 3 }, |
| | | { name: 'ç©æµè½¦ç³è¯·', id: 6 } |
| | | // { name: '鿣鿿', id: 3 }, |
| | | // { name: 'ç©æµè½¦ç³è¯·', id: 6 } |
| | | ] |
| | | } |
| | | }, |
| | |
| | | <span v-else-if="row.bizType ==1">å¤åè¿è¾è½¦è¾</span> |
| | | <span v-else-if="row.bizType ==2">å¸å
¬å¸å¸è´§è½¦è¾</span> |
| | | <span v-else-if="row.bizType ==3">å å·¥çå¸è´§è½¦è¾</span> |
| | | <span v-else-if="row.bizType ==4">ç©æµå
¬å¡ç¨è½¦</span> |
| | | <span v-else-if="row.bizType ==5">ç©æµè´§è¿è½¦è¾</span> |
| | | <span v-else-if="row.bizType ==4">èªæå
¬å¡è½¦</span> |
| | | <span v-else-if="row.bizType ==5">èªæè´§è¿è½¦è¾</span> |
| | | <span v-else >-</span> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | { key: 1, name: 'å¤åè¿è¾è½¦è¾' }, |
| | | { key: 2, name: 'å¸å
¬å¸å¸è´§è½¦è¾' }, |
| | | { key: 3, name: 'å å·¥çå¸è´§è½¦è¾' }, |
| | | { key: 4, name: 'ç©æµå
¬å¡ç¨è½¦' }, |
| | | { key: 5, name: 'ç©æµè´§è¿è½¦è¾' } |
| | | { key: 4, name: 'èªæå
¬å¡è½¦' }, |
| | | { key: 5, name: 'èªæè´§è¿è½¦è¾' } |
| | | ], |
| | | // éªè¯è§å |
| | | rules: { |
| | |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>dingtalk</artifactId> |
| | | <version>1.3.54</version> |
| | | <version>2.2.25</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.dingtalk.open</groupId> |
| | | <artifactId>app-stream-client</artifactId> |
| | | <version>1.3.7</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | |
| | | public static final int ZERO = 0 ; |
| | | public static final int ONE = 1 ; |
| | | public static final int TWO = 2 ; |
| | | public static final Integer DD_STATUS_SUCCESS_CODE = 200 ; |
| | | public static final Long DD_ERR_CODE = 0L ; |
| | | public static final String HK_PARAM ="HK_PARAM" ; |
| | | public static final String HK_WEBSITE_DOMAIN_URL ="HK_WEBSITE_DOMAIN_URL" ; |
| | | public static final String LED_CONTENT_SPEED ="LED_CONTENT_SPEED" ; |
| | |
| | | public static final String PRESSURE_LEVEL_UNIT = "PRESSURE_LEVEL_UNIT"; |
| | | public static final String LIQUID_LEVEL_UNIT ="LIQUID_LEVEL_UNIT" ; |
| | | public static final String OUT_HY_LOT_TOTAL ="OUT_HY_LOT_TOTAL" ; |
| | | public static final String BANNER_IMG ="BANNER_IMG" ; |
| | | |
| | | public static boolean DEALING_HK_SYNCPRIVILEGE= false; |
| | | public static boolean DEALING_HK_SYNCDEVICE = false; |
| | |
| | | |
| | | |
| | | public static final String HOME_IMAGE ="HOME_IMAGE"; |
| | | public static final String DD_TALK ="DD_TALK"; |
| | | public static final String APP_KEY ="APP_KEY"; |
| | | public static final String APP_SECRET ="APP_SECRET"; |
| | | public static final String ACCESS_TOKEN ="ACCESS_TOKEN"; |
| | | |
| | | |
| | | |
| | |
| | | import com.doumee.service.business.CompanyService; |
| | | import com.doumee.service.business.ext.ERPSyncService; |
| | | import com.doumee.service.business.impl.hksync.fhk.HkSyncOrgUserFromHKServiceImpl; |
| | | import com.taobao.api.ApiException; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | public ApiResponse<List<CompanyDTO>> findCompanyTreePage(Integer type){ |
| | | return ApiResponse.success(companyService.findCompanyTreePage(type)); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("å
¨éé¨é¨ä¿¡æ¯åæ¥") |
| | | @PostMapping("/syncAll") |
| | |
| | | import com.doumee.service.business.ext.ERPSyncService; |
| | | import com.doumee.service.business.impl.hksync.fhk.HkSyncOrgUserFromHKServiceImpl; |
| | | import com.doumee.service.business.impl.hksync.fhk.HkSyncOrgUserFromSelfServiceImpl; |
| | | import com.taobao.api.ApiException; |
| | | import io.swagger.annotations.*; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | return ApiResponse.success(companyService.findCompanyTreePage(type)); |
| | | } |
| | | |
| | | @ApiOperation("å
¨éé¨é¨ä¿¡æ¯åæ¥ - éé") |
| | | @PostMapping("/syncAllDingding") |
| | | // @CloudRequiredPermission("business:company:sync") |
| | | public ApiResponse syncAllDingding() throws ApiException { |
| | | companyService.syncDDCompany(); |
| | | return ApiResponse.success("忥æå"); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("å
¨éé¨é¨ä¿¡æ¯åæ¥") |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.dingTalk; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aliyun.dingtalkoauth2_1_0.Client; |
| | | import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest; |
| | | import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse; |
| | | import com.aliyun.tea.TeaException; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dingtalk.api.DefaultDingTalkClient; |
| | | import com.dingtalk.api.DingTalkClient; |
| | | import com.dingtalk.api.request.*; |
| | | import com.dingtalk.api.response.*; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.dao.CompanyMapper; |
| | | import com.doumee.dao.business.model.Company; |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.doumee.service.business.CompanyService; |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import com.taobao.api.ApiException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2025/9/24 16:25 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class DingTalk { |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | |
| | | /** |
| | | * ä½¿ç¨ Token åå§åè´¦å·Client |
| | | * @return Client com.aliyun.dingtalkoauth2_1_0. |
| | | * @throws Exception |
| | | */ |
| | | public static Client createClient() throws Exception { |
| | | com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config(); |
| | | config.protocol = "https"; |
| | | config.regionId = "central"; |
| | | return new Client(config); |
| | | } |
| | | |
| | | |
| | | public void updTokenInfo() throws Exception { |
| | | String appKey = systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.APP_KEY).getCode(); |
| | | String appSecret = systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.APP_SECRET).getCode(); |
| | | Client client = DingTalk.createClient(); |
| | | GetAccessTokenRequest getAccessTokenRequest = new GetAccessTokenRequest() |
| | | .setAppKey(appKey) |
| | | .setAppSecret(appSecret); |
| | | try { |
| | | GetAccessTokenResponse getAccessTokenResponse = client.getAccessToken(getAccessTokenRequest); |
| | | //è¿åæè¿° ä¾ï¼{"body":{"accessToken":"76a248ea72ba3f359b39c9e70073d642","expireIn":7200},"headers":{"access-control-allow-origin":"*","date":"Wed, 24 Sep 2025 08:39:36 GMT","server":"DingTalk/1.0.0","transfer-encoding":"chunked","x-acs-request-id":"9E8AF053-04DD-7031-9766-14DFFB087A79","access-control-allow-headers":"X-Requested-With, X-Sequence, _aop_secret, _aop_signature, x-acs-dingtalk-access-token","connection":"keep-alive","content-type":"application/json;charset=utf-8","access-control-expose-headers":"*","x-acs-trace-id":"96e7cf1f3c0e059779a6d581d4b5fca7"},"statusCode":200} |
| | | if(Constants.equalsInteger(getAccessTokenResponse.statusCode,Constants.DD_STATUS_SUCCESS_CODE)){ |
| | | //è§£ætokenä¿¡æ¯ åå¨ |
| | | String accessToken = getAccessTokenResponse.getBody().getAccessToken(); |
| | | //æ´æ°tokenä¿¡æ¯åå¨ |
| | | SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.ACCESS_TOKEN); |
| | | systemDictData.setCode(accessToken); |
| | | systemDictData.setUpdateTime(new Date()); |
| | | systemDictDataBiz.updateByIdNew(systemDictData); |
| | | } |
| | | |
| | | //æ´æ°Tokenä¿¡æ¯ |
| | | System.out.println(JSONObject.toJSONString(getAccessTokenResponse)); |
| | | |
| | | } catch (TeaException err) { |
| | | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { |
| | | // err ä¸å«æ code å message 屿§ï¼å¯å¸®å©å¼åå®ä½é®é¢ |
| | | log.error("æ´æ°ééToken失败ï¼{}" + err.message); |
| | | } |
| | | |
| | | } catch (Exception _err) { |
| | | TeaException err = new TeaException(_err.getMessage(), _err); |
| | | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { |
| | | // err ä¸å«æ code å message 屿§ï¼å¯å¸®å©å¼åå®ä½é®é¢ |
| | | log.error("æ´æ°ééToken失败ï¼{}" + err.message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·åééToken |
| | | * @return |
| | | */ |
| | | public String getToken(){ |
| | | String accessToken = systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.ACCESS_TOKEN).getCode(); |
| | | return accessToken; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å
¨é忥 é¨é¨ä¿¡æ¯ |
| | | * æ¥å£ææ¡£å°å https://open.dingtalk.com/document/orgapp/obtain-the-department-list-v2 |
| | | * æ¬æ¥å£åªæ¯æè·åå½åé¨é¨çä¸ä¸çº§é¨é¨åºç¡ä¿¡æ¯ï¼ä¸æ¯æè·åå½åé¨é¨ä¸ææå±çº§åé¨é¨ |
| | | * @throws ApiException |
| | | */ |
| | | public List<OapiV2DepartmentGetResponse.DeptGetResponse> syncAllDDDepartmentList() throws ApiException { |
| | | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub"); |
| | | List<Long> headList = new ArrayList<>(); |
| | | headList.add(1L); |
| | | List<OapiV2DepartmentListsubResponse.DeptBaseResponse> deptBaseResponseList = new ArrayList<>(); |
| | | List<OapiV2DepartmentListsubResponse.DeptBaseResponse> thisLevelList = getDepartmentList(client,headList); |
| | | deptBaseResponseList.addAll(thisLevelList); |
| | | while (CollectionUtils.isNotEmpty(thisLevelList)){ |
| | | headList = thisLevelList.stream().map(i->i.getDeptId()).collect(Collectors.toList()); |
| | | thisLevelList = getDepartmentList(client,headList); |
| | | if(CollectionUtils.isNotEmpty(thisLevelList)){ |
| | | deptBaseResponseList.addAll(thisLevelList); |
| | | } |
| | | } |
| | | List<OapiV2DepartmentGetResponse.DeptGetResponse> getResponseList = new ArrayList<>(); |
| | | if(CollectionUtils.isNotEmpty(deptBaseResponseList)){ |
| | | for (OapiV2DepartmentListsubResponse.DeptBaseResponse deptBaseResponse:deptBaseResponseList) { |
| | | OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse = syncDepartmentInfo(deptBaseResponse.getDeptId()); |
| | | getResponseList.add(deptGetResponse); |
| | | } |
| | | } |
| | | |
| | | return getResponseList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·åé¨é¨ä¸çº§æ°æ® |
| | | * @param client |
| | | * @param deptIdList |
| | | * @return |
| | | * @throws ApiException |
| | | */ |
| | | public List<OapiV2DepartmentListsubResponse.DeptBaseResponse> getDepartmentList |
| | | (DingTalkClient client, List<Long> deptIdList) throws ApiException{ |
| | | List<OapiV2DepartmentListsubResponse.DeptBaseResponse> thisLevelList = new ArrayList<>(); |
| | | for (Long deptId:deptIdList) { |
| | | OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest(); |
| | | req.setDeptId(deptId); |
| | | req.setLanguage("zh_CN"); |
| | | OapiV2DepartmentListsubResponse rsp = client.execute(req, this.getToken()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | if(CollectionUtils.isNotEmpty(rsp.getResult())){ |
| | | thisLevelList.addAll(rsp.getResult()); |
| | | } |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | } |
| | | return thisLevelList; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * å建ç»ç»é¨é¨ æä¸ä½¿ç¨ |
| | | * æ¥å£ææ¡£å°åï¼https://open.dingtalk.com/document/orgapp/create-a-department-v2 |
| | | * @param ddParentId ééä¸çº§é¨é¨ä¸»é® å¦ææ²¡æåå
¥null |
| | | * @param name é¨é¨åç§° |
| | | * @param sn åºå· |
| | | * @param id ç³»ç»é¨é¨ä¸»é® |
| | | * @throws ApiException |
| | | */ |
| | | public void pushCreatDepartment(Integer ddParentId,String name,Long sn,Integer id) throws ApiException { |
| | | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/create"); |
| | | OapiV2DepartmentCreateRequest req = new OapiV2DepartmentCreateRequest(); |
| | | //å¿
å
¥åæ° |
| | | //妿æ ç¶çº§ åé»è®¤è·ç»ç» 1L |
| | | req.setParentId(Objects.isNull(ddParentId)?1L:ddParentId); |
| | | req.setName(name); |
| | | req.setOrder(sn); |
| | | //å¤é¨é¨é¨å段 |
| | | req.setSourceIdentifier(id.toString()); |
| | | |
| | | //é»è®¤åæ° |
| | | req.setHideDept(false); |
| | | req.setOuterDept(false); |
| | | req.setCreateDeptGroup(false); |
| | | |
| | | OapiV2DepartmentCreateResponse rsp = client.execute(req, getToken()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | |
| | | System.out.println(rsp.getBody()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ´æ°ç»ç»é¨é¨ æä¸ä½¿ç¨ |
| | | * æ¥å£ææ¡£å°åï¼https://open.dingtalk.com/document/orgapp/update-a-department-v2 |
| | | * @param deptId ééé¨é¨ä¸»é® |
| | | * @param name é¨é¨åç§° |
| | | * @param parentId ç¶çº§ééé¨é¨ä¸»é® |
| | | * @param sn åºå· |
| | | * @throws ApiException |
| | | */ |
| | | public void pushUpdDepartment(Integer deptId,String name,Integer parentId,Long sn) throws ApiException { |
| | | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/update"); |
| | | OapiV2DepartmentUpdateRequest req = new OapiV2DepartmentUpdateRequest(); |
| | | req.setDeptId(deptId.longValue()); |
| | | //妿æ ç¶çº§ åé»è®¤è·ç»ç» 1L |
| | | req.setParentId(Objects.isNull(parentId)?1L:parentId.longValue()); |
| | | req.setOrder(sn); |
| | | req.setName(name); |
| | | OapiV2DepartmentUpdateResponse rsp = client.execute(req, getToken()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * å é¤ç»ç»é¨é¨ æä¸ä½¿ç¨ |
| | | * æ¥å£ææ¡£å°åï¼https://open.dingtalk.com/document/orgapp/delete-a-department-v2 |
| | | * @param deptId ééé¨é¨ä¸»é® |
| | | * @throws ApiException |
| | | */ |
| | | public void pushDelDepartment(Integer deptId) throws ApiException { |
| | | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/delete"); |
| | | OapiV2DepartmentDeleteRequest req = new OapiV2DepartmentDeleteRequest(); |
| | | req.setDeptId(deptId.longValue()); |
| | | OapiV2DepartmentDeleteResponse rsp = client.execute(req, getToken()); |
| | | System.out.println(rsp.getBody()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è·åééé¨é¨è¯¦æ
|
| | | * @param deptId |
| | | * @return |
| | | * @throws ApiException |
| | | */ |
| | | public OapiV2DepartmentGetResponse.DeptGetResponse syncDepartmentInfo(Long deptId) throws ApiException { |
| | | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get"); |
| | | OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest(); |
| | | req.setDeptId(deptId); |
| | | req.setLanguage("zh_CN"); |
| | | OapiV2DepartmentGetResponse rsp = client.execute(req, getToken()); |
| | | System.out.println(rsp.getBody()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | return rsp.getResult(); |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public List<OapiV2UserGetResponse.UserGetResponse> syncAllUserInfo() throws ApiException { |
| | | List<Company> deptList = companyMapper.selectList(new QueryWrapper<Company>().lambda() |
| | | .eq(Company::getIsdeleted,Constants.ZERO) |
| | | .eq(Company::getType,Constants.ONE) |
| | | .isNotNull(Company::getErpId) |
| | | ); |
| | | if(CollectionUtils.isEmpty(deptList)){ |
| | | return null; |
| | | } |
| | | List<String> allUserIdList = new ArrayList<>(); |
| | | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/user/listid"); |
| | | OapiUserListidRequest req = new OapiUserListidRequest(); |
| | | for (Company company:deptList) { |
| | | req.setDeptId(Long.valueOf(company.getErpId())); |
| | | OapiUserListidResponse rsp = client.execute(req, getToken()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | if(CollectionUtils.isNotEmpty(rsp.getResult().getUseridList())){ |
| | | allUserIdList.addAll(rsp.getResult().getUseridList()); |
| | | } |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | } |
| | | if(CollectionUtils.isEmpty(allUserIdList)){ |
| | | return null; |
| | | } |
| | | Set<String> setUserIdList = new HashSet<>(allUserIdList); |
| | | return syncUserInfoList(setUserIdList); |
| | | } |
| | | |
| | | |
| | | public List<OapiV2UserGetResponse.UserGetResponse> syncUserInfoList(Set<String> setUserIdList) throws ApiException { |
| | | List<OapiV2UserGetResponse.UserGetResponse> userList = new ArrayList<>(); |
| | | DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get"); |
| | | OapiV2UserGetRequest req = new OapiV2UserGetRequest(); |
| | | for (String userId:setUserIdList) { |
| | | req.setUserid(userId); |
| | | req.setLanguage("zh_CN"); |
| | | OapiV2UserGetResponse rsp = client.execute(req, getToken()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | OapiV2UserGetResponse.UserGetResponse userGetResponse = rsp.getResult(); |
| | | userList.add(userGetResponse); |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | } |
| | | return userList; |
| | | } |
| | | |
| | | |
| | | public OapiV2UserGetResponse.UserGetResponse syncUserInfo(String userId)throws ApiException { |
| | | DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get"); |
| | | OapiV2UserGetRequest req = new OapiV2UserGetRequest(); |
| | | req.setUserid(userId); |
| | | req.setLanguage("zh_CN"); |
| | | OapiV2UserGetResponse rsp = client.execute(req, getToken()); |
| | | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ |
| | | OapiV2UserGetResponse.UserGetResponse userGetResponse = rsp.getResult(); |
| | | return userGetResponse; |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | String appKey = "dingkfglaktqmfd2dmo2";//systemDictDataBiz.queryByCode("","").getCode(); |
| | | String appSecret = "0e22TT2s794Yj49Exgvq8nU2ulpXmxlw9ThBh5s-vDv5Cfspv-f8HPmta4cg2evk";//systemDictDataBiz.queryByCode("","").getCode(); |
| | | Client client = DingTalk.createClient(); |
| | | GetAccessTokenRequest getAccessTokenRequest = new GetAccessTokenRequest() |
| | | .setAppKey(appKey) |
| | | .setAppSecret(appSecret); |
| | | try { |
| | | GetAccessTokenResponse getAccessTokenResponse = client.getAccessToken(getAccessTokenRequest); |
| | | |
| | | //æ´æ°Tokenä¿¡æ¯ |
| | | System.out.println(JSONObject.toJSONString(getAccessTokenResponse)); |
| | | |
| | | } catch (TeaException err) { |
| | | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { |
| | | // err ä¸å«æ code å message 屿§ï¼å¯å¸®å©å¼åå®ä½é®é¢ |
| | | log.error("æ´æ°ééToken失败ï¼{}" + err.message); |
| | | } |
| | | |
| | | } catch (Exception _err) { |
| | | TeaException err = new TeaException(_err.getMessage(), _err); |
| | | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { |
| | | // err ä¸å«æ code å message 屿§ï¼å¯å¸®å©å¼åå®ä½é®é¢ |
| | | log.error("æ´æ°ééToken失败ï¼{}" + err.message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.dingTalk; |
| | | |
| | | import com.dingtalk.open.app.api.GenericEventListener; |
| | | import com.dingtalk.open.app.api.OpenDingTalkStreamClientBuilder; |
| | | import com.dingtalk.open.app.api.message.GenericOpenDingTalkEvent; |
| | | import com.dingtalk.open.app.api.security.AuthClientCredential; |
| | | import com.dingtalk.open.app.stream.protocol.event.EventAckStatus; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.dao.CompanyMapper; |
| | | import com.doumee.dao.business.dao.MemberMapper; |
| | | import com.doumee.service.business.CompanyService; |
| | | import com.doumee.service.business.MemberService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.chanjar.weixin.mp.config.WxMpConfigStorage; |
| | | import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import shade.com.alibaba.fastjson2.JSONObject; |
| | | |
| | | /** |
| | | * éé 订é
äºä»¶éç¥ |
| | | * |
| | | * @Author : Rk |
| | | * @create 2025/9/24 17:14 |
| | | */ |
| | | @Slf4j |
| | | @Configuration |
| | | public class DingTalkStream { |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private MemberService memberService; |
| | | |
| | | @Autowired |
| | | private CompanyService companyService; |
| | | |
| | | |
| | | @Bean |
| | | public void DingTalkStreamRun() throws Exception { |
| | | String appKey = systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.APP_KEY).getCode(); |
| | | String appSecret = systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.APP_SECRET).getCode(); |
| | | |
| | | OpenDingTalkStreamClientBuilder |
| | | .custom() |
| | | .credential(new AuthClientCredential(appKey, appSecret)) |
| | | //注åäºä»¶çå¬ |
| | | .registerAllEventListener(new GenericEventListener() { |
| | | @Override |
| | | public EventAckStatus onEvent(GenericOpenDingTalkEvent event) { |
| | | try { |
| | | //äºä»¶å¯ä¸Id |
| | | String eventId = event.getEventId(); |
| | | log.error("é鿍éäºä»¶Id:{}"+eventId); |
| | | //äºä»¶ç±»å |
| | | String eventType = event.getEventType(); |
| | | log.error("é鿍éäºä»¶ç±»å:{}"+eventType); |
| | | // org_dept_create é¨é¨æ°å»º {"timeStamp":"1758783935796","eventId":"0c779adba04143958a3960e8e36bbce5","deptId":[1040735458]} |
| | | // org_dept_modify é¨é¨ä¿®æ¹ {"timeStamp":"1758785791639","eventId":"6c2d8c7a61a7419e8928fda3effb3bf4","deptId":[1040735458]} |
| | | // org_dept_remove é¨é¨å é¤ {"timeStamp":"1758785817760","eventId":"47e289f334e041719ed354052da474de","deptId":[1040735458]} |
| | | |
| | | // user_add_org å工添å |
| | | // user_modify_org åå·¥ä¿®æ¹ {"timeStamp":"1758786235842","diffInfo":[{"prev":{"extFields":"{}","hiredDate":"2022-03-30","name":"任康","telephone":"145","remark":"","workPlace":"è²è±ç§åå F401","jobNumber":"","email":"rk@doumee.com"},"curr":{"extFields":"{}","hiredDate":"2022-03-30","name":"任康","telephone":"145","remark":"","workPlace":"è²è±ç§åå F401","jobNumber":"","email":"rk@doumee.com"},"userid":"1568490244651036"}],"eventId":"e54d8991aed14c669e22e460459433f6","optStaffId":"045831294126209983","userId":["1568490244651036"]} |
| | | // user_leave_org åå·¥å é¤ |
| | | |
| | | //äºä»¶äº§çæ¶é´ |
| | | Long bornTime = event.getEventBornTime(); |
| | | log.error("é鿍éäºä»¶äº§çæ¶é´:{}"+bornTime); |
| | | //è·åäºä»¶ä½ |
| | | JSONObject bizData = event.getData(); |
| | | log.error("é鿍éäºä»¶è¯¦æ
:{}"+bizData); |
| | | |
| | | if(eventType.startsWith("org")){ |
| | | companyService.ddPushCompanyInfo(eventType,bizData); |
| | | }else if(eventType.startsWith("user")){ |
| | | |
| | | } |
| | | //å¤çäºä»¶ |
| | | // process(bizData); |
| | | //æ¶è´¹æå |
| | | return EventAckStatus.SUCCESS; |
| | | } catch (Exception e) { |
| | | //æ¶è´¹å¤±è´¥ |
| | | return EventAckStatus.LATER; |
| | | } |
| | | } |
| | | }) |
| | | .build().start(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | //@ExcelColumn(name="徿 ") |
| | | private String imgurl; |
| | | |
| | | @ApiModelProperty(value = "ç±»å 0å
¬å¸ç±»å 1车è¾ç±»å") |
| | | @ApiModelProperty(value = "ç±»å 0å
¬å¸ç±»å 1车è¾ç±»å 2èµæåç±» 3é¥åæç»ç«¯å¹¿å 4交æ§ä¸»çº¿è·¯") |
| | | //@ExcelColumn(name="ç±»å 0å
¬å¸ç±»å 1车è¾ç±»å") |
| | | private Integer type; |
| | | @ApiModelProperty(value = "ä¸å¡ç±»å " + |
| | |
| | | @TableField(exist = false) |
| | | @ExcelColumn(name="ç»ååç§°",index = 3,width = 20) |
| | | private String groupName; |
| | | @ApiModelProperty(value = "宿´å¾çå°å ") |
| | | private String imgurlFull; |
| | | |
| | | @ApiModelProperty(value = "åéåç±»") |
| | | @TableField(exist = false) |
| | |
| | | package com.doumee.service.business; |
| | | |
| | | import com.dingtalk.api.response.OapiV2DepartmentListsubResponse; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.doumee.dao.admin.request.UpdateCompanySortDTO; |
| | | import com.doumee.dao.admin.response.CompanyDTO; |
| | | import com.doumee.dao.business.model.Company; |
| | | import com.taobao.api.ApiException; |
| | | import shade.com.alibaba.fastjson2.JSONObject; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | List<Company> companyTree(Integer type); |
| | | |
| | | void updateSort(UpdateCompanySortDTO dto); |
| | | |
| | | void ddPushCompanyInfo(String eventType, JSONObject eventData) throws ApiException; |
| | | |
| | | String syncDDCompany()throws ApiException; |
| | | } |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | |
| | | @Service |
| | | public class CategoryServiceImpl implements CategoryService { |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private CategoryMapper categoryMapper; |
| | | |
| | |
| | | IPage<Category> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<Category> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + |
| | | systemDictDataBiz.queryByCode(Constants.FTP,Constants.BANNER_IMG).getCode(); |
| | | |
| | | queryWrapper.lambda().eq(Category::getIsdeleted,Constants.ZERO) |
| | | .eq(Objects.nonNull(pageWrap.getModel().getType()),Category::getType,pageWrap.getModel().getType()) |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Category::getName,pageWrap.getModel().getName()) |
| | |
| | | category.setChildCategoryList( |
| | | categoryList.stream().filter(i->Constants.equalsInteger(i.getParentId(),category.getId())).collect(Collectors.toList()) |
| | | ); |
| | | if(StringUtils.isNotBlank(category.getImgurl())){ |
| | | category.setImgurlFull(prefixUrl + category.getImgurl()); |
| | | } |
| | | } |
| | | |
| | | return categoryPageData; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dingtalk.api.response.OapiV2DepartmentGetResponse; |
| | | import com.dingtalk.api.response.OapiV2DepartmentListsubResponse; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.DataSyncConfig; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.dingTalk.DingTalk; |
| | | import com.doumee.core.erp.ErpConstants; |
| | | import com.doumee.core.erp.model.openapi.request.erp.OrgListRequest; |
| | | import com.doumee.core.erp.model.openapi.response.erp.ErpOrgListResponse; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.CompanyService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.taobao.api.ApiException; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import shade.com.alibaba.fastjson2.JSONArray; |
| | | import shade.com.alibaba.fastjson2.JSONObject; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Autowired |
| | | private CompanyJoinMapper companyJoinMapper; |
| | | |
| | | @Autowired |
| | | private DingTalk dingTalk; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | |
| | | for (Company updCompany:companyPool) { |
| | | companyMapper.updateById(updCompany); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // org_dept_create é¨é¨æ°å»º {"timeStamp":"1758783935796","eventId":"0c779adba04143958a3960e8e36bbce5","deptId":[1040735458]} |
| | | // org_dept_modify é¨é¨ä¿®æ¹ {"timeStamp":"1758785791639","eventId":"6c2d8c7a61a7419e8928fda3effb3bf4","deptId":[1040735458]} |
| | | // org_dept_remove é¨é¨å é¤ {"timeStamp":"1758785817760","eventId":"47e289f334e041719ed354052da474de","deptId":[1040735458]} |
| | | |
| | | @Override |
| | | public void ddPushCompanyInfo(String eventType, JSONObject eventData) throws ApiException { |
| | | JSONArray jsonArray = eventData.getJSONArray("deptId"); |
| | | if(jsonArray.isEmpty()){ |
| | | return; |
| | | } |
| | | if(eventType.equals("org_dept_remove")){ |
| | | //å é¤å¯¹åºé¨é¨ä¿¡æ¯ |
| | | List<Long> deptIdList = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Long deptId = jsonArray.getLong(i); |
| | | deptIdList.add(deptId); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(deptIdList)){ |
| | | syncDelCompany(deptIdList); |
| | | } |
| | | }else if(eventType.equals("org_dept_create")||eventType.equals("org_dept_modify")){ |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Company company = companyMapper.selectOne(new QueryWrapper<Company>().lambda() |
| | | .eq(Company::getIsdeleted,Constants.ZERO) |
| | | .eq(Company::getErpId,jsonArray.getLong(i)) |
| | | ); |
| | | OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse = dingTalk.syncDepartmentInfo(jsonArray.getLong(i)); |
| | | if(Objects.isNull(company)){ |
| | | getAddCompanyModel(deptGetResponse,company); |
| | | }else{ |
| | | getUpdateCompanyModel(deptGetResponse,company); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void doHkDeleteOrg(List<Integer> delIds,List<String> delHkIds, Date date) { |
| | | if(delHkIds.size() == 0){ |
| | | return; |
| | | } |
| | | OrgDelRequest request = new OrgDelRequest(); |
| | | request.setIndexCodes( delHkIds.toArray(new String[]{})); |
| | | BaseResponse<List<OrgUpdateFailureResponse>> result = HKService.delBatchOrg(request); |
| | | if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){ |
| | | List<String> fIds = new ArrayList<>(); |
| | | if(result.getData()!=null){ |
| | | for(OrgUpdateFailureResponse r : result.getData()){ |
| | | if(r.getCode().equals("0x00052102")){ |
| | | //ä¸åå¨çä¹ç®å 餿å |
| | | fIds.add(r.getOrgIndexCode());//å é¤å¤±è´¥çæ°æ®éå |
| | | } |
| | | } |
| | | } |
| | | //æ è®°å 餿åçæ°æ®ï¼æµ·åº·å¯¹æ¥ç¶æä¸ºå·²åæ¥ï¼ï¼åæ¥å¤±è´¥çä»ä¸ºå¾
忥ï¼çä¸ä¸æ¬¡ç»§ç»å¤çï¼ç¥éå
¨é¨å é¤å®æ¯ï¼ |
| | | companyMapper.update(null,new UpdateWrapper<Company>().lambda() |
| | | .set(Company::getHkStatus,Constants.ONE) |
| | | .set(Company::getHkDate,date) |
| | | .set(Company::getHkId,null ) |
| | | .in(Company::getId, delIds) |
| | | .notIn(fIds.size()>0,Company::getHkId, fIds)); |
| | | companyMapper.update(null,new UpdateWrapper<Company>().lambda() |
| | | .set(Company::getHkStatus,Constants.TWO) |
| | | .set(Company::getHkDate,date) |
| | | .in(Company::getId, delIds) |
| | | .in(fIds.size()>0,Company::getHkId, fIds)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String syncDDCompany() throws ApiException { |
| | | List<OapiV2DepartmentGetResponse.DeptGetResponse> list = dingTalk.syncAllDDDepartmentList(); |
| | | if(list !=null && list.size()>0){ |
| | | List<Company> addList = new ArrayList<>(); |
| | | List<Company> updateList = new ArrayList<>(); |
| | | List<Long> delIds = new ArrayList<>();//ä¿®æ¹ä¸ºä½¿ç¨ééid erpId |
| | | List<Company> allList = companyMapper.selectList(new QueryWrapper<Company>().lambda() |
| | | .eq(Company::getIsdeleted,Constants.ZERO).eq(Company::getType,Constants.ONE)); |
| | | dealCompanyChangeList(list,addList,updateList,delIds,allList); |
| | | if(delIds.size()>0){ |
| | | syncDelCompany(delIds); |
| | | } |
| | | return "åæ¥æ°æ®ï¼æ°å¢ã"+addList.size()+"ãæ¡ï¼æ´æ°ã"+updateList.size()+"ãæ¡ï¼å é¤ã"+delIds.size()+"ãæ¡"; |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "忥ééæ°æ®ä¸ºç©ºï¼"); |
| | | } |
| | | } |
| | | |
| | | private void dealCompanyChangeList(List<OapiV2DepartmentGetResponse.DeptGetResponse> list, List<Company> addList, List<Company> updateList, List<Long> delIds, List<Company> allList) { |
| | | Date date = new Date(); |
| | | for(OapiV2DepartmentGetResponse.DeptGetResponse respone : list){ |
| | | //æ ¹æ®erpidæ¥è¯¢ä¼ä¸ä¿¡æ¯ï¼å¤ææ¯æ°å¢è¿æ¯æ´æ° |
| | | Company company = findCompanyByERPId(allList,respone.getDeptId().toString()); |
| | | if(company == null){ |
| | | //å¦ææ¯æ°å¢ |
| | | //å°è£
æ°å¢ç»ç»å¯¹è±¡æ°æ® |
| | | addList.add(getAddCompanyModel(respone,new Company())); |
| | | }else{ |
| | | updateList.add(getUpdateCompanyModel(respone,company)); |
| | | } |
| | | } |
| | | if(allList!=null && allList.size()>0){ |
| | | for(Company c : allList){ |
| | | if(!isCompanyDeleted(c,list)){ |
| | | delIds.add(Long.valueOf(c.getErpId())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ´çéé忥 æ°å¢ç»ç»å¯¹è±¡ |
| | | * @param deptGetResponse |
| | | * @return |
| | | */ |
| | | private Company getAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company) { |
| | | return syncDDAddCompanyModel(deptGetResponse,company); |
| | | } |
| | | |
| | | /** |
| | | * æ´çéé忥 æ°å¢ éè¦ä¿®æ¹çç»ç»å¯¹è±¡ |
| | | * @param deptGetResponse |
| | | * @param company |
| | | * @return |
| | | */ |
| | | private Company getUpdateCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse, Company company) { |
| | | return syncDDEditCompanyModel(deptGetResponse,company); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®ERPID å¤ææ°æ®æ¯å¦å·²å¨éåéåå¨ |
| | | * @param allList |
| | | * @param id |
| | | * @return |
| | | */ |
| | | private Company findCompanyByERPId(List<Company> allList, String id) { |
| | | if(allList!=null){ |
| | | for(Company com :allList){ |
| | | if(StringUtils.equals(com.getErpId(),id)){ |
| | | return com; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private boolean isCompanyDeleted(Company c, List<OapiV2DepartmentGetResponse.DeptGetResponse> list) { |
| | | for(OapiV2DepartmentGetResponse.DeptGetResponse m : list){ |
| | | if(StringUtils.equals(c.getErpId(),m.getDeptId().toString())){ |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ´ç éé忥ç ç»ç»ä¿¡æ¯ |
| | | * @param deptGetResponse |
| | | * @param company |
| | | * @return |
| | | */ |
| | | public Company syncDDAddCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){ |
| | | company = new Company(); |
| | | company.setCreateDate(new Date()); |
| | | company.setIsdeleted(Constants.ZERO); |
| | | company.setStatus(Constants.ZERO); |
| | | |
| | | company.setName(deptGetResponse.getName()); |
| | | company.setErpId(deptGetResponse.getDeptId().toString()); |
| | | company.setErpParentId(deptGetResponse.getParentId().toString()); |
| | | company.setSortnum(deptGetResponse.getOrder().intValue());//é»è®¤æä¸é¢ |
| | | |
| | | company.setType(Constants.ONE); |
| | | String rootOrgId = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_ROOTORG_CODE).getCode(); |
| | | company.setCompanyPath(company.getId()+"/");//åç§°è·¯å¾ |
| | | company.setCompanyNamePath(company.getName());//åç§°è·¯å¾ |
| | | company.setHkParentId(rootOrgId); |
| | | String idPath = ""; |
| | | if(StringUtils.isNotBlank(company.getErpParentId()) && !StringUtils.equals(company.getErpParentId(),Constants.ONE+"")){ |
| | | Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId()) |
| | | .eq(Company::getIsdeleted,Constants.ZERO).last(" limit 1 ")); |
| | | if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对ä¸èµ·ï¼ç¶çº§ç»ç»ä¿¡æ¯ä¸åå¨~"); |
| | | } |
| | | // if(StringUtils.isBlank(parent.getHkId())){ |
| | | // throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对ä¸èµ·ï¼ç¶çº§ç»ç»ä¿¡æ¯å°æªåæ¥ä¸åæå~"); |
| | | // } |
| | | if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){ |
| | | if(!Constants.equalsInteger(company.getType(),parent.getType())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对ä¸èµ·ï¼ç»ç»ä¿¡æ¯é误"); |
| | | } |
| | | }else if(Objects.isNull(parent.getType())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对ä¸èµ·ï¼ç»ç»ä¿¡æ¯é误"); |
| | | } |
| | | idPath = parent.getCompanyPath(); |
| | | company.setHkParentId(parent.getHkId()); |
| | | company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/"); |
| | | company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName()); |
| | | } |
| | | company.setHkCompanyPath(company.getCompanyNamePath()); |
| | | company.setCreateDate(new Date()); |
| | | company.setIsdeleted(Constants.ZERO); |
| | | company.setHkStatus(Constants.ZERO); |
| | | company.setStatus(Constants.ZERO); |
| | | company.setHkDate(company.getCreateDate()); |
| | | company.setEditDate(company.getCreateDate()); |
| | | company.setEditor(company.getCreator()); |
| | | company.setPinyin(Constants.getChinesePingyin(company.getName())); |
| | | companyMapper.insert(company); |
| | | |
| | | company.setHkId(UUID.randomUUID().toString().replace("-","")); |
| | | //ä¸å海康å®é²å¹³å° |
| | | Boolean issueStatus = addHkOrg(company); |
| | | Company com = new Company(); |
| | | com.setId(company.getId()); |
| | | com.setHkId(issueStatus?company.getHkId():null); |
| | | com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO); |
| | | com.setCompanyPath(idPath+company.getId()+"/"); |
| | | companyMapper.updateById(com); |
| | | return company; |
| | | } |
| | | |
| | | |
| | | public Company syncDDEditCompanyModel(OapiV2DepartmentGetResponse.DeptGetResponse deptGetResponse,Company company){ |
| | | company.setErpParentId(deptGetResponse.getParentId().toString()); |
| | | String idPath = ""; |
| | | if(StringUtils.isNotBlank(company.getErpParentId()) && !StringUtils.equals(company.getErpParentId(),Constants.ONE+"")){ |
| | | Company parent = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getErpId,company.getErpParentId()) |
| | | .eq(Company::getIsdeleted,Constants.ZERO).last("limit 1 ")); |
| | | if(parent == null || Constants.equalsInteger(parent.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "对ä¸èµ·ï¼ç¶çº§ç»ç»ä¿¡æ¯ä¸åå¨~"); |
| | | } |
| | | if(Objects.nonNull(parent.getType())&&!Constants.equalsInteger(parent.getType(),-1)){ |
| | | if(!Constants.equalsInteger(company.getType(),parent.getType())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对ä¸èµ·ï¼ç»ç»ä¿¡æ¯é误"); |
| | | } |
| | | }else if(Objects.isNull(parent.getType())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对ä¸èµ·ï¼ç»ç»ä¿¡æ¯é误"); |
| | | } |
| | | idPath = parent.getCompanyPath(); |
| | | company.setHkParentId(parent.getHkId()); |
| | | company.setCompanyPath(parent.getCompanyPath()+company.getId()+"/"); |
| | | company.setCompanyNamePath(parent.getCompanyNamePath()+"/"+company.getName()); |
| | | } |
| | | |
| | | company.setName(deptGetResponse.getName()); |
| | | company.setErpId(deptGetResponse.getDeptId().toString()); |
| | | company.setErpParentId(deptGetResponse.getParentId().toString()); |
| | | company.setSortnum(deptGetResponse.getOrder().intValue());//é»è®¤æä¸é¢ |
| | | company.setEditDate(new Date()); |
| | | company.setHkCompanyPath(company.getCompanyNamePath()); |
| | | company.setHkStatus(Constants.ZERO); |
| | | company.setStatus(Constants.ZERO); |
| | | company.setSortnum(deptGetResponse.getOrder().intValue()); |
| | | company.setHkDate(company.getCreateDate()); |
| | | company.setEditDate(company.getCreateDate()); |
| | | company.setEditor(company.getCreator()); |
| | | company.setPinyin(Constants.getChinesePingyin(company.getName())); |
| | | companyMapper.updateById(company); |
| | | //ä¸å海康å®é²å¹³å° |
| | | Boolean issueStatus = editHkOrg(company); |
| | | Company com = new Company(); |
| | | com.setId(company.getId()); |
| | | com.setHkId(issueStatus?company.getHkId():null); |
| | | com.setHkStatus(issueStatus?Constants.ONE:Constants.TWO); |
| | | com.setCompanyPath(idPath+company.getId()+"/"); |
| | | companyMapper.updateById(com); |
| | | return company; |
| | | } |
| | | |
| | | |
| | | |
| | | public void syncDelCompany(List<Long> deptIdList){ |
| | | List<Company> companyList = companyMapper.selectList(new QueryWrapper<Company>() |
| | | .lambda() |
| | | .eq(Company::getIsdeleted,Constants.ZERO) |
| | | .in(Company::getErpId,deptIdList) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(companyList)){ |
| | | List<Integer> delIds = companyList.stream().map(i->i.getId()).collect(Collectors.toList()); |
| | | List<String> delHKIds = companyList.stream().filter(i->StringUtils.isNotBlank(i.getHkId())).map(i->i.getHkId()).collect(Collectors.toList()); |
| | | |
| | | //æ è®°ä¸å¡å é¤ |
| | | companyMapper.update(new UpdateWrapper<Company>().lambda() |
| | | .set(Company::getIsdeleted,Constants.ONE) |
| | | .set(Company::getEditDate,new Date()) |
| | | .in(Company::getId,delIds) |
| | | ); |
| | | //海康å é¤çæ°æ®ï¼è¿è¡å é¤ |
| | | doHkDeleteOrg(delIds,delHKIds,new Date()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dingtalk.api.response.OapiV2DepartmentGetResponse; |
| | | import com.dingtalk.api.response.OapiV2UserGetResponse; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.DataSyncConfig; |
| | | import com.doumee.core.annotation.excel.ExcelImporter; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.dingTalk.DingTalk; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | |
| | | import com.doumee.service.business.third.model.response.TmsEmployeeListResponse; |
| | | import com.doumee.service.system.SystemLoginService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.taobao.api.ApiException; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import shade.com.alibaba.fastjson2.JSONArray; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | |
| | | private SmsEmailService smsEmailService; |
| | | |
| | | @Autowired |
| | | private SystemLoginService systemLoginService; |
| | | private SystemLoginService systemLoginService; |
| | | |
| | | @Autowired |
| | | private DingTalk dingTalk; |
| | | |
| | | @Value("${debug_model}") |
| | | private Boolean isDebug; |
| | |
| | | |
| | | private Member initAddMemberModel(Member member, LoginUserInfo loginUserInfo) { |
| | | Member insert= new Member(); |
| | | insert.setCreator(loginUserInfo.getId()); |
| | | insert.setCreator(Objects.nonNull(loginUserInfo.getId())?loginUserInfo.getId():null); |
| | | insert.setCreateDate(new Date()); |
| | | insert.setEditor(loginUserInfo.getId()); |
| | | insert.setEditor(Objects.nonNull(loginUserInfo.getId())?loginUserInfo.getId():null); |
| | | insert.setEditDate(new Date()); |
| | | insert.setHkOrgId(member.getHkOrgId()); |
| | | insert.setIsdeleted(Constants.ZERO); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private Member isMemberUpdateParamValid(Member member) { |
| | | Member model = memberJoinMapper.selectJoinOne(Member.class,new MPJLambdaWrapper<Member>() |
| | | .selectAll(Member.class) |
| | |
| | | } |
| | | TrainTime trainTime = new TrainTime(); |
| | | trainTime.setIsdeleted(Constants.ZERO); |
| | | trainTime.setCreator(loginUserInfo.getId()); |
| | | trainTime.setCreator(Objects.nonNull(loginUserInfo)?loginUserInfo.getId():null); |
| | | trainTime.setCreateDate(new Date()); |
| | | trainTime.setEdirot(trainTime.getCreator()); |
| | | trainTime.setEditDate(trainTime.getCreateDate()); |
| | | trainTime.setStartTime(updateMember.getTrainStartTime()); |
| | | trainTime.setEndTime(updateMember.getTrainEndTime()); |
| | | trainTime.setMemberId(updateMember.getId()); |
| | | trainTime.setImportInfo("ç±ã"+loginUserInfo.getRealname()+"ãäº"+DateUtil.getPlusTime2(trainTime.getCreateDate())+(i==0?"å建":"æ´æ°")+"å½å
¥"); |
| | | trainTime.setImportInfo("ç±ã"+(Objects.nonNull(loginUserInfo)?loginUserInfo.getRealname():"éé忥")+"ãäº"+DateUtil.getPlusTime2(trainTime.getCreateDate())+(i==0?"å建":"æ´æ°")+"å½å
¥"); |
| | | //导å
¥å¹è®æææ |
| | | trainTimeMapper.insert(trainTime); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 忥ééå
é¨åå·¥ä¿¡æ¯ |
| | | */ |
| | | public void syncDDUserInfo() throws ApiException { |
| | | List<OapiV2UserGetResponse.UserGetResponse> list = dingTalk.syncAllUserInfo(); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return; |
| | | } |
| | | List<Member> addList = new ArrayList<>(); |
| | | List<Member> updateList = new ArrayList<>(); |
| | | List<String> delIds = new ArrayList<>();//ä¿®æ¹ä¸ºä½¿ç¨ééid erpId |
| | | List<Member> allList = memberMapper.selectList(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getIsdeleted,Constants.ZERO) |
| | | .eq(Member::getType,Constants.TWO)); |
| | | dealMemberChangeList(list,addList,updateList,delIds,allList); |
| | | |
| | | if(delIds.size()>0){ |
| | | syncDelMember(delIds); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void syncDelMember(List<String> delIds) { |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().in(Member::getErpId,delIds) |
| | | .eq(Member::getIsdeleted,Constants.ZERO)); |
| | | if(CollectionUtils.isNotEmpty(memberList)){ |
| | | for (Member member:memberList) { |
| | | this.deleteById(member.getId(),null); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private void dealMemberChangeList(List<OapiV2UserGetResponse.UserGetResponse> list, List<Member> addList, List<Member> updateList, List<String> delIds, List<Member> allList) { |
| | | Date date = new Date(); |
| | | for(OapiV2UserGetResponse.UserGetResponse respone : list){ |
| | | //æ ¹æ®erpidæ¥è¯¢ä¼ä¸ä¿¡æ¯ï¼å¤ææ¯æ°å¢è¿æ¯æ´æ° |
| | | Member member = findMemberByERPId(allList,respone.getUnionid()); |
| | | if(member == null){ |
| | | //å¦ææ¯æ°å¢ |
| | | //å°è£
æ°å¢ç»ç»å¯¹è±¡æ°æ® |
| | | addList.add(getAddMemberModel(respone,new Member())); |
| | | }else{ |
| | | updateList.add(getUpdateMemberModel(respone,member)); |
| | | } |
| | | } |
| | | if(allList!=null && allList.size()>0){ |
| | | for(Member m : allList){ |
| | | if(!isMemberDeleted(m,list)){ |
| | | delIds.add(m.getErpId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Member getAddMemberModel(OapiV2UserGetResponse.UserGetResponse deptGetResponse,Member member) { |
| | | return syncDDAddMemberModel(deptGetResponse,member); |
| | | } |
| | | |
| | | |
| | | private Member getUpdateMemberModel(OapiV2UserGetResponse.UserGetResponse deptGetResponse,Member member) { |
| | | return syncDDEditMemberModel(deptGetResponse,member); |
| | | } |
| | | |
| | | |
| | | private Member syncDDAddMemberModel(OapiV2UserGetResponse.UserGetResponse deptGetResponse,Member member) { |
| | | member.setCreateDate(new Date()); |
| | | member.setErpId(deptGetResponse.getUserid()); |
| | | member.setPhone(deptGetResponse.getMobile()); |
| | | member.setName(deptGetResponse.getName()); |
| | | member.setCode(deptGetResponse.getJobNumber()); |
| | | isMemberParamValidDetail(member,deptGetResponse.getDeptIdList()); |
| | | //è·ååºçæ¥æ |
| | | //è±ææä½ |
| | | Member insert = initAddMemberModel(member,null); |
| | | //æµ·åº·äººåæ°å¢ä¸å¡ |
| | | insert.setHkStatus(dealHkUserBiz(insert)?Constants.ONE:Constants.TWO); |
| | | insert.setHkDate(new Date()); |
| | | memberMapper.insert(insert); |
| | | //妿æ¯å
é¨ç»ç»äººåï¼æ°å¢ç³»ç»ç»éè´¦å· |
| | | systemUserMapper.insert(createSystemUser(insert,systemDictDataBiz)); |
| | | //å¤çå¹è®æææä¸å¡ |
| | | dealTrainTIme(member,0,null); |
| | | return insert; |
| | | } |
| | | |
| | | |
| | | public void isMemberParamValidDetail(Member member,List<Long> deptIdList) { |
| | | if(memberMapper.selectCount(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getPhone, member.getPhone()) |
| | | .in(Member::getType,new Integer[]{Constants.ZERO,Constants.TWO}) |
| | | .eq(Member::getIsdeleted,Constants.ZERO) ) >0){ |
| | | //throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "ææºå·ã"+member.getPhone()+"ã已被使ç¨ï¼ä¸è½éå¤"); |
| | | } |
| | | if(Objects.nonNull(deptIdList)){ |
| | | List<Company> companyList = companyMapper.selectList(new QueryWrapper<Company>().lambda().in(Company::getErpId,deptIdList) |
| | | .eq(Company::getType,Constants.ONE).eq(Company::getIsdeleted,Constants.ZERO) |
| | | .isNotNull(Company::getHkId) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(companyList)){ |
| | | member.setHkOrgId(companyList.get(Constants.ZERO).getHkId()); |
| | | member.setCompanyId(companyList.get(Constants.ZERO).getId()); |
| | | } |
| | | } |
| | | member.setCompanyType(Constants.ONE); |
| | | SystemUser queryUserDto = new SystemUser(); |
| | | queryUserDto.setUsername(member.getPhone()); |
| | | queryUserDto.setDeleted(Boolean.FALSE); |
| | | SystemUser user = systemUserMapper.selectOne(new QueryWrapper<>(queryUserDto).last("limit 1")); |
| | | if (user != null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "ææºå·ã"+queryUserDto.getUsername()+"ã已被使ç¨ï¼ä¸è½éå¤"); |
| | | } |
| | | // // éªè¯å·¥å· |
| | | if (StringUtils.isNotBlank(member.getCode())) { |
| | | queryUserDto = new SystemUser(); |
| | | queryUserDto.setDeleted(Boolean.FALSE); |
| | | queryUserDto.setEmpNo(member.getCode()); |
| | | user = systemUserMapper.selectOne(new QueryWrapper<>(queryUserDto).last("limit 1")); |
| | | if (user != null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "å·¥å·ã"+member.getCode()+"ãå·²åå¨"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public Member syncDDEditMemberModel(OapiV2UserGetResponse.UserGetResponse deptGetResponse,Member updateMember) { |
| | | updateMember.setEditDate(new Date()); |
| | | updateMember.setErpId(deptGetResponse.getUserid()); |
| | | updateMember.setPhone(deptGetResponse.getMobile()); |
| | | updateMember.setName(deptGetResponse.getName()); |
| | | updateMember.setCode(deptGetResponse.getJobNumber()); |
| | | |
| | | updateMember.setHkId(null); |
| | | updateMember.setAuthStatus(Constants.ZERO); |
| | | Boolean hkFlag = dealHkUserForUpdateBiz(updateMember); |
| | | memberMapper.update(null,new UpdateWrapper<Member>().lambda() |
| | | .set(Member::getStartTime,null) |
| | | .set(Member::getEndTime,null) |
| | | .set(Member::getRoleId,null) |
| | | .set(Member::getHkStatus,hkFlag?Constants.ONE:Constants.TWO) |
| | | .set(StringUtils.isNotBlank(updateMember.getPhone()),Member::getPhone,updateMember.getPhone()) |
| | | .set(StringUtils.isNotBlank(updateMember.getName()),Member::getName,updateMember.getName()) |
| | | .set(Member::getEditDate,updateMember.getEditDate()) |
| | | .set(Member::getEditor,updateMember.getEditor()) |
| | | .set(StringUtils.isNotBlank(updateMember.getName()),Member::getPinyin,Constants.getChinesePingyin(updateMember.getName())) |
| | | .set(StringUtils.isNotBlank(updateMember.getIdcardNo()),Member::getIdcardNo,updateMember.getIdcardNo()) |
| | | .set(StringUtils.isNotBlank(updateMember.getIdcardDecode()),Member::getIdcardDecode,updateMember.getIdcardDecode()) |
| | | .set( Member::getAuthStatus,Constants.ZERO) |
| | | .set(updateMember.getSex()!=null,Member::getSex,updateMember.getSex()) |
| | | .set(updateMember.getFaceStatus()!=null,Member::getFaceStatus,updateMember.getFaceStatus()) |
| | | .set(updateMember.getHkDate()!=null,Member::getHkDate,updateMember.getHkDate()) |
| | | .set(StringUtils.isNotBlank(updateMember.getRemark()),Member::getRemark,updateMember.getRemark()) |
| | | .set(StringUtils.isNotBlank(updateMember.getFaceImg()),Member::getFaceImg,updateMember.getFaceImg()) |
| | | .set(updateMember.getFaceId()!=null,Member::getFaceId,updateMember.getFaceId()) |
| | | .set(updateMember.getCompanyId()!=null,Member::getCompanyId,updateMember.getCompanyId()) |
| | | .set(Member::getCode,updateMember.getCode()) |
| | | .set( updateMember.getPositionId()!=null,Member::getPositionId,updateMember.getPositionId()) |
| | | .set( updateMember.getIsDangyuan()!=null,Member::getIsDangyuan,updateMember.getIsDangyuan()) |
| | | .set( updateMember.getJobDate()!=null,Member::getJobDate,updateMember.getJobDate()) |
| | | .eq(Member::getId,updateMember.getId())); |
| | | dealTrainTIme(updateMember,1,null); |
| | | cancelAllMemberEmpower(updateMember,memberRoleMapper,empowerMapper); |
| | | //è®°å½æä½æ¥å¿ |
| | | saveUserActionBiz(updateMember,null,Constants.UserActionType.EDIT,userActionJoinMapper,null); |
| | | return updateMember; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ERPID å¤ææ°æ®æ¯å¦å·²å¨éåéåå¨ |
| | | * @param allList |
| | | * @param id |
| | | * @return |
| | | */ |
| | | private Member findMemberByERPId(List<Member> allList, String id) { |
| | | if(allList!=null){ |
| | | for(Member com :allList){ |
| | | if(StringUtils.equals(com.getErpId(),id)){ |
| | | return com; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private boolean isMemberDeleted(Member member, List<OapiV2UserGetResponse.UserGetResponse> list) { |
| | | for(OapiV2UserGetResponse.UserGetResponse m : list){ |
| | | if(StringUtils.equals(m.getUnionid(),member.getErpId())){ |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public void ddPushMemberInfo(String eventType, shade.com.alibaba.fastjson2.JSONObject eventData) throws ApiException { |
| | | JSONArray jsonArray = eventData.getJSONArray("userId"); |
| | | if(jsonArray.isEmpty()){ |
| | | return; |
| | | } |
| | | if(eventType.equals("user_leave_org")){ |
| | | //å é¤å¯¹äººåä¿¡æ¯ |
| | | List<String> userIdList = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | String deptId = jsonArray.getString(i); |
| | | userIdList.add(deptId); |
| | | } |
| | | if(CollectionUtils.isNotEmpty(userIdList)){ |
| | | syncDelMember(userIdList); |
| | | } |
| | | }else if(eventType.equals("user_add_org")||eventType.equals("user_modify_org")){ |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getIsdeleted,Constants.ZERO) |
| | | .eq(Member::getErpId,jsonArray.getLong(i)) |
| | | .last(" limit 1") |
| | | ); |
| | | OapiV2UserGetResponse.UserGetResponse deptGetResponse = dingTalk.syncUserInfo(jsonArray.getString(i)); |
| | | if(Objects.isNull(member)){ |
| | | getAddMemberModel(deptGetResponse,member); |
| | | }else{ |
| | | getUpdateMemberModel(deptGetResponse,member); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |