Commit 63ba6ded by huangjinxin

fix:组织结构,网点数据同步相关

1 parent ff5aa178
...@@ -73,7 +73,7 @@ public class RedisService { ...@@ -73,7 +73,7 @@ public class RedisService {
try { try {
ValueOperations<String, String> operations = redisTemplate.opsForValue(); ValueOperations<String, String> operations = redisTemplate.opsForValue();
operations.set(key, value); operations.set(key, value);
redisTemplate.expire(key, expireTime, TimeUnit.SECONDS); redisTemplate.expire(key, expireTime, TimeUnit.MILLISECONDS);
result = true; result = true;
} catch (Exception e) { } catch (Exception e) {
log.error("[set]---------->redis存值失败, key为: {}, 失败原因:{}", key, e.getMessage(), e); log.error("[set]---------->redis存值失败, key为: {}, 失败原因:{}", key, e.getMessage(), e);
......
...@@ -17,7 +17,7 @@ public class OrderServiceDetailResp { ...@@ -17,7 +17,7 @@ public class OrderServiceDetailResp {
private String location; private String location;
private String orderStatus; private String orderStatus;
private String serviceStatus; private String serviceStatus;
private OrderDetail reschedulingParams; // private OrderDetail reschedulingParams;
private List<KV> items; private List<KV> items;
/** /**
...@@ -93,14 +93,18 @@ public class OrderServiceDetailResp { ...@@ -93,14 +93,18 @@ public class OrderServiceDetailResp {
private String beanTags; private String beanTags;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class OrderDetail {
private String location;
private String address; private String address;
private String brand;
private String date; private String date;
private String type; //
private String skill; // @Data
} // @JsonInclude(JsonInclude.Include.NON_NULL)
// public static class OrderDetail {
// private String location;
// private String address;
// private String brand;
// private String date;
// private String type;
// private String skill;
// }
} }
...@@ -13,6 +13,10 @@ public class BelongRB { ...@@ -13,6 +13,10 @@ public class BelongRB {
* 账号中心部门id * 账号中心部门id
*/ */
private String bsDeptId; private String bsDeptId;
/**
* bean部门id
*/
private String beanDeptId;
/** /**
* 部门名称 * 部门名称
......
...@@ -24,6 +24,10 @@ public class Department { ...@@ -24,6 +24,10 @@ public class Department {
*/ */
private String tagName; private String tagName;
/** /**
* 部门中文名称
*/
private String tagNameCn;
/**
* 部门描述 非必须 * 部门描述 非必须
*/ */
private String desc; private String desc;
......
package com.dituhui.pea.order.feign.bean.enums;
public enum BeanPointTypeEnum {
// 类型(1分站,2外围,3小组,4网点,5自保点,6社会独立点,7商家独立点,8连锁网点,9网点伞下店)
// Self("1", "自保点"),
// Social("2", "社会独立点"),
// Business("3", "商家独立点"),
// Chain("4", "连锁网点"),
// Umbrella("5", "网点伞下店"),
// Umbrella("5", "网点伞下店"),
peaSelf(5, "自保点"),
peaSocial(6, "社会独立点"),
peaBusiness(7, "商家独立点"),
peaChain(8, "连锁网点"),
peaUmbrella(9, "网点伞下店");
private Integer type;
private String clazz;
BeanPointTypeEnum() {
}
BeanPointTypeEnum(Integer type, String clazz) {
this.type = type;
this.clazz = clazz;
}
public Integer getType() {
return type;
}
public String getClazz() {
return clazz;
}
public static Integer getTypeByClazz(String clazz) {
for (BeanPointTypeEnum value : BeanPointTypeEnum.values()) {
if (value.getClazz().equals(clazz)) {
return value.getType();
}
}
return null;
}
}
...@@ -17,6 +17,7 @@ import com.dituhui.pea.order.entity.OrgGroupEntity; ...@@ -17,6 +17,7 @@ import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.feign.IBeanRemoteService; import com.dituhui.pea.order.feign.IBeanRemoteService;
import com.dituhui.pea.order.feign.bean.*; import com.dituhui.pea.order.feign.bean.*;
import com.dituhui.pea.order.feign.bean.enums.BeanOrgLevelEnum; import com.dituhui.pea.order.feign.bean.enums.BeanOrgLevelEnum;
import com.dituhui.pea.order.feign.bean.enums.BeanPointTypeEnum;
import com.dituhui.pea.order.feign.bean.enums.BeanRegionIdEnum; import com.dituhui.pea.order.feign.bean.enums.BeanRegionIdEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -166,13 +167,13 @@ public class BeanRemoteServiceImpl { ...@@ -166,13 +167,13 @@ public class BeanRemoteServiceImpl {
log.info("处理部门详情---->{}", department.getBsDeptId()); log.info("处理部门详情---->{}", department.getBsDeptId());
Boolean isDisposeData = true; Boolean isDisposeData = true;
if (!BeanRegionIdEnum.getEnumByRegionId(department.getBsDeptId())) { if (!BeanRegionIdEnum.getEnumByRegionId(department.getBsDeptId())) {
log.info("处理部门详情ID不在所需同步大区---->{}", department.getBsDeptId()); log.info("处理部门详情ID不在所需同步大区---->{}", department.getId());
isDisposeData = false; isDisposeData = false;
} }
if (isDisposeData) { if (isDisposeData) {
System.out.println(222); System.out.println(222);
Result result = this.departmentDetail(accessToken, department.getBsDeptId(), null); Result result = this.departmentDetail(accessToken, department.getId(), null);
log.info("处理部门详情,id:{},结果---->{}", department.getBsDeptId(), result.getCode()); log.info("处理部门详情,id:{},结果---->{}", department.getId(), result.getCode());
if (result.getCode().equals(StatusCodeEnum.SUCCESS.getCode()) && ObjUtil.isNotNull(department.getChildren())) { if (result.getCode().equals(StatusCodeEnum.SUCCESS.getCode()) && ObjUtil.isNotNull(department.getChildren())) {
continue; continue;
} }
...@@ -203,13 +204,17 @@ public class BeanRemoteServiceImpl { ...@@ -203,13 +204,17 @@ public class BeanRemoteServiceImpl {
} }
if (isDisposeData) { if (isDisposeData) {
System.out.println(222); System.out.println(222);
Result result = this.departmentDetail(accessToken, department.getBsDeptId(), departments.getBsDeptId()); Result result = this.departmentDetail(accessToken, department.getId(), departments.getBsDeptId());
log.info("处理部门详情,id:{},结果---->{}", department.getBsDeptId(), result.getCode()); log.info("处理部门详情,id:{},结果---->{}", department.getId(), result.getCode());
if (result.getCode().equals(StatusCodeEnum.SUCCESS.getCode()) && ObjUtil.isNotNull(department.getChildren())) { if (result.getCode().equals(StatusCodeEnum.SUCCESS.getCode()) && ObjUtil.isNotNull(department.getChildren())) {
continue; continue;
} }
} }
disposeChildren(department, accessToken, isDisposeData, departments.getBsDeptId()); disposeChildren(department, accessToken, isDisposeData, departments.getBsDeptId());
//大区数据处理完重置
if (department.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) {
isDisposeData = false;
}
} }
} }
...@@ -231,12 +236,12 @@ public class BeanRemoteServiceImpl { ...@@ -231,12 +236,12 @@ public class BeanRemoteServiceImpl {
//处理大区,分部数据 //处理大区,分部数据
if (StringUtils.isNotBlank(data.getDeptLevel())) { if (StringUtils.isNotBlank(data.getDeptLevel())) {
if (data.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) { if (data.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) {
OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getBsDeptId()); OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getId());
if (ObjUtil.isNull(clusterEntity)) { if (ObjUtil.isNull(clusterEntity)) {
clusterEntity = new OrgClusterEntity(); clusterEntity = new OrgClusterEntity();
} }
clusterEntity.setName(StringUtils.isNotBlank(data.getDesc()) ? data.getDesc() : data.getTagName()); clusterEntity.setName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
clusterEntity.setClusterId(data.getBsDeptId()); clusterEntity.setClusterId(data.getId());
clusterEntity.setAbbreviation(data.getAbbreviation()); clusterEntity.setAbbreviation(data.getAbbreviation());
clusterEntity.setStatus(data.getEnable()); clusterEntity.setStatus(data.getEnable());
clusterEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList())); clusterEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
...@@ -245,15 +250,16 @@ public class BeanRemoteServiceImpl { ...@@ -245,15 +250,16 @@ public class BeanRemoteServiceImpl {
clusterEntity.setPhone(data.getPhone()); clusterEntity.setPhone(data.getPhone());
clusterEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled()); clusterEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
clusterEntity.setReserveTimeMax(data.getPartReserveTimeMax()); clusterEntity.setReserveTimeMax(data.getPartReserveTimeMax());
clusterEntity.setBsDeptId(data.getBsDeptId());
orgClusterDao.save(clusterEntity); orgClusterDao.save(clusterEntity);
} else if (data.getDeptLevel().equals(BeanOrgLevelEnum.BRANCH.getCode())) { } else if (data.getDeptLevel().equals(BeanOrgLevelEnum.BRANCH.getCode())) {
OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getBsDeptId()); OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getId());
if (ObjUtil.isNull(branchEntity)) { if (ObjUtil.isNull(branchEntity)) {
branchEntity = new OrgBranchEntity(); branchEntity = new OrgBranchEntity();
} }
// branchEntity.setBranchName(data.getTagName()); // branchEntity.setBranchName(data.getTagName());
branchEntity.setBranchName(StringUtils.isNotBlank(data.getDesc()) ? data.getDesc() : data.getTagName()); branchEntity.setBranchName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
branchEntity.setBranchId(data.getBsDeptId()); branchEntity.setBranchId(data.getId());
branchEntity.setAbbreviation(data.getAbbreviation()); branchEntity.setAbbreviation(data.getAbbreviation());
branchEntity.setStatus(data.getEnable()); branchEntity.setStatus(data.getEnable());
branchEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList())); branchEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
...@@ -262,7 +268,8 @@ public class BeanRemoteServiceImpl { ...@@ -262,7 +268,8 @@ public class BeanRemoteServiceImpl {
branchEntity.setPhone(data.getPhone()); branchEntity.setPhone(data.getPhone());
branchEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled()); branchEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
branchEntity.setReserveTimeMax(data.getPartReserveTimeMax()); branchEntity.setReserveTimeMax(data.getPartReserveTimeMax());
branchEntity.setClusterId(parentId); branchEntity.setClusterId(data.getParentId());
branchEntity.setBsDeptId(data.getBsDeptId());
orgBranchDao.save(branchEntity); orgBranchDao.save(branchEntity);
branchMap.put(data.getBsDeptId(), branchEntity); branchMap.put(data.getBsDeptId(), branchEntity);
} }
...@@ -270,13 +277,13 @@ public class BeanRemoteServiceImpl { ...@@ -270,13 +277,13 @@ public class BeanRemoteServiceImpl {
//处理分站外围数据 //处理分站外围数据
if (StringUtils.isNotBlank(data.getDeptType()) && (data.getDeptType().equals(BeanOrgLevelEnum.STATION.getCode()) if (StringUtils.isNotBlank(data.getDeptType()) && (data.getDeptType().equals(BeanOrgLevelEnum.STATION.getCode())
|| data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode()))) { || data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode()))) {
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getBsDeptId()); OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getId());
if (ObjUtil.isNull(groupEntity)) { if (ObjUtil.isNull(groupEntity)) {
groupEntity = new OrgGroupEntity(); groupEntity = new OrgGroupEntity();
} }
// groupEntity.setGroupName(data.getTagName()); // groupEntity.setGroupName(data.getTagName());
groupEntity.setGroupName(StringUtils.isNotBlank(data.getDesc()) ? data.getDesc() : data.getTagName()); groupEntity.setGroupName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
groupEntity.setGroupId(data.getBsDeptId()); groupEntity.setGroupId(data.getId());
groupEntity.setAbbreviation(data.getAbbreviation()); groupEntity.setAbbreviation(data.getAbbreviation());
groupEntity.setStatus(data.getEnable()); groupEntity.setStatus(data.getEnable());
groupEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList())); groupEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
...@@ -286,15 +293,15 @@ public class BeanRemoteServiceImpl { ...@@ -286,15 +293,15 @@ public class BeanRemoteServiceImpl {
groupEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled()); groupEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
groupEntity.setReserveTimeMax(data.getPartReserveTimeMax()); groupEntity.setReserveTimeMax(data.getPartReserveTimeMax());
//处理clusterId和branchId //处理clusterId和branchId
OrgBranchEntity branchEntity = branchMap.get(parentId); OrgBranchEntity branchEntity = branchMap.get(data.getParentId());
if (ObjUtil.isNull(branchEntity)) { if (ObjUtil.isNull(branchEntity)) {
branchEntity = orgBranchDao.getByBranchId(parentId); branchEntity = orgBranchDao.getByBranchId(data.getParentId());
if (ObjUtil.isNull(branchEntity)) { if (ObjUtil.isNull(branchEntity)) {
return Result.failed(); return Result.failed();
} }
branchMap.put(parentId, branchEntity); branchMap.put(data.getParentId(), branchEntity);
} }
groupEntity.setBranchId(parentId); groupEntity.setBranchId(data.getParentId());
groupEntity.setClusterId(branchEntity.getClusterId()); groupEntity.setClusterId(branchEntity.getClusterId());
//处理分站外围 //处理分站外围
if (data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode())) { if (data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode())) {
...@@ -304,6 +311,7 @@ public class BeanRemoteServiceImpl { ...@@ -304,6 +311,7 @@ public class BeanRemoteServiceImpl {
groupEntity.setKind(1); groupEntity.setKind(1);
} }
groupEntity.setCategory(1); groupEntity.setCategory(1);
groupEntity.setBsDeptId(data.getBsDeptId());
orgGroupDao.save(groupEntity); orgGroupDao.save(groupEntity);
return Result.success(); return Result.success();
} }
...@@ -326,8 +334,8 @@ public class BeanRemoteServiceImpl { ...@@ -326,8 +334,8 @@ public class BeanRemoteServiceImpl {
} }
for (ServiceOrg serviceOrg : listBeanR.getData()) { for (ServiceOrg serviceOrg : listBeanR.getData()) {
log.info("处理网点部门详情---->{}", serviceOrg.getServiceOrgId()); log.info("处理网点部门详情---->{}", serviceOrg.getServiceOrgId());
// Result result = this.serviceOrgDetail(accessToken, serviceOrg); Result result = this.serviceOrgDetail(accessToken, serviceOrg);
// log.info("处理网点部门详情,id:{},结果---->{}", serviceOrg.getServiceOrgId(), result.getCode()); log.info("处理网点部门详情,id:{},结果---->{}", serviceOrg.getServiceOrgId(), result.getCode());
} }
return Result.success(); return Result.success();
} }
...@@ -343,17 +351,29 @@ public class BeanRemoteServiceImpl { ...@@ -343,17 +351,29 @@ public class BeanRemoteServiceImpl {
if (ObjUtil.isNull(groupEntity)) { if (ObjUtil.isNull(groupEntity)) {
groupEntity = new OrgGroupEntity(); groupEntity = new OrgGroupEntity();
} }
//处理clusterId和branchId
OrgBranchEntity branchEntity = branchMap.get(data.getBelongBranch().getBeanDeptId());
if (ObjUtil.isNull(branchEntity)) {
branchEntity = orgBranchDao.getByBranchId(data.getBelongBranch().getBeanDeptId());
if (ObjUtil.isNull(branchEntity)) {
return Result.failed("分布不存在");
}
branchMap.put(data.getBelongBranch().getBeanDeptId(), branchEntity);
}
groupEntity.setGroupId(data.getServiceOrgId()); groupEntity.setGroupId(data.getServiceOrgId());
groupEntity.setGroupName(data.getName()); groupEntity.setGroupName(data.getName());
groupEntity.setStatus(data.getStatus()); groupEntity.setStatus(data.getStatus());
groupEntity.setCitycodeList(CollectionUtils.isEmpty(data.getServiceRange()) ? "" : JSONObject.toJSONString(data.getServiceRange())); groupEntity.setCitycodeList(CollectionUtils.isEmpty(data.getServiceRange()) ? "{}" : JSONObject.toJSONString(data.getServiceRange()));
groupEntity.setPhone(data.getContactPhone()); groupEntity.setPhone(data.getContactPhone());
groupEntity.setBranchId(data.getBelongBranch().getBsDeptId()); groupEntity.setBranchId(data.getBelongBranch().getBeanDeptId());
groupEntity.setClusterId(data.getBelongRegion().getBsDeptId()); groupEntity.setClusterId(data.getBelongRegion().getBeanDeptId());
// groupEntity.setBsDeptId(data.getBelongRegion().getBsDeptId());
//处理分站外围 //处理分站外围
groupEntity.setKind(4); groupEntity.setKind(CollectionUtils.isEmpty(data.getType()) ? 4 : BeanPointTypeEnum.getTypeByClazz(data.getType().get(0)));
groupEntity.setCategory(2); groupEntity.setCategory(2);
groupEntity.setAddress(data.getBusinessAddress().getAddress()); groupEntity.setAddress(data.getBusinessAddress().getAddress());
groupEntity.setX(data.getBusinessAddress().getLongitude());
groupEntity.setY(data.getBusinessAddress().getLatitude());
orgGroupDao.save(groupEntity); orgGroupDao.save(groupEntity);
return Result.success(); return Result.success();
} }
......
...@@ -49,14 +49,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -49,14 +49,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
List<KV> items = this.packOrderDetail(order); List<KV> items = this.packOrderDetail(order);
// 设置订单详情信息 // 设置订单详情信息
OrderServiceDetailResp.OrderDetail detail = new OrderServiceDetailResp.OrderDetail();
detail.setAddress(String.format("%s%s%s", order.getCity(), order.getCounty(), order.getAddress()));
detail.setLocation(String.format("%s,%s", order.getX(), order.getY()));
detail.setDate(TimeUtils.IsoLocalDate2String(order.getDt()));
detail.setBrand(order.getBrand());
detail.setType(order.getType());
detail.setSkill(order.getSkill());
OrderServiceDetailResp res = new OrderServiceDetailResp(); OrderServiceDetailResp res = new OrderServiceDetailResp();
res.setOrderId(orderId); res.setOrderId(orderId);
res.setRisk(""); res.setRisk("");
...@@ -67,9 +59,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -67,9 +59,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setOrderStatus(order.getOrderStatus()); res.setOrderStatus(order.getOrderStatus());
res.setServiceStatus(order.getServiceStatus()); res.setServiceStatus(order.getServiceStatus());
res.setLocation(String.format("%s,%s", order.getX(), order.getY())); res.setLocation(String.format("%s,%s", order.getX(), order.getY()));
res.setReschedulingParams(detail);
res.setItems(items); res.setItems(items);
res.setDate(TimeUtils.IsoLocalDate2String(order.getDt()));
res.setAddress(String.format("%s%s%s", order.getCity(), order.getCounty(), order.getAddress()));
res.setIsMultiple(order.getIsMultiple()); res.setIsMultiple(order.getIsMultiple());
res.setIsAppointEngineer(order.getIsAppointEngineer()); res.setIsAppointEngineer(order.getIsAppointEngineer());
if (StringUtils.isNotBlank(order.getAppointEngineerCodes())) { if (StringUtils.isNotBlank(order.getAppointEngineerCodes())) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!