diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressInfoController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressInfoController.java index ae09c6b0b..fc2474be1 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressInfoController.java +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/ExpressInfoController.java @@ -7,6 +7,7 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.controller.BaseController; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -14,7 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import java.util.ArrayList; import java.util.List; /** @@ -121,4 +124,37 @@ public class ExpressInfoController extends BaseController { return toAjax(expressInfoService.deleteExpressInfoByIds(ids)); } + + + + @GetMapping ( "/importTemplate" ) + @ResponseBody + public AjaxResult importTemplate ( ) { + ExcelUtil < ExpressInfo > util = new ExcelUtil<>(ExpressInfo.class); + return util.importTemplateExcel ( "快递查询导入模板" ); + } + + @PostMapping("/importData") + @ResponseBody + public TableDataInfo importData(MultipartFile file, boolean updateSupport) throws Exception + { + /*ExcelUtil util = new ExcelUtil(SysUser.class); + List userList = util.importExcel(file.getInputStream()); + String operName = ShiroUtils.getSysUser().getLoginName(); + String message = userService.importUser(userList, updateSupport, operName); + return AjaxResult.success(message);*/ + + ExcelUtil util= new ExcelUtil(ExpressInfo.class); + List expressInfoList=util.importExcel(file.getInputStream()); + List list = new ArrayList<>(); + for( ExpressInfo expressInfo:expressInfoList) + { + list.add(expressInfo); + + } + + //String message = expressInfoList.importUser(userList, updateSupport, operName); + + return getDataTable(list); + } } diff --git a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java index 72b2d967e..e34dd86b6 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java +++ b/box-bps/src/main/java/com/ruoyi/bps/domain/ExpressInfo.java @@ -16,53 +16,79 @@ public class ExpressInfo extends BaseEntity private static final long serialVersionUID = 1L; /** 消息 */ - @Excel(name = "消息") + @Excel(name = "消息",type= Excel.Type.EXPORT) private String message; + + /** 出货单号 */ + @Excel(name = "出货单号") + private String deliveryNum; + /** 快递单号 */ @Excel(name = "快递单号") private String nu; /** 签收状态 */ - @Excel(name = "签收状态") + @Excel(name = "签收状态",type= Excel.Type.EXPORT,readConverterExp = "0=未签收,1=已签收") private String ischeck; /** 快递公司 */ - @Excel(name = "快递公司") + @Excel(name = "快递公司",type= Excel.Type.EXPORT,dictType = "express_company") private String com; /** 通信状态 */ - @Excel(name = "通信状态") + //@Excel(name = "通信状态",type= Excel.Type.EXPORT) private String status; /** 运单详情 */ - @Excel(name = "运单详情") + @Excel(name = "运单详情",type= Excel.Type.EXPORT) private String data; /** 当前状态 */ - @Excel(name = "当前状态") + @Excel(name = "当前状态",type= Excel.Type.EXPORT,dictType = "express_stats") private String state; /** 状态标志 */ - @Excel(name = "状态标志") + //@Excel(name = "状态标志",type= Excel.Type.EXPORT) private String condition; /** 路由信息 */ - @Excel(name = "路由信息") + //@Excel(name = "路由信息",type= Excel.Type.EXPORT) private String routeInfo; /** 返回码 */ - @Excel(name = "返回码") + //@Excel(name = "返回码",type= Excel.Type.EXPORT) private String returnCode; /** 返回结果 */ - @Excel(name = "返回结果") + //@Excel(name = "返回结果",type= Excel.Type.EXPORT) private String result; /** 电话号码 */ - @Excel(name = "电话号码") + //@Excel(name = "电话号码",type= Excel.Type.EXPORT) private String phone; + /** 揽收时间*/ + @Excel(name = "揽收时间",type= Excel.Type.EXPORT) + private String collectTime; + + /** 签收时间*/ + @Excel(name = "签收时间",type= Excel.Type.EXPORT) + private String singedTime; + + /** 最后更新时间*/ + @Excel(name = "最后更新时间",type= Excel.Type.EXPORT) + private String lastUpdateTime; + + /** 查询时间*/ + @Excel(name = "查询时间",type= Excel.Type.EXPORT) + private String queryTime; + + /** 查询人*/ + @Excel(name = "查询人",type= Excel.Type.EXPORT) + private String queryUser; + + public void setMessage(String message) { this.message = message; @@ -172,21 +198,79 @@ public class ExpressInfo extends BaseEntity return phone; } + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getCollectTime() { + return collectTime; + } + + public void setCollectTime(String collectTime) { + this.collectTime = collectTime; + } + + public String getSingedTime() { + return singedTime; + } + + public void setSingedTime(String singedTime) { + this.singedTime = singedTime; + } + + public String getLastUpdateTime() { + return lastUpdateTime; + } + + public void setLastUpdateTime(String lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public String getQueryTime() { + return queryTime; + } + + public void setQueryTime(String queryTime) { + this.queryTime = queryTime; + } + + public String getQueryUser() { + return queryUser; + } + + public void setQueryUser(String queryUser) { + this.queryUser = queryUser; + } + + public String getDeliveryNum() { + return deliveryNum; + } + + public void setDeliveryNum(String deliveryNum) { + this.deliveryNum = deliveryNum; + } + @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("message", getMessage()) - .append("nu", getNu()) - .append("ischeck", getIscheck()) - .append("com", getCom()) - .append("status", getStatus()) - .append("data", getData()) - .append("state", getState()) - .append("condition", getCondition()) - .append("routeInfo", getRouteInfo()) - .append("returnCode", getReturnCode()) - .append("result", getResult()) - .append("phone", getPhone()) - .toString(); + return "ExpressInfo{" + + "message='" + message + '\'' + + ", deliveryNum='" + deliveryNum + '\'' + + ", nu='" + nu + '\'' + + ", ischeck='" + ischeck + '\'' + + ", com='" + com + '\'' + + ", status='" + status + '\'' + + ", data='" + data + '\'' + + ", state='" + state + '\'' + + ", condition='" + condition + '\'' + + ", routeInfo='" + routeInfo + '\'' + + ", returnCode='" + returnCode + '\'' + + ", result='" + result + '\'' + + ", phone='" + phone + '\'' + + ", collectTime='" + collectTime + '\'' + + ", singedTime='" + singedTime + '\'' + + ", lastUpdateTime='" + lastUpdateTime + '\'' + + ", queryTime='" + queryTime + '\'' + + ", queryUser='" + queryUser + '\'' + + '}'; } } diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java index 8786681d9..fcec56e11 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java @@ -4,6 +4,8 @@ import com.ruoyi.bps.domain.ExpressInfo; import com.ruoyi.bps.mapper.ExpressInfoMapper; import com.ruoyi.bps.service.IExpressInfoService; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.google.gson.Gson; import com.kuaidi100.sdk.api.AutoNum; @@ -109,10 +111,12 @@ public class ExpressInfoServiceImpl implements IExpressInfoService String nu=expressInfo.getNu(); //快递单号 String com=expressInfo.getCom(); //快递公司 String phone=expressInfo.getPhone(); //收、寄件人电话号码 + String deliveryNum= expressInfo.getDeliveryNum(); ExpressInfo callbackExpressInfo=new ExpressInfo(); callbackExpressInfo.setNu(nu); callbackExpressInfo.setPhone(phone); + callbackExpressInfo.setDeliveryNum(deliveryNum); //如果没有输入快递公司编号,则查询快递公司编号 if(StringUtils.isEmpty(com)){ if(AutoGetExpressCom(nu)==null){ @@ -159,6 +163,24 @@ public class ExpressInfoServiceImpl implements IExpressInfoService return expressInfo; } + //获取签收时间 + String signedTime=null; + if(queryTrackResp.getState().equals("3")) { + signedTime=queryTrackResp.getData().get(0).getFtime(); + } + + //获取最后更新时间 + String lastUpdateTime=queryTrackResp.getData().get(0).getFtime(); + + //获取揽收时间 + String collectTime= queryTrackResp.getData().get(queryTrackResp.getData().size()-1).getTime(); + + //获取查询时间 + String queryTime= DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss"); + + //获取查询人(登录用户) + String queryUser= ShiroUtils.getLoginName(); + //将快递信息中的Context转化为字符 String dataStr=""; for(QueryTrackData queryTrackData :queryTrackResp.getData()){ @@ -181,6 +203,12 @@ public class ExpressInfoServiceImpl implements IExpressInfoService callbackExpressInfo.setReturnCode(queryTrackResp.getReturnCode()); callbackExpressInfo.setResult(queryTrackResp.isResult()?"Y":"N"); callbackExpressInfo.setPhone(expressInfo.getPhone()); + callbackExpressInfo.setSingedTime(signedTime); + callbackExpressInfo.setCollectTime(collectTime); + callbackExpressInfo.setLastUpdateTime(lastUpdateTime); + callbackExpressInfo.setQueryTime(queryTime); + callbackExpressInfo.setQueryUser(queryUser); + callbackExpressInfo.setDeliveryNum(expressInfo.getDeliveryNum()); return callbackExpressInfo; } diff --git a/box-bps/src/main/resources/templates/bps/expressInfo/expressInfo.html b/box-bps/src/main/resources/templates/bps/expressInfo/expressInfo.html index 10189c314..5cb02ff5c 100644 --- a/box-bps/src/main/resources/templates/bps/expressInfo/expressInfo.html +++ b/box-bps/src/main/resources/templates/bps/expressInfo/expressInfo.html @@ -22,6 +22,10 @@ +
  • + + +
  •  搜索  重置 @@ -41,6 +45,9 @@ 删除 --> + + 导入 + 导出 @@ -66,6 +73,8 @@ updateUrl: prefix + "/edit/{id}", removeUrl: prefix + "/remove", exportUrl: prefix + "/export", + importUrl: prefix + "/importData", + importTemplateUrl: prefix + "/importTemplate", modalName: "快递信息", columns: [{ checkbox: false @@ -75,6 +84,10 @@ field: 'message', title: '消息' },*/ + { + field: 'deliveryNum', + title: '出货单号' + }, { field: 'nu', title: '快递单号' @@ -126,10 +139,32 @@ field: 'result', title: '返回结果' },*/ + { field: 'phone', title: '电话号码' - }/*, + }, + { + field: 'singedTime', + title: '签收时间' + }, + { + field: 'collectTime', + title: '揽收时间' + }, + { + field: 'lastUpdateTime', + title: '最后更新时间' + }, + { + field: 'queryTime', + title: '查询时间' + }, + { + field: 'queryUser', + title: '查询人' + } + /* { title: '操作', align: 'center', @@ -144,5 +179,19 @@ $.table.init(options); }); + + \ No newline at end of file diff --git a/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html b/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html index 3326a905b..a3c79046e 100644 --- a/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html +++ b/box-bps/src/main/resources/templates/bps/expsubspushresp/expsubspushresp.html @@ -12,23 +12,23 @@
    • - -
    • - -
    • - - diff --git a/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html b/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html index be3e4f9c8..1520a1125 100644 --- a/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html +++ b/box-bps/src/main/resources/templates/bps/subscribe/subscribe.html @@ -13,8 +13,8 @@
      • - - @@ -33,7 +33,7 @@
      • - diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/GetEcologyInfoTestController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetEcologyInfoTestController.java index 8952c1a9b..faf741d0d 100644 --- a/box-test/src/main/java/com/ruoyi/test/conrtroller/GetEcologyInfoTestController.java +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetEcologyInfoTestController.java @@ -1,37 +1,30 @@ package com.ruoyi.test.conrtroller; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.entity.SysDept; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.http.HttpUtils; -import com.ruoyi.system.domain.EcologyDept; -import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - @RestController public class GetEcologyInfoTestController extends BaseController { @Autowired - private SysDeptMapper deptMapper; + private ISysDeptService deptService; @Autowired private ISysUserService userService; @RequestMapping("/anon/getEcologyDept") public String getEcologyDept() throws Exception { String url="http://192.168.2.85:90/api/hrm/resful/getHrmdepartmentWithPage"; - String params="{\"params\":{\"pagesize\":1000}}"; + String params="{\"params\":{\"pagesize\":999999}}"; //return sendPost(url,params); - return deptSync(HttpUtils.sendPostWithRest(url,params)); + int result = deptService.syncEcologyDept(url,params); + if(result==200){ + return "同步成功"; + } + return "同步失败"; } @@ -46,7 +39,7 @@ public class GetEcologyInfoTestController extends BaseController { return "同步失败"; } - /*public Map sendPostWithRest(String url,String params){ + /* *//*public Map sendPostWithRest(String url,String params){ RestTemplate restTemplate=new RestTemplate(); ResponseEntity result=null; int statusCode=0; @@ -65,7 +58,7 @@ public class GetEcologyInfoTestController extends BaseController { } return map; - }*/ + }*//* public SysDept insertEcologyDept(EcologyDept ecologyDept){ SysDept dept=new SysDept(); @@ -123,10 +116,10 @@ public class GetEcologyInfoTestController extends BaseController { //同步Ecology部门信息 for(EcologyDept ecologyDept:depts){ if(ecologyDept.getSubcompanyid1().equals("1")) { //只取分部ID为“1”的部门,排除代理商 - /* String pAncestors=null; + *//* String pAncestors=null; if(ecologyDept.getSupdepid().equals("0")){ //如果Ecology部门为一级部门,则设定ancestors="0,999999" pAncestors="0,999999"; - }*/ + }*//* SysDept dept= insertEcologyDept(ecologyDept); list.add(dept); } @@ -137,7 +130,7 @@ public class GetEcologyInfoTestController extends BaseController { return result; } - /* public String sendPost(String url,String params) throws Exception { + *//* public String sendPost(String url,String params) throws Exception { RestTemplate restTemplate=new RestTemplate(); ResponseEntity result = null; int statusCode = 0; @@ -158,8 +151,8 @@ public class GetEcologyInfoTestController extends BaseController { return result.getStatusCode().toString(); } +*//* + */ - - } diff --git a/pom.xml b/pom.xml index 5e0e7258b..81de1e84b 100644 --- a/pom.xml +++ b/pom.xml @@ -268,6 +268,7 @@ ${java.version} ${java.version} ${project.build.sourceEncoding} + -Xlint:unchecked diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 168fa2cd7..5582ace2b 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -7,7 +7,7 @@ ruoyi: # 版权年份 copyrightYear: 2021 # 实例演示开关 - demoEnabled: true + demoEnabled: false # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) profile: C:/bps-it/uploadPath # 获取ip地址开关 diff --git a/ruoyi-admin/src/main/resources/templates/system/user/add.html b/ruoyi-admin/src/main/resources/templates/system/user/add.html index c7f25c5ad..f6dbf21e1 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/user/add.html @@ -238,7 +238,7 @@ /* 用户管理-新增-选择部门树 */ function selectDeptTree() { var treeId = $("#treeId").val(); - var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val(); + var deptId = $.common.isEmpty(treeId) ? "999999" : $("#treeId").val(); var url = ctx + "system/dept/selectDeptTree/" + deptId; var options = { title: '选择部门', diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 77c2764df..7eb8a88eb 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -22,6 +22,10 @@ com.ruoyi ruoyi-common + + com.google.code.gson + gson + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/EcologyUser.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/EcologyUser.java index cf763af3f..0ddfb7242 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/EcologyUser.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/EcologyUser.java @@ -10,7 +10,7 @@ public class EcologyUser { String mobile; String email; String sex; - String Status; + String status; public String getSubcompanyid1() { return subcompanyid1; @@ -85,11 +85,11 @@ public class EcologyUser { } public String getStatus() { - return Status; + return status; } public void setStatus(String status) { - Status = status; + this.status = status; } @Override @@ -104,7 +104,7 @@ public class EcologyUser { ", mobile='" + mobile + '\'' + ", email='" + email + '\'' + ", sex='" + sex + '\'' + - ", Status='" + Status + '\'' + + ", status='" + status + '\'' + '}'; } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 87c650e19..d665df5df 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -1,17 +1,7 @@ package com.ruoyi.system.service.impl; -import java.util.*; - import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; -import com.ruoyi.common.utils.http.HttpUtils; -import com.ruoyi.system.domain.EcologyDept; -import org.apache.commons.lang3.ArrayUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.Ztree; @@ -20,10 +10,19 @@ import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.http.HttpUtils; +import com.ruoyi.system.domain.EcologyDept; import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.service.ISysDeptService; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; /** * 部门管理 服务实现 @@ -325,26 +324,40 @@ public class SysDeptServiceImpl implements ISysDeptService return result; } + @SuppressWarnings("unchecked") public int deptSync(Map mapResult){ //如果接口返回状态码不为200,则不做同步处理 - String statusCode=mapResult.get("statusCode"); - String result= mapResult.get("result"); - if(!statusCode.equals("200")) + if(!mapResult.get("statusCode").equals("200")) { return 0; } + //取Ecology返回信息中的部门信息 - Map map = (Map) JSON.parse(result); - Map o= (Map) map.get("data"); - JSONArray json = (JSONArray) o.get("dataList"); - List depts = JSONArray.parseArray(json.toJSONString(), EcologyDept.class); - //清空部门表,并插入顶级部门 - SysDept sysDept=deptMapper.selectDeptById(Long.parseLong("999999")); + Map map = (Map) JSON.parse(mapResult.get("result")); + Map dataMap= (Map) map.get("data"); + JSONArray json = (JSONArray) dataMap.get("dataList"); + List deptList = JSONArray.parseArray(json.toJSONString(), EcologyDept.class); + /*Map map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class); + Map dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class); + List deptList= new Gson().fromJson(new Gson().toJson(dataMap.get("dataList")), new TypeToken>(){}.getType());*/ + + //清空部门表 deptMapper.truncateDept(); - deptMapper.insertDept(sysDept); - List list=new ArrayList<>(); + + //插入顶级部门 + SysDept topDept= new SysDept();//deptMapper.selectDeptById(Long.parseLong("999999")); + topDept.setDeptId(Long.parseLong("999999")); + topDept.setParentId(Long.parseLong("0")); + topDept.setDeptName("BPS"); + topDept.setAncestors("0"); + topDept.setOrderNum("0"); + topDept.setStatus("0"); + topDept.setCreateBy("Admin"); + deptMapper.insertDept(topDept); + //同步Ecology部门信息 - for(EcologyDept ecologyDept:depts){ + List list=new ArrayList<>(); + for(EcologyDept ecologyDept:deptList){ if(ecologyDept.getSubcompanyid1().equals("1")) { //只取分部ID为“1”的部门,排除代理商 SysDept dept= insertEcologyDept(ecologyDept); list.add(dept); @@ -388,7 +401,4 @@ public class SysDeptServiceImpl implements ISysDeptService } updateAncestors(list); } - - - } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index c4f7a7d30..6b6cdf99e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -2,6 +2,8 @@ package com.ruoyi.system.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.SysRole; @@ -11,10 +13,7 @@ import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.http.HttpUtils; import com.ruoyi.common.utils.security.Md5Utils; -import com.ruoyi.system.domain.EcologyUser; -import com.ruoyi.system.domain.SysPost; -import com.ruoyi.system.domain.SysUserPost; -import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.domain.*; import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysUserService; @@ -25,6 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -540,34 +540,47 @@ public class SysUserServiceImpl implements ISysUserService return result; } + @SuppressWarnings("unchecked") public int userSync(Map mapResult){ //如果接口返回状态码不为200,则不做同步处理 - String statusCode=mapResult.get("statusCode"); - String result= mapResult.get("result"); - if(!statusCode.equals("200")) + if(!mapResult.get("statusCode").equals("200")) { return 0; } - //取Ecology返回信息中的部门信息 - Map map = (Map) JSON.parse(result); - Map o= (Map) map.get("data"); - JSONArray json = (JSONArray) o.get("dataList"); - List ecologyUserList = JSONArray.parseArray(json.toJSONString(), EcologyUser.class); + //取Ecology返回信息中的部门信息 + Map map = (Map) JSON.parse(mapResult.get("result")); + Map dataMap= (Map) map.get("data"); + JSONArray json = (JSONArray) dataMap.get("dataList"); + List ecologyUserList = JSONArray.parseArray(json.toJSONString(), EcologyUser.class); + /*Map map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class); + Map dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class); + List ecologyUserList= new Gson().fromJson(dataMap.get("dataList").toString(), new TypeToken>(){}.getType()); + */ + + //删除从Ecology同步过来(用户类型为02)的用户 userMapper.deleteEcologySyncUser(); - SysUser user = new SysUser(); + //同步Ecology部门信息 - for(EcologyUser ecologyuser:ecologyUserList){ - if(ecologyuser.getSubcompanyid1().equals("1") && StringUtils.isNotEmpty(ecologyuser.getLoginid())) { //只取分部ID为“1”的员工 - user.setUserId(Long.parseLong(ecologyuser.getId())); - user.setDeptId(Long.parseLong(ecologyuser.getDepartmentid())); - user.setLoginName(ecologyuser.getLoginid()); - user.setUserName(ecologyuser.getLastname()); - user.setUserType("02"); - user.setEmail(ecologyuser.getEmail()); - user.setSex(ecologyuser.getSex()); - user.setPhonenumber(ecologyuser.getMobile()); - user.setStatus(ecologyuser.getStatus().equals("5")?"1":"0"); //Ecology为离职状态5,则无效 + SysUser user = new SysUser(); + for(EcologyUser ecologyUser:ecologyUserList){ + if(ecologyUser.getSubcompanyid1().equals("1") && StringUtils.isNotEmpty(ecologyUser.getLoginid())) { //只取分部ID为“1”的员工 + String sex="2"; + if(ecologyUser.getSex().equals("男")){ + sex="0"; + } + if(ecologyUser.getSex().equals("女")){ + sex="1"; + } + user.setUserId(Long.parseLong(ecologyUser.getId())); + user.setDeptId(Long.parseLong(ecologyUser.getDepartmentid())); + user.setLoginName(ecologyUser.getLoginid()); + user.setUserName(ecologyUser.getLastname()); + user.setUserType("02"); //设置从Ecology同步的用户类型为02 + user.setEmail(ecologyUser.getEmail()); + user.setSex(sex); + user.setPhonenumber(ecologyUser.getMobile()); + user.setStatus(ecologyUser.getStatus().equals("5")?"1":"0"); //Ecology为离职状态5,则无效 user.setDelFlag("0"); userMapper.insertUser(user); }