Browse Source

1.司机导入仓库信息bug

pull/6/head
zhenghaoyu 10 months ago
parent
commit
3299baa640
  1. 1
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataDriverArteryMapper.xml
  2. 45
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataDriverArteryServiceImpl.java

1
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataDriverArteryMapper.xml

@ -173,6 +173,7 @@
from logpm_basicdata_driver_artery lbda
left join logpm_basicdata_driver_warehouse lbdw on lbdw.driver_id = lbda.id
where lbdw.warehouse_id = #{warehouseId}
and lbda.is_deleted = 0
</select>
<select id="findEntityByPhone" resultType="com.logpm.basicdata.entity.BasicdataDriverArteryEntity">

45
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataDriverArteryServiceImpl.java

@ -16,6 +16,7 @@
*/
package com.logpm.basicdata.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@ -218,15 +219,28 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
datum.setCarrierId(basicdataCarrierEntities.get(0).getId());
}
}
List<JSONObject> warehouseList = new ArrayList<>();
if (!ObjectUtils.isEmpty(datum.getWarehouseName())) {
//在数据库找到仓库名字对应
BasicdataWarehouseEntity byName = warehouseClient.findByName(datum.getWarehouseName());
if (ObjectUtils.isEmpty(byName)) {
// log.error("未找到仓库");
// continue;
throw new ServiceException("未找到仓库!");
} else {
datum.setWarehouseId(String.valueOf(byName.getId()));
String warehouseNames = datum.getWarehouseName();
warehouseNames = warehouseNames.replaceAll(",",",");
List<String> warehouseNameList = new ArrayList<>();
if(warehouseNames.contains(",")){
warehouseNameList = Arrays.asList(warehouseNames.split(","));
}else{
warehouseNameList.add(warehouseNames);
}
for (String wn : warehouseNameList) {
//在数据库找到仓库名字对应
BasicdataWarehouseEntity byName = warehouseClient.findByName(wn);
if (ObjectUtils.isEmpty(byName)) {
throw new ServiceException("未找到仓库!");
} else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("warehouseId",byName.getId());
jsonObject.put("warehouseName",wn);
warehouseList.add(jsonObject);
}
}
}
//根据手机号去重 如果有手机号相同 就删除老数据
@ -246,6 +260,21 @@ public class BasicdataDriverArteryServiceImpl extends BaseServiceImpl<BasicdataD
log.info("复制后>>>>>>>>>>>>{}", copy);
this.save(copy);
List<BasicdataDriverWarehouseEntity> driverWarehouseEntities = new ArrayList<>();
for (JSONObject jsonObject : warehouseList) {
Long warehouseId = jsonObject.getLong("warehouseId");
BasicdataDriverWarehouseEntity basicdataDriverWarehouseEntity = new BasicdataDriverWarehouseEntity();
basicdataDriverWarehouseEntity.setTenantId(AuthUtil.getTenantId());
basicdataDriverWarehouseEntity.setCreateUser(AuthUtil.getUserId());
basicdataDriverWarehouseEntity.setUpdateUser(AuthUtil.getUserId());
basicdataDriverWarehouseEntity.setCreateDept(Func.firstLong(AuthUtil.getDeptId()));
basicdataDriverWarehouseEntity.setDriverId(copy.getId());
basicdataDriverWarehouseEntity.setWarehouseId(warehouseId);
driverWarehouseEntities.add(basicdataDriverWarehouseEntity);
}
basicdataDriverWarehouseService.saveBatch(driverWarehouseEntities);
//车辆和司机绑定关系
for (BasicdataDrivermiddleEntity basicdataDrivermiddleEntity : driverMiddleEntity) {
basicdataDrivermiddleEntity.setDriverId(copy.getId());

Loading…
Cancel
Save