Commit 63ba6ded by huangjinxin

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

1 parent ff5aa178
......@@ -73,7 +73,7 @@ public class RedisService {
try {
ValueOperations<String, String> operations = redisTemplate.opsForValue();
operations.set(key, value);
redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
redisTemplate.expire(key, expireTime, TimeUnit.MILLISECONDS);
result = true;
} catch (Exception e) {
log.error("[set]---------->redis存值失败, key为: {}, 失败原因:{}", key, e.getMessage(), e);
......
......@@ -17,7 +17,7 @@ public class OrderServiceDetailResp {
private String location;
private String orderStatus;
private String serviceStatus;
private OrderDetail reschedulingParams;
// private OrderDetail reschedulingParams;
private List<KV> items;
/**
......@@ -93,14 +93,18 @@ public class OrderServiceDetailResp {
private String beanTags;
@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;
}
//
// @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 {
* 账号中心部门id
*/
private String bsDeptId;
/**
* bean部门id
*/
private String beanDeptId;
/**
* 部门名称
......
......@@ -24,6 +24,10 @@ public class Department {
*/
private String tagName;
/**
* 部门中文名称
*/
private String tagNameCn;
/**
* 部门描述 非必须
*/
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;
import com.dituhui.pea.order.feign.IBeanRemoteService;
import com.dituhui.pea.order.feign.bean.*;
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -166,13 +167,13 @@ public class BeanRemoteServiceImpl {
log.info("处理部门详情---->{}", department.getBsDeptId());
Boolean isDisposeData = true;
if (!BeanRegionIdEnum.getEnumByRegionId(department.getBsDeptId())) {
log.info("处理部门详情ID不在所需同步大区---->{}", department.getBsDeptId());
log.info("处理部门详情ID不在所需同步大区---->{}", department.getId());
isDisposeData = false;
}
if (isDisposeData) {
System.out.println(222);
Result result = this.departmentDetail(accessToken, department.getBsDeptId(), null);
log.info("处理部门详情,id:{},结果---->{}", department.getBsDeptId(), result.getCode());
Result result = this.departmentDetail(accessToken, department.getId(), null);
log.info("处理部门详情,id:{},结果---->{}", department.getId(), result.getCode());
if (result.getCode().equals(StatusCodeEnum.SUCCESS.getCode()) && ObjUtil.isNotNull(department.getChildren())) {
continue;
}
......@@ -203,13 +204,17 @@ public class BeanRemoteServiceImpl {
}
if (isDisposeData) {
System.out.println(222);
Result result = this.departmentDetail(accessToken, department.getBsDeptId(), departments.getBsDeptId());
log.info("处理部门详情,id:{},结果---->{}", department.getBsDeptId(), result.getCode());
Result result = this.departmentDetail(accessToken, department.getId(), departments.getBsDeptId());
log.info("处理部门详情,id:{},结果---->{}", department.getId(), result.getCode());
if (result.getCode().equals(StatusCodeEnum.SUCCESS.getCode()) && ObjUtil.isNotNull(department.getChildren())) {
continue;
}
}
disposeChildren(department, accessToken, isDisposeData, departments.getBsDeptId());
//大区数据处理完重置
if (department.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) {
isDisposeData = false;
}
}
}
......@@ -231,12 +236,12 @@ public class BeanRemoteServiceImpl {
//处理大区,分部数据
if (StringUtils.isNotBlank(data.getDeptLevel())) {
if (data.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) {
OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getBsDeptId());
OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getId());
if (ObjUtil.isNull(clusterEntity)) {
clusterEntity = new OrgClusterEntity();
}
clusterEntity.setName(StringUtils.isNotBlank(data.getDesc()) ? data.getDesc() : data.getTagName());
clusterEntity.setClusterId(data.getBsDeptId());
clusterEntity.setName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
clusterEntity.setClusterId(data.getId());
clusterEntity.setAbbreviation(data.getAbbreviation());
clusterEntity.setStatus(data.getEnable());
clusterEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
......@@ -245,15 +250,16 @@ public class BeanRemoteServiceImpl {
clusterEntity.setPhone(data.getPhone());
clusterEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
clusterEntity.setReserveTimeMax(data.getPartReserveTimeMax());
clusterEntity.setBsDeptId(data.getBsDeptId());
orgClusterDao.save(clusterEntity);
} else if (data.getDeptLevel().equals(BeanOrgLevelEnum.BRANCH.getCode())) {
OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getBsDeptId());
OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getId());
if (ObjUtil.isNull(branchEntity)) {
branchEntity = new OrgBranchEntity();
}
// branchEntity.setBranchName(data.getTagName());
branchEntity.setBranchName(StringUtils.isNotBlank(data.getDesc()) ? data.getDesc() : data.getTagName());
branchEntity.setBranchId(data.getBsDeptId());
branchEntity.setBranchName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
branchEntity.setBranchId(data.getId());
branchEntity.setAbbreviation(data.getAbbreviation());
branchEntity.setStatus(data.getEnable());
branchEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
......@@ -262,7 +268,8 @@ public class BeanRemoteServiceImpl {
branchEntity.setPhone(data.getPhone());
branchEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
branchEntity.setReserveTimeMax(data.getPartReserveTimeMax());
branchEntity.setClusterId(parentId);
branchEntity.setClusterId(data.getParentId());
branchEntity.setBsDeptId(data.getBsDeptId());
orgBranchDao.save(branchEntity);
branchMap.put(data.getBsDeptId(), branchEntity);
}
......@@ -270,13 +277,13 @@ public class BeanRemoteServiceImpl {
//处理分站外围数据
if (StringUtils.isNotBlank(data.getDeptType()) && (data.getDeptType().equals(BeanOrgLevelEnum.STATION.getCode())
|| data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode()))) {
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getBsDeptId());
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getId());
if (ObjUtil.isNull(groupEntity)) {
groupEntity = new OrgGroupEntity();
}
// groupEntity.setGroupName(data.getTagName());
groupEntity.setGroupName(StringUtils.isNotBlank(data.getDesc()) ? data.getDesc() : data.getTagName());
groupEntity.setGroupId(data.getBsDeptId());
groupEntity.setGroupName(StringUtils.isNotBlank(data.getTagNameCn()) ? data.getTagNameCn() : data.getTagName());
groupEntity.setGroupId(data.getId());
groupEntity.setAbbreviation(data.getAbbreviation());
groupEntity.setStatus(data.getEnable());
groupEntity.setCitycodeList(CollectionUtils.isEmpty(data.getManageCityList()) ? "{}" : JSONObject.toJSONString(data.getManageCityList()));
......@@ -286,15 +293,15 @@ public class BeanRemoteServiceImpl {
groupEntity.setWarehouseEnabled(data.getPeripheralWarehouseEnabled());
groupEntity.setReserveTimeMax(data.getPartReserveTimeMax());
//处理clusterId和branchId
OrgBranchEntity branchEntity = branchMap.get(parentId);
OrgBranchEntity branchEntity = branchMap.get(data.getParentId());
if (ObjUtil.isNull(branchEntity)) {
branchEntity = orgBranchDao.getByBranchId(parentId);
branchEntity = orgBranchDao.getByBranchId(data.getParentId());
if (ObjUtil.isNull(branchEntity)) {
return Result.failed();
}
branchMap.put(parentId, branchEntity);
branchMap.put(data.getParentId(), branchEntity);
}
groupEntity.setBranchId(parentId);
groupEntity.setBranchId(data.getParentId());
groupEntity.setClusterId(branchEntity.getClusterId());
//处理分站外围
if (data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode())) {
......@@ -304,6 +311,7 @@ public class BeanRemoteServiceImpl {
groupEntity.setKind(1);
}
groupEntity.setCategory(1);
groupEntity.setBsDeptId(data.getBsDeptId());
orgGroupDao.save(groupEntity);
return Result.success();
}
......@@ -326,8 +334,8 @@ public class BeanRemoteServiceImpl {
}
for (ServiceOrg serviceOrg : listBeanR.getData()) {
log.info("处理网点部门详情---->{}", serviceOrg.getServiceOrgId());
// Result result = this.serviceOrgDetail(accessToken, serviceOrg);
// log.info("处理网点部门详情,id:{},结果---->{}", serviceOrg.getServiceOrgId(), result.getCode());
Result result = this.serviceOrgDetail(accessToken, serviceOrg);
log.info("处理网点部门详情,id:{},结果---->{}", serviceOrg.getServiceOrgId(), result.getCode());
}
return Result.success();
}
......@@ -343,17 +351,29 @@ public class BeanRemoteServiceImpl {
if (ObjUtil.isNull(groupEntity)) {
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.setGroupName(data.getName());
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.setBranchId(data.getBelongBranch().getBsDeptId());
groupEntity.setClusterId(data.getBelongRegion().getBsDeptId());
groupEntity.setBranchId(data.getBelongBranch().getBeanDeptId());
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.setAddress(data.getBusinessAddress().getAddress());
groupEntity.setX(data.getBusinessAddress().getLongitude());
groupEntity.setY(data.getBusinessAddress().getLatitude());
orgGroupDao.save(groupEntity);
return Result.success();
}
......
......@@ -49,14 +49,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
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();
res.setOrderId(orderId);
res.setRisk("");
......@@ -67,9 +59,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setOrderStatus(order.getOrderStatus());
res.setServiceStatus(order.getServiceStatus());
res.setLocation(String.format("%s,%s", order.getX(), order.getY()));
res.setReschedulingParams(detail);
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.setIsAppointEngineer(order.getIsAppointEngineer());
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!