Browse Source

楼栋调用ruoyi接口存储数据

master
HAHA 3 years ago
parent
commit
3e780435d5
  1. 41
      epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/PreserVationFormDTO.java
  2. 15
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/controller/CaLoudongController.java
  3. 2
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaLoudongDao.java
  4. 10
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/CaResidentEntity.java
  5. 10
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/CaRotatorsEntity.java
  6. 8
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/CaLoudongService.java
  7. 94
      epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/CaLoudongServiceImpl.java
  8. 3
      epmet-module/open-data-worker/open-data-worker-server/src/main/resources/mapper/CaLoudongDao.xml

41
epmet-module/open-data-worker/open-data-worker-client/src/main/java/com/epmet/opendata/dto/form/PreserVationFormDTO.java

@ -0,0 +1,41 @@
package com.epmet.opendata.dto.form;
import lombok.Data;
import java.io.Serializable;
@Data
public class PreserVationFormDTO implements Serializable {
private static final long serialVersionUID = 3489407841261413891L;
/**
* 表名
*/
private String tableSchema;
/**
* 表名
*/
private String tableName;
/**
* 页码
*/
private Integer pageNo;
/**
* 每页条数
*/
private Integer pageSize;
/**
* 查询条件
*/
private String whereCase;
/**
*排序字段
*/
private String orderBy;
}

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

@ -14,6 +14,7 @@ import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.opendata.dto.CaLoudongDTO;
import com.epmet.opendata.dto.form.CaLoudongDetailsFormDTO;
import com.epmet.opendata.dto.form.CaLoudongFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaLoudongDetailsResultDTO;
import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.excel.CaLoudongExcel;
@ -113,4 +114,18 @@ public class CaLoudongController {
return new Result().ok(result);
}
/**
* 楼栋调用ruoyi接口存储数据
*
* @param dto
* @return com.epmet.commons.tools.utils.Result
* @author LZN
* @date 2022/6/2 10:02
*/
@PostMapping("/preserLouDongVation")
public Result getPreserLouDongVation(@RequestBody PreserVationFormDTO dto) {
caLoudongService.preserLouDongVation(dto);
return new Result();
}
}

2
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/dao/CaLoudongDao.java

@ -41,4 +41,6 @@ public interface CaLoudongDao extends BaseDao<CaLoudongEntity> {
* @return
*/
CaLoudongDetailsResultDTO getLouDongDetails(@Param("buildingId") BigInteger buildingId);
void deleteAll();
}

10
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/CaResidentEntity.java

@ -26,6 +26,16 @@ public class CaResidentEntity extends BaseEpmetEntity {
*/
private Long residentId;
/**
* homeId
*/
private String homeId;
/**
* 对应的ic_resi_user主表Id
*/
private String icResiUser;
/**
* 网格ID
*/

10
epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/entity/CaRotatorsEntity.java

@ -26,6 +26,16 @@ public class CaRotatorsEntity extends BaseEpmetEntity {
*/
private Long rotatorsId;
/**
* homeId
*/
private String homeId;
/**
* 对应的ic_resi_user主表Id
*/
private String icResiUser;
/**
* 公民身份证号
*/

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

@ -6,6 +6,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.opendata.dto.CaLoudongDTO;
import com.epmet.opendata.dto.form.CaLoudongDetailsFormDTO;
import com.epmet.opendata.dto.form.CaLoudongFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaLoudongDetailsResultDTO;
import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.entity.CaLoudongEntity;
@ -99,4 +100,11 @@ public interface CaLoudongService extends BaseService<CaLoudongEntity> {
* @return
*/
CaLoudongDetailsResultDTO getLouDongDetails(CaLoudongDetailsFormDTO dto);
/**
* 楼栋调用ruoyi接口存储数据
*
* @param dto
*/
void preserLouDongVation(PreserVationFormDTO dto);
}

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

@ -1,14 +1,21 @@
package com.epmet.opendata.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
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.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.opendata.dao.CaLoudongDao;
import com.epmet.opendata.dto.CaLoudongDTO;
import com.epmet.opendata.dto.form.CaLoudongDetailsFormDTO;
import com.epmet.opendata.dto.form.CaLoudongFormDTO;
import com.epmet.opendata.dto.form.PreserVationFormDTO;
import com.epmet.opendata.dto.result.CaLoudongDetailsResultDTO;
import com.epmet.opendata.dto.result.CaLoudongResultDTO;
import com.epmet.opendata.entity.CaLoudongEntity;
@ -16,14 +23,14 @@ import com.epmet.opendata.redis.CaLoudongRedis;
import com.epmet.opendata.service.CaLoudongService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 楼栋基本信息表
@ -111,5 +118,86 @@ public class CaLoudongServiceImpl extends BaseServiceImpl<CaLoudongDao, CaLoudon
return result;
}
/**
* 楼栋调用ruoyi接口存储数据
*
* @param dto
* @return void
* @author LZN
* @date 2022/6/2 10:03
*/
@Override
public void preserLouDongVation(PreserVationFormDTO dto) {
baseDao.deleteAll();
dto.setPageNo(NumConstant.ONE);
dto.setPageSize(NumConstant.FIFTY);
dto.setTableSchema(loudongEnum.LD.name);
dto.setTableName(loudongEnum.LD.code);
dto.setWhereCase("delete_flag = 'normal'");
dto.setOrderBy("grid_id,update_date desc");
int pageNo = 1;
int total = 0;
do {
total = listLouDong(dto);
pageNo++;
dto.setPageNo(pageNo);
} while (total > (pageNo * NumConstant.FIFTY));
}
enum loudongEnum {
LD("unicom", "ca_loudong"),
;
private String name;
private String code;
loudongEnum(String name, String code) {
this.name = name;
this.code = code;
}
}
private int listLouDong(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<CaLoudongEntity> list;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<CaLoudongEntity> getList() {
return list;
}
public void setList(List<CaLoudongEntity> list) {
this.list = list;
}
}
}

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

@ -48,6 +48,9 @@
<result property="attribute10" column="attribute10"/>
<result property="communityId" column="community_id"/>
</resultMap>
<delete id="deleteAll">
delete from ca_loudong
</delete>
<select id="getList" resultType="com.epmet.opendata.dto.CaLoudongDTO">
select * from ca_loudong where delete_flag = 'normal'
</select>

Loading…
Cancel
Save