Browse Source

出租房调用ruoyi接口存储数据

dev
HAHA 3 years ago
parent
commit
89f164c9d0
  1. 15
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CaRentalController.java
  2. 3
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaRentalDao.java
  3. 8
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CaRentalService.java
  4. 92
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaRentalServiceImpl.java
  5. 3
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CaRentalDao.xml

15
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CaRentalController.java

@ -14,6 +14,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.opendata.dto.CaRentalDTO;
import com.epmet.opendata.dto.form.CaLoudongFormDTO;
import com.epmet.opendata.dto.form.CaRentalFormtDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.dto.result.CaRentalResultDTO;
import com.epmet.opendata.excel.CaRentalExcel;
@ -98,4 +99,18 @@ public class CaRentalController {
return new Result<PageData<CaRentalResultDTO>>().ok(data);
}
/**
* 出租房调用ruoyi接口存储数据
*
* @param dto
* @return com.epmet.commons.tools.utils.Result
* @author LZN
* @date 2022/6/2 10:31
*/
@PostMapping("/preserRentalVation")
public Result getPreserRentalVation(@RequestBody PreserVationFormDTO dto) {
caRentalService.preserRentalVation(dto);
return new Result();
}
}

3
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaRentalDao.java

@ -26,4 +26,7 @@ public interface CaRentalDao extends BaseDao<CaRentalEntity> {
* @return
*/
List<CaRentalResultDTO> getPage(@Param("residentName") String residentName);
void deleteAll();
}

8
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CaRentalService.java

@ -4,6 +4,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.opendata.dto.CaRentalDTO;
import com.epmet.opendata.dto.form.CaRentalFormtDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaRentalResultDTO;
import com.epmet.opendata.entity.CaRentalEntity;
@ -86,4 +87,11 @@ public interface CaRentalService extends BaseService<CaRentalEntity> {
* @return
*/
PageData<CaRentalResultDTO> getPage(CaRentalFormtDTO dto);
/**
* 出租房调用ruoyi接口存储数据
*
* @param dto
*/
void preserRentalVation(PreserVationFormDTO dto);
}

92
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaRentalServiceImpl.java

@ -1,17 +1,24 @@
package com.epmet.opendata.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.opendata.dao.CaRentalDao;
import com.epmet.opendata.dto.CaRentalDTO;
import com.epmet.opendata.dto.form.CaRentalFormtDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.dto.result.CaRentalResultDTO;
import com.epmet.opendata.entity.CaLoudongEntity;
import com.epmet.opendata.entity.CaRentalEntity;
import com.epmet.opendata.redis.CaRentalRedis;
import com.epmet.opendata.service.CaRentalService;
@ -98,4 +105,89 @@ public class CaRentalServiceImpl extends BaseServiceImpl<CaRentalDao, CaRentalEn
return new PageData<>(result, info.getTotal());
}
/**
* 出租房调用ruoyi接口存储数据
*
* @param dto
* @return void
* @author LZN
* @date 2022/6/2 10:31
*/
@Override
public void preserRentalVation(PreserVationFormDTO dto) {
baseDao.deleteAll();
dto.setPageNo(NumConstant.ONE);
dto.setPageSize(NumConstant.FIFTY);
dto.setTableSchema(rentalEnum.CZF.name);
dto.setTableName(rentalEnum.CZF.code);
dto.setWhereCase("delete_flag = 'normal'");
dto.setOrderBy("grid_id,update_date desc");
int pageNo = 1;
int total = 0;
do {
total = listRental(dto);
pageNo++;
dto.setPageNo(pageNo);
} while (total > (pageNo * NumConstant.FIFTY));
}
enum rentalEnum {
CZF("unicom", "ca_rental"),
;
private String name;
private String code;
rentalEnum(String name, String code) {
this.name = name;
this.code = code;
}
}
private int listRental(PreserVationFormDTO dto) {
String data = HttpClientManager.getInstance().sendPostByJSON("http://120.221.72.83:9090/bridge/unicom/page", JSON.toJSONString(dto)).getData();
JSONObject toResult = JSON.parseObject(data);
Result result = ConvertUtils.mapToEntity(toResult, Result.class);
if (!result.success()) {
return dto.getPageNo() + 1;
}
ReturnDate returnDate = JSONObject.parseObject(JSONObject.toJSONString(result.getData()), ReturnDate.class);
this.insertBatch(returnDate.getList());
return returnDate.getTotal();
}
class ReturnDate {
private int total;
private List<CaRentalEntity> list;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<CaRentalEntity> getList() {
return list;
}
public void setList(List<CaRentalEntity> list) {
this.list = list;
}
}
}

3
epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CaRentalDao.xml

@ -44,6 +44,9 @@
<result property="attribute9" column="attribute9"/>
<result property="attribute10" column="attribute10"/>
</resultMap>
<delete id="deleteAll">
delete from ca_rental
</delete>
<select id="getPage" resultType="com.epmet.opendata.dto.result.CaRentalResultDTO">
SELECT
rental_id,

Loading…
Cancel
Save