xiangpei
2024-08-31 a2813f7399cb27e6f66e99b5d9577eb21f4ddac3
ycl-server/src/main/java/com/ycl/platform/service/impl/YwUnitServiceImpl.java
@@ -7,6 +7,7 @@
import com.ycl.platform.base.BaseSelect;
import com.ycl.platform.domain.entity.YwUnit;
import com.ycl.platform.domain.form.YwUnitForm;
import com.ycl.platform.domain.query.DistributeWorkOrderQuery;
import com.ycl.platform.domain.query.YwUnitQuery;
import com.ycl.platform.domain.vo.YwUnitVO;
import com.ycl.platform.mapper.YwUnitMapper;
@@ -23,16 +24,14 @@
import com.ycl.utils.DateUtils;
import com.ycl.utils.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -59,6 +58,9 @@
    @Transactional(rollbackFor = Exception.class)
    public Result add(YwUnitForm form) {
        YwUnit entity = YwUnitForm.getEntityByForm(form, null);
        Date now = new Date();
        entity.setCreateTime(now);
        entity.setUpdateTime(now);
        if(baseMapper.insert(entity) > 0) {
            // 新增运维人员账号
            SysUser sysUser = new SysUser();
@@ -90,10 +92,11 @@
    @Transactional(rollbackFor = Exception.class)
    public Result update(YwUnitForm form) {
        YwUnit entity = baseMapper.selectById(form.getId());
        // 为空抛IllegalArgumentException,做全局异常处理
        Assert.notNull(entity, "记录不存在");
        BeanUtils.copyProperties(form, entity);
        Date now = new Date();
        entity.setUpdateTime(now);
        if (baseMapper.updateById(entity) > 0) {
            // 修改运维单位账号信息
            SysUser sysUser = sysUserMapper.selectUserByUserName(entity.getUnitAdminAccount());
@@ -210,8 +213,8 @@
    }
    @Override
    public Result workList() {
        List<YwUnitVO> entities = baseMapper.workList();
    public Result workList(DistributeWorkOrderQuery query) {
        List<YwUnitVO> entities = baseMapper.workList(query);
        return Result.ok().data(entities);
    }