Commit 1431c090 authored by lixuan's avatar lixuan

feat: 房源

parent 73221044
Pipeline #145288 failed with stages
package com.ruoyi.web.controller.house;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.grid.GridRegion;
import com.ruoyi.system.domain.house.Contrast;
import com.ruoyi.system.domain.house.vo.HouseResourcePage;
import com.ruoyi.system.mapper.grid.GridRegionMapper;
import com.ruoyi.system.mapper.house.ContrastMapper;
import com.ruoyi.system.mapper.house.HouseResourceMapper;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
@RestController
@RequestMapping("/api/contrast")
public class ContrastController extends BaseController {
private final ContrastMapper contrastMapper;
private final GridRegionMapper gridRegionMapper;
private final HouseResourceMapper houseResourceMapper;
public ContrastController(ContrastMapper contrastMapper, GridRegionMapper gridRegionMapper, HouseResourceMapper houseResourceMapper) {
this.contrastMapper = contrastMapper;
this.gridRegionMapper = gridRegionMapper;
this.houseResourceMapper = houseResourceMapper;
}
@PutMapping("/start")
@Transactional(rollbackFor = Exception.class)
public AjaxResult start() {
List<Contrast> contrasts = contrastMapper.selectAll();
for (Contrast contrast : contrasts) {
if (Objects.isNull(contrast.getWgName())) {
setFlag(contrast, "未设置网格名称");
} else {
GridRegion gridRegion = gridRegionMapper.selectByWgName(contrast.getWgName());
if (Objects.isNull(contrast.getName())) {
setFlag(contrast, "未设置经营主体名称");
} else {
List<HouseResourcePage> list = houseResourceMapper.selectForContrast(gridRegion.getWgCode(), contrast.getName());
if (list.isEmpty()) {
setFlag(contrast, "该网格下没有该经营主体");
} else if (list.size() > 1) {
setFlag(contrast, "该网格下有多个同样名字的经营主体");
} else {
String flag = "";
HouseResourcePage houseResourcePage = list.get(0);
if (Objects.isNull(contrast.getPrincipal()) || !houseResourcePage.getPrincipal().equals(contrast.getPrincipal())) {
flag = flag += "联系人不一致,";
} else if (Objects.isNull(contrast.getPrincipalTel()) || !houseResourcePage.getPrincipalTel().equals(contrast.getPrincipalTel())) {
flag = flag += "联系电话不一致,";
}
setFlag(contrast, flag);
}
}
}
}
return AjaxResult.success();
}
private void setFlag(Contrast contrast, String flag) {
contrast.setFlag(flag);
contrastMapper.updateById(contrast);
}
}
package com.ruoyi.system.domain.house;
import lombok.Data;
import java.io.Serializable;
@Data
public class Contrast implements Serializable {
private Long id;
private String wgName;
private String name;
private String principal;
private String principalTel;
private String flag;
}
......@@ -94,4 +94,6 @@ public interface GridRegionMapper {
int countByFourthCode(String code);
int selectMaxPosition();
}
\ No newline at end of file
GridRegion selectByWgName(@Param("wgName") String wgName);
}
package com.ruoyi.system.mapper.house;
import com.ruoyi.system.domain.house.Contrast;
import java.util.List;
public interface ContrastMapper {
List<Contrast> selectAll();
void updateById(Contrast contrast);
}
......@@ -31,4 +31,6 @@ public interface HouseResourceMapper {
List<HouseResource> selectAll();
List<HouseResource> selectPageBusinessEntityStatistics();
List<HouseResourcePage> selectForContrast(@Param("two") String two, @Param("name") String name);
}
......@@ -793,5 +793,9 @@
SELECT MAX(position)
FROM grid_region
</select>
<select id="selectByWgName" resultType="com.ruoyi.system.domain.grid.GridRegion">
select * from grid_region
where wg_name = #{wgName} and is_valid = '1' limit 1
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.house.ContrastMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.house.Contrast">
<id property="id" column="id" jdbcType="NUMERIC"/>
<result property="wgName" column="wg_name" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="principal" column="principal" jdbcType="VARCHAR"/>
<result property="principalTel" column="principal_tel" jdbcType="VARCHAR"/>
<result property="flag" column="flag" jdbcType="VARCHAR"/>
</resultMap>
<select id="selectAll" resultType="com.ruoyi.system.domain.house.Contrast">
SELECT * FROM contrast
</select>
<update id="updateById">
UPDATE contrast
SET wg_name = #{wgName,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
principal = #{principal,jdbcType=VARCHAR},
principal_tel = #{principalTel,jdbcType=VARCHAR},
flag = #{flag,jdbcType=VARCHAR}
WHERE id = #{id,jdbcType=NUMERIC}
</update>
</mapper>
......@@ -356,4 +356,37 @@
LEFT JOIN business_entity_sell t4 ON t4.business_entity_info_id = t3.id
GROUP BY t1.id
</select>
<select id="selectForContrast" resultType="com.ruoyi.system.domain.house.vo.HouseResourcePage">
SELECT
t1.id,
t1.two,
t1.three,
t2.wg_name AS wgName4,
t1.type,
t1.house_number,
t1.address,
t1.house_area,
t1.house_resource_attribute,
t1.house_resource_type,
t1.ownership,
t1.house_resource_equity_tel,
t1.unit_price,
t3.nature,
t3.NAME,
t3.principal_tel,
t3.business,
t3.worker_number,
t3.registration_place_flag,
t3.registered_address,
t3.industry_classification,
t3.gs,
t1.remark,
t3.name AS businessEntityInfoName,
t3.principal
FROM
house_resource t1
LEFT JOIN grid_region t2 ON t2.wg_code = t1.four
LEFT JOIN business_entity_info t3 ON t1.id = t3.house_resource_id
WHERE t1.two = #{two} AND t3.NAME = #{name}
</select>
</mapper>
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