|
|
@ -2,27 +2,29 @@ package com.cloud.kicc.commonbiz.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.ListUtil; |
|
|
|
import cn.hutool.core.collection.ListUtil; |
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
|
|
|
|
import cn.hutool.core.lang.UUID; |
|
|
|
|
|
|
|
import cn.hutool.core.thread.ThreadUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
import com.cloud.kicc.common.core.api.R; |
|
|
|
|
|
|
|
import com.cloud.kicc.common.core.constant.SecurityConstants; |
|
|
|
import com.cloud.kicc.common.security.util.SecurityUtils; |
|
|
|
import com.cloud.kicc.common.security.util.SecurityUtils; |
|
|
|
import com.cloud.kicc.commonbiz.api.entity.MapLogistic; |
|
|
|
import com.cloud.kicc.commonbiz.api.entity.*; |
|
|
|
import com.cloud.kicc.commonbiz.api.entity.MapLogisticPoint; |
|
|
|
|
|
|
|
import com.cloud.kicc.commonbiz.api.entity.MapTask; |
|
|
|
|
|
|
|
import com.cloud.kicc.commonbiz.api.entity.MapTaskPreset; |
|
|
|
|
|
|
|
import com.cloud.kicc.commonbiz.mapper.MapLogisticMapper; |
|
|
|
import com.cloud.kicc.commonbiz.mapper.MapLogisticMapper; |
|
|
|
import com.cloud.kicc.commonbiz.service.IMapLogisticPointService; |
|
|
|
import com.cloud.kicc.commonbiz.service.*; |
|
|
|
import com.cloud.kicc.commonbiz.service.IMapLogisticService; |
|
|
|
|
|
|
|
import com.cloud.kicc.commonbiz.service.IMapTaskPresetService; |
|
|
|
|
|
|
|
import com.cloud.kicc.commonbiz.service.IMapTaskService; |
|
|
|
|
|
|
|
import com.cloud.kicc.commonbiz.util.PushClientUtil; |
|
|
|
import com.cloud.kicc.commonbiz.util.PushClientUtil; |
|
|
|
|
|
|
|
import com.cloud.kicc.system.api.entity.User; |
|
|
|
|
|
|
|
import com.cloud.kicc.system.api.feign.RemoteUserService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import okhttp3.OkHttpClient; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import okhttp3.*; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -34,6 +36,7 @@ import java.util.List; |
|
|
|
* @author entfrm开发团队-王翔 |
|
|
|
* @author entfrm开发团队-王翔 |
|
|
|
* @since 2022-07-22 |
|
|
|
* @since 2022-07-22 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@ -43,6 +46,10 @@ public class MapLogisticServiceImpl extends ServiceImpl<MapLogisticMapper, MapLo |
|
|
|
private final IMapTaskPresetService iMapTaskPresetService; |
|
|
|
private final IMapTaskPresetService iMapTaskPresetService; |
|
|
|
private final IMapLogisticPointService iMapLogisticPointService; |
|
|
|
private final IMapLogisticPointService iMapLogisticPointService; |
|
|
|
private final OkHttpClient okHttpClient; |
|
|
|
private final OkHttpClient okHttpClient; |
|
|
|
|
|
|
|
private final RemoteUserService remoteUserService; |
|
|
|
|
|
|
|
private final OrgService orgService; |
|
|
|
|
|
|
|
private final HospitalService hospitalService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mapSaveOrUpdate(MapLogistic mapLogistic) { |
|
|
|
public void mapSaveOrUpdate(MapLogistic mapLogistic) { |
|
|
@ -90,9 +97,77 @@ public class MapLogisticServiceImpl extends ServiceImpl<MapLogisticMapper, MapLo |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
mapLogistic.getMapLogisticPoint().forEach(item -> item.setMapLogisticId(mapLogistic.getId())); |
|
|
|
mapLogistic.getMapLogisticPoint().forEach(item -> item.setMapLogisticId(mapLogistic.getId())); |
|
|
|
|
|
|
|
createReportFormSetData(mapLogistic); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ThreadUtil.execute(() -> createReportFormSetData(mapLogistic));
|
|
|
|
iMapLogisticPointService.saveBatch(mapLogistic.getMapLogisticPoint()); |
|
|
|
iMapLogisticPointService.saveBatch(mapLogistic.getMapLogisticPoint()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createReportFormSetData(MapLogistic mapLogistic) { |
|
|
|
|
|
|
|
String batchCode = UUID.fromString(UUID.randomUUID().toString()).toString(); |
|
|
|
|
|
|
|
mapLogistic.getMapTask().forEach(mapTask -> { |
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(mapTask.getReceiptFileId())) { |
|
|
|
|
|
|
|
R<User> user = remoteUserService.selectByUserId(mapTask.getCourierUserId(), SecurityConstants.FROM_IN); |
|
|
|
|
|
|
|
Org org = orgService.getById(mapTask.getOrgId()); |
|
|
|
|
|
|
|
Hospital hospital = hospitalService.getById(mapTask.getHospitalId()); |
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
|
|
|
jsonObject.put("hospitalId", hospital.getKlabHospitalAccount()); |
|
|
|
|
|
|
|
jsonObject.put("institutionId", org.getKlabOrgAccount()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// todo:任务科室医生还需讨论需求
|
|
|
|
|
|
|
|
jsonObject.put("officeId", 0); |
|
|
|
|
|
|
|
jsonObject.put("doctorId", 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonObject.put("syUserId", user.getData().getKlabUserAccount()); |
|
|
|
|
|
|
|
jsonObject.put("batchCode", batchCode); |
|
|
|
|
|
|
|
jsonObject.put("taskType", 0); |
|
|
|
|
|
|
|
jsonObject.put("originImages", mapTask.getReceiptFileId()); |
|
|
|
|
|
|
|
jsonObject.put("remark", mapTask.getRemarks()); |
|
|
|
|
|
|
|
internalSystemCreateReportForm(jsonObject); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapTask.getMapTaskPreset().forEach(mapTaskPreset -> { |
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(mapTaskPreset.getReceiptFileId())) { |
|
|
|
|
|
|
|
R<User> taskPresetUser = remoteUserService.selectByUserId(mapTaskPreset.getCourierUserId(), SecurityConstants.FROM_IN); |
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// todo:交接点位置由自己设置
|
|
|
|
|
|
|
|
jsonObject.put("hospitalId", 0); |
|
|
|
|
|
|
|
jsonObject.put("institutionId", 0); |
|
|
|
|
|
|
|
jsonObject.put("officeId", 0); |
|
|
|
|
|
|
|
jsonObject.put("doctorId", 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jsonObject.put("syUserId", taskPresetUser.getData().getKlabUserAccount()); |
|
|
|
|
|
|
|
jsonObject.put("batchCode", mapTaskPreset); |
|
|
|
|
|
|
|
jsonObject.put("taskType", 1); |
|
|
|
|
|
|
|
jsonObject.put("originImages", mapTaskPreset.getReceiptFileId()); |
|
|
|
|
|
|
|
jsonObject.put("remark", mapTaskPreset.getRemarks()); |
|
|
|
|
|
|
|
jsonObject.put("batchCode", batchCode); |
|
|
|
|
|
|
|
internalSystemCreateReportForm(jsonObject); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void internalSystemCreateReportForm(JSONObject jsonObject) { |
|
|
|
|
|
|
|
okhttp3.Request request = new okhttp3.Request |
|
|
|
|
|
|
|
.Builder() |
|
|
|
|
|
|
|
.url("https://cmsapi.kanglailab.com/reportTask/add") |
|
|
|
|
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonObject.toJSONString())) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
okHttpClient.newCall(request).enqueue(new Callback() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onResponse(Call call, Response response) { |
|
|
|
|
|
|
|
log.info("对接内部平台创建报告单成功:", response); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onFailure(Call call, IOException e) { |
|
|
|
|
|
|
|
log.info("对接内部平台创建报告单失败:", e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mapRemove(List<String> mapLogisticIds) { |
|
|
|
public void mapRemove(List<String> mapLogisticIds) { |
|
|
|
super.removeByIds(mapLogisticIds); |
|
|
|
super.removeByIds(mapLogisticIds); |
|
|
|