zhongrj
2023-09-04 bd473c0a1ef0c950ab52d66376f56979adc1ad71
电站填报调整
5 files modified
304 ■■■■■ changed files
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/controller/TbAttResPowerStationController.java 8 ●●●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/entity/TbAttResPowerStation.java 7 ●●●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/mapper/TbAttResPowerStationMapper.java 4 ●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/ITbAttResPowerStationService.java 8 ●●●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbAttResPowerStationServiceImpl.java 277 ●●●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/controller/TbAttResPowerStationController.java
@@ -10,6 +10,8 @@
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @ClassName TbAttResPowerStationController
@@ -36,7 +38,7 @@
    @ApiOperation(value = "中台水库-查询水库填报详情信息", notes = "中台水库-查询水库填报详情信息")
    @GetMapping(value = "/getDetailByGuid")
    public R getDetailByCode(String resGuid) {
        TbAttResPowerStation attResBase = tbAttResPowerStationService.getDetailByGuid(resGuid);
        List<TbAttResPowerStation> attResBase = tbAttResPowerStationService.getDetailByGuid(resGuid);
        return R.data(attResBase);
    }
@@ -47,7 +49,7 @@
     */
    @ApiOperation(value = "水库信息-编辑", notes = "水库信息-编辑")
    @PostMapping(value = "/edit")
    public R edit(@RequestBody TbAttResPowerStation tbAttResPowerStation) {
    public R edit(@RequestBody List<TbAttResPowerStation> tbAttResPowerStation) {
        return R.status(tbAttResPowerStationService.updateByGuid(tbAttResPowerStation));
    }
@@ -58,7 +60,7 @@
     */
    @ApiOperation(value = "水库信息-审核", notes = "水库信息-审核")
    @PostMapping(value = "/audit")
    public R audit(@RequestBody TbAttResPowerStation tbAttResPowerStation) {
    public R audit(@RequestBody List<TbAttResPowerStation> tbAttResPowerStation) {
        return R.status(tbAttResPowerStationService.auditByGuid(tbAttResPowerStation));
    }
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/entity/TbAttResPowerStation.java
@@ -50,6 +50,13 @@
    private String name;
    /**
     * 数量
     */
    @ApiModelProperty(value = "数量")
    @TableField("\"num\"")
    private Integer num;
    /**
     * 厂房布置型式
     */
    @ApiModelProperty(value = "厂房布置型式")
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/mapper/TbAttResPowerStationMapper.java
@@ -5,6 +5,8 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * TbAttResPowerStationMapper 接口
@@ -20,5 +22,5 @@
     * @param resGuid
     * @return
     */
    TbAttResPowerStation getDetailByResGuid(@Param("resGuid") String resGuid);
    List<TbAttResPowerStation> getDetailByResGuid(@Param("resGuid") String resGuid);
}
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/ITbAttResPowerStationService.java
@@ -3,6 +3,8 @@
import cn.gistack.sm.sjztmd.entity.TbAttResPowerStation;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
 * @ClassName ITbAttResPowerStationService
 * @Description TODO
@@ -17,19 +19,19 @@
     * @param guid
     * @return
     */
    TbAttResPowerStation getDetailByGuid(String guid);
    List<TbAttResPowerStation> getDetailByGuid(String guid);
    /**
     * 编辑
     * @param tbAttResPowerStation
     * @return
     */
    boolean updateByGuid(TbAttResPowerStation tbAttResPowerStation);
    boolean updateByGuid(List<TbAttResPowerStation> tbAttResPowerStation);
    /**
     * 审核
     * @param tbAttResPowerStation
     * @return
     */
    boolean auditByGuid(TbAttResPowerStation tbAttResPowerStation);
    boolean auditByGuid(List<TbAttResPowerStation> tbAttResPowerStation);
}
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbAttResPowerStationServiceImpl.java
@@ -1,5 +1,6 @@
package cn.gistack.sm.sjztmd.service.impl;
import cn.gistack.sm.intelligentCall.entity.Scene;
import cn.gistack.sm.sjztmd.entity.TbAttResPowerStation;
import cn.gistack.sm.sjztmd.mapper.TbAttResPowerStationMapper;
import cn.gistack.sm.sjztmd.service.ITbAttResPowerStationService;
@@ -7,11 +8,16 @@
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.node.TreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @ClassName TbAttResPowerStationServiceImpl
@@ -33,162 +39,197 @@
     * @return
     */
    @Override
    public TbAttResPowerStation getDetailByGuid(String guid) {
    public List<TbAttResPowerStation> getDetailByGuid(String guid) {
        return baseMapper.getDetailByResGuid(guid);
    }
    /**
     * 编辑
     * @param tbAttResPowerStation
     * @param newList
     * @return
     */
    @Override
    public boolean updateByGuid(TbAttResPowerStation tbAttResPowerStation) {
    public boolean updateByGuid(List<TbAttResPowerStation> newList) {
        // 查询是否存在
        TbAttResPowerStation detail = baseMapper.getDetailByResGuid(tbAttResPowerStation.getResGuid());
        List<TbAttResPowerStation> oldList = baseMapper.getDetailByResGuid(newList.get(0).getResGuid());
        // 更新日志
        setUpdateLog(detail,tbAttResPowerStation);
        // 修改
        int i = addOrUpdateByGuid(detail,tbAttResPowerStation);
        if (i>0){
        setUpdateLog(oldList,newList);
        // 创建或更新数据
        boolean flag = addOrUpdate(oldList,newList);
        // 返回
        return flag;
    }
    /**
     * 新增或更新数据
     * @param oldList
     * @param newList
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean addOrUpdate(List<TbAttResPowerStation> oldList,List<TbAttResPowerStation> newList) {
        // 取旧数据和新提交数据差集--删除
        // 去除前一天已填报的人员手机号集合
        List<TbAttResPowerStation> removeList = oldList.stream().filter(vo -> !newList.stream().map(e ->
            e.getGuid()).collect(Collectors.toList()).contains(vo.getGuid())).collect(Collectors.toList());
        // 取旧数据和新提交数据交集--更新
        List<TbAttResPowerStation> updateList = newList.stream().filter(vo -> oldList.stream().map(e ->
            e.getGuid()).collect(Collectors.toList()).contains(vo.getGuid())).collect(Collectors.toList());
        // 取新数提交据和旧数据交集--新增
        List<TbAttResPowerStation> addList = newList.stream().filter(vo -> !oldList.stream().map(e ->
            e.getGuid()).collect(Collectors.toList()).contains(vo.getGuid())).collect(Collectors.toList());
        boolean addFlag = true;
        boolean updateFlag = true;
        boolean removeFlag = true;
        if (addList.size()>0){
            // 批量新增
            addFlag = saveBatch(addList);
        }
        if (updateList.size()>0){
            // 批量更新
            addFlag = updateBatchById(updateList);
        }
        if (removeList.size()>0){
            // 批量删除
            removeFlag = removeBatchByIds(removeList);
        }
        if (addFlag && updateFlag && removeFlag){
            return true;
        }
        // 返回
        return false;
    }
    /**
     * 审核
     * @param tbAttResPowerStation
     * @param newList
     * @return
     */
    @Override
    public boolean auditByGuid(TbAttResPowerStation tbAttResPowerStation) {
    public boolean auditByGuid(List<TbAttResPowerStation> newList) {
        // 查询是否存在
        TbAttResPowerStation detail = baseMapper.getDetailByResGuid(tbAttResPowerStation.getResGuid());
        List<TbAttResPowerStation> oldList = baseMapper.getDetailByResGuid(newList.get(0).getResGuid());
        // 更新操作日志
        setUpdateLog(detail,tbAttResPowerStation);
        setUpdateLog(oldList,newList);
        // 更新审核日志
        setUpdateCheckLog(detail,tbAttResPowerStation);
        if (null!=detail){
            tbAttResPowerStation.setGuid(detail.getGuid());
        }
        // 驳回情况下将状态修改回0即已填写未提交状态
        if (tbAttResPowerStation.getCheckState()==3){
            tbAttResPowerStation.setCheckState(0);
        }
        setUpdateCheckLog(oldList,newList);
        // 更新数据
        int i = baseMapper.updateById(tbAttResPowerStation);
        if (i>0){
            return true;
        }
        return false;
    }
    /**
     * 更新
     * @param tbAttResPowerStation
     * @return
     */
    private int addOrUpdateByGuid(TbAttResPowerStation oldAbAttResBase,TbAttResPowerStation tbAttResPowerStation){
        int i = 0;
        if (null!=oldAbAttResBase){
            tbAttResPowerStation.setGuid(oldAbAttResBase.getGuid());
            // 更新
            i = baseMapper.updateById(tbAttResPowerStation);
        }else {
            tbAttResPowerStation.setCreateTime(new Date());
            i = baseMapper.insert(tbAttResPowerStation);
        }
        boolean batch = updateBatchById(newList);
        // 返回
        return i;
        return batch;
    }
    /**
     * @param oldAbAttResBase
     * @param newTbAttResPowerStation
     * @param oldList
     * @param newList
     * 更新审核记录
     */
    private void setUpdateCheckLog(TbAttResPowerStation oldAbAttResBase,TbAttResPowerStation newTbAttResPowerStation) {
        String fillName = "";
        if (newTbAttResPowerStation.getCheckState()==2){
            fillName = "审核";
        }
        if (newTbAttResPowerStation.getCheckState()==3){
            fillName = "退回" + (null==newTbAttResPowerStation.getCheckLog()?"":":" + newTbAttResPowerStation.getCheckLog());
        }
    private void setUpdateCheckLog(List<TbAttResPowerStation> oldList,List<TbAttResPowerStation> newList) {
        // 遍历
        for (TbAttResPowerStation newTbAttResPowerStation : newList) {
            String fillName = "";
            if (newTbAttResPowerStation.getCheckState() == 2) {
                fillName = "审核";
            }
            if (newTbAttResPowerStation.getCheckState() == 3) {
                fillName = "退回" + (null == newTbAttResPowerStation.getCheckLog() ? "" : ":" + newTbAttResPowerStation.getCheckLog());
                for (TbAttResPowerStation tbAttResPowerStation : oldList) {
                    if (tbAttResPowerStation.getGuid().equals(newTbAttResPowerStation.getGuid())){
                        // 退回时进行设置状态为填写中
                        newTbAttResPowerStation.setCheckState(0);
                    }
                }
            }
        // 拼接
        String time = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
        String userName = AuthUtil.getUser().getUserName();
        String phone = userClient.userInfoById(AuthUtil.getUserId()).getData().getPhone();
        StringBuilder builder = new StringBuilder();
        builder.append(time)
            .append(",")
            .append(fillName)
            .append(",")
            .append(userName)
            .append(",")
            .append(phone)
            .append(";");
        // 判断是否存在
        if (null==oldAbAttResBase){
            // 填报
            newTbAttResPowerStation.setCheckLog(builder.toString());
        }else {
            StringBuilder stringBuilder = new StringBuilder(null==oldAbAttResBase.getCheckLog()?"":oldAbAttResBase.getCheckLog());
            stringBuilder.append(builder);
            // 填报
            newTbAttResPowerStation.setCheckLog(stringBuilder.toString());
            // 拼接
            String time = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
            String userName = AuthUtil.getUser().getUserName();
            String phone = userClient.userInfoById(AuthUtil.getUserId()).getData().getPhone();
            StringBuilder builder = new StringBuilder();
            builder.append(time)
                .append(",")
                .append(fillName)
                .append(",")
                .append(userName)
                .append(",")
                .append(phone)
                .append(";");
            // 判断是否存在
            if (null==newTbAttResPowerStation.getGuid() || newTbAttResPowerStation.getGuid().equals("")){
                // 填报
                newTbAttResPowerStation.setCheckLog(builder.toString());
            } else {
                for (TbAttResPowerStation tbAttResPowerStation : oldList) {
                    if (tbAttResPowerStation.getGuid().equals(newTbAttResPowerStation.getGuid())){
                        StringBuilder stringBuilder = new StringBuilder(null == tbAttResPowerStation.getCheckLog() ? "" : tbAttResPowerStation.getCheckLog());
                        stringBuilder.append(builder);
                        // 填报
                        newTbAttResPowerStation.setCheckLog(stringBuilder.toString());
                    }
                }
            }
        }
    }
    /**
     * @param oldAbAttResBase
     * @param newTbAttResPowerStation
     * @param oldList
     * @param newList
     * 更新操作记录
     */
    private void setUpdateLog(TbAttResPowerStation oldAbAttResBase,TbAttResPowerStation newTbAttResPowerStation) {
        String fillName = "";
        if (newTbAttResPowerStation.getCheckState()==0){
            fillName = "编辑";
        }
        if (newTbAttResPowerStation.getCheckState()==1){
            fillName = "提交";
        }
        if (newTbAttResPowerStation.getCheckState()==2){
            fillName = "审核";
        }
        if (newTbAttResPowerStation.getCheckState()==3){
            fillName = "退回" + (null==newTbAttResPowerStation.getCheckLog()?"":":" + newTbAttResPowerStation.getCheckLog());
        }
        // 管理员编辑
        if (newTbAttResPowerStation.getCheckState()==4){
            fillName = "编辑";
            newTbAttResPowerStation.setCheckState(oldAbAttResBase.getCheckState());
        }
    private void setUpdateLog(List<TbAttResPowerStation> oldList,List<TbAttResPowerStation> newList) {
        // 遍历
        for (TbAttResPowerStation newTbAttResPowerStation : newList){
            String fillName = "";
            if (newTbAttResPowerStation.getCheckState()==0){
                fillName = "编辑";
            }
            if (newTbAttResPowerStation.getCheckState()==1){
                fillName = "提交";
            }
            if (newTbAttResPowerStation.getCheckState()==2){
                fillName = "审核";
            }
            if (newTbAttResPowerStation.getCheckState()==3){
                fillName = "退回" + (null==newTbAttResPowerStation.getCheckLog()?"":":" + newTbAttResPowerStation.getCheckLog());
            }
            // 管理员编辑
            if (newTbAttResPowerStation.getCheckState()==4){
                fillName = "编辑";
                // 找到相关的 guid 数据
                for (TbAttResPowerStation tbAttResPowerStation : oldList) {
                    if (tbAttResPowerStation.getGuid().equals(newTbAttResPowerStation.getGuid())){
                        newTbAttResPowerStation.setCheckState(tbAttResPowerStation.getCheckState());
                    }
                }
            }
        // 拼接
        String time = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
        String userName = AuthUtil.getUser().getUserName();
        String phone = userClient.userInfoById(AuthUtil.getUserId()).getData().getPhone();
        StringBuilder builder = new StringBuilder();
        builder.append(time)
            .append(",")
            .append(fillName)
            .append(",")
            .append(userName)
            .append(",")
            .append(phone)
            .append(";");
        // 判断是否存在
        if (null==oldAbAttResBase){
            // 填报
            newTbAttResPowerStation.setLog(builder.toString());
        }else {
            StringBuilder stringBuilder = new StringBuilder(null==oldAbAttResBase.getLog()?"":oldAbAttResBase.getLog());
            stringBuilder.append(builder);
            // 填报
            newTbAttResPowerStation.setLog(stringBuilder.toString());
            // 拼接
            String time = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
            String userName = AuthUtil.getUser().getUserName();
            String phone = userClient.userInfoById(AuthUtil.getUserId()).getData().getPhone();
            StringBuilder builder = new StringBuilder();
            builder.append(time)
                .append(",")
                .append(fillName)
                .append(",")
                .append(userName)
                .append(",")
                .append(phone)
                .append(";");
            // 判断是否存在
            if (null==newTbAttResPowerStation.getGuid() || newTbAttResPowerStation.getGuid().equals("")){
                // 填报
                newTbAttResPowerStation.setLog(builder.toString());
            }else {
                for (TbAttResPowerStation tbAttResPowerStation : oldList) {
                    if (tbAttResPowerStation.getGuid().equals(newTbAttResPowerStation.getGuid())){
                        StringBuilder stringBuilder = new StringBuilder(null==tbAttResPowerStation.getLog()?"":tbAttResPowerStation.getLog());
                        stringBuilder.append(builder);
                        // 填报
                        newTbAttResPowerStation.setLog(stringBuilder.toString());
                    }
                }
            }
        }
    }
}