package cn.com.goldenwater.dcproj.service.impl; import cn.com.goldenwater.dcproj.dao.BisInspSvwtqhChkDao; import cn.com.goldenwater.dcproj.model.BisInspSvwtqhChk; import cn.com.goldenwater.dcproj.param.BisInspSvwtqhChkParam; import cn.com.goldenwater.dcproj.service.BisInspSvwtqhChkService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.service.BisInspSvwtqhService; import cn.com.goldenwater.target.CheckException; import com.github.pagehelper.PageHelper; 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.HashMap; import java.util.List; import java.util.Date; import java.util.Map; /** * @author lhc * @date 2021-6-23 */ @Service @Transactional public class BisInspSvwtqhChkServiceImpl extends AbstractCrudService implements BisInspSvwtqhChkService { @Autowired private BisInspSvwtqhChkDao bisInspSvwtqhChkDao; @Autowired private BisInspSvwtqhService bisInspSvwtqhService; public BisInspSvwtqhChkServiceImpl(BisInspSvwtqhChkDao bisInspSvwtqhChkDao) { super(bisInspSvwtqhChkDao); this.bisInspSvwtqhChkDao = bisInspSvwtqhChkDao; } @Override public int insert(BisInspSvwtqhChk bisInspSvwtqhChk) { BisInspSvwtqhChk chk = bisInspSvwtqhChkDao.get(bisInspSvwtqhChk.getRgstrId()); if(chk != null){ bisInspSvwtqhChk.setId(chk.getId()); return update(bisInspSvwtqhChk); } updateRgstrState(bisInspSvwtqhChk); String uuid = UuidUtil.uuid(); // 生成uuid bisInspSvwtqhChk.setId(uuid); bisInspSvwtqhChk.setIntm(new Date()); bisInspSvwtqhChk.setUptm(new Date()); bisInspSvwtqhChk.setDataStat("0"); return this.bisInspSvwtqhChkDao.insert(bisInspSvwtqhChk); } @Override public int update(BisInspSvwtqhChk bisInspSvwtqhChk) { BisInspSvwtqhChk chk = bisInspSvwtqhChkDao.get(bisInspSvwtqhChk.getRgstrId()); if(chk == null){ throw new CheckException("未找到此登记表下的子表"); } bisInspSvwtqhChk.setId(chk.getId()); bisInspSvwtqhChk.setUptm(new Date()); int ret = bisInspSvwtqhChkDao.update(bisInspSvwtqhChk); updateRgstrState(bisInspSvwtqhChk); return ret; } private void updateRgstrState(BisInspSvwtqhChk bisInspSvwtqhChk){ Map map = new HashMap<>(3); map.put("rgstrId", bisInspSvwtqhChk.getRgstrId()); map.put("param", "case"); map.put("state", bisInspSvwtqhChk.getState()); bisInspSvwtqhService.updateState(map); } @Override public int delete(String id) { return this.bisInspSvwtqhChkDao.delete(id); } }