|
@@ -1,9 +1,10 @@
|
|
|
package com.tofly.sxgk.custom.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
|
|
import com.tofly.common.oauth.util.SecurityUtils;
|
|
|
+import com.tofly.sxgk.custom.entity.CheckEntity;
|
|
|
import com.tofly.sxgk.custom.entity.CustomChildUnitVersionPublish;
|
|
|
import com.tofly.sxgk.custom.service.CustomPsHistoryAppService;
|
|
|
import com.tofly.sxgk.custom.util.PbsCodeBuilderUtil;
|
|
@@ -38,8 +39,8 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
private final AreacompanyService areacompanyService;
|
|
|
|
|
|
private final PbsprjService pbsprjService;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ private final static Boolean isNeedCheck=Boolean.FALSE;
|
|
|
private final static short version_seq_default=1;
|
|
|
private final static short version_default = 1;
|
|
|
private final static short modify_version_default=1;
|
|
@@ -49,13 +50,14 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
psnodeHistory.setIsPublish("1");
|
|
|
paraVerification(psnodeHistory,Boolean.TRUE);
|
|
|
fillCode(psnodeHistory);
|
|
|
- saveToNodeAndHistory(psnodeHistory,Boolean.TRUE);
|
|
|
+
|
|
|
+ saveToNodeAndHistory(psnodeHistory,Boolean.TRUE,isNeedCheck);
|
|
|
|
|
|
return psnodeHistory;
|
|
|
|
|
|
}
|
|
|
@Override
|
|
|
- public PsnodeHistory nodeUpdate(PsnodeHistory psnodeHistory,boolean updateToPs) {
|
|
|
+ public PsnodeHistory nodeUpdate(PsnodeHistory psnodeHistory,boolean updateToPs,boolean isNeedCheck) {
|
|
|
paraVerification(psnodeHistory,Boolean.FALSE);
|
|
|
|
|
|
|
|
@@ -71,13 +73,15 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
PsnodeHistory psnodeHistoryOld = new PsnodeHistory();
|
|
|
BeanUtils.copyProperties(sourcePsnode,psnodeHistoryOld);
|
|
|
psnodeHistoryOld.setId(null);
|
|
|
- psnodeHistoryOld.setModifyVersion(modify_version_default);
|
|
|
+ psnodeHistoryOld.setModifyVersion(psnodeHistoryService.getMaxModifyVersion(pbsCode,modify_version_default));
|
|
|
psnodeHistoryOld.setPublishVersion(psnodeHistoryService.
|
|
|
getMaxChildUnitVersion(getChildUnitCodeByPbsCode(psnodeHistory.getCode())));
|
|
|
psnodeHistoryOld.setPublishVersionSeq(version_seq_default);
|
|
|
+ psnodeHistoryOld.setIsPublish("1");
|
|
|
+ psnodeHistoryOld.setIsNew("1");
|
|
|
psnodeHistoryService.saveOrUpdate(psnodeHistoryOld);
|
|
|
}else {
|
|
|
- modifyVersion = currentHistory.getModifyVersion();
|
|
|
+ modifyVersion = psnodeHistoryService.getMaxModifyVersion(pbsCode,modify_version_default);
|
|
|
|
|
|
if( psnodeHistory.getPublishVersionSeq()!=null){
|
|
|
publishVersionSeq = psnodeHistory.getPublishVersionSeq();
|
|
@@ -96,26 +100,24 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
psnodeHistory.setModifyVersion(modifyVersion);
|
|
|
psnodeHistory.setPublishVersion(version);
|
|
|
psnodeHistory.setPublishVersionSeq(publishVersionSeq);
|
|
|
-
|
|
|
+ psnodeHistory.setIsNew("0");
|
|
|
+ psnodeHistory.setIsPublish("1");
|
|
|
+ psnodeHistoryService.saveOrUpdate(psnodeHistory);
|
|
|
|
|
|
+ if(!isNeedCheck){
|
|
|
+ synchronized (this){
|
|
|
+ updateNodeIsNew("0",currentHistory.getId());
|
|
|
+ psnodeHistory.setIsNew("1");
|
|
|
+ psnodeHistory.setModifyTime(new Date());
|
|
|
+ psnodeHistoryService.saveOrUpdate(psnodeHistory);
|
|
|
|
|
|
- synchronized (this){
|
|
|
- updateNodeIsNew("0",currentHistory.getId());
|
|
|
- psnodeHistory.setIsNew("1");
|
|
|
- psnodeHistory.setModifyTime(new Date());
|
|
|
- psnodeHistoryService.saveOrUpdate(psnodeHistory);
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if(updateToPs){
|
|
|
-
|
|
|
- Psnode oldPsnode = psnodeService.getOne(Wrappers.<Psnode>lambdaQuery().eq(Psnode::getCode, psnodeHistory.getCode()));
|
|
|
- Long oldPspipeId = oldPsnode.getId();
|
|
|
-
|
|
|
- BeanUtils.copyProperties(psnodeHistory,oldPsnode);
|
|
|
- oldPsnode.setId(oldPspipeId);
|
|
|
|
|
|
- psnodeService.saveOrUpdate(oldPsnode);
|
|
|
+ if(updateToPs&&!isNeedCheck){
|
|
|
+
|
|
|
+ updateNodeByHistory(psnodeHistory);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -140,14 +142,14 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
pspipeHistory.setIsPublish("1");
|
|
|
paraVerification(pspipeHistory,Boolean.TRUE);
|
|
|
fillCode(pspipeHistory);
|
|
|
- saveToPipeAndHistory(pspipeHistory);
|
|
|
+ saveToPipeAndHistory(pspipeHistory,Boolean.TRUE,isNeedCheck);
|
|
|
return pspipeHistory;
|
|
|
|
|
|
|
|
|
}
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public PspipeHistory pipeUpdate(PspipeHistory pspipeHistory,boolean updateToPs) {
|
|
|
+ public PspipeHistory pipeUpdate(PspipeHistory pspipeHistory,boolean updateToPs,boolean isNeedCheck) {
|
|
|
|
|
|
paraVerification(pspipeHistory,Boolean.FALSE);
|
|
|
|
|
@@ -166,14 +168,14 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
PspipeHistory pspipeHistoryOld = new PspipeHistory();
|
|
|
BeanUtils.copyProperties(sourcePspipe,pspipeHistoryOld);
|
|
|
pspipeHistoryOld.setId(null);
|
|
|
- pspipeHistoryOld.setModifyVersion(modify_version_default);
|
|
|
+ pspipeHistoryOld.setModifyVersion(pspipeHistoryService.getMaxModifyVersion(pbsCode,modify_version_default));
|
|
|
|
|
|
pspipeHistoryOld.setPublishVersion(pspipeHistoryService.
|
|
|
getMaxChildUnitVersion(getChildUnitCodeByPbsCode(pspipeHistory.getCode())));
|
|
|
pspipeHistoryOld.setPublishVersionSeq(version_seq_default);
|
|
|
pspipeHistoryService.saveOrUpdate(pspipeHistoryOld);
|
|
|
}else {
|
|
|
- modifyVersion = currentHistory.getModifyVersion();
|
|
|
+ modifyVersion = pspipeHistoryService.getMaxModifyVersion(pbsCode,modify_version_default);
|
|
|
publishVersionSeq = currentHistory.getPublishVersionSeq();
|
|
|
version = currentHistory.getPublishVersion();
|
|
|
modifyVersion++;
|
|
@@ -188,14 +190,22 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
|
|
|
|
|
|
|
|
|
- updatePipeIsNew("0",currentHistory.getId());
|
|
|
- pspipeHistory.setIsNew("1");
|
|
|
- pspipeHistory.setModifyTime(new Date());
|
|
|
- pspipeHistoryService.saveOrUpdate(pspipeHistory);
|
|
|
+ pspipeHistory.setIsNew("0");
|
|
|
+ pspipeHistory.setIsPublish("1");
|
|
|
+ pspipeHistoryService.saveOrUpdate(pspipeHistory);
|
|
|
+ if(!isNeedCheck){
|
|
|
+ synchronized (this){
|
|
|
+ updatePipeIsNew("0",currentHistory.getId());
|
|
|
+ pspipeHistory.setIsNew("1");
|
|
|
+ pspipeHistory.setModifyTime(new Date());
|
|
|
+ pspipeHistoryService.saveOrUpdate(pspipeHistory);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
- if(updateToPs){
|
|
|
+
|
|
|
+ if(updateToPs&&!isNeedCheck){
|
|
|
|
|
|
Pspipe oldPspipe = pspipeService.getOne(Wrappers.<Pspipe>lambdaQuery().eq(Pspipe::getCode, pspipeHistory.getCode()));
|
|
|
Long oldPspipeId = oldPspipe.getId();
|
|
@@ -245,6 +255,64 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean nodeCheck(CheckEntity checkEntity) {
|
|
|
+
|
|
|
+ PsnodeHistory currentForCheckHistory =
|
|
|
+ psnodeHistoryService.findCurrentForCheckHistory(checkEntity.getPbsCode());
|
|
|
+ Assert.notNull(currentForCheckHistory,"该部件无法审核");
|
|
|
+ checkEntity.setUserId(SecurityUtils.getUserId());
|
|
|
+ currentForCheckHistory.setCheckNote(JSON.toJSONString(checkEntity));
|
|
|
+
|
|
|
+ if("1".equals(checkEntity.getCheckStatus())){
|
|
|
+ PsnodeHistory currentHistory = psnodeHistoryService.findCurrentHistory(checkEntity.getPbsCode());
|
|
|
+ currentForCheckHistory.setIsNew("1");
|
|
|
+ psnodeHistoryService.saveOrUpdate(currentForCheckHistory);
|
|
|
+ updateNodeIsNew("0",currentHistory.getId());
|
|
|
+
|
|
|
+ updateNodeByHistory(currentForCheckHistory);
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ currentForCheckHistory.setIsPublish("0");
|
|
|
+ psnodeHistoryService.saveOrUpdate(currentForCheckHistory);
|
|
|
+
|
|
|
+ psnodeHistoryService.removeById(currentForCheckHistory.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean pipeCheck(CheckEntity checkEntity) {
|
|
|
+
|
|
|
+ PspipeHistory currentForCheckHistory =
|
|
|
+ pspipeHistoryService.findCurrentForCheckHistory(checkEntity.getPbsCode());
|
|
|
+ Assert.notNull(currentForCheckHistory,"该部件无法审核");
|
|
|
+ checkEntity.setUserId(SecurityUtils.getUserId());
|
|
|
+ currentForCheckHistory.setCheckNote(JSON.toJSONString(checkEntity));
|
|
|
+
|
|
|
+ if("1".equals(checkEntity.getCheckStatus())){
|
|
|
+ PspipeHistory currentHistory = pspipeHistoryService.findCurrentHistory(checkEntity.getPbsCode());
|
|
|
+ currentForCheckHistory.setIsNew("1");
|
|
|
+ pspipeHistoryService.saveOrUpdate(currentForCheckHistory);
|
|
|
+ updatePipeIsNew("0",currentHistory.getId());
|
|
|
+
|
|
|
+ updatePipeByHistory(currentForCheckHistory);
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ currentForCheckHistory.setIsPublish("0");
|
|
|
+ pspipeHistoryService.saveOrUpdate(currentForCheckHistory);
|
|
|
+
|
|
|
+ pspipeHistoryService.removeById(currentForCheckHistory.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void publishPipeVersionToHistory(Structuredetail childUnitDetail, CustomChildUnitVersionPublish customChildUnitVersionPublish) {
|
|
|
Short publishVersion = customChildUnitVersionPublish.getPublishVersion();
|
|
|
if(publishVersion==null || publishVersion==0){
|
|
@@ -301,7 +369,7 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
for(PsnodeHistory li:list){
|
|
|
li.setPublishVersion(publishVersion);
|
|
|
li.setPublishVersionSeq(version_seq_default);
|
|
|
- nodeUpdate(li,Boolean.FALSE);
|
|
|
+ nodeUpdate(li,Boolean.FALSE,Boolean.FALSE);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -338,7 +406,7 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void saveToPipeAndHistory(PspipeHistory pspipeHistory) {
|
|
|
+ private void saveToPipeAndHistory(PspipeHistory pspipeHistory,boolean isAddToPs,boolean isNeedCheck) {
|
|
|
|
|
|
pspipeHistory.setModifyTime(new Date());
|
|
|
pspipeHistory.setModifyVersion(modify_version_default);
|
|
@@ -354,13 +422,14 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
getMaxChildUnitVersion(getChildUnitCodeByPbsCode(pspipeHistory.getCode())));
|
|
|
pspipeHistory.setIsNew("1");
|
|
|
pspipeHistoryService.save(pspipeHistory);
|
|
|
-
|
|
|
-
|
|
|
+ if(isAddToPs&&!isNeedCheck){
|
|
|
Pspipe pspipe = new Pspipe();
|
|
|
BeanUtils.copyProperties(pspipeHistory,pspipe);
|
|
|
pspipe.setId(null);
|
|
|
-
|
|
|
pspipeService.saveOrUpdate(pspipe);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -373,7 +442,7 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
* addToPs 是否增加到成果表中
|
|
|
*/
|
|
|
@Transactional
|
|
|
- void saveToNodeAndHistory(PsnodeHistory psnodeHistory,boolean isAddToPs) {
|
|
|
+ void saveToNodeAndHistory(PsnodeHistory psnodeHistory,boolean isAddToPs,boolean isNeedCheck) {
|
|
|
|
|
|
|
|
|
psnodeHistory.setModifyTime(new Date());
|
|
@@ -383,11 +452,17 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
|
|
|
|
|
|
saveStructure(psnodeHistory);
|
|
|
- psnodeHistory.setIsNew("1");
|
|
|
+ if(isNeedCheck){
|
|
|
+ psnodeHistory.setIsNew("0");
|
|
|
+ }else{
|
|
|
+ psnodeHistory.setIsNew("1");
|
|
|
+ }
|
|
|
+
|
|
|
psnodeHistory.setPublishVersion(psnodeHistoryService.
|
|
|
getMaxChildUnitVersion(getChildUnitCodeByPbsCode(psnodeHistory.getCode())));
|
|
|
psnodeHistoryService.save(psnodeHistory);
|
|
|
- if(isAddToPs){
|
|
|
+
|
|
|
+ if(isAddToPs&&!isNeedCheck){
|
|
|
Psnode psnode = new Psnode();
|
|
|
BeanUtils.copyProperties(psnodeHistory,psnode);
|
|
|
psnode.setId(null);
|
|
@@ -401,6 +476,7 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Transactional
|
|
|
void saveStructure(Object obj) {
|
|
|
Long prjId =null;
|
|
@@ -467,6 +543,9 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
psnodeHistory.setId(null);
|
|
|
|
|
|
Assert.notNull(psnodeHistory.getCode(),"pbs编码未传入,请检查后传入");
|
|
|
+
|
|
|
+ PsnodeHistory currentForCheckHistory = psnodeHistoryService.findCurrentForCheckHistory(psnodeHistory.getCode());
|
|
|
+ Assert.isNull(currentForCheckHistory,"该部件存在待审核数据,请联系管理员审核后再修改");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -490,6 +569,9 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
pspipeHistory.setId(null);
|
|
|
|
|
|
Assert.notNull(pspipeHistory.getCode(),"pbs编码未传入,请检查后传入");
|
|
|
+
|
|
|
+ PspipeHistory currentForCheckHistory = pspipeHistoryService.findCurrentForCheckHistory(pspipeHistory.getCode());
|
|
|
+ Assert.isNull(currentForCheckHistory,"该部件存在待审核数据,请联系管理员审核后再修改");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -548,24 +630,14 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
}
|
|
|
|
|
|
|
|
|
- private synchronized void updatePipeIsNew(String isNew,Long... id){
|
|
|
- synchronized (CustomPsHistoryAppServiceImpl.class){
|
|
|
- boolean update1 = pspipeHistoryService.update(Wrappers.<PspipeHistory>lambdaUpdate()
|
|
|
- .eq(PspipeHistory::getId, id).eq(PspipeHistory::getIsNew, "1").set(PspipeHistory::getIsNew, isNew));
|
|
|
- if(!update1){
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ private synchronized void updatePipeIsNew(String isNew,Long id){
|
|
|
+ pspipeHistoryService.update(Wrappers.<PspipeHistory>lambdaUpdate()
|
|
|
+ .eq(PspipeHistory::getId, id).set(PspipeHistory::getIsNew, isNew));
|
|
|
}
|
|
|
|
|
|
- private synchronized void updateNodeIsNew(String isNew,Long... id){
|
|
|
- synchronized (CustomPsHistoryAppServiceImpl.class){
|
|
|
- boolean update1 = psnodeHistoryService.update(Wrappers.<PsnodeHistory>lambdaUpdate()
|
|
|
- .in(PsnodeHistory::getId, id).eq(PsnodeHistory::getIsNew, "1").set(PsnodeHistory::getIsNew, isNew));
|
|
|
- if(!update1){
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ private synchronized void updateNodeIsNew(String isNew,Long id){
|
|
|
+ psnodeHistoryService.update(Wrappers.<PsnodeHistory>lambdaUpdate()
|
|
|
+ .eq(PsnodeHistory::getId, id).set(PsnodeHistory::getIsNew, isNew));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -578,4 +650,25 @@ public class CustomPsHistoryAppServiceImpl implements CustomPsHistoryAppService
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void updateNodeByHistory(PsnodeHistory currentForCheckHistory){
|
|
|
+ Psnode oldPsnode = psnodeService.getOne(Wrappers.<Psnode>lambdaQuery().eq(Psnode::getCode, currentForCheckHistory.getCode()));
|
|
|
+ Long oldPspipeId = null;
|
|
|
+ if(oldPsnode!=null){
|
|
|
+ oldPspipeId = oldPsnode.getId();
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(currentForCheckHistory,oldPsnode);
|
|
|
+ oldPsnode.setId(oldPspipeId);
|
|
|
+ psnodeService.saveOrUpdate(oldPsnode);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updatePipeByHistory(PspipeHistory currentForCheckHistory){
|
|
|
+ Pspipe oldPspipe = pspipeService.getOne(Wrappers.<Pspipe>lambdaQuery().eq(Pspipe::getCode, currentForCheckHistory.getCode()));
|
|
|
+ Long oldPspipeId = null;
|
|
|
+ if(oldPspipe!=null){
|
|
|
+ oldPspipeId = oldPspipe.getId();
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(currentForCheckHistory,oldPspipe);
|
|
|
+ oldPspipe.setId(oldPspipeId);
|
|
|
+ pspipeService.saveOrUpdate(oldPspipe);
|
|
|
+ }
|
|
|
}
|