| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- package cn.com.goldenwater.dcproj.service.impl;
- import cn.com.goldenwater.dcproj.dao.BisInspKeychkqhSectionDao;
- import cn.com.goldenwater.dcproj.model.BisInspKeychkqhRegister;
- import cn.com.goldenwater.dcproj.model.BisInspKeychkqhSection;
- import cn.com.goldenwater.dcproj.param.BisInspKeychkqhSectionParam;
- import cn.com.goldenwater.dcproj.service.BisInspKeychkqhRegisterService;
- import cn.com.goldenwater.dcproj.service.BisInspKeychkqhSectionService;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.utils.Builder;
- import cn.com.goldenwater.dcproj.utils.Constant;
- import cn.com.goldenwater.target.CheckException;
- import com.github.pagehelper.PageHelper;
- import net.bytebuddy.implementation.bytecode.Throw;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import cn.com.goldenwater.id.util.UuidUtil;
- import java.util.List;
- import java.util.Date;
- import java.util.Optional;
- /**
- * @author lhc
- * @date 2021-6-25
- */
- @Service
- @Transactional
- public class BisInspKeychkqhSectionServiceImpl extends AbstractCrudService<BisInspKeychkqhSection, BisInspKeychkqhSectionParam> implements BisInspKeychkqhSectionService {
- @Autowired
- private BisInspKeychkqhSectionDao bisInspKeychkqhSectionDao;
- @Autowired
- private BisInspKeychkqhRegisterService bisInspKeychkqhRegisterService;
- public BisInspKeychkqhSectionServiceImpl(BisInspKeychkqhSectionDao bisInspKeychkqhSectionDao) {
- super(bisInspKeychkqhSectionDao);
- this.bisInspKeychkqhSectionDao = bisInspKeychkqhSectionDao;
- }
- @Override
- public int insert(BisInspKeychkqhSection bisInspKeychkqhSection) {
- if (StringUtils.isBlank(bisInspKeychkqhSection.getRegId())){
- throw new CheckException("登记表ID为空");
- }
- if(StringUtils.isBlank(bisInspKeychkqhSection.getNm())){
- throw new CheckException("标段名称为空");
- }
- BisInspKeychkqhRegister rgstr = bisInspKeychkqhRegisterService.get(bisInspKeychkqhSection.getRegId());
- if (rgstr == null ){
- throw new CheckException("登记表ID有误");
- }
- String uuid = UuidUtil.uuid(); // 生成uuid
- bisInspKeychkqhSection.setId(uuid);
- bisInspKeychkqhSection.setObjId(rgstr.getObjId());
- bisInspKeychkqhSection.setIntm(new Date());
- bisInspKeychkqhSection.setUptm(new Date());
- bisInspKeychkqhSection.setDataStat("0");
- int ret = this.bisInspKeychkqhSectionDao.insert(bisInspKeychkqhSection);
- updateRgstrState(bisInspKeychkqhSection.getRegId());
- return ret;
- }
- void updateRgstrState(String rgstrId) {
- BisInspKeychkqhRegister rgstr = bisInspKeychkqhRegisterService.get(rgstrId);
- Optional.ofNullable(rgstr).ifPresent(r -> {
- if (!Constant.STRING_TWO.equals(r.getState()) &&
- !Constant.STRING_ONE.equals(r.getState())) {
- r.setUptm(new Date());
- r.setState(Constant.STRING_ONE);
- bisInspKeychkqhRegisterService.update(r);
- }
- });
- }
- @Override
- public int update(BisInspKeychkqhSection bisInspKeychkqhSection) {
- BisInspKeychkqhSection child =get(bisInspKeychkqhSection.getId());
- Optional.ofNullable(child).orElseThrow(() -> new CheckException("未找到此登记表下的标段"));
- bisInspKeychkqhSection.setUptm(new Date());
- int ret = this.bisInspKeychkqhSectionDao.update(bisInspKeychkqhSection);
- updateRgstrState(child.getRegId());
- return ret;
- }
- @Override
- public int delete(String id) {
- return this.bisInspKeychkqhSectionDao.delete(id);
- }
- @Override
- public List<BisInspKeychkqhSection> listByRegId(String rgstrId) {
- return bisInspKeychkqhSectionDao.findList(Builder.of(BisInspKeychkqhSectionParam::new).with(BisInspKeychkqhSectionParam::setRegId , rgstrId).build());
- }
- }
|