|
@@ -1,20 +1,25 @@
|
|
|
package com.ruoyi.zdsz.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.baomidou.mybatisplus.annotation.Version;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.ruoyi.common.annotation.DynamicName;
|
|
|
+import com.ruoyi.common.helper.LoginHelper;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.core.domain.PageQuery;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.ruoyi.zdsz.domain.ZEngineeringInfo;
|
|
|
+import com.ruoyi.framework.handler.MonthTableNameHandler;
|
|
|
+import com.ruoyi.zdsz.domain.ZEngineeringReview;
|
|
|
import com.ruoyi.zdsz.domain.bo.ZEngineeringInfoBo;
|
|
|
+import com.ruoyi.zdsz.domain.bo.ZEngineeringReviewBo;
|
|
|
import com.ruoyi.zdsz.service.IZEngineeringInfoService;
|
|
|
+import com.ruoyi.zdsz.service.IZEngineeringMaterialService;
|
|
|
+import com.ruoyi.zdsz.service.IZEngineeringReviewService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.zdsz.domain.bo.ZEngineeringNodeBo;
|
|
|
import com.ruoyi.zdsz.domain.vo.ZEngineeringNodeVo;
|
|
@@ -24,8 +29,14 @@ import com.ruoyi.zdsz.service.IZEngineeringNodeService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static cn.hutool.core.date.DateUtil.format;
|
|
|
+
|
|
|
/**
|
|
|
* 工程节点Service业务层处理
|
|
|
*
|
|
@@ -34,11 +45,17 @@ import java.util.*;
|
|
|
*/
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
+
|
|
|
public class ZEngineeringNodeServiceImpl implements IZEngineeringNodeService {
|
|
|
|
|
|
private final ZEngineeringNodeMapper baseMapper;
|
|
|
@Resource
|
|
|
private IZEngineeringInfoService izEngineeringInfoService;
|
|
|
+ @Resource
|
|
|
+ private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
+ @Resource
|
|
|
+ private IZEngineeringReviewService izEngineeringReviewService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询工程节点
|
|
|
*/
|
|
@@ -50,10 +67,21 @@ public class ZEngineeringNodeServiceImpl implements IZEngineeringNodeService {
|
|
|
@Override
|
|
|
@DynamicName(spel = "#bo.createTime")
|
|
|
public ZEngineeringNodeBo query(ZEngineeringNodeBo bo) {
|
|
|
- ZEngineeringNode zEngineeringNodeVo=baseMapper.selectById(bo.getId());
|
|
|
- ZEngineeringNodeBo zEngineeringNodeBo= BeanUtil.toBean(zEngineeringNodeVo, ZEngineeringNodeBo.class);
|
|
|
- ZEngineeringInfoBo zEngineeringInfoBo= izEngineeringInfoService.query(zEngineeringNodeBo);
|
|
|
- zEngineeringNodeBo.setzEngineeringInfoBo(zEngineeringInfoBo);
|
|
|
+ LambdaQueryWrapper<ZEngineeringNode> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getCivliId()), ZEngineeringNode::getCivliId, bo.getCivliId());
|
|
|
+// lqw.eq(StringUtils.isNotBlank(bo.getType()), ZEngineeringNode::getType, bo.getType());
|
|
|
+ lqw.eq(ZEngineeringNode::getCreateBy, LoginHelper.getLoginUser().getUsername());
|
|
|
+ ZEngineeringNode zEngineeringNode=baseMapper.selectOne(lqw);
|
|
|
+// ZEngineeringNode zEngineeringNodeVo=baseMapper.selectById(bo.getId());
|
|
|
+
|
|
|
+ if (zEngineeringNode==null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ ZEngineeringNodeBo zEngineeringNodeBo= BeanUtil.toBean(zEngineeringNode, ZEngineeringNodeBo.class);
|
|
|
+ ZEngineeringInfoBo zEngineeringInfoBo= izEngineeringInfoService.query(zEngineeringNodeBo);
|
|
|
+ zEngineeringNodeBo.setzEngineeringInfoBo(zEngineeringInfoBo);
|
|
|
+ ZEngineeringReview(zEngineeringNodeBo);
|
|
|
return zEngineeringNodeBo;
|
|
|
}
|
|
|
|
|
@@ -72,6 +100,7 @@ public class ZEngineeringNodeServiceImpl implements IZEngineeringNodeService {
|
|
|
return zEngineeringNodeBoList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 查询工程节点列表
|
|
|
*/
|
|
@@ -86,6 +115,7 @@ public class ZEngineeringNodeServiceImpl implements IZEngineeringNodeService {
|
|
|
* 查询工程节点列表
|
|
|
*/
|
|
|
@Override
|
|
|
+// @DynamicName(spel = "#bo.createTime")
|
|
|
public List<ZEngineeringNodeVo> queryList(ZEngineeringNodeBo bo) {
|
|
|
LambdaQueryWrapper<ZEngineeringNode> lqw = buildQueryWrapper(bo);
|
|
|
return baseMapper.selectVoList(lqw);
|
|
@@ -98,12 +128,67 @@ public class ZEngineeringNodeServiceImpl implements IZEngineeringNodeService {
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getType()), ZEngineeringNode::getType, bo.getType());
|
|
|
return lqw;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public String ZEngineeringReview(ZEngineeringNodeBo bo) {
|
|
|
+ String userId=LoginHelper.getLoginUser().getUserId().toString();
|
|
|
+ SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date(System.currentTimeMillis());
|
|
|
+ formatter.format(date);
|
|
|
+ List<String>dateList= getMonthBetweenDates("2023-12","2024-01");
|
|
|
+ dateList.stream().forEach(item->{
|
|
|
+ Runnable runnable=new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run( ) {
|
|
|
+ try {
|
|
|
+ getZEngineeringNodeList(item,userId);
|
|
|
+ Thread.sleep(30000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ threadPoolTaskExecutor.execute(runnable);
|
|
|
+ });
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ public List getZEngineeringNodeList(String date,String UserId)
|
|
|
+ {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
|
|
|
+ List<ZEngineeringNodeVo> list= new ArrayList<>();
|
|
|
+ try {
|
|
|
+ Date startdate = format.parse(date);
|
|
|
+ ZEngineeringNodeBo zEngineeringNodeBo=new ZEngineeringNodeBo();
|
|
|
+ zEngineeringNodeBo.setCreateTime(startdate);
|
|
|
+ SimpleDateFormat format2 = new SimpleDateFormat("yyyy_MM");
|
|
|
+ MonthTableNameHandler.setData(format2.format(startdate));
|
|
|
+ list =queryList(zEngineeringNodeBo);
|
|
|
+ List zEngineeringReviewList=new ArrayList<>();
|
|
|
+ list.stream().forEach(item->{
|
|
|
+ ZEngineeringReviewBo zEngineeringReview =new ZEngineeringReviewBo();
|
|
|
+ zEngineeringReview.setReviewTime( new Date());
|
|
|
+ zEngineeringReview.setReviewContent("批量审核");
|
|
|
+ zEngineeringReview.setReviewStatus("1");
|
|
|
+ zEngineeringReview.setReviewUser(UserId);
|
|
|
+ zEngineeringReview.setEngInfoId(item.getId());
|
|
|
+ zEngineeringReviewList.add(zEngineeringReview);
|
|
|
+
|
|
|
+ });
|
|
|
+ izEngineeringReviewService.insertBacth(zEngineeringReviewList);
|
|
|
+ MonthTableNameHandler.removeData();
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 新增工程节点
|
|
|
*/
|
|
|
@Override
|
|
|
-
|
|
|
public Boolean insertByBo(ZEngineeringNodeBo bo) {
|
|
|
ZEngineeringNode add = BeanUtil.toBean(bo, ZEngineeringNode.class);
|
|
|
validEntityBeforeSave(add);
|
|
@@ -133,6 +218,9 @@ public class ZEngineeringNodeServiceImpl implements IZEngineeringNodeService {
|
|
|
izEngineeringInfoService.insert(bo.getzEngineeringInfoBo());
|
|
|
return add;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 修改工程节点
|
|
|
*/
|
|
@@ -182,4 +270,36 @@ public class ZEngineeringNodeServiceImpl implements IZEngineeringNodeService {
|
|
|
}
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取某个时间段内所有月份
|
|
|
+ * @param minDate
|
|
|
+ * @param maxDate
|
|
|
+ * @return
|
|
|
+ * @throws ParseException
|
|
|
+ */
|
|
|
+ public List<String> getMonthBetweenDates(String minDate, String maxDate){
|
|
|
+ ArrayList<String> result = new ArrayList<String>();
|
|
|
+ Calendar min = Calendar.getInstance();
|
|
|
+ Calendar max = Calendar.getInstance();
|
|
|
+ min.setTime(parse(minDate,"yyyy-MM"));
|
|
|
+ min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
|
|
|
+ max.setTime(parse(maxDate,"yyyy-MM"));
|
|
|
+ max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
|
|
|
+ Calendar curr = min;
|
|
|
+ while (curr.before(max)) {
|
|
|
+ result.add(format(curr.getTime(),"yyyy-MM"));
|
|
|
+ curr.add(Calendar.MONTH, 1);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ public Date parse(String date, String pattern) {
|
|
|
+ try {
|
|
|
+ return new SimpleDateFormat(pattern).parse(date);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|