From cdd6551b190b981b807a3b95e9635c559ccc769d Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 19 五月 2025 09:45:07 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/service/business/impl/SolutionsBaseServiceImpl.java |   85 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/SolutionsBaseServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/SolutionsBaseServiceImpl.java
index c190001..791341b 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/SolutionsBaseServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/SolutionsBaseServiceImpl.java
@@ -22,6 +22,7 @@
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -66,6 +67,7 @@
     private InsuranceApplyMapper insuranceApplyMapper;
 
     @Override
+    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
     public Integer create(SolutionsBase solutionsBase) {
         LoginUserInfo user= (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         initCreateParam(solutionsBase);
@@ -146,6 +148,7 @@
             newType.setSolutionId(newModel.getId());
             solutionWorktypeJoinMapper.insert(newType);
         }
+
     }
 
 
@@ -209,6 +212,7 @@
     }
 
     @Override
+    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
     public void updateById(SolutionsBase solutionsBase) {
         LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal();
         SolutionsBase model = findById(solutionsBase.getId());
@@ -248,6 +252,7 @@
             solutionsBase.setAddValidDays(solutionsBase.getDelValidDays());
         }
         solutionsBaseMapper.updateById(solutionsBase);
+
         SolutionsBase oldVersion = solutionsBaseMapper.selectOne(new QueryWrapper<SolutionsBase>()
                 .lambda()
                 .eq(SolutionsBase::getBaseId,solutionsBase.getId())
@@ -276,7 +281,6 @@
                 .eq(SolutionWorktype::getType,Constants.ONE)
         );
         //鍒犻櫎鐖舵柟妗堜笅鎵�鏈夊瓙鏂规鐨勫伐绉嶆暟鎹�
-
         solutionWorktypeJoinMapper.delete(new UpdateWrapper<SolutionWorktype>()
                 .lambda()
                 .eq(SolutionWorktype::getType,Constants.ZERO)
@@ -284,7 +288,6 @@
         );
 
         dealWorkTypeInsurance(solutionsBase,newModel,solutionsBase.getWorktypeIdList());
-
 
         solutionsBaseMapper.update(null,new UpdateWrapper<SolutionsBase>()
                 .lambda()
@@ -440,4 +443,82 @@
         QueryWrapper<SolutionsBase> wrapper = new QueryWrapper<>(solutionsBase);
         return solutionsBaseMapper.selectCount(wrapper);
     }
+
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+    public void createSolutionBase(Integer solutionId){
+        List<Solutions> solutionsList = solutionsMapper.selectList(new QueryWrapper<Solutions>().lambda()
+                    .eq(Objects.nonNull(solutionId),Solutions::getId,solutionId)
+                .isNull(Solutions::getParentId).eq(Solutions::getDataType,Constants.ZERO).eq(Solutions::getIsdeleted,Constants.ZERO));
+        for (Solutions solutions: solutionsList) {
+            SolutionsBase solutionsBase = new SolutionsBase();
+            solutionsBase.setCreator(solutions.getCreator());
+            solutionsBase.setCreateDate(new Date());
+            solutionsBase.setIsdeleted(Constants.ZERO);
+            solutionsBase.setName(solutions.getName());
+            solutionsBase.setStatus(solutions.getStatus());
+            solutionsBase.setSortnum(Constants.ZERO);
+            solutionsBase.setInsuranceId(solutions.getInsuranceId());
+            solutionsBase.setValidType(solutions.getValidType());
+            solutionsBase.setMinAge(solutions.getMinAge());
+            solutionsBase.setMaxAge(solutions.getMaxAge());
+            solutionsBase.setSingleWorktype(solutions.getSingleWorktype());
+            solutionsBase.setSpecialInfo(solutions.getSpecialInfo());
+            solutionsBase.setSpecialAgreement(solutions.getSpecialAgreement());
+            solutionsBase.setOrtherInfo(solutions.getOrtherInfo());
+            solutionsBase.setDataType(Constants.ZERO);
+            solutionsBase.setValidTypeNum(solutions.getValidTypeNum());
+            solutionsBase.setShopId(solutions.getShopId());
+            solutionsBase.setAddValidDays(solutions.getAddValidDays());
+            solutionsBase.setDelValidDays(solutions.getDelValidDays());
+            solutionsBase.setCanAdd(solutions.getCanAdd());
+            solutionsBase.setCanReduce(solutions.getCanReduce());
+            solutionsBase.setCanChangeUnit(solutions.getCanChangeUnit());
+            solutionsBase.setDelOnlyReplace(solutions.getDelOnlyReplace());
+            solutionsBase.setCompanyName(solutions.getCompanyName());
+            solutionsBase.setCompanyName(solutions.getCompanyName());
+            solutionsBase.setCorrectWarnTime("18:30");
+            solutionsBaseMapper.insert(solutionsBase);
+
+
+            //濡傛灉鏈夊伐绉嶏紝鍒欎骇鐢熶竴涓柊鐨勬湁鏁堝巻鍙茬増鏈� ~
+            SolutionsBase newModel = new SolutionsBase();
+            BeanUtils.copyProperties(solutionsBase,newModel);
+            newModel.setId(null);
+            newModel.setBaseId(solutionsBase.getId());
+            newModel.setDataType(Constants.TWO);
+            solutionsBaseMapper.insert(newModel);
+
+            List<SolutionWorktype> solutionWorktypeList = solutionWorktypeJoinMapper.selectList(new QueryWrapper<SolutionWorktype>().lambda().eq(SolutionWorktype::getType,Constants.ZERO).eq(SolutionWorktype::getSolutionId,solutions.getId()));
+
+            Integer num = 1;
+            for(SolutionWorktype solutionWorktype : solutionWorktypeList) {
+                //鍩虹鐗堟湰
+                SolutionWorktype w = new SolutionWorktype();
+                w.setSolutionId(solutionsBase.getId());
+                w.setIsdeleted(Constants.ZERO);
+                w.setCreator(newModel.getCreator());
+                w.setCreateDate(solutionsBase.getCreateDate());
+                w.setStatus(Constants.ZERO);
+                w.setSortnum(num++);
+                w.setWorktypeId(solutionWorktype.getWorktypeId());
+                w.setType(Constants.ONE);
+                solutionWorktypeJoinMapper.insert(w);
+
+                //鍘嗗彶鐗堟湰鐨勫伐绉嶄俊鎭�
+                SolutionWorktype newType = new SolutionWorktype();
+                BeanUtils.copyProperties(w, newType);
+                newType.setSolutionId(newModel.getId());
+                solutionWorktypeJoinMapper.insert(newType);
+            }
+
+            solutionsMapper.update(null,new UpdateWrapper<Solutions>().lambda().set(Solutions::getParentId,solutionsBase.getId())
+                    .and(i->i.eq(Solutions::getId,solutions.getId()).or().eq(Solutions::getBaseId,solutions.getId()))
+            );
+        }
+    }
+
+
+
 }

--
Gitblit v1.9.3