Commit 7773ad2c authored by “yiyousong”'s avatar “yiyousong”
parents d9915efe 8e989b63
......@@ -40,6 +40,7 @@
<package.environment>test</package.environment>
<skipUi>false</skipUi>
<showSql>false</showSql>
<profiles.holidayUrl>https://timor.tech/api/holiday/year/</profiles.holidayUrl>
</properties>
</profile>
<profile>
......@@ -60,6 +61,7 @@
<profiles.log.level>info</profiles.log.level>
<package.environment>test</package.environment>
<skipUi>false</skipUi>
<profiles.holidayUrl>https://timor.tech/api/holiday/year/</profiles.holidayUrl>
</properties>
</profile>
......@@ -81,6 +83,7 @@
<profiles.log.level>info</profiles.log.level>
<package.environment>build</package.environment>
<skipUi>false</skipUi>
<profiles.holidayUrl>https://timor.tech/api/holiday/year/</profiles.holidayUrl>
</properties>
</profile>
......@@ -104,6 +107,7 @@
<profiles.log.level>INFO</profiles.log.level>
<package.environment>yibin</package.environment>
<skipUi>false</skipUi>
<profiles.holidayUrl>https://timor.tech/api/holiday/year/</profiles.holidayUrl>
</properties>
</profile>
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.holiday.model.vo.HolidayVo;
import com.mortals.xhx.module.holiday.service.HolidayService;
import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 同步假期与周末需要补班的
*
* @author: zxfei
* @date: 2023/10/8 16:31
*/
@Slf4j
@Service("SyncHolidayTask")
public class SyncHolidayTaskImpl implements ITaskExcuteService {
@Autowired
private HolidayService holidayService;
@Value("${holidayUrl:https://timor.tech/api/holiday/year/2023}")
private String holidayUrl;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("开始同步当年假期列表!");
syncHoliday();
log.info("结束同步当年假期列表!");
}
private void syncHoliday() throws AppException {
holidayUrl += DateUtil.year(new Date());
String holidayJson = HttpUtil.get(holidayUrl);
ObjectMapper mapper = new ObjectMapper();
//查询全年节假日、调休
Map holidayMap = null;
try {
holidayMap = mapper.readValue(holidayJson, Map.class);
LinkedHashMap holidayList = (LinkedHashMap) holidayMap.get("holiday");
holidayList.forEach((key, value) -> {
Map value1 = (Map) value;
String date = value1.get("date").toString();
//判断当前日期的节假日是否存在
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(date);
holidayQuery.setStartTimeEnd(date);
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (ObjectUtils.isEmpty(holidayEntity)) {
//新增
holidayEntity = new HolidayEntity();
holidayEntity.initAttrValue();
holidayEntity.setSiteId(1L);
holidayEntity.setStartTime(DateUtil.parseDateTime(date));
holidayEntity.setEndTime(DateUtil.parseDateTime(date));
holidayEntity.setYear(DateUtil.year(new Date()));
String name = "法定节假日(" + value1.get("name").toString() + ")";
Boolean holiday = (Boolean) value1.get("holiday");
if (!holiday) {
name = "节假日调休补班(" + value1.get("target").toString() + ")";
holidayEntity.setWorkorholiday(1);
} else {
holidayEntity.setWorkorholiday(0);
}
holidayEntity.setName(name);
holidayEntity.setCreateTime(new Date());
holidayEntity.setCreateUserId(1L);
holidayService.save(holidayEntity);
}
});
} catch (JsonProcessingException e) {
throw new AppException(e.getMessage());
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
......@@ -50,5 +50,5 @@ application:
auth:
unloginUrl: /refresh,/error,/login/login,/login/index,/login/logout,/securitycode/createCode,/file/common/*,/test*,/padsign/*,/terminal/*,/resource/list,/api/asset/*,/api/*,/flow/*,/uploads/*,/project/file/*,/file/*,/assessment/*
uncheckUrl: /refresh,/error,/login/login,/login/index,/login/logout,/securitycode/createCode,/file/common/*,/test*,/padsign/*,/terminal/*,/resource/list,/api/asset/*,/api/*,/flow/*,/uploads/*,/project/file/*,/file/*,/assessment/*
holidayUrl: @profiles.holidayUrl@
POST http://192.168.0.98:11078/base/app/list
Content-Type: application/json
{}
###
###登录
POST {{baseUrl}}/login/login
Content-Type: application/json
......@@ -19,7 +25,8 @@ Content-Type: application/json
{
"page":1,
"size":1
"size":10,
"idList": [10,9,8]
}
......
......@@ -6,7 +6,7 @@
"baseUrl": "http://192.168.0.60:17211/base"
},
"base-test": {
"baseUrl": "http://192.168.0.98:11071/basics_api/base"
"baseUrl": "http://192.168.0.98:11078/base"
},
"base-test-https": {
......
......@@ -242,7 +242,7 @@ setup_mysql() {
tar -zvxf ${BASEDIR}/soft/${MYSQL}/${MYSQL_CENTOS_FILENAME} -C ${MYSQL_EXECPATH} --strip-components 1
cd ${MYSQL_EXECPATH}
chown mysql:mysql mysql-files
chmod 750 mysql-file
chmod 750 mysql-files
echo "
[mysqld]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment