|
@@ -1,15 +1,22 @@
|
|
|
package com.zhongzheng.modules.top.financial.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
-import com.zhongzheng.modules.top.financial.bo.TopCostInstTpAddBo;
|
|
|
-import com.zhongzheng.modules.top.financial.bo.TopCostInstTpEditBo;
|
|
|
-import com.zhongzheng.modules.top.financial.bo.TopCostInstTpQueryBo;
|
|
|
+import com.zhongzheng.modules.top.financial.bo.*;
|
|
|
import com.zhongzheng.modules.top.financial.domain.TopCostInstTp;
|
|
|
+import com.zhongzheng.modules.top.financial.domain.TopCostInstTpItem;
|
|
|
+import com.zhongzheng.modules.top.financial.domain.TopCostTp;
|
|
|
+import com.zhongzheng.modules.top.financial.domain.TopCostTpItem;
|
|
|
import com.zhongzheng.modules.top.financial.mapper.TopCostInstTpMapper;
|
|
|
+import com.zhongzheng.modules.top.financial.service.ITopCostInstTpItemService;
|
|
|
import com.zhongzheng.modules.top.financial.service.ITopCostInstTpService;
|
|
|
+import com.zhongzheng.modules.top.financial.service.ITopCostTpItemService;
|
|
|
import com.zhongzheng.modules.top.financial.vo.TopCostInstTpVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -31,6 +38,10 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class TopCostInstTpServiceImpl extends ServiceImpl<TopCostInstTpMapper, TopCostInstTp> implements ITopCostInstTpService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ITopCostInstTpItemService iTopCostInstTpItemService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public TopCostInstTpVo queryById(Long tpId){
|
|
|
TopCostInstTp db = this.baseMapper.selectById(tpId);
|
|
@@ -69,11 +80,37 @@ public class TopCostInstTpServiceImpl extends ServiceImpl<TopCostInstTpMapper, T
|
|
|
|
|
|
@Override
|
|
|
public Boolean insertByAddBo(TopCostInstTpAddBo bo) {
|
|
|
+ if(Validator.isEmpty(bo.getTpName())){
|
|
|
+ throw new CustomException("参数缺少");
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(bo.getInstId())){
|
|
|
+ throw new CustomException("缺少供应商ID");
|
|
|
+ }
|
|
|
+ TopCostInstTp mplatformLog = getOne(new LambdaQueryWrapper<TopCostInstTp>()
|
|
|
+ .eq(TopCostInstTp::getTpName,bo.getTpName()).ne(TopCostInstTp::getStatus,-1).last("limit 1"));
|
|
|
+ if(Validator.isNotEmpty(mplatformLog)){
|
|
|
+ throw new CustomException("该模板名称已存在");
|
|
|
+ }
|
|
|
TopCostInstTp add = BeanUtil.toBean(bo, TopCostInstTp.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.save(add);
|
|
|
+ if(this.save(add)){
|
|
|
+ if(add.getDefaultStatus()==1){
|
|
|
+ LambdaUpdateWrapper<TopCostInstTp> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
+ objectLambdaUpdateWrapper.ne(TopCostInstTp::getTpId, add.getTpId());
|
|
|
+ objectLambdaUpdateWrapper.eq(TopCostInstTp::getInstId, bo.getInstId());
|
|
|
+ objectLambdaUpdateWrapper.set(TopCostInstTp::getDefaultStatus, 0);
|
|
|
+ objectLambdaUpdateWrapper.set(TopCostInstTp::getUpdateTime, DateUtils.getNowTime());
|
|
|
+ update(null, objectLambdaUpdateWrapper);
|
|
|
+ }
|
|
|
+ for(TopCostInstTpItemAddBo itemBo : bo.getItemList()){
|
|
|
+ itemBo.setTpId(add.getTpId());
|
|
|
+ iTopCostInstTpItemService.insertByAddBo(itemBo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -81,6 +118,20 @@ public class TopCostInstTpServiceImpl extends ServiceImpl<TopCostInstTpMapper, T
|
|
|
TopCostInstTp update = BeanUtil.toBean(bo, TopCostInstTp.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ if(Validator.isNotEmpty(bo.getTpName())){
|
|
|
+ TopCostInstTp mplatformLog = getOne(new LambdaQueryWrapper<TopCostInstTp>()
|
|
|
+ .eq(TopCostInstTp::getTpName,bo.getTpName()).ne(TopCostInstTp::getStatus,-1).ne(TopCostInstTp::getTpId,bo.getTpId()).last("limit 1"));
|
|
|
+ if(Validator.isNotEmpty(mplatformLog)){
|
|
|
+ throw new CustomException("该模板名称已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(bo.getItemList())){
|
|
|
+ iTopCostInstTpItemService.remove(new LambdaQueryWrapper<TopCostInstTpItem>().eq(TopCostInstTpItem::getTpId, bo.getTpId()));
|
|
|
+ for(TopCostInstTpItemAddBo itemBo : bo.getItemList()){
|
|
|
+ itemBo.setTpId(bo.getTpId());
|
|
|
+ iTopCostInstTpItemService.insertByAddBo(itemBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
return this.updateById(update);
|
|
|
}
|
|
|
|
|
@@ -100,4 +151,15 @@ public class TopCostInstTpServiceImpl extends ServiceImpl<TopCostInstTpMapper, T
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean deleteBatch(TopCostInstTpQueryBo queryBo) {
|
|
|
+ for(Long id : queryBo.getIds()){
|
|
|
+ TopCostInstTp update = new TopCostInstTp();
|
|
|
+ update.setTpId(id);
|
|
|
+ update.setStatus(-1);
|
|
|
+ this.updateById(update);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|