|
|
@@ -1,20 +1,25 @@
|
|
|
package com.linkwechat.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.linkwechat.common.core.domain.AjaxResult;
|
|
|
import com.linkwechat.common.exception.wecom.WeComException;
|
|
|
import com.linkwechat.common.utils.bean.BeanUtils;
|
|
|
import com.linkwechat.domain.sop.WeSopBase;
|
|
|
+import com.linkwechat.domain.sop.WeSopBaseTime;
|
|
|
import com.linkwechat.domain.sop.vo.WeSopAddQueryVo;
|
|
|
import com.linkwechat.domain.sop.vo.WeSopListsVo;
|
|
|
import com.linkwechat.domain.sop.vo.WeSopQueryListVo;
|
|
|
import com.linkwechat.mapper.WeSopBaseMapper;
|
|
|
import com.linkwechat.service.IWeSopBaseService;
|
|
|
+import com.linkwechat.service.IWeSopBaseTimeService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -27,12 +32,23 @@ public class IWeSopBaseServiceImpl extends ServiceImpl<WeSopBaseMapper, WeSopBas
|
|
|
@Resource
|
|
|
private IWeSopBaseService weSopBaseService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IWeSopBaseTimeService weSopBaseTimeService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public WeSopBase addSop(WeSopAddQueryVo weSopAddQueryVo) {
|
|
|
WeSopBase weSopBase = new WeSopBase();
|
|
|
BeanUtil.copyProperties(weSopAddQueryVo,weSopBase);
|
|
|
this.save(weSopBase);
|
|
|
+ if (weSopAddQueryVo.getTimeType() == 2) {
|
|
|
+ for (String time : weSopAddQueryVo.getAbsoluteTime()) {
|
|
|
+ WeSopBaseTime weSopBaseTime = new WeSopBaseTime();
|
|
|
+ weSopBaseTime.setSopId(weSopBase.getId());
|
|
|
+ weSopBaseTime.setAbsoluteTime(time);
|
|
|
+ weSopBaseTimeService.save(weSopBaseTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
return weSopBase;
|
|
|
}
|
|
|
|
|
|
@@ -45,6 +61,15 @@ public class IWeSopBaseServiceImpl extends ServiceImpl<WeSopBaseMapper, WeSopBas
|
|
|
}
|
|
|
BeanUtils.copyProperties(weSopAddQueryVo,weSopBase);
|
|
|
this.updateById(weSopBase);
|
|
|
+ if (weSopAddQueryVo.getTimeType() == 2) {
|
|
|
+ weSopBaseTimeService.remove(new LambdaQueryWrapper<WeSopBaseTime>().eq(WeSopBaseTime::getSopId,weSopBase.getId()));
|
|
|
+ for (String time : weSopAddQueryVo.getAbsoluteTime()) {
|
|
|
+ WeSopBaseTime weSopBaseTime = new WeSopBaseTime();
|
|
|
+ weSopBaseTime.setSopId(weSopBase.getId());
|
|
|
+ weSopBaseTime.setAbsoluteTime(time);
|
|
|
+ weSopBaseTimeService.save(weSopBaseTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
return weSopBase;
|
|
|
}
|
|
|
|
|
|
@@ -56,6 +81,7 @@ public class IWeSopBaseServiceImpl extends ServiceImpl<WeSopBaseMapper, WeSopBas
|
|
|
}
|
|
|
weSopBase.setDelFlag(1);
|
|
|
this.removeById(weSopBase);
|
|
|
+ weSopBaseTimeService.remove(new LambdaQueryWrapper<WeSopBaseTime>().eq(WeSopBaseTime::getSopId,id));
|
|
|
return AjaxResult.success("删除成功");
|
|
|
}
|
|
|
|
|
|
@@ -70,6 +96,17 @@ public class IWeSopBaseServiceImpl extends ServiceImpl<WeSopBaseMapper, WeSopBas
|
|
|
return AjaxResult.success(weSopBase.getSopStatus() == 1 ? "启用成功" : "禁用成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AjaxResult getSop(String id) {
|
|
|
+ WeSopBase weSopBase = weSopBaseService.getById(id);
|
|
|
+ if (weSopBase == null) {
|
|
|
+ throw new WeComException("SOP不存在");
|
|
|
+ }
|
|
|
+ List<WeSopBaseTime> weSopBaseTimes = weSopBaseTimeService.list(new LambdaQueryWrapper<WeSopBaseTime>().eq(WeSopBaseTime::getSopId,id));
|
|
|
+ weSopBase.setAbsoluteTimeList(weSopBaseTimes);
|
|
|
+ return AjaxResult.success(weSopBase);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public WeSopBase copySop(String id) {
|
|
|
WeSopBase weSopBase = weSopBaseService.getById(id);
|
|
|
@@ -81,6 +118,13 @@ public class IWeSopBaseServiceImpl extends ServiceImpl<WeSopBaseMapper, WeSopBas
|
|
|
weSopBaseCopy.setId(null);
|
|
|
weSopBaseCopy.setSopStatus(2);
|
|
|
weSopBaseService.save(weSopBaseCopy);
|
|
|
+ List<WeSopBaseTime> weSopBaseTimes = weSopBaseTimeService.list(new LambdaQueryWrapper<WeSopBaseTime>().eq(WeSopBaseTime::getSopId,id));
|
|
|
+ for (WeSopBaseTime weSopBaseTime : weSopBaseTimes) {
|
|
|
+ weSopBaseTime.setId(null);
|
|
|
+ weSopBaseTime.setSopId(weSopBaseCopy.getId());
|
|
|
+ weSopBaseTime.setAbsoluteTime(weSopBaseTime.getAbsoluteTime());
|
|
|
+ weSopBaseTimeService.save(weSopBaseTime);
|
|
|
+ }
|
|
|
return weSopBaseCopy;
|
|
|
}
|
|
|
|