|
@ -14,6 +14,7 @@ import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.BeanClassLoaderAware;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@ -1619,7 +1620,71 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
|
|
|
return creditsDetailDOS;
|
|
|
}
|
|
|
|
|
|
public void reduceIntegrate(String hospital,String startTime,String endTime,Integer year){
|
|
|
String sql ="SELECT hbcd.patient_id, " +
|
|
|
"SUM(hbcd.integrate) AS total FROM wlyy_health_bank_credits_detail hbcd " +
|
|
|
"WHERE hbcd.patient_id IN ( SELECT sf.patient AS patient FROM wlyy.wlyy_sign_family sf " +
|
|
|
"WHERE sf.hospital = '"+hospital+"' AND sf. STATUS =- 4 AND sf.sign_year = "+year+" )AND hbcd.create_time < '"+endTime+"' " +
|
|
|
"AND hbcd.trade_direction = 1 AND hbcd.transaction_id IN ('402885ed63debfcc0163dec956200002','402885ed63debfcc0163deca5ca90003','402885ed63debfcc0163decbba230004','402885ed63debfcc0163decc0a1a0005') GROUP BY hbcd.patient_id";
|
|
|
List<Map<String,Object>> addIntegrate = jdbcTemplate.queryForList(sql);
|
|
|
if (addIntegrate==null||addIntegrate.size()==0){
|
|
|
logger.info("居民列表为空");
|
|
|
}
|
|
|
for (Map<String,Object> map:addIntegrate){
|
|
|
String patient = map.get("patient_id").toString();
|
|
|
Long reduceIntegrate = credittsLogDetailDao.selectTotalByPatient(patient);
|
|
|
if (reduceIntegrate == null){
|
|
|
reduceIntegrate = Long.parseLong("0");
|
|
|
}
|
|
|
Long total = Long.parseLong(map.get("total").toString());
|
|
|
if (total <=reduceIntegrate){
|
|
|
logger.info("居民code"+patient+"不需要扣减");
|
|
|
}else {
|
|
|
Long between = total - reduceIntegrate;
|
|
|
AccountDO accountDO = accountDao.selectByPatientId(patient);
|
|
|
String sql1 = "select p.idcard from wlyy.wlyy_patient p where p.code ='"+patient+"'";
|
|
|
List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql1);
|
|
|
String idcard = null;
|
|
|
if (maps!=null&&maps.size()!=0){
|
|
|
idcard = maps.get(0).get("idcard").toString();
|
|
|
accountDO.setIdCard(idcard);
|
|
|
}
|
|
|
TaskDO taskDO = taskDao.selectById("5e5d857d684d77f201684d7f58b3000a132");
|
|
|
TaskPatientDetailDO patientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId("5e5d857d684d77f201684d7f58b3000a132",patient);
|
|
|
if (patientDetailDO == null){
|
|
|
TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
|
|
|
taskPatientDetailDO.setSaasId("dev");
|
|
|
taskPatientDetailDO.setTaskId("5e5d857d684d77f201684d7f58b3000a132");
|
|
|
taskPatientDetailDO.setPatientId(patient);
|
|
|
taskPatientDetailDO.setDoctorId("system");
|
|
|
taskPatientDetailDO.setPatientIdcard(idcard);
|
|
|
taskPatientDetailDO.setCreateTime(new Date());
|
|
|
taskPatientDetailDO.setUpdateTime(new Date());
|
|
|
taskPatientDetailDO.setStatus(1);
|
|
|
taskPatientDetailDao.save(taskPatientDetailDO);
|
|
|
}
|
|
|
CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
|
|
|
creditsDetailDO.setAccountId(accountDO.getId());
|
|
|
creditsDetailDO.setIdCard(accountDO.getIdCard());
|
|
|
creditsDetailDO.setSaasId("dev");
|
|
|
creditsDetailDO.setTradeType("ACTIVITY_TASK");
|
|
|
creditsDetailDO.setTradeDirection(-1);
|
|
|
creditsDetailDO.setIntegrate(between.intValue());
|
|
|
creditsDetailDO.setDescription(taskDO.getTitle());
|
|
|
creditsDetailDO.setStatus(1);
|
|
|
creditsDetailDO.setHospital(hospital);
|
|
|
creditsDetailDO.setCreateTime(new Date());
|
|
|
creditsDetailDO.setUpdateTime(new Date());
|
|
|
creditsDetailDO.setTransactionId(taskDO.getId());
|
|
|
creditsDetailDO.setPatientId(patient);
|
|
|
credittsLogDetailDao.save(creditsDetailDO);
|
|
|
logger.info("===居民"+accountDO.getAccountName()+"("+patient+")失效"+creditsDetailDO.getIntegrate()+"===");
|
|
|
accountDO.setTotal(accountDO.getTotal()-between.intValue());
|
|
|
accountDao.save(accountDO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|