|
@@ -1,21 +1,23 @@
|
|
|
package com.fs.his.service.impl;
|
|
package com.fs.his.service.impl;
|
|
|
|
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
|
|
|
+import java.lang.reflect.Method;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
-import com.fs.common.core.page.TableDataInfo;
|
|
|
|
|
import com.fs.common.utils.ParseUtils;
|
|
import com.fs.common.utils.ParseUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
|
-import com.fs.his.domain.FsStoreOrderDf;
|
|
|
|
|
import com.fs.his.mapper.FsStoreOrderMapper;
|
|
import com.fs.his.mapper.FsStoreOrderMapper;
|
|
|
import com.fs.his.mapper.FsStorePaymentMapper;
|
|
import com.fs.his.mapper.FsStorePaymentMapper;
|
|
|
import com.fs.his.param.FsStoreOrderParam;
|
|
import com.fs.his.param.FsStoreOrderParam;
|
|
|
import com.fs.his.param.FsStorePaymentParam;
|
|
import com.fs.his.param.FsStorePaymentParam;
|
|
|
-import com.fs.his.service.IFsStoreOrderService;
|
|
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.*;
|
|
import com.fs.his.vo.*;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -32,6 +34,7 @@ import com.fs.his.service.IFsExportTaskService;
|
|
|
@Service
|
|
@Service
|
|
|
public class FsExportTaskServiceImpl implements IFsExportTaskService
|
|
public class FsExportTaskServiceImpl implements IFsExportTaskService
|
|
|
{
|
|
{
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(FsExportTaskServiceImpl.class);
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsExportTaskMapper fsExportTaskMapper;
|
|
private FsExportTaskMapper fsExportTaskMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -121,11 +124,12 @@ public class FsExportTaskServiceImpl implements IFsExportTaskService
|
|
|
|
|
|
|
|
@Async
|
|
@Async
|
|
|
@Override
|
|
@Override
|
|
|
- public void exportStore1Data(FsStoreOrderParam fsStoreOrder,boolean isAdmin) {
|
|
|
|
|
|
|
+ public void exportStore1Data(FsStoreOrderParam fsStoreOrder,boolean isAdmin,ArrayList<String> filter) {
|
|
|
if ("金牛明医".equals(cloudHostProper.getCompanyName())){
|
|
if ("金牛明医".equals(cloudHostProper.getCompanyName())){
|
|
|
- exportErpData(fsStoreOrder, isAdmin);
|
|
|
|
|
|
|
+ exportErpData(fsStoreOrder, isAdmin,filter);
|
|
|
} else {
|
|
} else {
|
|
|
List<FsStoreOrderExportVO> list = fsStoreOrderMapper.selectFsStoreOrderListVOByExport(fsStoreOrder);
|
|
List<FsStoreOrderExportVO> list = fsStoreOrderMapper.selectFsStoreOrderListVOByExport(fsStoreOrder);
|
|
|
|
|
+
|
|
|
//对手机号脱敏
|
|
//对手机号脱敏
|
|
|
if (list != null) {
|
|
if (list != null) {
|
|
|
for (FsStoreOrderExportVO vo : list) {
|
|
for (FsStoreOrderExportVO vo : list) {
|
|
@@ -144,8 +148,16 @@ public class FsExportTaskServiceImpl implements IFsExportTaskService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 动态导出:根据选中的字段生成Excel
|
|
|
ExcelUtil<FsStoreOrderExportVO> util = new ExcelUtil<FsStoreOrderExportVO>(FsStoreOrderExportVO.class);
|
|
ExcelUtil<FsStoreOrderExportVO> util = new ExcelUtil<FsStoreOrderExportVO>(FsStoreOrderExportVO.class);
|
|
|
- AjaxResult result= util.exportExcel(list, "订单数据");
|
|
|
|
|
|
|
+ AjaxResult result;
|
|
|
|
|
+ // 如果有选中的字段,只导出这些字段
|
|
|
|
|
+ if (filter != null && !filter.isEmpty()) {
|
|
|
|
|
+ result = util.exportExcelSelectedColumns(list, "订单数据", filter);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 导出所有字段
|
|
|
|
|
+ result = util.exportExcel(list, "订单数据");
|
|
|
|
|
+ }
|
|
|
FsExportTask task=fsExportTaskMapper.selectFsExportTaskByTaskId(fsStoreOrder.getTaskId());
|
|
FsExportTask task=fsExportTaskMapper.selectFsExportTaskByTaskId(fsStoreOrder.getTaskId());
|
|
|
task.setFinishTime(new Date());
|
|
task.setFinishTime(new Date());
|
|
|
task.setStatus(1);
|
|
task.setStatus(1);
|
|
@@ -155,7 +167,50 @@ public class FsExportTaskServiceImpl implements IFsExportTaskService
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void exportErpData(FsStoreOrderParam fsStoreOrder, boolean isAdmin) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查对象是否至少有一个指定字段有有效值
|
|
|
|
|
+ * @param vo 要检查的对象
|
|
|
|
|
+ * @param fields 字段列表
|
|
|
|
|
+ * @return 是否符合条件
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean hasAtLeastOneFieldValue(FsStoreOrderErpExportVO vo, List<String> fields) {
|
|
|
|
|
+ if (vo == null || fields == null || fields.isEmpty()) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 通过反射检查每个字段
|
|
|
|
|
+ for (String fieldName : fields) {
|
|
|
|
|
+ // 根据字段名获取对应的getter方法
|
|
|
|
|
+ String getterMethod = "get" +
|
|
|
|
|
+ fieldName.substring(0, 1).toUpperCase() +
|
|
|
|
|
+ fieldName.substring(1);
|
|
|
|
|
+
|
|
|
|
|
+ Method method = vo.getClass().getMethod(getterMethod);
|
|
|
|
|
+ Object value = method.invoke(vo);
|
|
|
|
|
+
|
|
|
|
|
+ // 检查值是否有效(非空且非空字符串)
|
|
|
|
|
+ if (value != null) {
|
|
|
|
|
+ if (value instanceof String) {
|
|
|
|
|
+ if (!((String) value).trim().isEmpty()) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 非字符串类型只要不为null就算有效
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 处理反射异常,如字段不存在等情况
|
|
|
|
|
+ log.error("检查字段值时发生错误", e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 所有字段都无效
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void exportErpData(FsStoreOrderParam fsStoreOrder, boolean isAdmin,ArrayList<String> filter) {
|
|
|
List<FsStoreOrderErpExportVO> erpList = fsStoreOrderMapper.selectFsStoreOrderListErpVOByExport(fsStoreOrder);
|
|
List<FsStoreOrderErpExportVO> erpList = fsStoreOrderMapper.selectFsStoreOrderListErpVOByExport(fsStoreOrder);
|
|
|
//对手机号脱敏
|
|
//对手机号脱敏
|
|
|
if (erpList != null) {
|
|
if (erpList != null) {
|
|
@@ -175,8 +230,17 @@ public class FsExportTaskServiceImpl implements IFsExportTaskService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 动态导出:根据选中的字段生成Excel
|
|
|
ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
|
|
ExcelUtil<FsStoreOrderErpExportVO> util = new ExcelUtil<FsStoreOrderErpExportVO>(FsStoreOrderErpExportVO.class);
|
|
|
- AjaxResult result= util.exportExcel(erpList, "订单数据");
|
|
|
|
|
|
|
+ AjaxResult result;
|
|
|
|
|
+ // 如果有选中的字段,只导出这些字段
|
|
|
|
|
+ if (filter != null && !filter.isEmpty()) {
|
|
|
|
|
+ result = util.exportExcelSelectedColumns(erpList, "订单数据", filter);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 导出所有字段
|
|
|
|
|
+ result = util.exportExcel(erpList, "订单数据");
|
|
|
|
|
+ }
|
|
|
FsExportTask task=fsExportTaskMapper.selectFsExportTaskByTaskId(fsStoreOrder.getTaskId());
|
|
FsExportTask task=fsExportTaskMapper.selectFsExportTaskByTaskId(fsStoreOrder.getTaskId());
|
|
|
task.setFinishTime(new Date());
|
|
task.setFinishTime(new Date());
|
|
|
task.setStatus(1);
|
|
task.setStatus(1);
|