From 66a1d58753d27035e7fe4d42466bcfbcd96f9a1a Mon Sep 17 00:00:00 2001 From: zhujj Date: Thu, 24 Jan 2019 16:23:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/wx/cp/controller/WxDepartmentController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ruoyi-weixin/src/main/java/com/ruoyi/wx/cp/controller/WxDepartmentController.java b/ruoyi-weixin/src/main/java/com/ruoyi/wx/cp/controller/WxDepartmentController.java index f0da622b6..9a68d43b5 100644 --- a/ruoyi-weixin/src/main/java/com/ruoyi/wx/cp/controller/WxDepartmentController.java +++ b/ruoyi-weixin/src/main/java/com/ruoyi/wx/cp/controller/WxDepartmentController.java @@ -70,10 +70,14 @@ public class WxDepartmentController { @PostMapping("/insertList") public AjaxResult insertList(@RequestBody List wxCpDeparts) { this.logger.info("全量新增组织机构"); + int i=0; + int u=0; + WxCpDepart temp=null; try { WxCpDepartmentService departmentService = WxCpConfiguration.getCpService(999999).getDepartmentService(); for (WxCpDepart wxCpDepart : wxCpDeparts) { List list =null; + temp=wxCpDepart; try { list = departmentService.list(wxCpDepart.getId()); } catch (WxErrorException e) { @@ -81,13 +85,15 @@ public class WxDepartmentController { } if(list!=null&& list.size()>0){ departmentService.update(wxCpDepart); + u++; }else{ Integer id = departmentService.create(wxCpDepart); + i++; } } - return AjaxResult.success(wxCpDeparts.size(),"全量新增组织机构成功"); + return AjaxResult.success(wxCpDeparts.size(),"全量同步组织机构成功,新增【"+i+"】条,更新【"+u+"】条"); } catch (WxErrorException e) { - return AjaxResult.error("全量新增组织机构失败,错误码【"+ e.getError().getErrorCode()+"】,原因:"+ ErrorCodeText.errorMsg(e.getError().getErrorCode())); + return AjaxResult.error("全量新增组织机构失败,新增成功【\"+i+\"】条,更新成功【\"+u+\"】条。出错部门名称信息【"+(temp!=null?temp.toString():"部门信息为空")+"】,错误码【"+ e.getError().getErrorCode()+"】,原因:"+ ErrorCodeText.errorMsg(e.getError().getErrorCode())); } } @Log(title = "获取组织机构", businessType = BusinessType.UPDATE)