Commit d65f4dfd authored by zhangwanglin's avatar zhangwanglin

异地结算定时

parent a69529ea
...@@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication; ...@@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
/** /**
...@@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableTransactionManagement @EnableTransactionManagement
@EnableFeignClients @EnableFeignClients
@EnableScheduling
public class AccountApplication { public class AccountApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(AccountApplication.class, args); SpringApplication.run(AccountApplication.class, args);
......
package com.hungraim.ltc.account.controller;
import com.hungraim.ltc.account.service.AccountService;
import com.hungraim.ltc.redis.RedisLock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Calendar;
/**
* @author zwl
* @ClassName
* @description
* @date 2024/5/12 15:14
**/
@Component
@EnableAsync
@Slf4j
public class PlaceOtherController {
@Autowired
private RedisLock redisLock;
@Autowired
private AccountService accountService;
public static final String JOB_PLACE_KEY = "redis.job.task:place";
@Scheduled(cron = "0 30 23 28-31 * ?")
public void disablePlaceHandler() {
boolean flag = redisLock.tryLock(JOB_PLACE_KEY, 1000 * 30);
if (flag) {
final Calendar c = Calendar.getInstance();
if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)) {
//是最后一天
accountService.placeOtherTaskQuery();
}
}
}
}
...@@ -1235,15 +1235,85 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis ...@@ -1235,15 +1235,85 @@ public class AccountServiceImpl extends ServiceImpl<ChDisabAccountsMapper, ChDis
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void placeOtherTaskQuery(){ public void placeOtherTaskQuery(){
List<PlaceOtherVO> placeOtherVOS = taskDetailMapper.placeOtherTaskQuery(); List<PlaceOtherVO> placeOtherVOS = taskDetailMapper.placeOtherTaskQuery();
if(CollectionUtil.isNotEmpty(placeOtherVOS)) {
int num = placeOtherVOS.size();
int days = DateUtils.getDays();
int total = days*20;
BigDecimal limit = BigDecimal.valueOf(total);
BigDecimal zero = BigDecimal.valueOf(0);
ChDisabAccounts chDisabAccounts = updateOtherAccounts(num, limit, zero);
for (PlaceOtherVO placeOtherVO : placeOtherVOS) { for (PlaceOtherVO placeOtherVO : placeOtherVOS) {
Integer disabInfoId = placeOtherVO.getDisabInfoId(); Integer disabInfoId = placeOtherVO.getDisabInfoId();
String otherApplyTime = placeOtherVO.getOtherApplyTime(); Long accountsId = chDisabAccounts.getAccountsId();
placeFreeHandler(disabInfoId,otherApplyTime); placeFreeHandler1(disabInfoId,accountsId,limit,zero);
}
}
}
private Result placeFreeHandler1(Integer disabInfoId,Long accountsId,BigDecimal limit,BigDecimal zero ) {
ChDisabDetailAccounts chDisabDetailAccountsDTO = chDisabAccountsDetailMapper.queryDisabDetailAccounts("1361", DateUtils.dateToStrYm(new Date()), String.valueOf(disabInfoId), "异地");
if (Objects.isNull(chDisabDetailAccountsDTO)) {
// 异地
ChDisabDetailAccounts chDisabDetailAccounts = new ChDisabDetailAccounts();
chDisabDetailAccounts.setAccountsAllCost(limit);
chDisabDetailAccounts.setAccountsOverallCost(limit);
chDisabDetailAccounts.setAccountsPersonalCost(zero);
chDisabDetailAccounts.setModeName("异地");
chDisabDetailAccounts.setSrvOrganId("1361");
chDisabDetailAccounts.setCreationTime(new Date());
chDisabDetailAccounts.setAccountsTime(new Date());
chDisabDetailAccounts.setDisabInfoId(String.valueOf(disabInfoId));
chDisabDetailAccounts.setStatus((short) 1);
chDisabDetailAccounts.setReissueAmount(BigDecimal.valueOf(0));
chDisabDetailAccounts.setDeductionAmount(BigDecimal.valueOf(0));
chDisabDetailAccounts.setAccountsId(accountsId);
chDisabAccountsDetailMapper.insert(chDisabDetailAccounts);
} else {
chDisabDetailAccountsDTO.setAccountsAllCost(limit);
chDisabDetailAccountsDTO.setAccountsOverallCost(limit);
chDisabDetailAccountsDTO.setAccountsPersonalCost(zero);
chDisabDetailAccountsDTO.setLcd(new Date());
chDisabAccountsDetailMapper.updateById(chDisabDetailAccountsDTO);
}
return Result.success();
}
private ChDisabAccounts updateOtherAccounts(int num, BigDecimal limit, BigDecimal zero) {
ChDisabAccounts chDisabAccounts = disabAccountsMapper.queryAccountByCondition(DateUtils.dateToStrYm(new Date()), "异地", "1361", null);
BigDecimal numBig = new BigDecimal(num);
BigDecimal cost = limit.multiply(numBig);
if (chDisabAccounts == null) {
chDisabAccounts = new ChDisabAccounts();
chDisabAccounts.setModeName("异地");
chDisabAccounts.setAccountsTime(new Date());
chDisabAccounts.setSrvOrganId(Long.valueOf(1361));
chDisabAccounts.setCreationTime(new Date());
chDisabAccounts.setAccountsStatus((short) 1);
chDisabAccounts.setAllCost(cost);
chDisabAccounts.setOverallCost(cost);
chDisabAccounts.setPersonalCost(zero);
chDisabAccounts.setReissueAmountTotal(zero);
chDisabAccounts.setDeductionAmountTotal(zero);
disabAccountsMapper.insert(chDisabAccounts);
}else {
ChDisabAccounts chDisabAccount = new ChDisabAccounts();
chDisabAccount.setAllCost(cost);
chDisabAccount.setOverallCost(cost);
Long accountsId = chDisabAccounts.getAccountsId();
chDisabAccount.setAccountsId(accountsId);
disabAccountsMapper.updateById(chDisabAccount);
} }
return chDisabAccounts;
} }
/** /**
*@desc 退回 *@desc 退回
* 1、根据服务机构,时间,失能人员,服务方式查询结算明细表 * 1、根据服务机构,时间,失能人员,服务方式查询结算明细表
......
...@@ -21,9 +21,14 @@ ...@@ -21,9 +21,14 @@
select * from CH_DISAB_ACCOUNTS t where t.MODE_NAME = #{modeName} select * from CH_DISAB_ACCOUNTS t where t.MODE_NAME = #{modeName}
and to_char(t.ACCOUNTS_TIME,'yyyy-MM') = #{accountsTime} and to_char(t.ACCOUNTS_TIME,'yyyy-MM') = #{accountsTime}
and t.SRV_ORGAN_ID = #{srvOrganId} and t.SRV_ORGAN_ID = #{srvOrganId}
<if test="isDelay !=null"> <choose>
<when test="isDelay != null">
and t.IS_DELAY = 2 and t.IS_DELAY = 2
</if> </when>
<otherwise>
and t.IS_DELAY is null
</otherwise>
</choose>
</select> </select>
......
...@@ -156,26 +156,17 @@ ...@@ -156,26 +156,17 @@
<select id="placeOtherTaskQuery" resultType="com.hungraim.ltc.pojo.vo.disable.PlaceOtherVO"> <select id="placeOtherTaskQuery" resultType="com.hungraim.ltc.pojo.vo.disable.PlaceOtherVO">
SELECT distinct info.DISAB_INFO_ID disabInfoId, SELECT distinct info.DISAB_INFO_ID disabInfoId,
report.evaluate_time evaluateTime,
task.ORGAN_ID organId,
report.disable_level_id disableLevelId,
info.REAL_NAME realName, info.REAL_NAME realName,
info.CERTI_CODE certiCode,
(SELECT DISE_TYPE_CODE FROM CH_FND_DISEASE_TYPE WHERE info.DISE_TYPE_S = DISE_TYPE_ID) diseTypeS,
info.disease_desc diseaseDesc,
lev.DISABLE_LEVEL_NAME riskLevel,
report.PUBLICITY_START_TIME publicityStartTime,
report.PUBLICITY_END_TIME publicityEndTime,
report.PUBLICITY_TIME publicityTime,
to_char(info.OTHER_APPLY_TIME,'yyyy-MM-dd') otherApplyTime to_char(info.OTHER_APPLY_TIME,'yyyy-MM-dd') otherApplyTime
FROM CH_DISABLE_INFO info FROM CH_DISABLE_INFO info
LEFT JOIN CH_APR_TASK task ON info.DISAB_INFO_ID = task.DISABLE_INFO_ID where info.SRV_MODE_ID ='4'
LEFT JOIN ch_apr_report report ON report.TASK_ID = task.TASK_ID
left join ch_apr_organ aprOrgan on task.apr_organ_id = aprOrgan.apr_organ_id
LEFT JOIN CH_CFG_SRV_DISABLE_LEVEL lev ON report.DISABLE_LEVEL_ID = lev.DISABLE_LEVEL_ID
where info.SRV_MODE_ID ='4' and sysdate <![CDATA[ > ]]> report.PUBLICITY_END_TIME
and info.OTHER_APPLY_TIME is not null and info.OTHER_APPLY_TIME is not null
and info.OTHER_APPLY_TIME = to_date(to_char(sysdate,'yyyy-MM-dd'),'yyyy-MM-dd') and (info.exit_reason_id !='1' or info.exit_reason_id is null)
and info.OTHER_APPLY_TIME <![CDATA[ <= ]]> to_date(to_char(sysdate,'yyyy-MM-dd'),'yyyy-MM-dd')
and info.DISAB_INFO_ID not in (
select d.disab_info_id from CH_DISAB_ACCOUNTS_detail d where d.mode_name <![CDATA[ <> ]]> '异地' and to_char(d.accounts_time,'yyyy-MM') = to_char(sysdate,'yyyy-MM')
)
</select> </select>
......
...@@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil; ...@@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
import java.text.ParseException; import java.text.ParseException;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
...@@ -156,6 +158,20 @@ public class DateUtils { ...@@ -156,6 +158,20 @@ public class DateUtils {
return strtodate; return strtodate;
} }
public static int getDays(){
LocalDate date = LocalDate.now();
// 获取当前年份和月份
YearMonth yearMonth = YearMonth.from(date);
// 获取当前月份的天数
int days = yearMonth.lengthOfMonth();
return days;
}
/** /**
* 将短时间格式字符串转换为时间 yyyyMMdd * 将短时间格式字符串转换为时间 yyyyMMdd
* *
......
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