Merge branch 'dev' into kone_dev

This commit is contained in:
18326186802 2021-07-22 17:23:45 +08:00
commit 8b5ce4d06b
14 changed files with 332 additions and 114 deletions

View File

@ -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<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = ShiroUtils.getSysUser().getLoginName();
String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message);*/
ExcelUtil<ExpressInfo> util= new ExcelUtil<ExpressInfo>(ExpressInfo.class);
List<ExpressInfo> expressInfoList=util.importExcel(file.getInputStream());
List<ExpressInfo> list = new ArrayList<>();
for( ExpressInfo expressInfo:expressInfoList)
{
list.add(expressInfo);
}
//String message = expressInfoList.importUser(userList, updateSupport, operName);
return getDataTable(list);
}
}

View File

@ -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 + '\'' +
'}';
}
}

View File

@ -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;
}

View File

@ -22,6 +22,10 @@
<label>电话号码:</label>
<input type="text" name="phone"/>
</li>
<li>
<label>出货单号:</label>
<input type="text" name="deliveryNum"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
@ -41,6 +45,9 @@
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="bps:expressInfo:remove">
<i class="fa fa-remove"></i> 删除
</a>-->
<a class="btn btn-info" onclick="$.table.importExcel()">
<i class="fa fa-upload"></i> 导入
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="bps:expressInfo:export">
<i class="fa fa-download"></i> 导出
</a>
@ -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);
});
</script>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
<div class="col-xs-offset-1">
<input type="file" id="file" name="file"/>
<div class="mt10 pt5">
<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
</div>
<span class="pull-left mt10" style="color: red; ">
提示仅允许导入“xls”或“xlsx”格式文件
</span>
</div>
</form>
</script>
</body>
</html>

View File

@ -12,23 +12,23 @@
<div class="select-list">
<ul>
<li>
<label class="font-noraml">当前状态:</label>
<select class="form-control select" name="lastResultState" th:with="type=${@dict.getType('express_stats')}">
<label>当前状态:</label>
<select name="lastResultState" th:with="type=${@dict.getType('express_stats')}">
<option value="">---所有---</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<label class="font-noraml">是否签收:</label>
<select class="form-control" name="lastResultIsCheck">
<label>是否签收:</label>
<select name="lastResultIsCheck">
<option value="">---所有---</option>
<option value="0">未签收</option>
<option value="1">已签收</option>
</select>
</li>
<li>
<label class="font-noraml">快递公司:</label>
<select class="form-control" name="lastResultCom" th:with="type=${@dict.getType('express_company')}">
<label>快递公司:</label>
<select name="lastResultCom" th:with="type=${@dict.getType('express_company')}">
<option value="">---所有---</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>

View File

@ -13,8 +13,8 @@
<div class="select-list">
<ul>
<li>
<label class="font-noraml">快递公司:</label>
<select class="form-control" name="company" th:with="type=${@dict.getType('express_company')}">
快递公司:
<select name="company" th:with="type=${@dict.getType('express_company')}">
<option value="">---所有---</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
@ -33,7 +33,7 @@
</li>
<li>
<label>订阅结果:</label>
<select class="form-control" name="result">
<select name="result">
<option value="">---所有---</option>
<option value="true">成功</option>
<option value="false">失败</option>

View File

@ -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<String,String> sendPostWithRest(String url,String params){
/* *//*public Map<String,String> sendPostWithRest(String url,String params){
RestTemplate restTemplate=new RestTemplate();
ResponseEntity<String> 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<String> result = null;
int statusCode = 0;
@ -158,8 +151,8 @@ public class GetEcologyInfoTestController extends BaseController {
return result.getStatusCode().toString();
}
*//*
*/
}

View File

@ -268,6 +268,7 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<compilerArgument>-Xlint:unchecked</compilerArgument>
</configuration>
</plugin>
</plugins>

View File

@ -7,7 +7,7 @@ ruoyi:
# 版权年份
copyrightYear: 2021
# 实例演示开关
demoEnabled: true
demoEnabled: false
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: C:/bps-it/uploadPath
# 获取ip地址开关

View File

@ -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: '选择部门',

View File

@ -22,6 +22,10 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>

View File

@ -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 + '\'' +
'}';
}
}

View File

@ -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<String,String> 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<String,Object> map = (Map) JSON.parse(result);
Map<String,Object> o= (Map<String, Object>) map.get("data");
JSONArray json = (JSONArray) o.get("dataList");
List<EcologyDept> depts = JSONArray.parseArray(json.toJSONString(), EcologyDept.class);
//清空部门表,并插入顶级部门
SysDept sysDept=deptMapper.selectDeptById(Long.parseLong("999999"));
Map<String,Object> map = (Map) JSON.parse(mapResult.get("result"));
Map<String,Object> dataMap= (Map<String, Object>) map.get("data");
JSONArray json = (JSONArray) dataMap.get("dataList");
List<EcologyDept> deptList = JSONArray.parseArray(json.toJSONString(), EcologyDept.class);
/*Map<String,Object> map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class);
Map<String,Object> dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class);
List<EcologyDept> deptList= new Gson().fromJson(new Gson().toJson(dataMap.get("dataList")), new TypeToken<List<EcologyDept>>(){}.getType());*/
//清空部门表
deptMapper.truncateDept();
deptMapper.insertDept(sysDept);
List<SysDept> 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<SysDept> 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);
}
}

View File

@ -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<String,String> 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<String,Object> map = (Map) JSON.parse(result);
Map<String,Object> o= (Map<String, Object>) map.get("data");
JSONArray json = (JSONArray) o.get("dataList");
List<EcologyUser> ecologyUserList = JSONArray.parseArray(json.toJSONString(), EcologyUser.class);
//取Ecology返回信息中的部门信息
Map<String,Object> map = (Map) JSON.parse(mapResult.get("result"));
Map<String,Object> dataMap= (Map<String, Object>) map.get("data");
JSONArray json = (JSONArray) dataMap.get("dataList");
List<EcologyUser> ecologyUserList = JSONArray.parseArray(json.toJSONString(), EcologyUser.class);
/*Map<String,Object> map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class);
Map<String,Object> dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class);
List<EcologyUser> ecologyUserList= new Gson().fromJson(dataMap.get("dataList").toString(), new TypeToken<List<EcologyUser>>(){}.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);
}