1242812a98ac13e86c6e15ea8964196f72fd2e6a.svn-base 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package cn.com.goldenwater.dcproj.service.impl.rsfco;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.BisInspRsfcoRgstrBaseInfoDao;
  4. import cn.com.goldenwater.dcproj.dao.BisInspRsfcoRgstrDao;
  5. import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstr;
  6. import cn.com.goldenwater.dcproj.model.BisInspRsfcoRgstrBaseInfo;
  7. import cn.com.goldenwater.dcproj.param.BisInspRsfcoRgstrBaseInfoParam;
  8. import cn.com.goldenwater.dcproj.service.BisInspRsfcoRgstrBaseInfoService;
  9. import cn.com.goldenwater.dcproj.util.CheckUtil;
  10. import cn.com.goldenwater.dcproj.utils.Builder;
  11. import org.apache.http.util.TextUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import org.springframework.transaction.annotation.Transactional;
  15. /**
  16. * @author lune
  17. * @date 2021年3月29日
  18. */
  19. @Service
  20. @Transactional(rollbackFor = Exception.class)
  21. public class BisInspRsfcoRgstrBaseInfoServiceImpl extends AbstractCrudService<BisInspRsfcoRgstrBaseInfo, BisInspRsfcoRgstrBaseInfoParam> implements BisInspRsfcoRgstrBaseInfoService {
  22. @Autowired
  23. private BisInspRsfcoRgstrBaseInfoDao bisInspRsfcoRgstrBaseInfoDao;
  24. @Autowired
  25. private BisInspRsfcoRgstrDao bisInspRsfcoRgstrDao;
  26. public BisInspRsfcoRgstrBaseInfoServiceImpl(BisInspRsfcoRgstrBaseInfoDao bisInspRsfcoRgstrBaseInfoDao) {
  27. super(bisInspRsfcoRgstrBaseInfoDao);
  28. this.bisInspRsfcoRgstrBaseInfoDao = bisInspRsfcoRgstrBaseInfoDao;
  29. }
  30. @Override
  31. public int insert(BisInspRsfcoRgstrBaseInfo entity) {
  32. CheckUtil.notEmpty(entity.getRgstrId(), "rgstrId.no");
  33. BisInspRsfcoRgstrBaseInfo info = getBy(Builder.of(BisInspRsfcoRgstrBaseInfoParam::new)
  34. .with(BisInspRsfcoRgstrBaseInfoParam::setRgstrId, entity.getRgstrId())
  35. .build());
  36. if (info != null) {
  37. if (null == bisInspRsfcoRgstrBaseInfoDao.get(entity.getId())) {
  38. return super.insert(entity);
  39. } else {
  40. return update(entity);
  41. }
  42. }
  43. return super.insert(entity);
  44. }
  45. @Override
  46. public BisInspRsfcoRgstrBaseInfo getBy(BisInspRsfcoRgstrBaseInfoParam bisInspRsfcoRgstrBaseInfoParam) {
  47. BisInspRsfcoRgstrBaseInfo info = super.getBy(bisInspRsfcoRgstrBaseInfoParam);
  48. if (info == null && bisInspRsfcoRgstrBaseInfoParam != null && !TextUtils.isBlank(bisInspRsfcoRgstrBaseInfoParam.getRgstrId())) {
  49. info = new BisInspRsfcoRgstrBaseInfo();
  50. BisInspRsfcoRgstr rgstr = bisInspRsfcoRgstrDao.get(bisInspRsfcoRgstrBaseInfoParam.getRgstrId());
  51. info.setEngScal(rgstr.getEngScal());
  52. info.setRsName(rgstr.getRsName());
  53. info.setAdCode(rgstr.getAdCode());
  54. info.setRgstrId(rgstr.getId());
  55. info.setLocation(rgstr.getLocation());
  56. }
  57. return info;
  58. }
  59. }