Commit b7f83f11 authored by lixuan's avatar lixuan

feat: 房源

parent 96a9217d
Pipeline #145427 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.house.BusinessEntityInfo;
import com.ruoyi.system.domain.house.BusinessEntitySell;
import com.ruoyi.system.domain.house.ContrastIncome;
import com.ruoyi.system.mapper.house.BusinessEntityInfoMapper;
import com.ruoyi.system.mapper.house.BusinessEntitySellMapper;
import com.ruoyi.system.mapper.house.ContrastIncomeMapper;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@RestController
@RequestMapping("/api/contrastIncome")
public class ContrastIncomeController extends BaseController {
private final ContrastIncomeMapper contrastIncomeMapper;
private final BusinessEntityInfoMapper businessEntityInfoMapper;
private final BusinessEntitySellMapper businessEntitySellMapper;
public ContrastIncomeController(ContrastIncomeMapper contrastIncomeMapper, BusinessEntityInfoMapper businessEntityInfoMapper, BusinessEntitySellMapper businessEntitySellMapper) {
this.contrastIncomeMapper = contrastIncomeMapper;
this.businessEntityInfoMapper = businessEntityInfoMapper;
this.businessEntitySellMapper = businessEntitySellMapper;
}
@PutMapping("/start")
@Transactional(rollbackFor = Exception.class)
public AjaxResult start() {
List<ContrastIncome> contrastIncomes = contrastIncomeMapper.selectAll();
for (ContrastIncome contrastIncome : contrastIncomes) {
contrastIncome.setWgName(contrastIncome.getWgName().replaceAll(" ", ""));
contrastIncome.setName(contrastIncome.getName().replaceAll(" ", ""));
contrastIncome.setPrincipal(contrastIncome.getPrincipal().replaceAll(" ", ""));
}
for (ContrastIncome contrastIncome : contrastIncomes) {
System.out.println("当前处理id: " + contrastIncome.getId());
List<BusinessEntityInfo> businessEntityInfos = businessEntityInfoMapper.selectByName(contrastIncome.getName());
if (CollectionUtils.isEmpty(businessEntityInfos)) {
System.out.println("当前名字: " + contrastIncome.getName() + " 下没有找到对应的经营主体");
} else if (businessEntityInfos.size() != 1) {
System.out.println("当前名字: " + contrastIncome.getName() + " 有多个对应的经营主体");
} else {
BusinessEntityInfo businessEntityInfo = businessEntityInfos.get(0);
BusinessEntitySell businessEntitySell = businessEntitySellMapper.selectBusinessEntitySellByBusinessEntityInfoId(businessEntityInfo.getId(), 2024);
if (Objects.nonNull(businessEntitySell)) {
businessEntitySell.setYearTax(new BigDecimal(contrastIncome.getIncome()));
System.out.println("为businessEntityInfo.getName() = " + businessEntityInfo.getName() + "更新了税收");
businessEntitySellMapper.updateBusinessEntitySell(businessEntitySell);
} else {
BusinessEntitySell entitySell = new BusinessEntitySell();
entitySell.setId(UUID.randomUUID().toString().replaceAll("-", ""));
entitySell.setBusinessEntityInfoId(businessEntityInfo.getId());
entitySell.setYear(2024);
entitySell.setYearTax(new BigDecimal(contrastIncome.getIncome()));
System.out.println("为businessEntityInfo.getName() = " + businessEntityInfo.getName() + " 创建了新的BusinessEntitySell: " + entitySell);
businessEntitySellMapper.insertBusinessEntitySell(entitySell);
}
}
}
System.out.println("处理完成");
return AjaxResult.success();
}
}
...@@ -18,4 +18,16 @@ public class BusinessEntitySell { ...@@ -18,4 +18,16 @@ public class BusinessEntitySell {
private BigDecimal yearTax; private BigDecimal yearTax;
private String compare; private String compare;
@Override
public String toString() {
return "BusinessEntitySell{" +
"id='" + id + '\'' +
", businessEntityInfoId='" + businessEntityInfoId + '\'' +
", year=" + year +
", yearSell=" + yearSell +
", yearTax=" + yearTax +
", compare='" + compare + '\'' +
'}';
}
} }
package com.ruoyi.system.domain.house;
import lombok.Data;
import java.io.Serializable;
@Data
public class ContrastIncome implements Serializable {
private Long id;
private String wgName;
private String name;
private String principal;
private String income;
}
...@@ -30,4 +30,6 @@ public interface BusinessEntityInfoMapper { ...@@ -30,4 +30,6 @@ public interface BusinessEntityInfoMapper {
List<BusinessEntityInfo> selectAllBusinessEntityInfosByHouseResourceIds(@Param("houseResourceIds") List<String> houseResourceIds); List<BusinessEntityInfo> selectAllBusinessEntityInfosByHouseResourceIds(@Param("houseResourceIds") List<String> houseResourceIds);
BigDecimal selectYearSellByHouseResourceId(@Param("houseResourceId") String houseResourceId); BigDecimal selectYearSellByHouseResourceId(@Param("houseResourceId") String houseResourceId);
List<BusinessEntityInfo> selectByName(@Param("name") String name);
} }
package com.ruoyi.system.mapper.house;
import com.ruoyi.system.domain.house.ContrastIncome;
import java.util.List;
public interface ContrastIncomeMapper {
List<ContrastIncome> selectAll();
void updateById(ContrastIncome contrastIncome);
}
...@@ -79,4 +79,7 @@ ...@@ -79,4 +79,7 @@
WHERE WHERE
t1.house_resource_id = #{houseResourceId} t1.house_resource_id = #{houseResourceId}
</select> </select>
<select id="selectByName" resultType="com.ruoyi.system.domain.house.BusinessEntityInfo">
SELECT * FROM business_entity_info WHERE name = #{name}
</select>
</mapper> </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.ContrastIncomeMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.house.ContrastIncome">
<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="income" column="flag" jdbcType="VARCHAR"/>
</resultMap>
<select id="selectAll" resultType="com.ruoyi.system.domain.house.ContrastIncome">
SELECT * FROM contrast_income
</select>
<update id="updateById">
UPDATE contrast_income
SET wg_name = #{wgName,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
principal = #{principal,jdbcType=VARCHAR},
income = #{income,jdbcType=VARCHAR}
WHERE id = #{id,jdbcType=NUMERIC}
</update>
</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