package cn.com.goldenwater.dcproj.service.impl.stnd; import cn.com.goldenwater.dcproj.dao.BisInspStndMgamtDao; import cn.com.goldenwater.dcproj.dao.BisInspStndRgstrDao; import cn.com.goldenwater.dcproj.model.BisInspStndDtymin; import cn.com.goldenwater.dcproj.model.BisInspStndMgamt; import cn.com.goldenwater.dcproj.model.BisInspStndRgstr; import cn.com.goldenwater.dcproj.param.BisInspStndDtyminParam; import cn.com.goldenwater.dcproj.param.BisInspStndMgamtParam; import cn.com.goldenwater.dcproj.service.BisInspStndMgamtService; import cn.com.goldenwater.core.service.AbstractCrudService; 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.List; import java.util.Date; /** * @author lhc * @date 2020-3-25 */ @Service @Transactional public class BisInspStndMgamtServiceImpl extends AbstractCrudService implements BisInspStndMgamtService { @Autowired private BisInspStndMgamtDao bisInspStndMgamtDao; @Autowired private BisInspStndRgstrDao bisInspStndRgstrDao; public BisInspStndMgamtServiceImpl(BisInspStndMgamtDao bisInspStndMgamtDao) { super(bisInspStndMgamtDao); this.bisInspStndMgamtDao = bisInspStndMgamtDao; } @Override public int insert(BisInspStndMgamt bisInspStndMgamt) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspStndMgamt.setId(uuid); bisInspStndMgamt.setIntm(new Date()); bisInspStndMgamt.setUptm(new Date()); bisInspStndMgamt.setDataStat("0"); //查询是否添加过同样的regId BisInspStndMgamtParam bisInspStndMgamtParam = new BisInspStndMgamtParam(); bisInspStndMgamtParam.setRgstrId(bisInspStndMgamt.getRgstrId()); BisInspStndMgamt bisInspStndMgamtTemp = bisInspStndMgamtDao.getBy(bisInspStndMgamtParam); if (null == bisInspStndMgamtTemp) { BisInspStndRgstr bisInspStndRgstr = new BisInspStndRgstr(); bisInspStndRgstr.setId(bisInspStndMgamt.getRgstrId()); bisInspStndRgstr.setMgamtState(bisInspStndMgamt.getStatus()); bisInspStndRgstr.setState("1"); bisInspStndRgstrDao.update(bisInspStndRgstr); return this.bisInspStndMgamtDao.insert(bisInspStndMgamt); } return 0; } @Override public int update(BisInspStndMgamt bisInspStndMgamt) { if (null != bisInspStndMgamt.getRgstrId()) { BisInspStndRgstr bisInspStndRgstr = new BisInspStndRgstr(); bisInspStndRgstr.setId(bisInspStndMgamt.getRgstrId()); bisInspStndRgstr.setMgamtState(bisInspStndMgamt.getStatus()); bisInspStndRgstr.setState("1"); bisInspStndRgstrDao.update(bisInspStndRgstr); } bisInspStndMgamt.setUptm(new Date()); return this.bisInspStndMgamtDao.update(bisInspStndMgamt); } @Override public int delete(String id) { return this.bisInspStndMgamtDao.delete(id); } @Override public BisInspStndMgamt getByRegId(String regId) { BisInspStndMgamtParam bisInspStndMgamtParam = new BisInspStndMgamtParam(); bisInspStndMgamtParam.setRgstrId(regId); return bisInspStndMgamtDao.getBy(bisInspStndMgamtParam); } }