修改合规性手续模块
This commit is contained in:
@ -48,7 +48,8 @@ public class BusFormalitiesAreConsolidatedController extends BaseController {
|
||||
@SaCheckPermission("formalities:formalitiesAreConsolidated:list")
|
||||
@GetMapping("/list")
|
||||
public R<List<BusFormalitiesAreConsolidatedVo>> list(BusFormalitiesAreConsolidatedBo bo) {
|
||||
return R.ok(busFormalitiesAreConsolidatedService.queryList(bo));
|
||||
List<BusFormalitiesAreConsolidatedVo> list = busFormalitiesAreConsolidatedService.getTree(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@SaCheckPermission("formalities:formalitiesAreConsolidated:list")
|
||||
|
@ -62,6 +62,11 @@ public class BusFormalitiesAreConsolidated extends BaseEntity {
|
||||
*/
|
||||
private LocalDate planTheStartTime;
|
||||
|
||||
/**
|
||||
* 计划结束时间
|
||||
*/
|
||||
private LocalDate planTheEndTime;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
@ -70,8 +75,10 @@ public class BusFormalitiesAreConsolidated extends BaseEntity {
|
||||
/**
|
||||
* 实际完成时间
|
||||
*/
|
||||
@TableField(value = "actual_completion_time", updateStrategy = FieldStrategy.IGNORED)
|
||||
private Date actualCompletionTime;
|
||||
|
||||
|
||||
/**
|
||||
* 办理状态
|
||||
*/
|
||||
|
@ -65,6 +65,11 @@ public class BusFormalitiesAreConsolidatedBo extends BaseEntity {
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING)
|
||||
private LocalDate planTheStartTime;
|
||||
|
||||
/**
|
||||
* 计划结束时间
|
||||
*/
|
||||
private LocalDate planTheEndTime;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.dromara.formalities.domain.vo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.dromara.formalities.domain.BusFormalitiesAreConsolidated;
|
||||
@ -14,7 +15,7 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -73,6 +74,11 @@ public class BusFormalitiesAreConsolidatedVo implements Serializable {
|
||||
@ExcelProperty(value = "计划开始时间")
|
||||
private LocalDate planTheStartTime;
|
||||
|
||||
/**
|
||||
* 计划结束时间
|
||||
*/
|
||||
private LocalDate planTheEndTime;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
@ -104,4 +110,6 @@ public class BusFormalitiesAreConsolidatedVo implements Serializable {
|
||||
private String remark;
|
||||
|
||||
|
||||
private List<BusFormalitiesAreConsolidatedVo> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
@ -78,4 +78,6 @@ public interface IBusFormalitiesAreConsolidatedService extends IService<BusForma
|
||||
Boolean editStatus(BusFormalitiesAreConsolidatedBo bo);
|
||||
|
||||
Boolean getWhetherItExists(BusFormalitiesAreConsolidatedBo bo);
|
||||
|
||||
List<BusFormalitiesAreConsolidatedVo> getTree(BusFormalitiesAreConsolidatedBo bo);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.dromara.formalities.domain.bo.AddBusFormalitiesAreConsolidatedBo;
|
||||
import org.dromara.formalities.enums.FormalitiesStatusEnum;
|
||||
import org.dromara.formalities.service.IBusFormalitiesAnnexService;
|
||||
import org.dromara.formalities.service.IBusListOfFormalitiesService;
|
||||
import org.dromara.formalities.utils.TreeUtil;
|
||||
import org.dromara.system.domain.vo.SysOssUploadVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -87,10 +88,18 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<BusFormalitiesAreConsolidatedVo> getTree(BusFormalitiesAreConsolidatedBo bo) {
|
||||
List<BusFormalitiesAreConsolidatedVo> voList = queryList(bo);
|
||||
return TreeUtil.buildTree1(voList);
|
||||
}
|
||||
|
||||
|
||||
private LambdaQueryWrapper<BusFormalitiesAreConsolidated> buildQueryWrapper(BusFormalitiesAreConsolidatedBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<BusFormalitiesAreConsolidated> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByDesc(BusFormalitiesAreConsolidated::getId);
|
||||
lqw.orderByDesc(BusFormalitiesAreConsolidated::getCreateTime);
|
||||
lqw.eq(bo.getProjectId() != null, BusFormalitiesAreConsolidated::getProjectId, bo.getProjectId());
|
||||
lqw.eq(bo.getFormalitiesPid() != null, BusFormalitiesAreConsolidated::getFormalitiesPid, bo.getFormalitiesPid());
|
||||
lqw.eq(bo.getFormalitiesId() != null, BusFormalitiesAreConsolidated::getFormalitiesId, bo.getFormalitiesId());
|
||||
@ -111,6 +120,7 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
|
||||
public Boolean insertByBo(BusFormalitiesAreConsolidatedBo bo) {
|
||||
List<AddBusFormalitiesAreConsolidatedBo> addBusFormalitiesAreConsolidatedBos = bo.getAddBusFormalitiesAreConsolidatedBos();
|
||||
List<BusFormalitiesAreConsolidated> list = new ArrayList<>();
|
||||
Set<Long> ids = new HashSet<>();
|
||||
addBusFormalitiesAreConsolidatedBos.forEach(addBusFormalitiesAreConsolidatedBo -> {
|
||||
BusFormalitiesAreConsolidated busFormalitiesAreConsolidated = new BusFormalitiesAreConsolidated();
|
||||
busFormalitiesAreConsolidated.setFormalitiesId(addBusFormalitiesAreConsolidatedBo.getFormalitiesId());
|
||||
@ -120,6 +130,7 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
|
||||
}
|
||||
if (addBusFormalitiesAreConsolidatedBo.getFormalitiesPid() != null) {
|
||||
busFormalitiesAreConsolidated.setFormalitiesPid(addBusFormalitiesAreConsolidatedBo.getFormalitiesPid());
|
||||
ids.add(addBusFormalitiesAreConsolidatedBo.getFormalitiesPid());
|
||||
BusListOfFormalities formalities = busListOfFormalitiesService.getById(addBusFormalitiesAreConsolidatedBo.getFormalitiesPid());
|
||||
if (formalities != null) {
|
||||
busFormalitiesAreConsolidated.setFormalitiesPname(formalities.getName());
|
||||
@ -129,6 +140,18 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
|
||||
busFormalitiesAreConsolidated.setProcessingStatus(FormalitiesStatusEnum.TOSTART.getText());
|
||||
list.add(busFormalitiesAreConsolidated);
|
||||
});
|
||||
for (Long id : ids) {
|
||||
BusListOfFormalities formalities = busListOfFormalitiesService.getById(id);
|
||||
if (formalities != null) {
|
||||
BusFormalitiesAreConsolidated busFormalitiesAreConsolidated = new BusFormalitiesAreConsolidated();
|
||||
busFormalitiesAreConsolidated.setFormalitiesId(id);
|
||||
busFormalitiesAreConsolidated.setFormalitiesName(formalities.getName());
|
||||
busFormalitiesAreConsolidated.setProjectId(bo.getProjectId());
|
||||
busFormalitiesAreConsolidated.setStatus(1);
|
||||
list.add(busFormalitiesAreConsolidated);
|
||||
}
|
||||
|
||||
}
|
||||
// BusFormalitiesAreConsolidated add = MapstructUtils.convert(bo, BusFormalitiesAreConsolidated.class);
|
||||
// validEntityBeforeSave(add);
|
||||
// boolean flag = baseMapper.insert(add) > 0;
|
||||
@ -149,7 +172,7 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
|
||||
|
||||
bo.setProcessingStatus(FormalitiesStatusEnum.PROCESSING.getText());
|
||||
BusFormalitiesAreConsolidated update = MapstructUtils.convert(bo, BusFormalitiesAreConsolidated.class);
|
||||
validEntityBeforeSave(update);
|
||||
// validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@ -158,8 +181,13 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
|
||||
*/
|
||||
private void validEntityBeforeSave(BusFormalitiesAreConsolidated entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
if (entity.getStatus() == 1){
|
||||
throw new ServiceException("已完成不允许修改");
|
||||
// if (entity.getStatus() == 1){
|
||||
// throw new ServiceException("已完成不允许修改!!!");
|
||||
// }
|
||||
if (!FormalitiesStatusEnum.TOSTART.getText().equals(entity.getProcessingStatus())
|
||||
&& !FormalitiesStatusEnum.PROCESSING.getText().equals(entity.getProcessingStatus())
|
||||
&& !FormalitiesStatusEnum.DELETE.getText().equals(entity.getProcessingStatus())){
|
||||
throw new ServiceException("办理状态错误!!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,23 +208,41 @@ public class BusFormalitiesAreConsolidatedServiceImpl extends ServiceImpl<BusFor
|
||||
|
||||
@Override
|
||||
public Boolean editStatus(BusFormalitiesAreConsolidatedBo bo) {
|
||||
if (bo.getProcessingStatus() ==null || bo.getProcessingStatus().isEmpty()){
|
||||
throw new ServiceException("办理状态不能为空");
|
||||
}
|
||||
BusFormalitiesAreConsolidated busFormalitiesAreConsolidated = baseMapper.selectById(bo.getId());
|
||||
if (busFormalitiesAreConsolidated == null) {
|
||||
throw new ServiceException("数据不存在");
|
||||
}
|
||||
if (busFormalitiesAreConsolidated.getHead() == null) {
|
||||
throw new ServiceException("负责人为空不能提交");
|
||||
// if (busFormalitiesAreConsolidated.getProcessingStatus() == null) {
|
||||
// throw new ServiceException("办理状态为空不能提交");
|
||||
// }
|
||||
// if (FormalitiesStatusEnum.DELETE.getText().equals(busFormalitiesAreConsolidated.getProcessingStatus())){
|
||||
// throw new ServiceException("办理状态为已完成才能提交");
|
||||
// }
|
||||
|
||||
busFormalitiesAreConsolidated.setProcessingStatus(bo.getProcessingStatus());
|
||||
if (FormalitiesStatusEnum.DELETE.getText().equals(busFormalitiesAreConsolidated.getProcessingStatus())){
|
||||
if (busFormalitiesAreConsolidated.getHead() == null) {
|
||||
throw new ServiceException("负责人为空不能提交");
|
||||
}
|
||||
if (busFormalitiesAreConsolidated.getPlanTheStartTime() == null) {
|
||||
throw new ServiceException("计划开始时间为空不能提交");
|
||||
}
|
||||
if (busFormalitiesAreConsolidated.getPlanTheEndTime() == null) {
|
||||
throw new ServiceException("计划结束时间为空不能提交");
|
||||
}
|
||||
long count = busFormalitiesAnnexService.count(new LambdaQueryWrapper<BusFormalitiesAnnex>().eq(BusFormalitiesAnnex::getFormalitiesId, bo.getId()));
|
||||
if (count == 0) {
|
||||
throw new ServiceException("手续材料为空不能提交");
|
||||
}
|
||||
busFormalitiesAreConsolidated.setActualCompletionTime(new Date());
|
||||
}else {
|
||||
busFormalitiesAreConsolidated.setActualCompletionTime(null);
|
||||
}
|
||||
if (busFormalitiesAreConsolidated.getPlanTheStartTime() == null) {
|
||||
throw new ServiceException("计划开始时间为空不能提交");
|
||||
}
|
||||
long count = busFormalitiesAnnexService.count(new LambdaQueryWrapper<BusFormalitiesAnnex>().eq(BusFormalitiesAnnex::getFormalitiesId, bo.getId()));
|
||||
if (count == 0) {
|
||||
throw new ServiceException("手续材料为空不能提交");
|
||||
}
|
||||
busFormalitiesAreConsolidated.setActualCompletionTime(new Date());
|
||||
busFormalitiesAreConsolidated.setProcessingStatus(FormalitiesStatusEnum.DELETE.getText());
|
||||
busFormalitiesAreConsolidated.setStatus(1);
|
||||
validEntityBeforeSave(busFormalitiesAreConsolidated);
|
||||
// busFormalitiesAreConsolidated.setStatus(1);
|
||||
// BusFormalitiesAreConsolidated update = MapstructUtils.convert(bo, BusFormalitiesAreConsolidated.class);
|
||||
return baseMapper.updateById(busFormalitiesAreConsolidated) > 0;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.formalities.utils;
|
||||
|
||||
import org.dromara.formalities.domain.vo.BusFormalitiesAreConsolidatedVo;
|
||||
import org.dromara.formalities.domain.vo.BusListOfFormalitiesVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -43,4 +44,38 @@ public class TreeUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建树形结构
|
||||
* @param list 所有节点列表
|
||||
* @return 树形结构的根节点列表
|
||||
*/
|
||||
public static List<BusFormalitiesAreConsolidatedVo> buildTree1(List<BusFormalitiesAreConsolidatedVo> list) {
|
||||
List<BusFormalitiesAreConsolidatedVo> result = new ArrayList<>();
|
||||
|
||||
// 找到所有根节点(pid为null或0的节点)
|
||||
for (BusFormalitiesAreConsolidatedVo node : list) {
|
||||
if (node.getFormalitiesPid() == null || node.getFormalitiesPid() == 0) {
|
||||
result.add(node);
|
||||
// 递归设置子节点
|
||||
setChildren1(node, list);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为节点设置子节点
|
||||
* @param parent 父节点
|
||||
* @param allNodes 所有节点
|
||||
*/
|
||||
private static void setChildren1(BusFormalitiesAreConsolidatedVo parent, List<BusFormalitiesAreConsolidatedVo> allNodes) {
|
||||
for (BusFormalitiesAreConsolidatedVo node : allNodes) {
|
||||
if (parent.getFormalitiesId().equals(node.getFormalitiesPid())) {
|
||||
parent.getChildren().add(node);
|
||||
// 递归设置子节点的子节点
|
||||
setChildren1(node, allNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user