forked from rongchao/epmet-cloud-rizhao
10 changed files with 153 additions and 207 deletions
@ -1,41 +0,0 @@ |
|||||
package com.epmet.task; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
import com.epmet.commons.tools.utils.Result; |
|
||||
import com.epmet.opendata.dto.form.PreserVationFormDTO; |
|
||||
import com.epmet.opendata.feign.GuardarDatosFeignClient; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.apache.commons.lang3.StringUtils; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
/** |
|
||||
* 获取楼栋的数据存入ca_开头的表 |
|
||||
* |
|
||||
* @param |
|
||||
* @return |
|
||||
* @author LZN |
|
||||
* @date 2022/6/6 14:37 |
|
||||
*/ |
|
||||
@Slf4j |
|
||||
@Component("getPreserLouDongVation") |
|
||||
public class GuardarDatosLouDongTask implements ITask { |
|
||||
|
|
||||
@Autowired |
|
||||
private GuardarDatosFeignClient guardarDatosFeignClient; |
|
||||
|
|
||||
@Override |
|
||||
public void run(String params) { |
|
||||
log.info("LouDong定时任务执行,参数为:" + params); |
|
||||
PreserVationFormDTO formDTO = new PreserVationFormDTO(); |
|
||||
if (StringUtils.isNotBlank(params)) { |
|
||||
formDTO = JSON.parseObject(params, PreserVationFormDTO.class); |
|
||||
} |
|
||||
Result result = guardarDatosFeignClient.getPreserLouDongVation(formDTO); |
|
||||
if (result.success()){ |
|
||||
log.debug("LouDong执行成功"); |
|
||||
}else{ |
|
||||
log.debug("LouDong执行失败" + result.getMsg()); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,41 +0,0 @@ |
|||||
package com.epmet.task; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
import com.epmet.commons.tools.utils.Result; |
|
||||
import com.epmet.opendata.dto.form.PreserVationFormDTO; |
|
||||
import com.epmet.opendata.feign.GuardarDatosFeignClient; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.apache.commons.lang3.StringUtils; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
import javax.annotation.Resource; |
|
||||
|
|
||||
/** |
|
||||
* 获取平房的数据存入ca_开头的表 |
|
||||
* |
|
||||
* @param |
|
||||
* @return |
|
||||
* @author LZN |
|
||||
* @date 2022/6/6 14:37 |
|
||||
*/ |
|
||||
@Component("getPreserPingFangVation") |
|
||||
@Slf4j |
|
||||
public class GuardarDatosPingFangTask implements ITask { |
|
||||
|
|
||||
@Resource |
|
||||
private GuardarDatosFeignClient feignClient; |
|
||||
|
|
||||
@Override |
|
||||
public void run(String params) { |
|
||||
PreserVationFormDTO formDTO = new PreserVationFormDTO(); |
|
||||
if (StringUtils.isNotBlank(params)) { |
|
||||
formDTO = JSON.parseObject(params, PreserVationFormDTO.class); |
|
||||
} |
|
||||
Result result = feignClient.getPreserPingFangVation(formDTO); |
|
||||
if (result.success()) { |
|
||||
log.debug("pingfang执行成功"); |
|
||||
} else { |
|
||||
log.debug("pingfang执行失败" + result.getMsg()); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,40 +0,0 @@ |
|||||
package com.epmet.task; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
import com.epmet.commons.tools.utils.Result; |
|
||||
import com.epmet.opendata.dto.form.PreserVationFormDTO; |
|
||||
import com.epmet.opendata.feign.GuardarDatosFeignClient; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.apache.commons.lang3.StringUtils; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
/** |
|
||||
* 获取出租房的数据存入ca_开头的表 |
|
||||
* |
|
||||
* @param |
|
||||
* @return |
|
||||
* @author LZN |
|
||||
* @date 2022/6/6 14:38 |
|
||||
*/ |
|
||||
@Component("getPreserRentalVation") |
|
||||
@Slf4j |
|
||||
public class GuardarDatosRentalTask implements ITask { |
|
||||
|
|
||||
@Autowired |
|
||||
private GuardarDatosFeignClient feignClient; |
|
||||
|
|
||||
@Override |
|
||||
public void run(String params) { |
|
||||
PreserVationFormDTO formDTO = new PreserVationFormDTO(); |
|
||||
if (StringUtils.isNotBlank(params)) { |
|
||||
formDTO = JSON.parseObject(params, PreserVationFormDTO.class); |
|
||||
} |
|
||||
Result result = feignClient.getPreserRentalVation(formDTO); |
|
||||
if (result.success()) { |
|
||||
log.debug("Rental执行成功"); |
|
||||
}else{ |
|
||||
log.debug("Rental执行失败" + result.getMsg()); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,41 +0,0 @@ |
|||||
package com.epmet.task; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
import com.epmet.commons.tools.utils.Result; |
|
||||
import com.epmet.opendata.dto.form.PreserVationFormDTO; |
|
||||
import com.epmet.opendata.feign.GuardarDatosFeignClient; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.apache.commons.lang3.StringUtils; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
import javax.annotation.Resource; |
|
||||
|
|
||||
/** |
|
||||
* 获取人口的数据存入ca_开头的表 |
|
||||
* |
|
||||
* @param |
|
||||
* @return |
|
||||
* @author LZN |
|
||||
* @date 2022/6/6 14:39 |
|
||||
*/ |
|
||||
@Component("getPreserResidentVation") |
|
||||
@Slf4j |
|
||||
public class GuardarDatosResidentTask implements ITask { |
|
||||
|
|
||||
@Resource |
|
||||
private GuardarDatosFeignClient feignClient; |
|
||||
|
|
||||
@Override |
|
||||
public void run(String params) { |
|
||||
PreserVationFormDTO formDTO = new PreserVationFormDTO(); |
|
||||
if (StringUtils.isNotBlank(params)) { |
|
||||
formDTO = JSON.parseObject(params, PreserVationFormDTO.class); |
|
||||
} |
|
||||
Result result = feignClient.getPreserResidentVation(formDTO); |
|
||||
if (result.success()) { |
|
||||
log.debug("Resident执行成功"); |
|
||||
} else { |
|
||||
log.debug("Resident执行失败" + result.getMsg()); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,33 @@ |
|||||
|
package com.epmet.opendata.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.opendata.dto.form.PreserVationFormDTO; |
||||
|
import com.epmet.opendata.service.GuardarDatosTaskService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* 定时任务 |
||||
|
* |
||||
|
* @param |
||||
|
* @author LZN |
||||
|
* @return |
||||
|
* @date 2022/6/7 15:54 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("caTask") |
||||
|
public class CaTaskController { |
||||
|
|
||||
|
@Autowired |
||||
|
private GuardarDatosTaskService taskService; |
||||
|
|
||||
|
@PostMapping("guardarDatosTask") |
||||
|
public Result guardarDatosTask(@RequestBody PreserVationFormDTO dto) { |
||||
|
taskService.guardarDatosTask(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.epmet.opendata.service; |
||||
|
|
||||
|
import com.epmet.opendata.dto.form.PreserVationFormDTO; |
||||
|
|
||||
|
/** |
||||
|
* 定时任务 |
||||
|
* |
||||
|
* @param |
||||
|
* @author LZN |
||||
|
* @return |
||||
|
* @date 2022/6/7 15:54 |
||||
|
*/ |
||||
|
public interface GuardarDatosTaskService { |
||||
|
|
||||
|
void guardarDatosTask(PreserVationFormDTO dto); |
||||
|
} |
@ -0,0 +1,91 @@ |
|||||
|
package com.epmet.opendata.service.impl; |
||||
|
|
||||
|
import com.epmet.opendata.dto.form.PreserVationFormDTO; |
||||
|
import com.epmet.opendata.service.*; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class GuardarDatosTaskServiceImpl implements GuardarDatosTaskService { |
||||
|
|
||||
|
@Autowired |
||||
|
private CaLoudongService caLoudongService; |
||||
|
|
||||
|
@Autowired |
||||
|
private CaPingfangService pingfangService; |
||||
|
|
||||
|
@Autowired |
||||
|
private CaRentalService rentalService; |
||||
|
|
||||
|
@Autowired |
||||
|
private CaResidentService residentService; |
||||
|
|
||||
|
@Autowired |
||||
|
private CaRotatorsService rotatorsService; |
||||
|
|
||||
|
@Override |
||||
|
public void guardarDatosTask(PreserVationFormDTO dto) { |
||||
|
if (StringUtils.isBlank(dto.getTableName())) { |
||||
|
caLoudongService.preserLouDongVation(dto); |
||||
|
pingfangService.preserPingFangVation(dto); |
||||
|
rentalService.preserRentalVation(dto); |
||||
|
residentService.preserResidentVation(dto); |
||||
|
rotatorsService.preserRotatorsVation(dto); |
||||
|
} |
||||
|
TableName name = TableName.getTableByOutSide(dto.getTableName()); |
||||
|
if (null == name) { |
||||
|
throw new Error(); |
||||
|
} |
||||
|
|
||||
|
switch (name) { |
||||
|
case LD: |
||||
|
caLoudongService.preserLouDongVation(dto); |
||||
|
break; |
||||
|
case PF: |
||||
|
pingfangService.preserPingFangVation(dto); |
||||
|
break; |
||||
|
case RK: |
||||
|
residentService.preserResidentVation(dto); |
||||
|
break; |
||||
|
case CZF: |
||||
|
rentalService.preserRentalVation(dto); |
||||
|
break; |
||||
|
case LDRK: |
||||
|
rotatorsService.preserRotatorsVation(dto); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
enum TableName { |
||||
|
LD("ca_loudong"), |
||||
|
PF("ca_pingfang"), |
||||
|
RK("ca_resident"), |
||||
|
LDRK("ca_rotators"), |
||||
|
CZF("ca_rental"); |
||||
|
|
||||
|
private String tableName; |
||||
|
|
||||
|
TableName(String tableOs) { |
||||
|
|
||||
|
this.tableName = tableOs; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public String getTableName() { |
||||
|
return tableName; |
||||
|
} |
||||
|
|
||||
|
static TableName getTableByOutSide(String outSideName) { |
||||
|
if (StringUtils.isNotBlank(outSideName)) { |
||||
|
TableName[] values = TableName.values(); |
||||
|
for (TableName value : values) { |
||||
|
if (value.getTableName().equals(outSideName)) { |
||||
|
return value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue