zqy
2024-11-26 8a3d7199725a52b555d46daae5e95cef914c9ab3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfAncestorController.java
@@ -10,7 +10,9 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.*;
import com.ruoyi.domain.dto.AncestorClan;
import com.ruoyi.domain.dto.AncestorHelper;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.ZfAncestorService;
@@ -23,12 +25,14 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import static com.ruoyi.common.core.domain.AjaxResult.error;
import static com.ruoyi.common.core.page.TableSupport.*;
//import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
@RestController
@RequestMapping("/ZfAncestor")
@@ -140,18 +144,79 @@
        zInfoUserService.updateById(infoUser);
    }
    @Log(title = "家庭大事件记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZfAncestor zfAncestor) {
        List<AncestorClan> list = new ArrayList<>();
        list = zfAncestorService.selectByCondition(zfAncestor);
       // log.info("导出记录为:{}", list);
        ExcelUtil<AncestorClan> util = new ExcelUtil<>(AncestorClan.class);
        util.exportExcel(response, list, "家庭大事件记录数据");
    }
    /**
     * 导出导出祖先信息记录列表
     */
//    @PreAuthorize("@ss.hasPermi('system:property:export')")
    @Log(title = "导出祖先信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export1/{ids}")
    public void export(HttpServletResponse response, @PathVariable Long[] ids)
    {
        List<AncestorClan> list = zfAncestorService.selectByIds(ids);
      //  log.info("导出记录为:{}",list);
        ExcelUtil<AncestorClan> util = new ExcelUtil<>(AncestorClan.class);
        util.exportExcel(response, list, "保洁收纳记录数据");
    }
    /**
     * 修改祖先信息
     */
    @Log(title = "祖先", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZfAncestor zfAncestor) {
    public AjaxResult edit(@RequestBody AncestorHelper ancestorHelper) {
        ZfAncestor spouseSex = zfAncestorService.update(zfAncestor);
        updateAncestor(zfAncestor);
        if (spouseSex.getId() != null)
        updateAncestor(spouseSex);
//        ZfAncestor spouseSex = zfAncestorService.update(zfAncestor);
//        updateAncestor(zfAncestor);
//        if (spouseSex.getId() != null)
//        updateAncestor(spouseSex);
        //修改sys_user表
        SysUser us = new SysUser();
        us.setNickName(ancestorHelper.getName());
        //   us.setStatus(String.valueOf(zfAncestor.getStatus()));
        us.setSex(String.valueOf(ancestorHelper.getSex()));
        us.setUserName(ancestorHelper.getName());
//        us.setClanId(ancestorHelper.getClanId());
        us.setUserId(ancestorHelper.getSysId());
        if (!userService.checkNickNameUnique(us)) {
            return error("修改祖先'" + us.getNickName() + "'失败,登录账号已存在");
        }
        userService.updateUser(us);
        //修改z_info_user表
        ZInfoUser infoUser = new ZInfoUser();
        infoUser.setSysId(us.getUserId());
        infoUser.setNickName(us.getNickName());
        infoUser.setOldName(us.getUserName());
        infoUser.setSex(Integer.parseInt(us.getSex()));
        ZInfoUser infoBysysId = zInfoUserService.getInfoBysysId(us.getUserId());
        infoUser.setUserId(infoBysysId.getUserId());
        zInfoUserService.saveOrUpdate(infoUser);
        //修改zf_ancestor表
        ZfAncestor zfAncestor = new ZfAncestor();
//        zfAncestor.setClanId(ancestorHelper.getClanId());
        zfAncestor.setName(ancestorHelper.getName());
        zfAncestor.setSex(ancestorHelper.getSex());
        zfAncestor.setSysId(ancestorHelper.getSysId());
        zfAncestorService.update(zfAncestor);
        return  AjaxResult.success();
    }
@@ -187,8 +252,8 @@
            us.setPassword("123456");
            us.setUserName(ancestorHelper.getName());
            us.setClanId(ancestorHelper.getClanId());
            if (!userService.checkUserNameUnique(us)) {
                return error("新增祖先'" + us.getUserName() + "'失败,登录账号已存在");
            if (!userService.checkNickNameUnique(us)) {
                return error("新增祖先'" + us.getNickName() + "'失败,登录账号已存在");
            }
            us.setPassword(SecurityUtils.encryptPassword(us.getPassword()));
@@ -201,8 +266,8 @@
            usa.setPassword("123456");
            usa.setClanId(ancestorHelper.getClanId());
            usa.setUserName(ancestorHelper.getFname());
            if (!userService.checkUserNameUnique(usa)) {
                return error("新增祖先1'" + usa.getUserName() + "'失败,登录账号已存在");
            if (!userService.checkNickNameUnique(usa)) {
                return error("新增祖先1'" + usa.getNickName() + "'失败,登录账号已存在");
            }
            us.setPassword(SecurityUtils.encryptPassword(usa.getPassword()));
@@ -277,10 +342,6 @@
            zfAncestor1.setStatus(0);
            zfAncestor1.setSysId(usa.getUserId());
            zfAncestorService.addData(zfAncestor1);
        }
        else{
            //保存祖先管理员,也先保存到sys_user
@@ -293,8 +354,8 @@
            us.setClanId(ancestorHelper.getClanId());
            System.out.println(ancestorHelper.getClanId());
            System.out.println("0000_______+++++++++++++999999999999");
            if (!userService.checkUserNameUnique(us)) {
                return error("新增祖先管理员'" + us.getUserName() + "'失败,登录账号已存在");
            if (!userService.checkNickNameUnique(us)) {
                return error("新增祖先管理员'" + us.getNickName() + "'失败,登录账号已存在");
            }
            us.setPassword(SecurityUtils.encryptPassword(us.getPassword()));
@@ -321,7 +382,6 @@
            zfAncestor.setSysId(us.getUserId());
            zfAncestorService.addData(zfAncestor);
        }