|
@@ -4,6 +4,8 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
+import com.zfjg.common.core.exception.ServiceException;
|
|
|
+import com.zfjg.common.core.interfaces.IHolidayCacheService;
|
|
|
import com.zfjg.common.core.utils.DateUtils;
|
|
|
import com.zfjg.manage.api.domain.enforce.obj.EnforceObj;
|
|
|
import com.zfjg.manage.task.obj.chian.*;
|
|
@@ -11,7 +13,9 @@ import com.zfjg.manage.task.obj.hospital.ObjSyncGeneralHospital;
|
|
|
import com.zfjg.manage.task.obj.hospital.ObjSyncSpecializedHospital;
|
|
|
import com.zfjg.manage.task.obj.hospital.ObjSyncTcmHospital;
|
|
|
import lombok.Data;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.cglib.beans.BeanMap;
|
|
@@ -21,10 +25,11 @@ import java.io.File;
|
|
|
import java.io.InputStream;
|
|
|
import java.net.URL;
|
|
|
import java.nio.charset.Charset;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
-
|
|
|
+@Slf4j
|
|
|
@SpringBootTest
|
|
|
public class ObjSyncHospitalTest {
|
|
|
|
|
@@ -36,7 +41,9 @@ public class ObjSyncHospitalTest {
|
|
|
|
|
|
@Autowired
|
|
|
private ObjSyncGeneralHospital generalHospital;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IHolidayCacheService holidayCacheService;
|
|
|
+ private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -59,10 +66,35 @@ public class ObjSyncHospitalTest {
|
|
|
* 测试同步综合医院单位
|
|
|
*/
|
|
|
// @Test
|
|
|
- public void test_sync_generalHospital() { generalHospital.runTask(); }
|
|
|
+ public void test_sync_generalHospital() {
|
|
|
+ generalHospital.runTask();
|
|
|
+ }
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testWorkTimeUtils() throws Exception {
|
|
|
+ Calendar instance = Calendar.getInstance();
|
|
|
+ instance.set(Calendar.MONTH, Calendar.JANUARY);
|
|
|
+ instance.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+
|
|
|
+ for (int i = 0; i < 365; i++) {
|
|
|
+ System.out.println(i);
|
|
|
+ instance.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ Date date = instance.getTime();
|
|
|
+ System.out.println(DateUtils.getDateFormat(date, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ try {
|
|
|
+ //此用引用了新节假日
|
|
|
+ String workDays = DateUtils.getWorkDays(date, 3, holidayCacheService);
|
|
|
+ date = format.parse(workDays);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ log.error("获取3个工作日后的日期失败", exception);
|
|
|
+ throw new ServiceException("获取3个工作日后的日期失败");
|
|
|
+ }
|
|
|
+ DateUtils.getWorkDays(date, 3, holidayCacheService);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- private <T> T readJSONUseCase(String caseName, TypeReference<T> typeReference) {
|
|
|
+ private <T> T readJSONUseCase(String caseName, TypeReference<T> typeReference) {
|
|
|
URL resource = Thread.currentThread().getContextClassLoader().getResource(caseName);
|
|
|
String content = FileUtil.readString(new File(resource.getPath()), Charset.forName("UTF-8"));
|
|
|
return JSON.parseObject(content, typeReference);
|
|
@@ -105,14 +137,14 @@ public class ObjSyncHospitalTest {
|
|
|
}
|
|
|
|
|
|
dealOrgParamChain.dealOrgParam(DealOrgParamChainHandler.Context.builder()
|
|
|
- .params(params)
|
|
|
- .obj(enforceObj)
|
|
|
+ .params(params)
|
|
|
+ .obj(enforceObj)
|
|
|
.build());
|
|
|
- System.out.println(enforceObj.getEnforceOrgName() + "====(" + item.getValue()+")");
|
|
|
+ System.out.println(enforceObj.getEnforceOrgName() + "====(" + item.getValue() + ")");
|
|
|
Assert.isTrue(enforceObj.getEnforceOrgName().equals(item.getValue()), "解析错误!机构应该是 => " + item.getValue());
|
|
|
});
|
|
|
|
|
|
-;
|
|
|
+ ;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -121,7 +153,8 @@ public class ObjSyncHospitalTest {
|
|
|
*/
|
|
|
//@Test
|
|
|
public void test_sync_to_db() {
|
|
|
- List<EnforceObj> list = readJSONUseCase("objs.json", new TypeReference<List<EnforceObj>>() {});
|
|
|
+ List<EnforceObj> list = readJSONUseCase("objs.json", new TypeReference<List<EnforceObj>>() {
|
|
|
+ });
|
|
|
specializedHospital.rsyncBatch(list);
|
|
|
}
|
|
|
|
|
@@ -154,8 +187,8 @@ public class ObjSyncHospitalTest {
|
|
|
}
|
|
|
});
|
|
|
dealOrgParamChain.dealOrgParam(DealOrgParamChainHandler.Context.builder()
|
|
|
- .params(new HashMap<>())
|
|
|
- .obj(new EnforceObj())
|
|
|
+ .params(new HashMap<>())
|
|
|
+ .obj(new EnforceObj())
|
|
|
.build());
|
|
|
}
|
|
|
|