|
|
|
@ -24,6 +24,7 @@ import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantType;
|
|
|
|
|
import com.glxp.api.dao.basic.UdiRelevanceDao;
|
|
|
|
|
import com.glxp.api.dao.collect.IoCollectOrderMapper;
|
|
|
|
|
import com.glxp.api.dao.inout.IoCodeTempDao;
|
|
|
|
|
import com.glxp.api.entity.auth.AuthAdmin;
|
|
|
|
@ -41,10 +42,7 @@ import com.glxp.api.http.ErpBasicClient;
|
|
|
|
|
import com.glxp.api.http.HttpOkClient;
|
|
|
|
|
import com.glxp.api.http.sync.SpGetHttpClient;
|
|
|
|
|
import com.glxp.api.req.basic.FilterUdiRelRequest;
|
|
|
|
|
import com.glxp.api.req.collect.CollectOrderBizRequest;
|
|
|
|
|
import com.glxp.api.req.collect.CollectOrderRequest;
|
|
|
|
|
import com.glxp.api.req.collect.IoCollectOrderUploadVo;
|
|
|
|
|
import com.glxp.api.req.collect.PostCollectOrderRequest;
|
|
|
|
|
import com.glxp.api.req.collect.*;
|
|
|
|
|
import com.glxp.api.req.inout.*;
|
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.basic.BasicSkPrescribeResponse;
|
|
|
|
@ -80,6 +78,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -145,6 +145,8 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC
|
|
|
|
|
DownloadFactory downloadFactory;
|
|
|
|
|
@Resource
|
|
|
|
|
ThrOrderDownload thrOrderDownload;
|
|
|
|
|
@Resource
|
|
|
|
|
UdiRelevanceDao udiRelevanceDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IoCollectOrder getByBillNo(String billNo) {
|
|
|
|
@ -1116,36 +1118,102 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IoCollectOrder> list = getList(file);
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
List<VA010Mx> a010details = this.getList(file);
|
|
|
|
|
if (CollUtil.isEmpty(a010details)) {
|
|
|
|
|
throw new JsonException("文件数据为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
CollectOrderRequest collectOrderRequest = new CollectOrderRequest();
|
|
|
|
|
Map<String, List<VA010Mx>> detailsMap = a010details.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(VA010Mx::getCodefk));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IoCollectOrder> ioCollectOrders = new ArrayList<>();
|
|
|
|
|
Map<String, List<VA010Mx>> finalDetailsMap = detailsMap;
|
|
|
|
|
for (Map.Entry<String, List<VA010Mx>> entry : finalDetailsMap.entrySet()) {
|
|
|
|
|
List<IoCollectOrderBiz> bizList = new ArrayList<>();
|
|
|
|
|
String billNo = entry.getKey();
|
|
|
|
|
List<VA010Mx> itemDetails = entry.getValue();
|
|
|
|
|
VA010Mx item = itemDetails.get(0);
|
|
|
|
|
|
|
|
|
|
StringBuilder errorMsg = new StringBuilder();
|
|
|
|
|
IoCollectOrder ioCollectOrder = new IoCollectOrder();
|
|
|
|
|
ioCollectOrder.setBillNo(item.getCodefk());
|
|
|
|
|
ioCollectOrder.setFromType("HIS系统");
|
|
|
|
|
ioCollectOrder.setFromCorp(item.getDeptcode());
|
|
|
|
|
ioCollectOrder.setWorkPlaceCode(null);
|
|
|
|
|
ioCollectOrder.setFromCorpName(item.getSickname());
|
|
|
|
|
ioCollectOrder.setShipperName(item.getDeptname());
|
|
|
|
|
ioCollectOrder.setBusType("YPCF002");
|
|
|
|
|
Date date = null;
|
|
|
|
|
try {
|
|
|
|
|
date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(item.getPrescribedate());
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ioCollectOrder.setBillTime(date);
|
|
|
|
|
ioCollectOrder.setCreateTime(new Date());
|
|
|
|
|
ioCollectOrder.setCreateUser(String.valueOf(customerService.getUserId()));
|
|
|
|
|
ioCollectOrder.setBackupOrderRemark1(item.getCodefk());
|
|
|
|
|
ioCollectOrder.setUpdateTime(new Date());
|
|
|
|
|
ioCollectOrder.setSplitStatus(0);
|
|
|
|
|
ioCollectOrder.setTagStatus(0);
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(itemDetails)) {
|
|
|
|
|
itemDetails.forEach(entity -> {
|
|
|
|
|
IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz();
|
|
|
|
|
BeanUtils.copyProperties(entity, collectOrderBiz);
|
|
|
|
|
|
|
|
|
|
List<UdiRelevanceEntity> basicUdirelEntities = udiRelevanceDao.selectList(new LambdaQueryWrapper<UdiRelevanceEntity>().eq(UdiRelevanceEntity::getMainId, entity.getItemcode()));
|
|
|
|
|
if (CollUtil.isNotEmpty(basicUdirelEntities)) {
|
|
|
|
|
UdiRelevanceEntity basicUdirelEntity = basicUdirelEntities.get(0);
|
|
|
|
|
collectOrderBiz.setRelId(basicUdirelEntity.getId());
|
|
|
|
|
} else {
|
|
|
|
|
errorMsg.append(entity.getItemname()).append("字典未对照").append(";");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
collectOrderBiz.setGgxh(entity.getBzgg());
|
|
|
|
|
collectOrderBiz.setMeasureUnit(entity.getMeasureunit());
|
|
|
|
|
collectOrderBiz.setCount(IntUtil.value(entity.getCount()));
|
|
|
|
|
collectOrderBiz.setThrCode(entity.getHiltstCode());
|
|
|
|
|
collectOrderBiz.setYbbm(entity.getHiltstCode());
|
|
|
|
|
collectOrderBiz.setCpmctymc(entity.getItemname());
|
|
|
|
|
collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo());
|
|
|
|
|
collectOrderBiz.setNameCode(entity.getHiltstCode());
|
|
|
|
|
collectOrderBiz.setTagStatus(1);
|
|
|
|
|
collectOrderBiz.setUnTagCount(0);
|
|
|
|
|
bizList.add(collectOrderBiz);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotBlank(errorMsg)) {
|
|
|
|
|
ioCollectOrder.setErrorMsg(errorMsg.toString());
|
|
|
|
|
ioCollectOrder.setTagStatus(4);
|
|
|
|
|
}
|
|
|
|
|
ioCollectOrder.setBizList(this.summarizeByCode(bizList));
|
|
|
|
|
ioCollectOrders.add(ioCollectOrder);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(ioCollectOrders)){
|
|
|
|
|
CollectOrderRequest collectOrderRequest = new CollectOrderRequest();
|
|
|
|
|
collectOrderRequest.setBusType("YPCF002");
|
|
|
|
|
collectOrderRequest.setCreateUser(String.valueOf(customerService.getUserId()));
|
|
|
|
|
collectOrderRequest.setWorkPlaceCode(null);
|
|
|
|
|
|
|
|
|
|
thrOrderDownload.importThrOrder(list, collectOrderRequest);
|
|
|
|
|
}
|
|
|
|
|
thrOrderDownload.importThrOrder(ioCollectOrders, collectOrderRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<IoCollectOrder> getList(MultipartFile file) {
|
|
|
|
|
List<IoCollectOrder> entities = new ArrayList<>();
|
|
|
|
|
public List<VA010Mx> getList(MultipartFile file) {
|
|
|
|
|
List<VA010Mx> entities = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
try (InputStream inputStream = file.getInputStream()) {
|
|
|
|
|
EasyExcel.read(inputStream, IoCollectOrderUploadVo.class, new AnalysisEventListener<IoCollectOrderUploadVo>() {
|
|
|
|
|
EasyExcel.read(inputStream, VA010Mx.class, new AnalysisEventListener<VA010Mx>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void invoke(IoCollectOrderUploadVo data, AnalysisContext context) {
|
|
|
|
|
// 每次读取到一行数据,都会调用这个方法
|
|
|
|
|
IoCollectOrder ioCollectOrder = new IoCollectOrder();
|
|
|
|
|
BeanUtils.copyProperties(data,ioCollectOrder);
|
|
|
|
|
entities.add(ioCollectOrder);
|
|
|
|
|
public void invoke(VA010Mx data, AnalysisContext context) {
|
|
|
|
|
entities.add(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1163,4 +1231,21 @@ public class IoCollectOrderService extends ServiceImpl<IoCollectOrderMapper, IoC
|
|
|
|
|
return entities;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<IoCollectOrderBiz> summarizeByCode(List<IoCollectOrderBiz> bizList) {
|
|
|
|
|
Map<String, IoCollectOrderBiz> summarizedMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
for (IoCollectOrderBiz biz : bizList) {
|
|
|
|
|
String code = biz.getThrCode();
|
|
|
|
|
|
|
|
|
|
if (summarizedMap.containsKey(code)) {
|
|
|
|
|
IoCollectOrderBiz existingBiz = summarizedMap.get(code);
|
|
|
|
|
existingBiz.setCount(existingBiz.getCount() + biz.getCount());
|
|
|
|
|
} else {
|
|
|
|
|
summarizedMap.put(code, biz);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ArrayList<>(summarizedMap.values());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|