派单2.0
This commit is contained in:
@ -8,7 +8,11 @@ import jakarta.validation.constraints.*;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.patch.domain.bo.PdMasterProgressReq;
|
||||||
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
||||||
|
import org.dromara.system.domain.SysUser;
|
||||||
|
import org.dromara.system.domain.vo.SysUserVo;
|
||||||
|
import org.dromara.system.service.ISysUserService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
@ -38,36 +42,41 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|||||||
public class PdMasterController extends BaseController {
|
public class PdMasterController extends BaseController {
|
||||||
|
|
||||||
private final IPdMasterService pdMasterService;
|
private final IPdMasterService pdMasterService;
|
||||||
|
|
||||||
|
private final ISysUserService userService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增进度详情
|
* 获取当前用户对应部门下的所有用户
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("patch:master:edit")
|
@SaCheckPermission("patch:master:findThis")
|
||||||
@PostMapping("/progress")
|
@GetMapping("/findThis")
|
||||||
public R<Void> addProgress(@Validated @RequestBody PdMasterProgressVo progress) {
|
public R<List<SysUser>> findThis() {
|
||||||
if (progress.getSlaveId() == null) {
|
return R.ok(userService.findThis());
|
||||||
throw new ServiceException("slaveId不能为空,无法更新进度");
|
|
||||||
}
|
|
||||||
// 将slaveId的值赋给updateBy
|
|
||||||
progress.setUpdateBy(progress.getSlaveId());
|
|
||||||
// 如果需要,也可以将slaveName赋给updateByName
|
|
||||||
progress.setUpdateByName(progress.getSlaveName());
|
|
||||||
return toAjax(pdMasterService.addProgress(progress));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改进度详情
|
* 新增进度详情
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("patch:master:edit")
|
@SaCheckPermission("patch:master:progress")
|
||||||
@PutMapping("/progress")
|
@PostMapping("/progress")
|
||||||
public R<Void> editProgress(@Validated @RequestBody PdMasterProgressVo progress) {
|
public R<Void> addProgress(@Validated @RequestBody PdMasterProgressReq progress) {
|
||||||
return toAjax(pdMasterService.editProgress(progress));
|
return toAjax(pdMasterService.addProgress(progress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 修改进度详情
|
||||||
|
// */
|
||||||
|
// @SaCheckPermission("patch:master:editProgress")
|
||||||
|
// @PutMapping("/editProgress")
|
||||||
|
// public R<Void> editProgress(@Validated @RequestBody PdMasterProgressVo progress) {
|
||||||
|
// return toAjax(pdMasterService.editProgress(progress));
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除进度详情
|
* 删除进度详情
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("patch:master:remove")
|
@SaCheckPermission("patch:master:removeProgress")
|
||||||
@DeleteMapping("/progress/{id}")
|
@DeleteMapping("/removeProgress/{id}")
|
||||||
public R<Void> removeProgress(@PathVariable Long id) {
|
public R<Void> removeProgress(@PathVariable Long id) {
|
||||||
return toAjax(pdMasterService.removeProgress(id));
|
return toAjax(pdMasterService.removeProgress(id));
|
||||||
}
|
}
|
||||||
@ -78,8 +87,8 @@ public class PdMasterController extends BaseController {
|
|||||||
* @param masterId 派单主表ID
|
* @param masterId 派单主表ID
|
||||||
* @return 进度详情列表
|
* @return 进度详情列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("patch:master:query")
|
@SaCheckPermission("patch:master:getProgressList")
|
||||||
@GetMapping("/progress/{masterId}")
|
@GetMapping("/getProgressList/{masterId}")
|
||||||
public R<List<PdMasterProgressVo>> getProgressList(
|
public R<List<PdMasterProgressVo>> getProgressList(
|
||||||
@NotNull(message = "主表ID不能为空")
|
@NotNull(message = "主表ID不能为空")
|
||||||
@PathVariable Long masterId) {
|
@PathVariable Long masterId) {
|
||||||
|
@ -41,6 +41,5 @@ public class PdMasterSon extends BaseEntity {
|
|||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
private Long updateBy;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ public class PdMasterUser extends BaseEntity {
|
|||||||
@TableId(type = IdType.INPUT)
|
@TableId(type = IdType.INPUT)
|
||||||
private Long ordersid;
|
private Long ordersid;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行人id
|
* 执行人id
|
||||||
*/
|
*/
|
||||||
|
@ -68,5 +68,15 @@ public class PdMasterBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行人
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行人姓名
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package org.dromara.patch.domain.bo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author 铁憨憨
|
||||||
|
* @Date 2025/8/20 20:52
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PdMasterProgressReq implements Serializable {
|
||||||
|
/**
|
||||||
|
* 进度ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主表任务ID
|
||||||
|
*/
|
||||||
|
private Long ordersId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进度
|
||||||
|
*/
|
||||||
|
private String progress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 执行人ID
|
||||||
|
// */
|
||||||
|
// @NotNull(message = "执行人不能你为空")
|
||||||
|
// private Long slaveId;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 执行人名字
|
||||||
|
// */
|
||||||
|
// private String slaveName;
|
||||||
|
}
|
@ -45,6 +45,4 @@ public class PdMasterProgressVo {
|
|||||||
* 执行人名字
|
* 执行人名字
|
||||||
*/
|
*/
|
||||||
private String slaveName;
|
private String slaveName;
|
||||||
private Long updateBy; // 新增字段
|
|
||||||
private String updateByName; // 新增字段
|
|
||||||
}
|
}
|
||||||
|
@ -84,5 +84,17 @@ public class PdMasterVo implements Serializable {
|
|||||||
@ExcelProperty(value = "备注")
|
@ExcelProperty(value = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子用户ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "子用户ID")
|
||||||
|
private Long slaveid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子用户
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "子用户")
|
||||||
|
private String slaveName;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.dromara.patch.domain.PdMaster;
|
import org.dromara.patch.domain.PdMaster;
|
||||||
|
import org.dromara.patch.domain.bo.PdMasterProgressReq;
|
||||||
import org.dromara.patch.domain.dto.ProgressDetailDto;
|
import org.dromara.patch.domain.dto.ProgressDetailDto;
|
||||||
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
||||||
import org.dromara.patch.domain.vo.PdMasterVo;
|
import org.dromara.patch.domain.vo.PdMasterVo;
|
||||||
@ -23,7 +24,7 @@ public interface PdMasterMapper extends BaseMapperPlus<PdMaster, PdMasterVo> {
|
|||||||
List<PdMasterProgressVo> selectProgressByMasterId(@Param("masterId") Long masterId);
|
List<PdMasterProgressVo> selectProgressByMasterId(@Param("masterId") Long masterId);
|
||||||
|
|
||||||
// 新增进度详情
|
// 新增进度详情
|
||||||
int insertProgress(@Param("progress") PdMasterProgressVo progress);
|
int insertProgress(@Param("progress") PdMasterProgressReq progress);
|
||||||
|
|
||||||
// 修改进度详情
|
// 修改进度详情
|
||||||
int updateProgress(@Param("progress") PdMasterProgressVo progress);
|
int updateProgress(@Param("progress") PdMasterProgressVo progress);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.patch.service;
|
package org.dromara.patch.service;
|
||||||
|
|
||||||
|
import org.dromara.patch.domain.bo.PdMasterProgressReq;
|
||||||
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
||||||
import org.dromara.patch.domain.vo.PdMasterVo;
|
import org.dromara.patch.domain.vo.PdMasterVo;
|
||||||
import org.dromara.patch.domain.bo.PdMasterBo;
|
import org.dromara.patch.domain.bo.PdMasterBo;
|
||||||
@ -22,7 +23,7 @@ public interface IPdMasterService extends IService<PdMaster>{
|
|||||||
void validEntityBeforeSave(PdMaster entity);
|
void validEntityBeforeSave(PdMaster entity);
|
||||||
|
|
||||||
// 新增进度
|
// 新增进度
|
||||||
Boolean addProgress(PdMasterProgressVo progress);
|
Boolean addProgress(PdMasterProgressReq progress);
|
||||||
|
|
||||||
// 修改进度
|
// 修改进度
|
||||||
Boolean editProgress(PdMasterProgressVo progress);
|
Boolean editProgress(PdMasterProgressVo progress);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.dromara.patch.service.impl;
|
package org.dromara.patch.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
@ -9,8 +11,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
|
import org.dromara.common.translation.annotation.Translation;
|
||||||
|
import org.dromara.patch.domain.PdMasterSon;
|
||||||
|
import org.dromara.patch.domain.PdMasterUser;
|
||||||
|
import org.dromara.patch.domain.bo.PdMasterProgressReq;
|
||||||
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
import org.dromara.patch.domain.vo.PdMasterProgressVo;
|
||||||
import org.dromara.patch.enums.TaskStatusEnum;
|
import org.dromara.patch.enums.TaskStatusEnum;
|
||||||
|
import org.dromara.patch.service.IPdMasterSonService;
|
||||||
|
import org.dromara.patch.service.IPdMasterUserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.dromara.patch.domain.bo.PdMasterBo;
|
import org.dromara.patch.domain.bo.PdMasterBo;
|
||||||
import org.dromara.patch.domain.vo.PdMasterVo;
|
import org.dromara.patch.domain.vo.PdMasterVo;
|
||||||
@ -18,11 +27,10 @@ import org.dromara.patch.domain.PdMaster;
|
|||||||
import org.dromara.patch.mapper.PdMasterMapper;
|
import org.dromara.patch.mapper.PdMasterMapper;
|
||||||
import org.dromara.patch.service.IPdMasterService;
|
import org.dromara.patch.service.IPdMasterService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 派单Service业务层处理
|
* 派单Service业务层处理
|
||||||
@ -36,6 +44,10 @@ public class PdMasterServiceImpl extends ServiceImpl<PdMasterMapper, PdMaster> i
|
|||||||
|
|
||||||
private final PdMasterMapper baseMapper;
|
private final PdMasterMapper baseMapper;
|
||||||
|
|
||||||
|
private final IPdMasterSonService pdMasterSonService;
|
||||||
|
|
||||||
|
private final IPdMasterUserService pdMasterUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validEntityBeforeSave(PdMaster entity) {
|
public void validEntityBeforeSave(PdMaster entity) {
|
||||||
// 如果有ID(更新操作),计算总进度
|
// 如果有ID(更新操作),计算总进度
|
||||||
@ -61,35 +73,44 @@ public class PdMasterServiceImpl extends ServiceImpl<PdMasterMapper, PdMaster> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean addProgress(PdMasterProgressVo progress) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean addProgress(PdMasterProgressReq progress) {
|
||||||
|
//获取当前用户,判断是否是这条数据的执行人
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
//获取这条数据的执行人
|
||||||
|
PdMasterUser one = pdMasterUserService.getOne(new LambdaQueryWrapper<PdMasterUser>().eq(PdMasterUser::getOrdersid, progress.getOrdersId()));
|
||||||
|
if (one == null) {
|
||||||
|
throw new RuntimeException("执行人未找到!");
|
||||||
|
}
|
||||||
|
if (!Objects.equals(userId, one.getSlaveid())){
|
||||||
|
throw new RuntimeException("执行人不匹配!");
|
||||||
|
}
|
||||||
if (progress.getOrdersId() == null) {
|
if (progress.getOrdersId() == null) {
|
||||||
throw new ServiceException("主表ID不能为空");
|
throw new ServiceException("主表ID不能为空");
|
||||||
}
|
}
|
||||||
if (baseMapper.selectById(progress.getOrdersId()) == null) {
|
if (baseMapper.selectById(progress.getOrdersId()) == null) {
|
||||||
throw new ServiceException("派单主表不存在");
|
throw new ServiceException("派单主表不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增进度到pd_master_son表
|
// 新增进度到pd_master_son表
|
||||||
boolean success = baseMapper.insertProgress(progress) > 0;
|
PdMasterSon pdMasterSon = BeanUtil.copyProperties(progress, PdMasterSon.class);
|
||||||
|
if (pdMasterSonService.save(pdMasterSon)) {
|
||||||
if (success) {
|
//判断数据是否百分之百
|
||||||
// 同时向pd_master_user表插入数据
|
List<PdMasterSon> list = pdMasterSonService.list(new LambdaQueryWrapper<PdMasterSon>().eq(PdMasterSon::getOrdersId, progress.getOrdersId()));
|
||||||
// 这里假设progress对象中有updateBy字段,如果没有需要从其他地方获取
|
BigDecimal bigDecimal = new BigDecimal("0");
|
||||||
Long updateBy = progress.getUpdateBy(); // 需要确保PdMasterProgressVo有这个字段
|
for (PdMasterSon masterSon : list) {
|
||||||
String updateByName = progress.getUpdateByName(); // 需要确保PdMasterProgressVo有这个字段
|
bigDecimal = bigDecimal.add(new BigDecimal(masterSon.getProgress()));
|
||||||
|
|
||||||
if (updateBy != null) {
|
|
||||||
// 检查是否已存在关联记录
|
|
||||||
int count = baseMapper.countMasterUser(progress.getOrdersId(), updateBy);
|
|
||||||
if (count == 0) {
|
|
||||||
// 不存在则插入
|
|
||||||
baseMapper.insertMasterUser(progress.getOrdersId(), updateBy, updateByName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//bigDecimal是否为100,100变更数据状态
|
||||||
updateMasterCompletionProgress(progress.getOrdersId());
|
if (bigDecimal.compareTo(new BigDecimal("100")) == 0){
|
||||||
|
//更新主表状态
|
||||||
|
PdMaster pdMaster = baseMapper.selectById(progress.getOrdersId());
|
||||||
|
pdMaster.setTaskStatus(TaskStatusEnum.FINISHED.getValue());
|
||||||
|
pdMaster.setAct(new Date());
|
||||||
|
baseMapper.updateById(pdMaster);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Boolean editProgress(PdMasterProgressVo progress) {
|
public Boolean editProgress(PdMasterProgressVo progress) {
|
||||||
@ -153,7 +174,17 @@ public class PdMasterServiceImpl extends ServiceImpl<PdMasterMapper, PdMaster> i
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PdMasterVo queryById(Long id){
|
public PdMasterVo queryById(Long id){
|
||||||
return baseMapper.selectVoById(id);
|
//1、获取基础数据
|
||||||
|
PdMasterVo pdMasterVo = baseMapper.selectVoById(id);
|
||||||
|
//2、查询下面的用户
|
||||||
|
LambdaQueryWrapper<PdMasterUser> eq = new LambdaQueryWrapper<PdMasterUser>().eq(PdMasterUser::getOrdersid, pdMasterVo.getId());
|
||||||
|
PdMasterUser one = pdMasterUserService.getOne(eq);
|
||||||
|
if (one == null) {
|
||||||
|
throw new ServiceException("子用户不存在");
|
||||||
|
}
|
||||||
|
pdMasterVo.setSlaveid(one.getSlaveid());
|
||||||
|
pdMasterVo.setSlaveName(one.getSlaveName());
|
||||||
|
return pdMasterVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,6 +198,15 @@ public class PdMasterServiceImpl extends ServiceImpl<PdMasterMapper, PdMaster> i
|
|||||||
public TableDataInfo<PdMasterVo> queryPageList(PdMasterBo bo, PageQuery pageQuery) {
|
public TableDataInfo<PdMasterVo> queryPageList(PdMasterBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<PdMaster> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<PdMaster> lqw = buildQueryWrapper(bo);
|
||||||
Page<PdMasterVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<PdMasterVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
//获取当前主数据下面的进度百分比
|
||||||
|
result.getRecords().forEach(item -> {
|
||||||
|
List<PdMasterSon> list = pdMasterSonService.list(new LambdaQueryWrapper<PdMasterSon>().eq(PdMasterSon::getOrdersId, item.getId()));
|
||||||
|
BigDecimal bigDecimal = new BigDecimal("0");
|
||||||
|
for (PdMasterSon pdMasterSon : list) {
|
||||||
|
bigDecimal = bigDecimal.add(new BigDecimal(pdMasterSon.getProgress()));
|
||||||
|
}
|
||||||
|
item.setCompletionProgress(bigDecimal+"%");
|
||||||
|
});
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,11 +244,18 @@ public class PdMasterServiceImpl extends ServiceImpl<PdMasterMapper, PdMaster> i
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByBo(PdMasterBo bo) {
|
public Boolean insertByBo(PdMasterBo bo) {
|
||||||
|
//1、新增数据
|
||||||
PdMaster add = MapstructUtils.convert(bo, PdMaster.class);
|
PdMaster add = MapstructUtils.convert(bo, PdMaster.class);
|
||||||
validEntityBeforeSave(add);
|
validEntityBeforeSave(add);
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
|
//2、增加子用户
|
||||||
|
PdMasterUser pdMasterUser = new PdMasterUser();
|
||||||
|
pdMasterUser.setOrdersid(add.getId());
|
||||||
|
pdMasterUser.setSlaveid(bo.getUserId());
|
||||||
|
pdMasterUser.setSlaveName(bo.getUserName());
|
||||||
|
pdMasterUserService.save(pdMasterUser);
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
@ -221,9 +268,21 @@ public class PdMasterServiceImpl extends ServiceImpl<PdMasterMapper, PdMaster> i
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateByBo(PdMasterBo bo) {
|
public Boolean updateByBo(PdMasterBo bo) {
|
||||||
|
//1、修改数据
|
||||||
PdMaster update = MapstructUtils.convert(bo, PdMaster.class);
|
PdMaster update = MapstructUtils.convert(bo, PdMaster.class);
|
||||||
validEntityBeforeSave(update);
|
validEntityBeforeSave(update);
|
||||||
return baseMapper.updateById(update) > 0;
|
if (baseMapper.updateById(update) > 0){
|
||||||
|
//2、删除子用户
|
||||||
|
pdMasterUserService.remove(new LambdaQueryWrapper<PdMasterUser>().eq(PdMasterUser::getOrdersid, bo.getId()));
|
||||||
|
//3、新增子用户
|
||||||
|
PdMasterUser pdMasterUser = new PdMasterUser();
|
||||||
|
pdMasterUser.setOrdersid(update.getId());
|
||||||
|
pdMasterUser.setSlaveid(bo.getUserId());
|
||||||
|
pdMasterUser.setSlaveName(bo.getUserName());
|
||||||
|
pdMasterUserService.save(pdMasterUser);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,21 +5,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<mapper namespace="org.dromara.patch.mapper.PdMasterMapper">
|
<mapper namespace="org.dromara.patch.mapper.PdMasterMapper">
|
||||||
<select id="selectProgressByMasterId" resultType="org.dromara.patch.domain.vo.PdMasterProgressVo">
|
<select id="selectProgressByMasterId" resultType="org.dromara.patch.domain.vo.PdMasterProgressVo">
|
||||||
SELECT
|
SELECT
|
||||||
s.id,
|
a.*,b.slave_name
|
||||||
s.orders_id as ordersId,
|
|
||||||
s.progress,
|
|
||||||
s.remark,
|
|
||||||
s.update_time as updateTime,
|
|
||||||
u.slaveid as slaveId,
|
|
||||||
u.slave_name as slaveName
|
|
||||||
FROM
|
FROM
|
||||||
pd_master m
|
pd_master_son as a
|
||||||
INNER JOIN pd_master_user u ON m.id = u.ordersid
|
LEFT JOIN pd_master_user as b on b.ordersid =a.orders_id
|
||||||
INNER JOIN pd_master_son s ON m.id = s.orders_id
|
|
||||||
WHERE
|
WHERE
|
||||||
m.id = #{masterId}
|
orders_id = #{masterId}
|
||||||
ORDER BY
|
|
||||||
s.update_time DESC
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 新增进度详情 -->
|
<!-- 新增进度详情 -->
|
||||||
@ -41,11 +32,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<delete id="deleteProgressById">
|
<delete id="deleteProgressById">
|
||||||
DELETE FROM pd_master_son WHERE id = #{id}
|
DELETE FROM pd_master_son WHERE id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectTotalProgressByMasterId" resultType="java.lang.Double">
|
<select id="selectTotalProgressByMasterId" resultType="java.lang.Double">
|
||||||
SELECT COALESCE(SUM(CAST(REPLACE(progress, '%', '') AS DECIMAL(5,2))), 0)
|
SELECT COALESCE(SUM(CAST(REPLACE(progress, '%', '') AS DECIMAL(5,2))), 0)
|
||||||
FROM pd_master_son
|
FROM pd_master_son
|
||||||
WHERE orders_id = #{masterId}
|
WHERE orders_id = #{masterId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectProgressById" resultType="org.dromara.patch.domain.vo.PdMasterProgressVo">
|
<select id="selectProgressById" resultType="org.dromara.patch.domain.vo.PdMasterProgressVo">
|
||||||
SELECT id, orders_id as ordersId, progress, remark, update_time as updateTime, update_by as updateBy
|
SELECT id, orders_id as ordersId, progress, remark, update_time as updateTime, update_by as updateBy
|
||||||
FROM pd_master_son
|
FROM pd_master_son
|
||||||
|
Reference in New Issue
Block a user