|
@@ -2,7 +2,7 @@ package org.jeecg.modules.prowork.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
-import io.swagger.annotations.ApiModel;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.common.dto.prowork.ProWorkLogicAddReqDTO;
|
|
|
import org.jeecg.common.dto.prowork.ProWorkLogicContentAddReqDTO;
|
|
|
import org.jeecg.common.dto.prowork.ProWorkLogicContentListRespDTO;
|
|
@@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -44,28 +43,41 @@ public class ProWorkLogicServiceImpl extends ServiceImpl<ProWorkLogicMapper, Pro
|
|
|
*/
|
|
|
@Override
|
|
|
public void add(ProWorkLogicAddReqDTO reqDTO) throws Exception {
|
|
|
- if(CollectionUtils.isEmpty(reqDTO.getDetailList())){
|
|
|
+ if(CollectionUtils.isEmpty(reqDTO.getDetailList())) {
|
|
|
throw new JeecgBootException("子表不能为空");
|
|
|
}
|
|
|
ProWorkLogic proWorkLogic = new ProWorkLogic(reqDTO);
|
|
|
|
|
|
CallResult<String> nextSerial = sysSerialPatternService.getNextSerial(proWorkLogic, "pro_work_logic", "billcode", true);
|
|
|
- if(!nextSerial.isSucceed()){
|
|
|
+ if(!nextSerial.isSucceed()) {
|
|
|
throw new RuntimeException("获取编号失败");
|
|
|
}
|
|
|
proWorkLogic.setBillcode(nextSerial.getContent());
|
|
|
save(proWorkLogic);
|
|
|
|
|
|
int sort = 1;
|
|
|
- for(ProWorkLogicContentAddReqDTO detail : reqDTO.getDetailList()){
|
|
|
+ for(ProWorkLogicContentAddReqDTO detail : reqDTO.getDetailList()) {
|
|
|
detail.setLogicId(proWorkLogic.getId());
|
|
|
- ProWorkLogicContent proWorkLogicContent = new ProWorkLogicContent(detail);
|
|
|
+ ProWorkLogicContent proWorkLogicContent = new ProWorkLogicContent(detail);
|
|
|
proWorkLogicContent.setSort(sort++);
|
|
|
proWorkLogicContentService.save(proWorkLogicContent);
|
|
|
|
|
|
|
|
|
- projectManageBusinessOtherService.updateById(new ProjectManageBusinessOther(proWorkLogicContent.getProPlanId(),
|
|
|
- proWorkLogicContent.getId(), proWorkLogicContent.getDuration().toString()));
|
|
|
+ QueryWrapper<ProjectManageBusinessOther> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("del_flag", "0");
|
|
|
+ queryWrapper.eq("id", proWorkLogicContent.getProPlanId());
|
|
|
+ ProjectManageBusinessOther other = projectManageBusinessOtherService.getById(proWorkLogicContent.getProPlanId());
|
|
|
+ if(other != null) {
|
|
|
+ String otherRealTime = other.getRealTime();
|
|
|
+ double orgRealTime = 0;
|
|
|
+ if(StringUtils.isNotBlank(otherRealTime)) {
|
|
|
+ orgRealTime = Double.parseDouble(otherRealTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ Double realTime = proWorkLogicContent.getDuration() / 8 + orgRealTime;
|
|
|
+ projectManageBusinessOtherService.updateById(new ProjectManageBusinessOther(proWorkLogicContent.getProPlanId(),
|
|
|
+ proWorkLogicContent.getId(), realTime.toString()));
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -77,18 +89,35 @@ public class ProWorkLogicServiceImpl extends ServiceImpl<ProWorkLogicMapper, Pro
|
|
|
public boolean edit(ProWorkLogicAddReqDTO reqDTO) {
|
|
|
ProWorkLogic proWorkLogic = new ProWorkLogic(reqDTO);
|
|
|
updateById(proWorkLogic);
|
|
|
+
|
|
|
+ dropOrgRealTime(reqDTO.getId());
|
|
|
+
|
|
|
|
|
|
deletChildren(reqDTO.getId());
|
|
|
|
|
|
int sort = 1;
|
|
|
- for(ProWorkLogicContentAddReqDTO detail : reqDTO.getDetailList()){
|
|
|
+ for(ProWorkLogicContentAddReqDTO detail : reqDTO.getDetailList()) {
|
|
|
detail.setLogicId(proWorkLogic.getId());
|
|
|
- ProWorkLogicContent proWorkLogicContent = new ProWorkLogicContent(detail);
|
|
|
+ ProWorkLogicContent proWorkLogicContent = new ProWorkLogicContent(detail);
|
|
|
proWorkLogicContent.setSort(sort++);
|
|
|
proWorkLogicContentService.save(proWorkLogicContent);
|
|
|
|
|
|
- projectManageBusinessOtherService.updateById(new ProjectManageBusinessOther(proWorkLogicContent.getProPlanId(),
|
|
|
- proWorkLogicContent.getId(), proWorkLogicContent.getDuration().toString()));
|
|
|
+ QueryWrapper<ProjectManageBusinessOther> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("del_flag", "0");
|
|
|
+ queryWrapper.eq("id", proWorkLogicContent.getProPlanId());
|
|
|
+ ProjectManageBusinessOther other = projectManageBusinessOtherService.getById(proWorkLogicContent.getProPlanId());
|
|
|
+ if(other != null) {
|
|
|
+ String otherRealTime = other.getRealTime();
|
|
|
+ double orgRealTime = 0;
|
|
|
+ if(StringUtils.isNotBlank(otherRealTime)) {
|
|
|
+ orgRealTime = Double.parseDouble(otherRealTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ Double realTime = proWorkLogicContent.getDuration() / 8 + orgRealTime;
|
|
|
+ projectManageBusinessOtherService.updateById(new ProjectManageBusinessOther(proWorkLogicContent.getProPlanId(),
|
|
|
+ proWorkLogicContent.getId(), realTime.toString()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -100,6 +129,9 @@ public class ProWorkLogicServiceImpl extends ServiceImpl<ProWorkLogicMapper, Pro
|
|
|
public boolean dropById(ProWorkLogic proWorkLogic) {
|
|
|
proWorkLogic.setDelFlag("1");
|
|
|
updateById(proWorkLogic);
|
|
|
+
|
|
|
+
|
|
|
+ dropOrgRealTime(proWorkLogic.getId());
|
|
|
|
|
|
deletChildren(proWorkLogic.getId());
|
|
|
return true;
|
|
@@ -119,15 +151,13 @@ public class ProWorkLogicServiceImpl extends ServiceImpl<ProWorkLogicMapper, Pro
|
|
|
queryWrapper.orderByAsc("sort");
|
|
|
List<ProWorkLogicContent> list = proWorkLogicContentService.list(queryWrapper);
|
|
|
List<ProWorkLogicContentListRespDTO> contentListRespDTOS = Lists.newArrayList();
|
|
|
- for(ProWorkLogicContent proWorkLogicContent : list){
|
|
|
+ for(ProWorkLogicContent proWorkLogicContent : list) {
|
|
|
contentListRespDTOS.add(new ProWorkLogicContentListRespDTO(proWorkLogicContent));
|
|
|
}
|
|
|
respDTO.setDetailList(contentListRespDTOS);
|
|
|
return respDTO;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
* @desc 删除子表
|
|
|
*/
|
|
@@ -137,4 +167,34 @@ public class ProWorkLogicServiceImpl extends ServiceImpl<ProWorkLogicMapper, Pro
|
|
|
queryWrapper.eq("logic_id", id);
|
|
|
proWorkLogicContentService.update(new ProWorkLogicContent("1"), queryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * @desc 回写轮天之前,先前减去新增时添加的轮天
|
|
|
+ */
|
|
|
+ private void dropOrgRealTime(String id) {
|
|
|
+ QueryWrapper<ProWorkLogicContent> contentQueryWrapper = new QueryWrapper<>();
|
|
|
+ contentQueryWrapper.eq("del_flag", "0");
|
|
|
+ contentQueryWrapper.eq("logic_id", id);
|
|
|
+ List<ProWorkLogicContent> contents = proWorkLogicContentService.list(contentQueryWrapper);
|
|
|
+
|
|
|
+ for(ProWorkLogicContent proWorkLogicContent : contents) {
|
|
|
+ QueryWrapper<ProjectManageBusinessOther> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("del_flag", "0");
|
|
|
+ queryWrapper.eq("id", proWorkLogicContent.getProPlanId());
|
|
|
+ ProjectManageBusinessOther other = projectManageBusinessOtherService.getById(proWorkLogicContent.getProPlanId());
|
|
|
+ if(other != null) {
|
|
|
+ String otherRealTime = other.getRealTime();
|
|
|
+ double orgRealTime = 0;
|
|
|
+ if(StringUtils.isNotBlank(otherRealTime)) {
|
|
|
+ orgRealTime = Double.parseDouble(otherRealTime);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Double realTime = orgRealTime - (proWorkLogicContent.getDuration() / 8);
|
|
|
+ projectManageBusinessOtherService.updateById(new ProjectManageBusinessOther(proWorkLogicContent.getProPlanId(),
|
|
|
+ proWorkLogicContent.getId(), realTime.toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|