linwei
2024-01-18 4cfc5f4240178a8efe5d44eee527ce1c626c6c64
物业评级
9 files modified
205 ■■■■■ changed files
src/main/java/org/springblade/modules/answerRecord/controller/AnswerRecordController.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/answerRecord/entity/AnswerRecordEntity.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/answerRecord/service/IAnswerRecordService.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/answerRecord/service/impl/AnswerRecordServiceImpl.java 76 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/property/entity/PropertyCompanyEntity.java 78 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/subjectChoices/controller/SubjectChoicesController.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/subjectChoices/mapper/SubjectChoicesMapper.xml 12 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/subjectChoices/vo/SubjectChoicesVO.java 10 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/subjectOption/vo/SubjectOptionVO.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/answerRecord/controller/AnswerRecordController.java
@@ -31,9 +31,11 @@
import org.springblade.modules.answerRecord.service.IAnswerRecordService;
import org.springblade.modules.answerRecord.vo.AnswerRecordVO;
import org.springblade.modules.answerRecord.wrapper.AnswerRecordWrapper;
import org.springblade.modules.subjectChoices.vo.SubjectChoicesVO;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
 * 答题记录表 控制器
@@ -108,8 +110,8 @@
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入answerRecord")
    public R submit(@Valid @RequestBody AnswerRecordEntity answerRecord) {
        return R.status(answerRecordService.saveOrUpdate(answerRecord));
    public R submit(@Valid @RequestBody List<SubjectChoicesVO> subjectChoicesList) {
        return R.status(answerRecordService.saveAnswer(subjectChoicesList));
    }
    /**
src/main/java/org/springblade/modules/answerRecord/entity/AnswerRecordEntity.java
@@ -111,4 +111,7 @@
    @TableField("create_time")
    private Date createTime;
    @TableField("delete_flage")
    private Integer deleteFlage;
}
src/main/java/org/springblade/modules/answerRecord/service/IAnswerRecordService.java
@@ -21,6 +21,7 @@
import org.springblade.modules.answerRecord.dto.AnswerRecordDTO;
import org.springblade.modules.answerRecord.entity.AnswerRecordEntity;
import org.springblade.modules.answerRecord.vo.AnswerRecordVO;
import org.springblade.modules.subjectChoices.vo.SubjectChoicesVO;
import java.util.List;
@@ -56,4 +57,6 @@
     * @return 答题记录表集合
     */
    List<AnswerRecordDTO> selectAnswerRecordList(AnswerRecordDTO answerRecordDTO);
    Boolean saveAnswer(List<SubjectChoicesVO> subjectChoicesVO);
}
src/main/java/org/springblade/modules/answerRecord/service/impl/AnswerRecordServiceImpl.java
@@ -17,14 +17,22 @@
package org.springblade.modules.answerRecord.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.utils.SpringUtils;
import org.springblade.modules.answerRecord.dto.AnswerRecordDTO;
import org.springblade.modules.answerRecord.entity.AnswerRecordEntity;
import org.springblade.modules.answerRecord.mapper.AnswerRecordMapper;
import org.springblade.modules.answerRecord.service.IAnswerRecordService;
import org.springblade.modules.answerRecord.vo.AnswerRecordVO;
import org.springblade.modules.property.entity.PropertyCompanyEntity;
import org.springblade.modules.property.service.IPropertyCompanyService;
import org.springblade.modules.subjectChoices.vo.SubjectChoicesVO;
import org.springblade.modules.subjectOption.vo.SubjectOptionVO;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
@@ -63,5 +71,73 @@
        return this.baseMapper.selectAnswerRecordList(answerRecordDTO);
    }
    @Override
    public Boolean saveAnswer(List<SubjectChoicesVO> subjectChoicesVO) {
        BigDecimal bigDecimal = BigDecimal.valueOf(0);
        List<AnswerRecordEntity> objects = new ArrayList<>();
        for (SubjectChoicesVO choicesVO : subjectChoicesVO) {
            List<SubjectOptionVO> subjectOptionList = choicesVO.getSubjectOptionList();
            if (choicesVO.getChoicesType().intValue() == 3) {
                bigDecimal = bigDecimal.add(choicesVO.getScore());
            }
            for (SubjectOptionVO subjectOptionVO : subjectOptionList) {
                boolean update = remove(Wrappers.<AnswerRecordEntity>lambdaQuery()
                    .eq(AnswerRecordEntity::getPropertyId, choicesVO.getPropertyId())
                    .eq(AnswerRecordEntity::getSubjectChoicesId, choicesVO.getId()));
                if (subjectOptionVO.getIds() != null) {
                    AnswerRecordDTO answerRecordDTO = new AnswerRecordDTO();
                    answerRecordDTO.setPropertyId(choicesVO.getPropertyId());
                    answerRecordDTO.setAnswerOption(subjectOptionVO.getId().toString());
                    answerRecordDTO.setSubjectChoicesId(choicesVO.getId());
                    answerRecordDTO.setSubjectOptionId(subjectOptionVO.getId());
                    objects.add(answerRecordDTO);
                    bigDecimal = bigDecimal.add(subjectOptionVO.getScore());
                }
                if (subjectOptionVO.getNumbers() != null) {
                    AnswerRecordDTO answerRecordDTO = new AnswerRecordDTO();
                    answerRecordDTO.setPropertyId(choicesVO.getPropertyId());
                    answerRecordDTO.setAnswerOption(subjectOptionVO.getId().toString());
                    answerRecordDTO.setSubjectChoicesId(choicesVO.getId());
                    answerRecordDTO.setAnswer(subjectOptionVO.getNumbers());
                    answerRecordDTO.setSubjectOptionId(subjectOptionVO.getId());
                    objects.add(answerRecordDTO);
                    BigDecimal multiply = BigDecimal.valueOf(subjectOptionVO.getNumbers()).multiply(subjectOptionVO.getScore());
                    bigDecimal = bigDecimal.subtract(multiply);
                }
            }
        }
        // 保存得分
        IPropertyCompanyService bean = SpringUtils.getBean(IPropertyCompanyService.class);
        PropertyCompanyEntity one = bean.getOne(Wrappers.<PropertyCompanyEntity>lambdaQuery().eq(PropertyCompanyEntity::getId, subjectChoicesVO.get(0).getPropertyId()));
        if (subjectChoicesVO.get(0).getSubclassName().equals("基础信息")) {
            one.setBaseInfoScore(bigDecimal);
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("经营信息")) {
            one.setOperateinfoScore(bigDecimal);
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("纳税信息")) {
            one.setTaxInfoScore(bigDecimal);
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("党建信息")) {
            one.setPartyBuildingInfoScore(bigDecimal);
            bean.update(Wrappers.<PropertyCompanyEntity>lambdaUpdate().set(PropertyCompanyEntity::getPartyBuildingInfoScore, bigDecimal)
                .eq(PropertyCompanyEntity::getId, subjectChoicesVO.get(0).getPropertyId()));
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("企业良好行为")) {
            one.setGoodCorporateScore(bigDecimal);
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("项目良好行为")) {
            one.setGoodProjectScore(bigDecimal);
        } else if (subjectChoicesVO.get(0).getSubclassName().equals("违法违规行为惩戒")) {
            one.setLllegalAndIrregularScore(bigDecimal);
        }
        BigDecimal add = one.getBaseInfoScore()
            .add(one.getOperateinfoScore())
            .add(one.getOperateinfoScore())
            .add(one.getPartyBuildingInfoScore())
            .add(one.getGoodCorporateScore())
            .add(one.getGoodProjectScore())
            .add(one.getLllegalAndIrregularScore())
            .add(one.getEvaluateScore());
        one.setAllScore(add);
        bean.updateById(one);
        return saveBatch(objects);
    }
}
src/main/java/org/springblade/modules/property/entity/PropertyCompanyEntity.java
@@ -20,15 +20,14 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springframework.format.annotation.DateTimeFormat;
/**
 * 物业公司 实体类
@@ -134,4 +133,75 @@
    @ApiModelProperty("是否已删除 0:否  1:是")
    private Integer isDeleted;
    /**
     * 基础信息分
     */
    @ApiModelProperty(value = "基础信息分", example = "")
    @TableField("base_info_score")
    private BigDecimal baseInfoScore;
    /**
     * 经营信息分
     */
    @ApiModelProperty(value = "经营信息分", example = "")
    @TableField("operateInfo_score")
    private BigDecimal operateinfoScore;
    /**
     * 纳税信息分
     */
    @ApiModelProperty(value = "纳税信息分", example = "")
    @TableField("tax_info_score")
    private BigDecimal taxInfoScore;
    /**
     * 党建信息分
     */
    @ApiModelProperty(value = "党建信息分", example = "")
    @TableField("party_building_info_score")
    private BigDecimal partyBuildingInfoScore;
    /**
     * 企业良好信息分
     */
    @ApiModelProperty(value = "企业良好信息分", example = "")
    @TableField("good_corporate_score")
    private BigDecimal goodCorporateScore;
    /**
     * 项目良好信息分
     */
    @ApiModelProperty(value = "项目良好信息分", example = "")
    @TableField("good_project_score")
    private BigDecimal goodProjectScore;
    /**
     * 违法违规行为分
     */
    @ApiModelProperty(value = "违法违规行为分", example = "")
    @TableField("lllegal_and_irregular_score")
    private BigDecimal lllegalAndIrregularScore;
    /**
     * 评价平均分
     */
    @ApiModelProperty(value = "评价平均分", example = "")
    @TableField("evaluate_score")
    private BigDecimal evaluateScore;
    /**
     * 街道社区分
     */
    @ApiModelProperty(value = "街道社区分", example = "")
    @TableField("street_score")
    private BigDecimal streetScore;
    /**
     * 总分
     */
    @ApiModelProperty(value = "总分", example = "")
    @TableField("all_score")
    private BigDecimal allScore;
}
src/main/java/org/springblade/modules/subjectChoices/controller/SubjectChoicesController.java
@@ -27,6 +27,7 @@
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.subjectChoices.entity.SubjectChoicesEntity;
import org.springblade.modules.subjectChoices.service.ISubjectChoicesService;
@@ -34,6 +35,7 @@
import org.springblade.modules.subjectChoices.wrapper.SubjectChoicesWrapper;
import org.springblade.modules.subjectOption.entity.SubjectOptionEntity;
import org.springblade.modules.subjectOption.service.ISubjectOptionService;
import org.springblade.modules.subjectOption.vo.SubjectOptionVO;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@@ -95,12 +97,13 @@
    public R save(@Valid @RequestBody SubjectChoicesVO subjectChoices) {
        boolean save = subjectChoicesService.save(subjectChoices);
        if (save) {
            List<SubjectOptionEntity> children = subjectChoices.getSubjectOptionList();
            List<SubjectOptionVO> children = subjectChoices.getSubjectOptionList();
            for (SubjectOptionEntity child : children) {
                child.setSubjectChoicesId(subjectChoices.getId());
            }
            List<SubjectOptionEntity> copy = BeanUtil.copy(children, SubjectOptionEntity.class);
            ISubjectOptionService bean = SpringUtils.getBean(ISubjectOptionService.class);
            bean.saveBatch(children);
            bean.saveOrUpdateBatch(copy);
        }
        return R.status(save);
    }
@@ -124,12 +127,13 @@
    public R submit(@Valid @RequestBody SubjectChoicesVO subjectChoices) {
        boolean save = subjectChoicesService.saveOrUpdate(subjectChoices);
        if (save) {
            List<SubjectOptionEntity> children = subjectChoices.getSubjectOptionList();
            List<SubjectOptionVO> children = subjectChoices.getSubjectOptionList();
            for (SubjectOptionEntity child : children) {
                child.setSubjectChoicesId(subjectChoices.getId());
            }
            List<SubjectOptionEntity> copy = BeanUtil.copy(children, SubjectOptionEntity.class);
            ISubjectOptionService bean = SpringUtils.getBean(ISubjectOptionService.class);
            bean.saveOrUpdateBatch(children);
            bean.saveOrUpdateBatch(copy);
        }
        return R.status(save);
    }
src/main/java/org/springblade/modules/subjectChoices/mapper/SubjectChoicesMapper.xml
@@ -30,9 +30,15 @@
    </resultMap>
    <select id="selectCircleCommentByParentId" parameterType="long"
            resultType="org.springblade.modules.subjectOption.entity.SubjectOptionEntity">
       select * from jczz_subject_option where
        subject_choices_id = #{id}
            resultType="org.springblade.modules.subjectOption.vo.SubjectOptionVO">
        SELECT
        jso.*,
        jar.subject_option_id ids,
        jar.answer numbers
        FROM
        jczz_subject_option jso LEFT JOIN jczz_answer_record jar on jso.id = jar.subject_option_id
        WHERE
        jso.subject_choices_id = #{id}
    </select>
src/main/java/org/springblade/modules/subjectChoices/vo/SubjectChoicesVO.java
@@ -19,7 +19,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.subjectChoices.entity.SubjectChoicesEntity;
import org.springblade.modules.subjectOption.entity.SubjectOptionEntity;
import org.springblade.modules.subjectOption.vo.SubjectOptionVO;
import java.util.List;
@@ -34,5 +34,11 @@
public class SubjectChoicesVO extends SubjectChoicesEntity {
    private static final long serialVersionUID = 1L;
    private List<SubjectOptionEntity> subjectOptionList;
    private Long propertyId;
//    private List<SubjectOptionEntity> subjectOptionList;
    private List<SubjectOptionVO> subjectOptionList;
}
src/main/java/org/springblade/modules/subjectOption/vo/SubjectOptionVO.java
@@ -31,4 +31,9 @@
public class SubjectOptionVO extends SubjectOptionEntity {
    private static final long serialVersionUID = 1L;
    // 选择的id
    private Long ids;
    // 填写的数字
    private Integer numbers;
}