优化sql
This commit is contained in:
parent
a47baa31dc
commit
2128d2572f
@ -41,14 +41,18 @@ public class PlanSubController {
|
|||||||
private PlanSubService planSubService;
|
private PlanSubService planSubService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* */
|
||||||
@PostMapping("/postOwnderChaHuo")
|
@PostMapping("/postOwnderChaHuo")
|
||||||
@Operation(summary = "查询设置的负责人设计时间是否和其他项目冲突")
|
@Operation(summary = "查询设置的负责人设计时间是否和其他项目冲突")
|
||||||
@Parameter(name = "names", description = "负责人", required = true)
|
@Parameter(name = "names", description = "负责人", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('heli:material-plan:delete')")
|
@PreAuthorize("@ss.hasPermission('heli:material-plan:delete')")
|
||||||
public CommonResult<String> postOwnderChaHuo(@RequestParam("names") String names,@RequestParam("dateOne") String dateOne,@RequestParam("dateTwo") String dateTwo,@RequestParam("id") String id,@RequestParam("diffDays") Long diffDays,@RequestParam("type") int type) {
|
public CommonResult<List<PlanSubRespVO>> postOwnderChaHuo(@RequestBody List<PlanSubRespVO> tableData){//(@RequestParam("planId") Long planId,@RequestParam("names") String names,@RequestParam("dateOne") String dateOne,@RequestParam("dateTwo") String dateTwo,@RequestParam("id") String id,@RequestParam("diffDays") Long diffDays,@RequestParam("type") int type,@RequestParam("dateThree") String dateThree) {
|
||||||
String planSubDOList = planSubService.postOwnderChaHuo(names, dateOne, dateTwo,id,diffDays,type);
|
System.out.println(tableData);
|
||||||
|
List<PlanSubDO> planSubDOList = planSubService.postOwnderChaHuo(tableData);
|
||||||
|
|
||||||
return success(null);
|
return success(BeanUtils.toBean(planSubDOList, PlanSubRespVO.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,4 +117,7 @@ public class PlanSubRespVO {
|
|||||||
@Schema(description = "要求预计设计结束日期")
|
@Schema(description = "要求预计设计结束日期")
|
||||||
private LocalDateTime changeEndTime;
|
private LocalDateTime changeEndTime;
|
||||||
|
|
||||||
|
@Schema(description = "设计类型")
|
||||||
|
private int type;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,41 @@ public interface PlanSubMapper extends BaseMapperX<PlanSubDO> {
|
|||||||
return selectList(query);
|
return selectList(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<PlanSubDO> searchOwnerTwos(Long planId,String name,String dateOne,String dateTwo,String id) {
|
||||||
|
MPJLambdaWrapper<PlanSubDO> query = new MPJLambdaWrapper<>();
|
||||||
|
query.selectAll(PlanSubDO.class)
|
||||||
|
.select("a.change_end_time as changeEndTime,b.name as projectSubName,b.amount,b.unit, c.name as equipName ,d.name as compositionName")
|
||||||
|
.leftJoin(PlanDO.class, "a", PlanDO::getId, PlanSubDO::getProjectPlanId)
|
||||||
|
.leftJoin(ProjectOrderSubDO.class, "b", ProjectOrderSubDO::getId, PlanSubDO::getProjectSubId)
|
||||||
|
.leftJoin(EquipDO.class,"c",EquipDO::getId,PlanSubDO::getEquipId)
|
||||||
|
.leftJoin(CompositionDO.class, "d", CompositionDO::getId, ProjectOrderSubDO::getCompositionId)
|
||||||
|
|
||||||
|
.disableSubLogicDel()
|
||||||
|
.orderByAsc(PlanSubDO::getId);
|
||||||
|
// 增加查询条件
|
||||||
|
query.eq(StringUtils.isNotBlank(name), PlanSubDO:: getTwoDimOwner, name);
|
||||||
|
// 添加日期范围查询条件
|
||||||
|
/*query.between(PlanSubDO::getStartBlankDate, dateOne, dateTwo);
|
||||||
|
query.between(PlanSubDO::getBlankDate, dateOne, dateTwo);*/
|
||||||
|
if (StringUtils.isNotBlank(dateOne) && StringUtils.isNotBlank(dateTwo)) {
|
||||||
|
|
||||||
|
|
||||||
|
query.and(i -> i.between(PlanSubDO::getStartTwoDimDate, dateOne, dateTwo)
|
||||||
|
.or(a -> a.between(PlanSubDO::getTwoDimDate, dateOne, dateTwo)));
|
||||||
|
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(id)){
|
||||||
|
query.ne(PlanSubDO::getId,id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!(planId == 0L)){
|
||||||
|
query.ne(PlanSubDO::getProjectPlanId,planId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectList(query);
|
||||||
|
}
|
||||||
|
|
||||||
default List<PlanSubDO> searchOwnerTwo(String name,String dateOne,String dateTwo,String id) {
|
default List<PlanSubDO> searchOwnerTwo(String name,String dateOne,String dateTwo,String id) {
|
||||||
MPJLambdaWrapper<PlanSubDO> query = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<PlanSubDO> query = new MPJLambdaWrapper<>();
|
||||||
query.selectAll(PlanSubDO.class)
|
query.selectAll(PlanSubDO.class)
|
||||||
@ -92,6 +127,41 @@ public interface PlanSubMapper extends BaseMapperX<PlanSubDO> {
|
|||||||
}
|
}
|
||||||
return selectList(query);
|
return selectList(query);
|
||||||
}
|
}
|
||||||
|
default List<PlanSubDO> searchOwners(Long planId,String name,String dateOne,String dateTwo,String id) {
|
||||||
|
MPJLambdaWrapper<PlanSubDO> query = new MPJLambdaWrapper<>();
|
||||||
|
query.selectAll(PlanSubDO.class)
|
||||||
|
.select("a.change_end_time as changeEndTime,b.name as projectSubName,b.amount,b.unit, c.name as equipName ,d.name as compositionName")
|
||||||
|
.leftJoin(PlanDO.class, "a", PlanDO::getId, PlanSubDO::getProjectPlanId)
|
||||||
|
.leftJoin(ProjectOrderSubDO.class, "b", ProjectOrderSubDO::getId, PlanSubDO::getProjectSubId)
|
||||||
|
.leftJoin(EquipDO.class,"c",EquipDO::getId,PlanSubDO::getEquipId)
|
||||||
|
.leftJoin(CompositionDO.class, "d", CompositionDO::getId, ProjectOrderSubDO::getCompositionId)
|
||||||
|
|
||||||
|
.disableSubLogicDel()
|
||||||
|
.orderByAsc(PlanSubDO::getId);
|
||||||
|
// 增加查询条件
|
||||||
|
query.eq(StringUtils.isNotBlank(name), PlanSubDO:: getBlankOwner, name);
|
||||||
|
// 添加日期范围查询条件
|
||||||
|
/*query.between(PlanSubDO::getStartBlankDate, dateOne, dateTwo);
|
||||||
|
query.between(PlanSubDO::getBlankDate, dateOne, dateTwo);*/
|
||||||
|
if (StringUtils.isNotBlank(dateOne) && StringUtils.isNotBlank(dateTwo)) {
|
||||||
|
|
||||||
|
|
||||||
|
query.and(i -> i.between(PlanSubDO::getStartBlankDate, dateOne, dateTwo)
|
||||||
|
.or(a -> a.between(PlanSubDO::getBlankDate, dateOne, dateTwo)));
|
||||||
|
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(id)){
|
||||||
|
query.ne(PlanSubDO::getId,id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!(planId == 0L)){
|
||||||
|
query.ne(PlanSubDO::getProjectPlanId,planId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return selectList(query);
|
||||||
|
}
|
||||||
default List<PlanSubDO> searchOwner(String name,String dateOne,String dateTwo,String id) {
|
default List<PlanSubDO> searchOwner(String name,String dateOne,String dateTwo,String id) {
|
||||||
MPJLambdaWrapper<PlanSubDO> query = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<PlanSubDO> query = new MPJLambdaWrapper<>();
|
||||||
query.selectAll(PlanSubDO.class)
|
query.selectAll(PlanSubDO.class)
|
||||||
|
@ -93,7 +93,8 @@ public interface ShopCalendarMapper extends BaseMapperX<ShopCalendarDO> {
|
|||||||
try {
|
try {
|
||||||
query.selectAll(ShopCalendarDO.class);
|
query.selectAll(ShopCalendarDO.class);
|
||||||
|
|
||||||
query.orderByAsc(ShopCalendarDO::getDates,ShopCalendarDO::getTimes)
|
query.eq(ShopCalendarDO::getIfjiejiari,"false")
|
||||||
|
.orderByAsc(ShopCalendarDO::getDates,ShopCalendarDO::getTimes)
|
||||||
.gt(ShopCalendarDO::getDates,reqVO.getDates())
|
.gt(ShopCalendarDO::getDates,reqVO.getDates())
|
||||||
.last("LIMIT "+reqVO.getTianshu())
|
.last("LIMIT "+reqVO.getTianshu())
|
||||||
;
|
;
|
||||||
|
@ -48,7 +48,7 @@ public interface PlanSubService {
|
|||||||
/*
|
/*
|
||||||
* 根据设计时间和负责人进行插活操作
|
* 根据设计时间和负责人进行插活操作
|
||||||
* */
|
* */
|
||||||
String postOwnderChaHuo (String name,String dateOne, String dateTwo,String id,Long diffDays,int type);
|
List<PlanSubDO> postOwnderChaHuo (List<PlanSubRespVO> tableData);//(Long planId,String name,String dateOne, String dateTwo,String id,Long diffDays,int type,String dateThree);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设计时间和负责人查询是否存在设计冲突
|
* 根据设计时间和负责人查询是否存在设计冲突
|
||||||
|
@ -95,78 +95,157 @@ public class PlanSubServiceImpl implements PlanSubService {
|
|||||||
|
|
||||||
return shopCalendarDOS1;
|
return shopCalendarDOS1;
|
||||||
}
|
}
|
||||||
|
/*List<PlanSubDO> planSubDOSs = new ArrayList<>();
|
||||||
|
LocalDateTime startTime = null;
|
||||||
|
LocalDateTime endTime = null;*/
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String postOwnderChaHuo(String name,String dateOne,String dateTwo,String id,Long diffDays,int type){
|
public List<PlanSubDO> postOwnderChaHuo(List<PlanSubRespVO> tableData){//(Long planId, String name, String dateOne, String dateTwo, String id, Long diffDays, int type, String dateThree) {
|
||||||
//根据传入的负责人设计时间将需要插活的数据查出
|
// 将 planSubDOSs 改为局部变量
|
||||||
List<PlanSubDO> planSubDOS = searchOwner(name,dateOne,dateTwo,id,type);
|
List<PlanSubDO> planSubDOSs = new ArrayList<>();
|
||||||
//查出数据后,根据结束日期查出日历天数
|
// 调用递归方法
|
||||||
ShopCalendarPageReqVO reqVO = new ShopCalendarPageReqVO();
|
return postOwnderChaHuoRecursive(tableData,planSubDOSs,0);//(planId, name, dateOne, dateTwo, id, diffDays, type, dateThree, planSubDOSs);
|
||||||
reqVO.setDates(dateTwo);
|
}
|
||||||
|
public List<PlanSubDO> postOwnderChaHuoRecursive(List<PlanSubRespVO> tableData,List<PlanSubDO> planSubDOSs,int index){//(Long planId, String name, String dateOne, String dateTwo, String id, Long diffDays, int type, String dateThree, List<PlanSubDO> planSubDOSs) {
|
||||||
|
//用来控制递归调用
|
||||||
|
int a = 0;
|
||||||
|
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
//遍历此集合
|
||||||
|
for(PlanSubRespVO planSubRespVO : tableData){
|
||||||
|
String formattedDateTime = null;//planSubRespVO.getStartBlankDate().format(formatter);
|
||||||
|
String endTime = null;//planSubRespVO.getBlankDate().format(formatter);
|
||||||
|
String owner = null;
|
||||||
|
// 将 LocalDateTime 转换为 String
|
||||||
|
if(tableData.get(0).getType() == 1){
|
||||||
|
formattedDateTime = planSubRespVO.getStartBlankDate().format(formatter);
|
||||||
|
endTime = planSubRespVO.getBlankDate().format(formatter);
|
||||||
|
owner = String.valueOf(planSubRespVO.getBlankOwner());
|
||||||
|
|
||||||
//循环需要更改设计时间的数据
|
}else if(tableData.get(0).getType() == 2){
|
||||||
for(PlanSubDO planSubDO : planSubDOS){
|
formattedDateTime = planSubRespVO.getStartTwoDimDate().format(formatter);
|
||||||
if(type == 1){
|
endTime = planSubRespVO.getTwoDimDate().format(formatter);
|
||||||
reqVO.setTianshu(planSubDO.getBlankNum());
|
owner = String.valueOf(planSubRespVO.getTwoDimOwner());
|
||||||
//先根据日期和设计天数查询出需要插入的设计天数信息
|
|
||||||
List<ShopCalendarDO> shopCalendarDOS =shopCalendarMapper.searchRllist(reqVO);
|
|
||||||
//然后更新设计开始时间和设计结束时间
|
|
||||||
planSubDO.setStartBlankDate(shopCalendarDOS.get(0).getDates());
|
|
||||||
int i = shopCalendarDOS.size();
|
|
||||||
planSubDO.setBlankDate(shopCalendarDOS.get(i-1).getDates());
|
|
||||||
planSubMapper.updateById(planSubDO);
|
|
||||||
//转换日期
|
|
||||||
reqVO.setDates(formatLocalDateTime(shopCalendarDOS.get(i-1).getDates()));
|
|
||||||
}else if (type == 2){
|
|
||||||
reqVO.setTianshu(planSubDO.getTwoDimNum());
|
|
||||||
//先根据日期和设计天数查询出需要插入的设计天数信息
|
|
||||||
List<ShopCalendarDO> shopCalendarDOS =shopCalendarMapper.searchRllist(reqVO);
|
|
||||||
//然后更新设计开始时间和设计结束时间
|
|
||||||
planSubDO.setStartTwoDimDate(shopCalendarDOS.get(0).getDates());
|
|
||||||
int i = shopCalendarDOS.size();
|
|
||||||
planSubDO.setTwoDimDate(shopCalendarDOS.get(i-1).getDates());
|
|
||||||
planSubMapper.updateById(planSubDO);
|
|
||||||
//转换日期
|
|
||||||
reqVO.setDates(formatLocalDateTime(shopCalendarDOS.get(i-1).getDates()));
|
|
||||||
}else{
|
}else{
|
||||||
reqVO.setTianshu(planSubDO.getThreeDimNum());
|
formattedDateTime = planSubRespVO.getStartThreeDimDate().format(formatter);
|
||||||
//先根据日期和设计天数查询出需要插入的设计天数信息
|
endTime = planSubRespVO.getThreeDimDate().format(formatter);
|
||||||
List<ShopCalendarDO> shopCalendarDOS =shopCalendarMapper.searchRllist(reqVO);
|
owner = String.valueOf(planSubRespVO.getThreeDimOwner());
|
||||||
//然后更新设计开始时间和设计结束时间
|
|
||||||
planSubDO.setStartThreeDimDate(shopCalendarDOS.get(0).getDates());
|
|
||||||
int i = shopCalendarDOS.size();
|
|
||||||
planSubDO.setThreeDimDate(shopCalendarDOS.get(i-1).getDates());
|
|
||||||
planSubMapper.updateById(planSubDO);
|
|
||||||
//转换日期
|
|
||||||
reqVO.setDates(formatLocalDateTime(shopCalendarDOS.get(i-1).getDates()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(reqVO.getDates());
|
//先根据第一个数组检索出其余项目是否是日期冲突的问题
|
||||||
}
|
|
||||||
//更新原有数据
|
|
||||||
|
|
||||||
PlanSubDO planSubDOs = planSubMapper.searchOne(id);
|
List<PlanSubDO> planSubDOS = searchOwners(planSubRespVO.getProjectPlanId(),owner,formattedDateTime , endTime, String.valueOf(planSubRespVO.getId()), tableData.get(0).getType());
|
||||||
if(type == 1){
|
//先将查出的数据存入集合中
|
||||||
planSubDOs.setStartBlankDate(stringformatLocatDateTime(dateOne));
|
for(PlanSubDO planSubDO : planSubDOS){
|
||||||
planSubDOs.setBlankDate(stringformatLocatDateTime(dateTwo));
|
//存入之前要判断集合中ID是否存在,存在则不添加
|
||||||
planSubDOs.setBlankNum(diffDays);
|
boolean exists = planSubDOSs.stream().anyMatch(p -> p.getId().equals(planSubDO.getId()));
|
||||||
}else if(type == 2){
|
if (!exists) {
|
||||||
planSubDOs.setStartTwoDimDate(stringformatLocatDateTime(dateOne));
|
planSubDOSs.add(planSubDO);
|
||||||
planSubDOs.setTwoDimDate(stringformatLocatDateTime(dateTwo));
|
a = a+1;
|
||||||
planSubDOs.setTwoDimNum(diffDays);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将所有信息查完之后,根据createTime进行排序
|
||||||
|
planSubDOSs.sort(Comparator.comparing(PlanSubDO::getCreateTime));
|
||||||
|
// 输出排序后的结果
|
||||||
|
System.out.println("输出排序后结果");
|
||||||
|
planSubDOSs.forEach(System.out::println);
|
||||||
|
//用来获取日历时间段
|
||||||
|
|
||||||
|
String endTimes = null;//tableData.get(tableData.size()-1).getBlankDate().format(formatter);
|
||||||
|
if(tableData.get(0).getType() == 1){
|
||||||
|
endTimes = tableData.get(tableData.size()-1).getBlankDate().format(formatter);
|
||||||
|
}else if(tableData.get(0).getType() == 2){
|
||||||
|
endTimes = tableData.get(tableData.size()-1).getTwoDimDate().format(formatter);
|
||||||
}else{
|
}else{
|
||||||
planSubDOs.setStartThreeDimDate(stringformatLocatDateTime(dateOne));
|
endTimes = tableData.get(tableData.size()-1).getThreeDimDate().format(formatter);
|
||||||
planSubDOs.setThreeDimDate(stringformatLocatDateTime(dateTwo));
|
|
||||||
planSubDOs.setThreeDimNum(diffDays);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
planSubMapper.updateById(planSubDOs);
|
List<PlanSubRespVO> tableDatas = new ArrayList<>();
|
||||||
|
|
||||||
return null;
|
//排序后根据tableData中最后一条数据的结束时间进行日历的取值并更新
|
||||||
|
//先循环排序后的集合
|
||||||
|
for(int i=index;i<planSubDOSs.size();i++){
|
||||||
|
|
||||||
|
//然后传入查询日历需要用到的参数,并将其查询出来
|
||||||
|
ShopCalendarPageReqVO reqVO = new ShopCalendarPageReqVO();
|
||||||
|
//获取前端传入最后一次变更的结束日期
|
||||||
|
reqVO.setDates(endTimes);
|
||||||
|
|
||||||
|
PlanSubRespVO planSubRespVO = new PlanSubRespVO();
|
||||||
|
//对日期进行更换
|
||||||
|
if(tableData.get(0).getType() == 1){
|
||||||
|
reqVO.setTianshu(planSubDOSs.get(i).getBlankNum());
|
||||||
|
List<ShopCalendarDO> shopCalendarDOS = shopCalendarMapper.searchRllist(reqVO);
|
||||||
|
planSubDOSs.get(i).setStartBlankDate(shopCalendarDOS.get(0).getDates());
|
||||||
|
int b = shopCalendarDOS.size();
|
||||||
|
planSubDOSs.get(i).setBlankDate(shopCalendarDOS.get(b - 1).getDates());
|
||||||
|
//更换完成后变更取值日期
|
||||||
|
endTimes = shopCalendarDOS.get(b - 1).getDates().format(formatter);
|
||||||
|
|
||||||
|
//开始时间
|
||||||
|
planSubRespVO.setStartBlankDate(planSubDOSs.get(i).getStartBlankDate());
|
||||||
|
//结束时间
|
||||||
|
planSubRespVO.setBlankDate(planSubDOSs.get(i).getBlankDate());
|
||||||
|
//负责人
|
||||||
|
planSubRespVO.setBlankOwner(planSubDOSs.get(i).getBlankOwner());
|
||||||
|
|
||||||
|
}else if(tableData.get(0).getType() == 2){
|
||||||
|
reqVO.setTianshu(planSubDOSs.get(i).getTwoDimNum());
|
||||||
|
List<ShopCalendarDO> shopCalendarDOS = shopCalendarMapper.searchRllist(reqVO);
|
||||||
|
planSubDOSs.get(i).setStartTwoDimDate(shopCalendarDOS.get(0).getDates());
|
||||||
|
int b = shopCalendarDOS.size();
|
||||||
|
planSubDOSs.get(i).setTwoDimDate(shopCalendarDOS.get(b - 1).getDates());
|
||||||
|
//更换完成后变更取值日期
|
||||||
|
endTimes = shopCalendarDOS.get(b - 1).getDates().format(formatter);
|
||||||
|
|
||||||
|
//开始时间
|
||||||
|
planSubRespVO.setStartTwoDimDate(planSubDOSs.get(i).getStartTwoDimDate());
|
||||||
|
//结束时间
|
||||||
|
planSubRespVO.setTwoDimDate(planSubDOSs.get(i).getTwoDimDate());
|
||||||
|
//负责人
|
||||||
|
planSubRespVO.setTwoDimOwner(planSubDOSs.get(i).getTwoDimOwner());
|
||||||
|
|
||||||
|
}else{
|
||||||
|
reqVO.setTianshu(planSubDOSs.get(i).getThreeDimNum());
|
||||||
|
List<ShopCalendarDO> shopCalendarDOS = shopCalendarMapper.searchRllist(reqVO);
|
||||||
|
planSubDOSs.get(i).setStartThreeDimDate(shopCalendarDOS.get(0).getDates());
|
||||||
|
int b = shopCalendarDOS.size();
|
||||||
|
planSubDOSs.get(i).setThreeDimDate(shopCalendarDOS.get(b - 1).getDates());
|
||||||
|
//更换完成后变更取值日期
|
||||||
|
endTimes = shopCalendarDOS.get(b - 1).getDates().format(formatter);
|
||||||
|
|
||||||
|
//开始时间
|
||||||
|
planSubRespVO.setStartThreeDimDate(planSubDOSs.get(i).getStartThreeDimDate());
|
||||||
|
//结束时间
|
||||||
|
planSubRespVO.setThreeDimDate(planSubDOSs.get(i).getThreeDimDate());
|
||||||
|
//负责人
|
||||||
|
planSubRespVO.setThreeDimOwner(planSubDOSs.get(i).getThreeDimOwner());
|
||||||
|
|
||||||
|
}
|
||||||
|
//计划ID
|
||||||
|
planSubRespVO.setProjectPlanId(0L);
|
||||||
|
|
||||||
|
//ID
|
||||||
|
planSubRespVO.setId(planSubDOSs.get(i).getId());
|
||||||
|
//
|
||||||
|
planSubRespVO.setType(tableData.get(0).getType());
|
||||||
|
|
||||||
|
tableDatas.add(planSubRespVO);
|
||||||
|
|
||||||
|
}
|
||||||
|
//用来判断是否更新数据的
|
||||||
|
index = planSubDOSs.size();
|
||||||
|
//当全部变更完成后,需要再用变更之后的数据,对每一条在进行一次检索,防止更改之后的数据有冲突。
|
||||||
|
if(a>0){
|
||||||
|
postOwnderChaHuoRecursive(tableDatas,planSubDOSs,index);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
return planSubDOSs; // 返回成功标志或其他需要的结果
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static LocalDateTime stringformatLocatDateTime(String date){
|
public static LocalDateTime stringformatLocatDateTime(String date){
|
||||||
String str = date+" 00:00:00";
|
String str = date+" 00:00:00";
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
@ -181,6 +260,18 @@ public class PlanSubServiceImpl implements PlanSubService {
|
|||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
return localDateTime.format(formatter);
|
return localDateTime.format(formatter);
|
||||||
}
|
}
|
||||||
|
public List<PlanSubDO> searchOwners(Long planId,String name,String dateOne,String dateTwo,String id,int type){
|
||||||
|
List<PlanSubDO> planSubDOS = new ArrayList<>();
|
||||||
|
|
||||||
|
if(type == 1){
|
||||||
|
planSubDOS = planSubMapper.searchOwners(planId,name,dateOne,dateTwo,id);
|
||||||
|
}else if(type == 2){
|
||||||
|
planSubDOS = planSubMapper.searchOwnerTwos(planId,name,dateOne,dateTwo,id);
|
||||||
|
}else{
|
||||||
|
planSubDOS = planSubMapper.searchOwnerThree(name,dateOne,dateTwo,id);
|
||||||
|
}
|
||||||
|
return planSubDOS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlanSubDO> searchOwner(String name,String dateOne,String dateTwo,String id,int type){
|
public List<PlanSubDO> searchOwner(String name,String dateOne,String dateTwo,String id,int type){
|
||||||
|
@ -29,10 +29,21 @@ export const getPlanSub = async (id: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//插活保存
|
//插活保存
|
||||||
export const getOwnderPlanChaHuo = async (ownder: number,dateOne: string ,dateTwo: string,id: number,diffDays: number,type: number) => {
|
export const getOwnderPlanChaHuo = async (data) => {
|
||||||
return await request.post({ url: `/heli/plan-sub/postOwnderChaHuo?names=` + ownder+`&dateOne=`+dateOne+`&dateTwo=`+dateTwo+`&id=`+id+`&diffDays=`+diffDays+`&type=`+type})
|
//return await request.post({ url: `/heli/plan-sub/postOwnderChaHuo`,data})
|
||||||
|
return await request.post({
|
||||||
|
url: `/heli/plan-sub/postOwnderChaHuo`,
|
||||||
|
data, // 请求体数据
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json' // 设置请求头
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* export const getOwnderPlanChaHuo = async (planId: number,ownder: number,dateOne: string ,dateTwo: string,id: number,diffDays: number,type: number,dateThree: string) => {
|
||||||
|
return await request.post({ url: `/heli/plan-sub/postOwnderChaHuo?planId=`+planId+`&names=` + ownder+`&dateOne=`+dateOne+`&dateTwo=`+dateTwo+`&id=`+id+`&diffDays=`+diffDays+`&type=`+type+`&dateThree=`+dateThree})
|
||||||
|
} */
|
||||||
|
|
||||||
//查询当前负责人设计时间是否冲突
|
//查询当前负责人设计时间是否冲突
|
||||||
export const getOwnderPlanSub = async (endDateTime: string,tianShu: number ) => {
|
export const getOwnderPlanSub = async (endDateTime: string,tianShu: number ) => {
|
||||||
return await request.get({ url: `/heli/plan-sub/getSearchRl?endDateTime=` + endDateTime+`&tianShu=`+tianShu})
|
return await request.get({ url: `/heli/plan-sub/getSearchRl?endDateTime=` + endDateTime+`&tianShu=`+tianShu})
|
||||||
|
@ -587,7 +587,10 @@ const reload = inject('reload')
|
|||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
const dialogVisible = ref(false); // 弹窗的是否展示
|
const dialogVisible = ref(false); // 弹窗的是否展示
|
||||||
const dialogTitle = ref('设计时间冲突信息窗'); // 弹窗的标题
|
const dialogTitle = ref('设计时间冲突信息窗'); // 弹窗的标题
|
||||||
|
const fuzerenId = ref();
|
||||||
|
const startTimeOne = ref();
|
||||||
|
const endTimeTwo = ref();
|
||||||
|
const dateThree = ref();
|
||||||
const formRef = ref() // 表单
|
const formRef = ref() // 表单
|
||||||
const subFormRef = ref() //子表单 Ref
|
const subFormRef = ref() //子表单 Ref
|
||||||
|
|
||||||
@ -596,7 +599,9 @@ const prod = ref({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const currentTime = ref('');
|
const currentTime = ref('');
|
||||||
|
const prods = ref({
|
||||||
|
projectPlanSubs: []
|
||||||
|
})
|
||||||
|
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
@ -636,6 +641,7 @@ const dataList = ref({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataListShuju = ref([]);
|
const dataListShuju = ref([]);
|
||||||
|
const dataListShujus = ref([]);
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
projectCode: [{ required: true, message: '项目编号不能为空', trigger: 'blur' }],
|
projectCode: [{ required: true, message: '项目编号不能为空', trigger: 'blur' }],
|
||||||
|
|
||||||
@ -664,11 +670,75 @@ const handleSelectedProjectOrder = (arr: ProjectOrderVO[]) => {
|
|||||||
|
|
||||||
handleInitPlanSub()
|
handleInitPlanSub()
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
const parentMethod = async () => {
|
||||||
const parentMethod = () => {
|
// 检查是否超过要求设计日期
|
||||||
|
const isOverdue = dataList.value.projectOrderSubs.some(sub => {
|
||||||
|
if (sub.changeEndTime) {
|
||||||
|
return sub.blankDate > sub.changeEndTime ||
|
||||||
|
sub.twoDimDate > sub.changeEndTime ||
|
||||||
|
sub.threeDimDate > sub.changeEndTime;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (isOverdue) {
|
||||||
|
message.error("本次插活已经超过要求设计结束日期,无法插活");
|
||||||
|
return; // 如果超过日期,直接返回,不执行后续代码
|
||||||
|
}
|
||||||
|
dialogVisible.value = false;
|
||||||
|
// 更新 formData 中的数据
|
||||||
|
dataList.value.projectOrderSubs.forEach(sub => {
|
||||||
|
const matchingPlanSub = formData.value.projectPlanSubs.find(planSub => planSub.id === sub.id);
|
||||||
|
if (matchingPlanSub) {
|
||||||
|
matchingPlanSub.startBlankDate = sub.startBlankDate;
|
||||||
|
matchingPlanSub.blankDate = sub.blankDate;
|
||||||
|
matchingPlanSub.startTwoDimDate = sub.startTwoDimDate;
|
||||||
|
matchingPlanSub.twoDimDate = sub.twoDimDate;
|
||||||
|
matchingPlanSub.startThreeDimDate = sub.startThreeDimDate;
|
||||||
|
matchingPlanSub.threeDimDate = sub.threeDimDate;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 直接调用提交方法
|
||||||
|
await submitForm();
|
||||||
|
// 清空数据
|
||||||
|
dataListShuju.value = [];
|
||||||
|
};
|
||||||
|
/* const parentMethod = () => {
|
||||||
//先判断是否超过要求设计日期,超过时给出提醒,不允许插活
|
//先判断是否超过要求设计日期,超过时给出提醒,不允许插活
|
||||||
if(formData.value.changeEndTime){
|
for(var a= 0;a<dataList.value.projectOrderSubs.length;a++){
|
||||||
|
if(dataList.value.projectOrderSubs[a].changeEndTime){
|
||||||
|
if(dataList.value.projectOrderSubs[a].blankDate>dataList.value.projectOrderSubs[a].changeEndTime
|
||||||
|
|| dataList.value.projectOrderSubs[a].twoDimDate>dataList.value.projectOrderSubs[a].changeEndTime
|
||||||
|
|| dataList.value.projectOrderSubs[a].threeDimDate>dataList.value.projectOrderSubs[a].changeEndTime)
|
||||||
|
{
|
||||||
|
message.error("本次插活已经超过要求设计结束日期,无法插活");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
for(var a= 0;a<dataList.value.projectOrderSubs.length;a++){
|
||||||
|
for(var b=0;b<formData.value.projectPlanSubs.length;b++){
|
||||||
|
if(dataList.value.projectOrderSubs[a].id == formData.value.projectPlanSubs[b].id){
|
||||||
|
formData.value.projectPlanSubs[b].startBlankDate = dataList.value.projectOrderSubs[a].startBlankDate
|
||||||
|
formData.value.projectPlanSubs[b].blankDate = dataList.value.projectOrderSubs[a].blankDate
|
||||||
|
|
||||||
|
formData.value.projectPlanSubs[b].startTwoDimDate = dataList.value.projectOrderSubs[a].startTwoDimDate
|
||||||
|
formData.value.projectPlanSubs[b].twoDimDate = dataList.value.projectOrderSubs[a].twoDimDate
|
||||||
|
|
||||||
|
formData.value.projectPlanSubs[b].startThreeDimDate= dataList.value.projectOrderSubs[a].startThreeDimDate
|
||||||
|
formData.value.projectPlanSubs[b].threeDimDate =dataList.value.projectOrderSubs[a].threeDimDate
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//直接调用提交方法
|
||||||
|
submitForm()
|
||||||
|
dataListShuju.value = []; */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* if(formData.value.changeEndTime){
|
||||||
if(currentTime.value>formData.value.changeEndTime){
|
if(currentTime.value>formData.value.changeEndTime){
|
||||||
message.error("本次插活已经超过要求设计结束日期,无法插活");
|
message.error("本次插活已经超过要求设计结束日期,无法插活");
|
||||||
}else{
|
}else{
|
||||||
@ -711,36 +781,14 @@ const parentMethod = () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* if(currentTime.value>formData.value.changeEndTime){
|
|
||||||
message.error("本次插活已经超过要求设计结束日期,无法插活");
|
|
||||||
}else{
|
|
||||||
//确定插活后,将日期进行更新,并在根据最后一个日期继续查看后面的时间是否有冲突
|
|
||||||
dialogVisible.value = false
|
|
||||||
console.log(dataList.value.projectOrderSubs);
|
|
||||||
for(var a= 0;a<dataList.value.projectOrderSubs.length;a++){
|
|
||||||
for(var b=0;b<formData.value.projectPlanSubs.length;b++){
|
|
||||||
if(dataList.value.projectOrderSubs[a].id == formData.value.projectPlanSubs[b].id){
|
|
||||||
formData.value.projectPlanSubs[b].startBlankDate = dataList.value.projectOrderSubs[a].startBlankDate
|
|
||||||
formData.value.projectPlanSubs[b].blankDate = dataList.value.projectOrderSubs[a].blankDate
|
|
||||||
|
|
||||||
formData.value.projectPlanSubs[b].startTwoDimDate = dataList.value.projectOrderSubs[a].startTwoDimDate
|
|
||||||
formData.value.projectPlanSubs[b].twoDimDate = dataList.value.projectOrderSubs[a].twoDimDate
|
|
||||||
|
|
||||||
formData.value.projectPlanSubs[b].startThreeDimDate= dataList.value.projectOrderSubs[a].startThreeDimDate
|
|
||||||
formData.value.projectPlanSubs[b].threeDimDate =dataList.value.projectOrderSubs[a].threeDimDate
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
|
||||||
dataListShuju.value = [];
|
|
||||||
///handleInitPlanSub()
|
|
||||||
|
|
||||||
};
|
//};
|
||||||
const clouse = () => {
|
const clouse = () => {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
dataListShuju.value = [];
|
dataListShuju.value = [];
|
||||||
@ -796,6 +844,9 @@ const getSearchRlTs = async(startDateTime:string,endDateTime:string,index:number
|
|||||||
// formatDate(startBlankDate,'YYYY-MM-DD')
|
// formatDate(startBlankDate,'YYYY-MM-DD')
|
||||||
if(ownder){
|
if(ownder){
|
||||||
prod.value.projectPlanSubs = JSON.parse(JSON.stringify(formData.value.projectPlanSubs));
|
prod.value.projectPlanSubs = JSON.parse(JSON.stringify(formData.value.projectPlanSubs));
|
||||||
|
startTimeOne.value = formatDate(startDateTime,'YYYY-MM-DD');
|
||||||
|
endTimeTwo.value = formatDate(endDateTime,'YYYY-MM-DD');
|
||||||
|
fuzerenId.value = ownder;
|
||||||
getOwnderList(index)
|
getOwnderList(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,7 +858,10 @@ const getSearchRlTs = async(startDateTime:string,endDateTime:string,index:number
|
|||||||
formData.value.projectPlanSubs[index].twoDimNum = data;
|
formData.value.projectPlanSubs[index].twoDimNum = data;
|
||||||
|
|
||||||
if(ownder){
|
if(ownder){
|
||||||
prod.value.projectPlanSubs = JSON.parse(JSON.stringify(formData.value.projectPlanSubs));
|
prod.value.projectPlanSubs = JSON.parse(JSON.stringify(formData.value.projectPlanSubs));
|
||||||
|
startTimeOne.value = formatDate(startDateTime,'YYYY-MM-DD');
|
||||||
|
endTimeTwo.value = formatDate(endDateTime,'YYYY-MM-DD');
|
||||||
|
fuzerenId.value = ownder;
|
||||||
getOwnderLists(index)
|
getOwnderLists(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,6 +869,9 @@ const getSearchRlTs = async(startDateTime:string,endDateTime:string,index:number
|
|||||||
formData.value.projectPlanSubs[index].threeDimNum = data;
|
formData.value.projectPlanSubs[index].threeDimNum = data;
|
||||||
if(ownder){
|
if(ownder){
|
||||||
prod.value.projectPlanSubs = JSON.parse(JSON.stringify(formData.value.projectPlanSubs));
|
prod.value.projectPlanSubs = JSON.parse(JSON.stringify(formData.value.projectPlanSubs));
|
||||||
|
startTimeOne.value = formatDate(startDateTime,'YYYY-MM-DD');
|
||||||
|
endTimeTwo.value = formatDate(endDateTime,'YYYY-MM-DD');
|
||||||
|
fuzerenId.value = ownder;
|
||||||
getOwnderListss(index)
|
getOwnderListss(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,7 +881,107 @@ const getSearchRlTs = async(startDateTime:string,endDateTime:string,index:number
|
|||||||
|
|
||||||
//选择3D
|
//选择3D
|
||||||
const getOwnderListss = async (index: number) => {
|
const getOwnderListss = async (index: number) => {
|
||||||
/* const dataListShuju = []; */
|
prod.value.projectPlanSubs[index].projectPlanId = formData.value.id;
|
||||||
|
prod.value.projectPlanSubs[index].type = 3;
|
||||||
|
dataListShujus.value = [];
|
||||||
|
|
||||||
|
const currentRow = prod.value.projectPlanSubs[index];
|
||||||
|
dateThree.value = currentRow.threeDimDate;
|
||||||
|
const blankOwner = currentRow.threeDimOwner;
|
||||||
|
dataListShujus.value.push(prod.value.projectPlanSubs[index]);
|
||||||
|
// 递归处理函数
|
||||||
|
const processRecursive = async (i: number) => {
|
||||||
|
const datas = { ...prod.value.projectPlanSubs[i] };
|
||||||
|
|
||||||
|
if (i!== index && prod.value.projectPlanSubs[i].threeDimOwner === blankOwner) {
|
||||||
|
if (isInRange(currentRow.startThreeDimDate,currentRow.threeDimDate, prod.value.projectPlanSubs[i].startThreeDimDate,prod.value.projectPlanSubs[i].threeDimDate)) {
|
||||||
|
const datalists = await PlanSubApi.getOwnderPlanSub(formatDate(currentRow.threeDimDate, 'YYYY-MM-DD'), prod.value.projectPlanSubs[i].threeDimNum);
|
||||||
|
prod.value.projectPlanSubs[i].startThreeDimDate = datalists[0].dates;
|
||||||
|
prod.value.projectPlanSubs[i].threeDimDate = datalists[1].dates;
|
||||||
|
datas.startThreeDimDate = datalists[0].dates;
|
||||||
|
datas.threeDimDate = datalists[1].dates;
|
||||||
|
datas.changeEndTime = formData.value.changeEndTime;
|
||||||
|
datas.projectPlanId = formData.value.id;
|
||||||
|
datas.type = 2;
|
||||||
|
currentTime.value = datalists[1].dates;
|
||||||
|
dateThree.value = datalists[1].dates;
|
||||||
|
dataListShuju.value.push(datas);
|
||||||
|
dataListShujus.value.push(datas);
|
||||||
|
await processRecursive(i); // 递归调用
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理所有相关行
|
||||||
|
for (let i = 0; i < prod.value.projectPlanSubs.length; i++) {
|
||||||
|
await processRecursive(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去重逻辑
|
||||||
|
for (let a = 0; a < dataListShuju.value.length; a++) {
|
||||||
|
for (let b = a + 1; b < dataListShuju.value.length; b++) {
|
||||||
|
if (dataListShuju.value[a] && dataListShuju.value[a].id && dataListShuju.value[b] && dataListShuju.value[b].id && dataListShuju.value[a].id === dataListShuju.value[b].id) {
|
||||||
|
dataListShuju.value[a].startThreeDimDate = dataListShuju.value[b].startThreeDimDate;
|
||||||
|
dataListShuju.value[a].threeDimDate = dataListShuju.value[b].threeDimDate;
|
||||||
|
dataListShuju.value.splice(b, 1);
|
||||||
|
b--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新数据
|
||||||
|
dataList.value.projectOrderSubs = dataListShuju.value;
|
||||||
|
ownerId.value = blankOwner;
|
||||||
|
dateOne.value = formatDate(currentRow.startThreeDimDate, 'YYYY-MM-DD');
|
||||||
|
dateTwo.value = formatDate(currentRow.threeDimDate, 'YYYY-MM-DD');
|
||||||
|
id.value = currentRow.id;
|
||||||
|
diffDays.value = '1';
|
||||||
|
typeNames.value = '1';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 递归执行完毕后,执行以下代码
|
||||||
|
const datalistss = await PlanSubApi.getOwnderPlanChaHuo(dataListShujus.value)//(formData.value.id, fuzerenId.value, startTimeOne.value, endTimeTwo.value, "", 0, 1, formatDate(dateThree.value, 'YYYY-MM-DD'));
|
||||||
|
prods.value.projectPlanSubs = [];
|
||||||
|
for (let a = 0; a < datalistss.length; a++) {
|
||||||
|
dataListShuju.value.push(datalistss[a]);
|
||||||
|
prods.value.projectPlanSubs.push(datalistss[a]);
|
||||||
|
|
||||||
|
}
|
||||||
|
let lastEndTime = null;
|
||||||
|
for (let a = 0; a < prods.value.projectPlanSubs.length; a++) {
|
||||||
|
const prodItem = { ...prods.value.projectPlanSubs[a]};
|
||||||
|
for (let b = 0; b < prod.value.projectPlanSubs.length; b++) {
|
||||||
|
const existingItem = { ...prod.value.projectPlanSubs[b]};
|
||||||
|
if (existingItem.threeDimOwner === prodItem.threeDimOwner) {
|
||||||
|
if (isInRange(prodItem.startThreeDimDate, prodItem.threeDimDate, existingItem.startThreeDimDate, existingItem.threeDimDate)) {
|
||||||
|
const queryStartTime = lastEndTime || prodItem.threeDimDate;
|
||||||
|
const datalists = await PlanSubApi.getOwnderPlanSub(formatDate(queryStartTime, 'YYYY-MM-DD'), prod.value.projectPlanSubs[b].threeDimNum);
|
||||||
|
prod.value.projectPlanSubs[b].startThreeDimDate = datalists[0].dates;
|
||||||
|
prod.value.projectPlanSubs[b].threeDimDate = datalists[1].dates;
|
||||||
|
existingItem.startThreeDimDate = datalists[0].dates;
|
||||||
|
existingItem.threeDimDate = datalists[1].dates;
|
||||||
|
lastEndTime = datalists[1].dates;
|
||||||
|
existingItem.changeEndTime = formData.value.changeEndTime;
|
||||||
|
existingItem.projectPlanId = formData.value.id;
|
||||||
|
existingItem.type = 2;
|
||||||
|
currentTime.value = datalists[1].dates;
|
||||||
|
dateThree.value = datalists[1].dates;
|
||||||
|
dataListShuju.value.push(existingItem);
|
||||||
|
dataListShujus.value.push(existingItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示对话框
|
||||||
|
if (dataList.value.projectOrderSubs.length > 0) {
|
||||||
|
dialogVisible.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/* const getOwnderListss = async (index: number) => {
|
||||||
|
|
||||||
//根据行索引获取到编辑行
|
//根据行索引获取到编辑行
|
||||||
|
|
||||||
const currentRow = prod.value.projectPlanSubs[index];
|
const currentRow = prod.value.projectPlanSubs[index];
|
||||||
@ -844,11 +1001,7 @@ const getOwnderListss = async (index: number) => {
|
|||||||
currentTime.value = datalists[1].dates;
|
currentTime.value = datalists[1].dates;
|
||||||
//赋值给集合
|
//赋值给集合
|
||||||
dataListShuju.value.push(datas);
|
dataListShuju.value.push(datas);
|
||||||
/* if(dataListShuju.length>0){
|
|
||||||
dataListShuju[dataListShuju.length] = datas
|
|
||||||
}else{
|
|
||||||
dataListShuju[0] = datas
|
|
||||||
} */
|
|
||||||
getOwnderListss(i);
|
getOwnderListss(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -883,12 +1036,115 @@ const getOwnderListss = async (index: number) => {
|
|||||||
|
|
||||||
// 通知子组件数据已经更新
|
// 通知子组件数据已经更新
|
||||||
//emit('update');
|
//emit('update');
|
||||||
}
|
} */
|
||||||
|
|
||||||
//选择2D
|
//选择2D
|
||||||
const getOwnderLists = async (index: number) => {
|
const getOwnderLists = async (index: number) => {
|
||||||
/* const dataListShuju = []; */
|
prod.value.projectPlanSubs[index].projectPlanId = formData.value.id;
|
||||||
//根据行索引获取到编辑行
|
prod.value.projectPlanSubs[index].type = 2;
|
||||||
|
dataListShujus.value = [];
|
||||||
|
|
||||||
|
const currentRow = prod.value.projectPlanSubs[index];
|
||||||
|
dateThree.value = currentRow.twoDimDate;
|
||||||
|
const blankOwner = currentRow.twoDimOwner;
|
||||||
|
dataListShujus.value.push(prod.value.projectPlanSubs[index]);
|
||||||
|
// 递归处理函数
|
||||||
|
const processRecursive = async (i: number) => {
|
||||||
|
const datas = { ...prod.value.projectPlanSubs[i] };
|
||||||
|
|
||||||
|
if (i!== index && prod.value.projectPlanSubs[i].twoDimOwner === blankOwner) {
|
||||||
|
if (isInRange(currentRow.startTwoDimDate,currentRow.twoDimDate, prod.value.projectPlanSubs[i].startTwoDimDate,prod.value.projectPlanSubs[i].twoDimDate)) {
|
||||||
|
const datalists = await PlanSubApi.getOwnderPlanSub(formatDate(currentRow.twoDimDate, 'YYYY-MM-DD'), prod.value.projectPlanSubs[i].twoDimNum);
|
||||||
|
prod.value.projectPlanSubs[i].startTwoDimDate = datalists[0].dates;
|
||||||
|
prod.value.projectPlanSubs[i].twoDimDate = datalists[1].dates;
|
||||||
|
datas.startTwoDimDate = datalists[0].dates;
|
||||||
|
datas.twoDimDate = datalists[1].dates;
|
||||||
|
datas.changeEndTime = formData.value.changeEndTime;
|
||||||
|
datas.projectPlanId = formData.value.id;
|
||||||
|
datas.type = 2;
|
||||||
|
currentTime.value = datalists[1].dates;
|
||||||
|
dateThree.value = datalists[1].dates;
|
||||||
|
dataListShuju.value.push(datas);
|
||||||
|
dataListShujus.value.push(datas);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await processRecursive(i); // 递归调用
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理所有相关行
|
||||||
|
for (let i = 0; i < prod.value.projectPlanSubs.length; i++) {
|
||||||
|
await processRecursive(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去重逻辑
|
||||||
|
for (let a = 0; a < dataListShuju.value.length; a++) {
|
||||||
|
for (let b = a + 1; b < dataListShuju.value.length; b++) {
|
||||||
|
if (dataListShuju.value[a] && dataListShuju.value[a].id && dataListShuju.value[b] && dataListShuju.value[b].id && dataListShuju.value[a].id === dataListShuju.value[b].id) {
|
||||||
|
dataListShuju.value[a].startTwoDimDate = dataListShuju.value[b].startTwoDimDate;
|
||||||
|
dataListShuju.value[a].twoDimDate = dataListShuju.value[b].twoDimDate;
|
||||||
|
dataListShuju.value.splice(b, 1);
|
||||||
|
b--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新数据
|
||||||
|
dataList.value.projectOrderSubs = dataListShuju.value;
|
||||||
|
ownerId.value = blankOwner;
|
||||||
|
dateOne.value = formatDate(currentRow.startTwoDimDate, 'YYYY-MM-DD');
|
||||||
|
dateTwo.value = formatDate(currentRow.twoDimDate, 'YYYY-MM-DD');
|
||||||
|
id.value = currentRow.id;
|
||||||
|
diffDays.value = '1';
|
||||||
|
typeNames.value = '1';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 递归执行完毕后,执行以下代码
|
||||||
|
const datalistss = await PlanSubApi.getOwnderPlanChaHuo(dataListShujus.value)//(formData.value.id, fuzerenId.value, startTimeOne.value, endTimeTwo.value, "", 0, 1, formatDate(dateThree.value, 'YYYY-MM-DD'));
|
||||||
|
prods.value.projectPlanSubs = [];
|
||||||
|
for (let a = 0; a < datalistss.length; a++) {
|
||||||
|
dataListShuju.value.push(datalistss[a]);
|
||||||
|
prods.value.projectPlanSubs.push(datalistss[a]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let lastEndTime = null;
|
||||||
|
for (let a = 0; a < prods.value.projectPlanSubs.length; a++) {
|
||||||
|
const prodItem = { ...prods.value.projectPlanSubs[a]};
|
||||||
|
for (let b = 0; b < prod.value.projectPlanSubs.length; b++) {
|
||||||
|
const existingItem = { ...prod.value.projectPlanSubs[b]};
|
||||||
|
if (existingItem.twoDimOwner === prodItem.twoDimOwner) {
|
||||||
|
if (isInRange(prodItem.startTwoDimDate, prodItem.twoDimDate, existingItem.startTwoDimDate, existingItem.twoDimDate)) {
|
||||||
|
const queryStartTime = lastEndTime || prodItem.twoDimDate;
|
||||||
|
const datalists = await PlanSubApi.getOwnderPlanSub(formatDate(queryStartTime, 'YYYY-MM-DD'), prod.value.projectPlanSubs[b].twoDimNum);
|
||||||
|
prod.value.projectPlanSubs[b].startTwoDimDate = datalists[0].dates;
|
||||||
|
prod.value.projectPlanSubs[b].twoDimDate = datalists[1].dates;
|
||||||
|
existingItem.startTwoDimDate = datalists[0].dates;
|
||||||
|
existingItem.twoDimDate = datalists[1].dates;
|
||||||
|
lastEndTime = datalists[1].dates;
|
||||||
|
existingItem.changeEndTime = formData.value.changeEndTime;
|
||||||
|
existingItem.projectPlanId = formData.value.id;
|
||||||
|
existingItem.type = 2;
|
||||||
|
currentTime.value = datalists[1].dates;
|
||||||
|
dateThree.value = datalists[1].dates;
|
||||||
|
dataListShuju.value.push(existingItem);
|
||||||
|
dataListShujus.value.push(existingItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示对话框
|
||||||
|
if (dataList.value.projectOrderSubs.length > 0) {
|
||||||
|
dialogVisible.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/* const getOwnderLists = async (index: number) => {
|
||||||
|
|
||||||
|
|
||||||
const currentRow = prod.value.projectPlanSubs[index];
|
const currentRow = prod.value.projectPlanSubs[index];
|
||||||
//获取到负责人ID
|
//获取到负责人ID
|
||||||
@ -906,11 +1162,6 @@ const getOwnderLists = async (index: number) => {
|
|||||||
currentTime.value = datalists[1].dates;
|
currentTime.value = datalists[1].dates;
|
||||||
//赋值给集合
|
//赋值给集合
|
||||||
dataListShuju.value.push(datas);
|
dataListShuju.value.push(datas);
|
||||||
/* if(dataListShuju.length>0){
|
|
||||||
dataListShuju[dataListShuju.length] = datas
|
|
||||||
}else{
|
|
||||||
dataListShuju[0] = datas
|
|
||||||
} */
|
|
||||||
getOwnderLists(i);
|
getOwnderLists(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -940,20 +1191,123 @@ const getOwnderLists = async (index: number) => {
|
|||||||
if(dataList.value.projectOrderSubs.length>0){
|
if(dataList.value.projectOrderSubs.length>0){
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
}
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 通知子组件数据已经更新
|
// 选择毛坯 ,ownder: number,newdateOne: number,newdateTwo: number,newid:number
|
||||||
//emit('update');
|
const getOwnderList = async (index: number) => {
|
||||||
}
|
prod.value.projectPlanSubs[index].projectPlanId = formData.value.id;
|
||||||
|
prod.value.projectPlanSubs[index].type = 1;
|
||||||
|
dataListShujus.value = [];
|
||||||
|
|
||||||
|
const currentRow = prod.value.projectPlanSubs[index];
|
||||||
|
dateThree.value = currentRow.blankDate;
|
||||||
|
const blankOwner = currentRow.blankOwner;
|
||||||
|
dataListShujus.value.push(prod.value.projectPlanSubs[index]);
|
||||||
|
// 递归处理函数
|
||||||
|
const processRecursive = async (i: number) => {
|
||||||
|
const datas = { ...prod.value.projectPlanSubs[i] };
|
||||||
|
|
||||||
|
if (i !== index && prod.value.projectPlanSubs[i].blankOwner === blankOwner) {
|
||||||
|
|
||||||
|
if (isInRange(currentRow.startBlankDate, currentRow.blankDate, prod.value.projectPlanSubs[i].startBlankDate, prod.value.projectPlanSubs[i].blankDate)) {
|
||||||
|
const datalists = await PlanSubApi.getOwnderPlanSub(formatDate(currentRow.blankDate, 'YYYY-MM-DD'), prod.value.projectPlanSubs[i].blankNum);
|
||||||
|
prod.value.projectPlanSubs[i].startBlankDate = datalists[0].dates;
|
||||||
|
prod.value.projectPlanSubs[i].blankDate = datalists[1].dates;
|
||||||
|
datas.startBlankDate = datalists[0].dates;
|
||||||
|
datas.blankDate = datalists[1].dates;
|
||||||
|
datas.changeEndTime = formData.value.changeEndTime;
|
||||||
|
datas.projectPlanId = formData.value.id
|
||||||
|
currentTime.value = datalists[1].dates;
|
||||||
|
dateThree.value = datalists[1].dates;
|
||||||
|
datas.type = 1;
|
||||||
|
dataListShuju.value.push(datas);
|
||||||
|
dataListShujus.value.push(datas);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await processRecursive(i); // 递归调用
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理所有相关行
|
||||||
|
for (let i = 0; i < prod.value.projectPlanSubs.length; i++) {
|
||||||
|
await processRecursive(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去重逻辑
|
||||||
|
for (let a = 0; a < dataListShuju.value.length; a++) {
|
||||||
|
for (let b = a + 1; b < dataListShuju.value.length; b++) {
|
||||||
|
if (dataListShuju.value[a] && dataListShuju.value[a].id && dataListShuju.value[b] && dataListShuju.value[b].id && dataListShuju.value[a].id === dataListShuju.value[b].id) {
|
||||||
|
dataListShuju.value[a].startBlankDate = dataListShuju.value[b].startBlankDate;
|
||||||
|
dataListShuju.value[a].blankDate = dataListShuju.value[b].blankDate;
|
||||||
|
dataListShuju.value.splice(b, 1);
|
||||||
|
b--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新数据
|
||||||
|
dataList.value.projectOrderSubs = dataListShuju.value;
|
||||||
|
ownerId.value = blankOwner;
|
||||||
|
dateOne.value = formatDate(currentRow.startBlankDate, 'YYYY-MM-DD');
|
||||||
|
dateTwo.value = formatDate(currentRow.blankDate, 'YYYY-MM-DD');
|
||||||
|
id.value = currentRow.id;
|
||||||
|
diffDays.value = '1';
|
||||||
|
typeNames.value = '1';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 递归执行完毕后,执行以下代码
|
||||||
|
const datalistss = await PlanSubApi.getOwnderPlanChaHuo(dataListShujus.value)//(formData.value.id, fuzerenId.value, startTimeOne.value, endTimeTwo.value, "", 0, 1, formatDate(dateThree.value, 'YYYY-MM-DD'));
|
||||||
|
prods.value.projectPlanSubs = [];
|
||||||
|
for (let a = 0; a < datalistss.length; a++) {
|
||||||
|
dataListShuju.value.push(datalistss[a]);
|
||||||
|
prods.value.projectPlanSubs.push(datalistss[a]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let lastEndTime = null;
|
||||||
|
for (let a = 0; a < prods.value.projectPlanSubs.length; a++) {
|
||||||
|
const prodItem = { ...prods.value.projectPlanSubs[a]};
|
||||||
|
for (let b = 0; b < prod.value.projectPlanSubs.length; b++) {
|
||||||
|
const existingItem = { ...prod.value.projectPlanSubs[b]};
|
||||||
|
if (existingItem.blankOwner === prodItem.blankOwner) {
|
||||||
|
if (isInRange(prodItem.startBlankDate, prodItem.blankDate, existingItem.startBlankDate, existingItem.blankDate)) {
|
||||||
|
const queryStartTime = lastEndTime || prodItem.blankDate;
|
||||||
|
const datalists = await PlanSubApi.getOwnderPlanSub(formatDate(queryStartTime, 'YYYY-MM-DD'), prod.value.projectPlanSubs[b].blankNum);
|
||||||
|
prod.value.projectPlanSubs[b].startBlankDate = datalists[0].dates;
|
||||||
|
prod.value.projectPlanSubs[b].blankDate = datalists[1].dates;
|
||||||
|
existingItem.startBlankDate = datalists[0].dates;
|
||||||
|
existingItem.blankDate = datalists[1].dates;
|
||||||
|
lastEndTime = datalists[1].dates;
|
||||||
|
existingItem.changeEndTime = formData.value.changeEndTime;
|
||||||
|
existingItem.projectPlanId = formData.value.id;
|
||||||
|
existingItem.type = 2;
|
||||||
|
currentTime.value = datalists[1].dates;
|
||||||
|
dateThree.value = datalists[1].dates;
|
||||||
|
dataListShuju.value.push(existingItem);
|
||||||
|
dataListShujus.value.push(existingItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示对话框
|
||||||
|
if (dataList.value.projectOrderSubs.length > 0) {
|
||||||
|
dialogVisible.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//选择毛坯 ,ownder: number,newdateOne: number,newdateTwo: number,newid:number
|
//选择毛坯 ,ownder: number,newdateOne: number,newdateTwo: number,newid:number
|
||||||
const getOwnderList = async (index: number) => {
|
/* const getOwnderList = async (index: number) => {
|
||||||
/* const dataListShuju = []; */
|
|
||||||
//根据行索引获取到编辑行
|
//根据行索引获取到编辑行
|
||||||
const currentRow = prod.value.projectPlanSubs[index];
|
const currentRow = prod.value.projectPlanSubs[index];
|
||||||
|
dateThree.value = prod.value.projectPlanSubs[index].blankDate;
|
||||||
//获取到负责人ID
|
//获取到负责人ID
|
||||||
const blankOwner = currentRow.blankOwner;
|
const blankOwner = currentRow.blankOwner;
|
||||||
for (let i = 0; i < prod.value.projectPlanSubs.length; i++) {
|
for (let i = 0; i < prod.value.projectPlanSubs.length; i++) {
|
||||||
@ -969,12 +1323,15 @@ const getOwnderList = async (index: number) => {
|
|||||||
datas.blankDate = datalists[1].dates;
|
datas.blankDate = datalists[1].dates;
|
||||||
datas.changeEndTime = formData.value.changeEndTime;
|
datas.changeEndTime = formData.value.changeEndTime;
|
||||||
currentTime.value = datalists[1].dates;
|
currentTime.value = datalists[1].dates;
|
||||||
|
dateThree.value = datalists[1].dates;
|
||||||
//赋值给集合
|
//赋值给集合
|
||||||
dataListShuju.value.push(datas);
|
dataListShuju.value.push(datas);
|
||||||
getOwnderList(i);
|
getOwnderList(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(let a=0;a<dataListShuju.value.length;a++){
|
for(let a=0;a<dataListShuju.value.length;a++){
|
||||||
|
|
||||||
for(let b=a+1;b<dataListShuju.value.length;b++){
|
for(let b=a+1;b<dataListShuju.value.length;b++){
|
||||||
@ -988,6 +1345,13 @@ const getOwnderList = async (index: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//完成后检查其他项目是否存在日期冲突
|
||||||
|
console.log('调用了');
|
||||||
|
const datalistss = await PlanSubApi.getOwnderPlanChaHuo(formData.value.id,fuzerenId.value,startTimeOne.value,endTimeTwo.value,"",0,1,formatDate(dateThree.value,'YYYY-MM-DD'))
|
||||||
|
for(var a=0;a<datalistss.length;a++){
|
||||||
|
dataListShuju.value.push(datalistss[a]);
|
||||||
|
}
|
||||||
|
|
||||||
dataList.value.projectOrderSubs = dataListShuju.value
|
dataList.value.projectOrderSubs = dataListShuju.value
|
||||||
ownerId.value = blankOwner
|
ownerId.value = blankOwner
|
||||||
dateOne.value = formatDate(currentRow.startBlankDate,'YYYY-MM-DD')
|
dateOne.value = formatDate(currentRow.startBlankDate,'YYYY-MM-DD')
|
||||||
@ -995,6 +1359,9 @@ const getOwnderList = async (index: number) => {
|
|||||||
id.value = currentRow.id
|
id.value = currentRow.id
|
||||||
diffDays.value = '1'
|
diffDays.value = '1'
|
||||||
typeNames.value = '1'
|
typeNames.value = '1'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(dataList.value.projectOrderSubs.length>0){
|
if(dataList.value.projectOrderSubs.length>0){
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
@ -1003,7 +1370,7 @@ const getOwnderList = async (index: number) => {
|
|||||||
|
|
||||||
// 通知子组件数据已经更新
|
// 通知子组件数据已经更新
|
||||||
//emit('update');
|
//emit('update');
|
||||||
}
|
} */
|
||||||
|
|
||||||
const isInRange = (start, end, target1, target2) => {
|
const isInRange = (start, end, target1, target2) => {
|
||||||
const startDate = new Date(start);
|
const startDate = new Date(start);
|
||||||
@ -1073,6 +1440,18 @@ const submitForm = async () => {
|
|||||||
}
|
}
|
||||||
//subData.id = subData.projectSubId
|
//subData.id = subData.projectSubId
|
||||||
})
|
})
|
||||||
|
//更新其余项目
|
||||||
|
prods.value.projectPlanSubs.forEach(item => {
|
||||||
|
var subData = item as unknown as PlanSubApid.PlanSubVo
|
||||||
|
if (subData.id == undefined) {
|
||||||
|
subData.id = 0
|
||||||
|
subData.id = PlanSubApi.createPlanSub(subData)
|
||||||
|
} else {
|
||||||
|
//subData.id = item.planSubId
|
||||||
|
PlanSubApi.updatePlanSub(subData)
|
||||||
|
}
|
||||||
|
//subData.id = subData.projectSubId
|
||||||
|
})
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
// 发送操作成功的事件
|
// 发送操作成功的事件
|
||||||
// emit('success')
|
// emit('success')
|
||||||
|
@ -142,7 +142,7 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
<div class="text-center hl-footer">
|
<div class="text-center hl-footer">
|
||||||
<el-button @click="clouse" size="large">取 消</el-button><!-- @click="() => router.back()" -->
|
<el-button @click="clouse" size="large">取 消</el-button><!-- @click="() => router.back()" -->
|
||||||
<el-button @click="submitForm" type="success" size="large">保 存</el-button><!-- @click="submitForm" -->
|
<el-button @click="submitForm" type="success" size="large">确认插活</el-button><!-- @click="submitForm" -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
|
Loading…
Reference in New Issue
Block a user