8da15c83546f7ff1a46ab6587253a9a8494b98cf.svn-base 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.dcproj.dao.BisInspSvwtqhChkDao;
  3. import cn.com.goldenwater.dcproj.model.BisInspSvwtqhChk;
  4. import cn.com.goldenwater.dcproj.param.BisInspSvwtqhChkParam;
  5. import cn.com.goldenwater.dcproj.service.BisInspSvwtqhChkService;
  6. import cn.com.goldenwater.core.service.AbstractCrudService;
  7. import cn.com.goldenwater.dcproj.service.BisInspSvwtqhService;
  8. import cn.com.goldenwater.target.CheckException;
  9. import com.github.pagehelper.PageHelper;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import cn.com.goldenwater.id.util.UuidUtil;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.Date;
  17. import java.util.Map;
  18. /**
  19. * @author lhc
  20. * @date 2021-6-23
  21. */
  22. @Service
  23. @Transactional
  24. public class BisInspSvwtqhChkServiceImpl extends AbstractCrudService<BisInspSvwtqhChk, BisInspSvwtqhChkParam> implements BisInspSvwtqhChkService {
  25. @Autowired
  26. private BisInspSvwtqhChkDao bisInspSvwtqhChkDao;
  27. @Autowired
  28. private BisInspSvwtqhService bisInspSvwtqhService;
  29. public BisInspSvwtqhChkServiceImpl(BisInspSvwtqhChkDao bisInspSvwtqhChkDao) {
  30. super(bisInspSvwtqhChkDao);
  31. this.bisInspSvwtqhChkDao = bisInspSvwtqhChkDao;
  32. }
  33. @Override
  34. public int insert(BisInspSvwtqhChk bisInspSvwtqhChk) {
  35. BisInspSvwtqhChk chk = bisInspSvwtqhChkDao.get(bisInspSvwtqhChk.getRgstrId());
  36. if(chk != null){
  37. bisInspSvwtqhChk.setId(chk.getId());
  38. return update(bisInspSvwtqhChk);
  39. }
  40. updateRgstrState(bisInspSvwtqhChk);
  41. String uuid = UuidUtil.uuid(); // 生成uuid
  42. bisInspSvwtqhChk.setId(uuid);
  43. bisInspSvwtqhChk.setIntm(new Date());
  44. bisInspSvwtqhChk.setUptm(new Date());
  45. bisInspSvwtqhChk.setDataStat("0");
  46. return this.bisInspSvwtqhChkDao.insert(bisInspSvwtqhChk);
  47. }
  48. @Override
  49. public int update(BisInspSvwtqhChk bisInspSvwtqhChk) {
  50. BisInspSvwtqhChk chk = bisInspSvwtqhChkDao.get(bisInspSvwtqhChk.getRgstrId());
  51. if(chk == null){
  52. throw new CheckException("未找到此登记表下的子表");
  53. }
  54. bisInspSvwtqhChk.setId(chk.getId());
  55. bisInspSvwtqhChk.setUptm(new Date());
  56. int ret = bisInspSvwtqhChkDao.update(bisInspSvwtqhChk);
  57. updateRgstrState(bisInspSvwtqhChk);
  58. return ret;
  59. }
  60. private void updateRgstrState(BisInspSvwtqhChk bisInspSvwtqhChk){
  61. Map<String, Object> map = new HashMap<>(3);
  62. map.put("rgstrId", bisInspSvwtqhChk.getRgstrId());
  63. map.put("param", "case");
  64. map.put("state", bisInspSvwtqhChk.getState());
  65. bisInspSvwtqhService.updateState(map);
  66. }
  67. @Override
  68. public int delete(String id) {
  69. return this.bisInspSvwtqhChkDao.delete(id);
  70. }
  71. }