| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package cn.com.goldenwater.dcproj.service.impl;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.dao.BisInspMfdpqhTownDao;
- import cn.com.goldenwater.dcproj.model.BisInspMfdpqhTown;
- import cn.com.goldenwater.dcproj.param.BisInspMfdpqhTownParam;
- import cn.com.goldenwater.dcproj.service.BisInspMfdpqhRgstrService;
- import cn.com.goldenwater.dcproj.service.BisInspMfdpqhTownService;
- import cn.com.goldenwater.id.util.UuidUtil;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Optional;
- import static cn.com.goldenwater.dcproj.util.CheckUtil.check;
- /**
- * @author lhc
- * @date 2021-6-15
- */
- @Service
- @Transactional
- public class BisInspMfdpqhTownServiceImpl extends AbstractCrudService<BisInspMfdpqhTown, BisInspMfdpqhTownParam> implements BisInspMfdpqhTownService {
- @Autowired
- private BisInspMfdpqhTownDao bisInspMfdpqhTownDao;
- @Autowired
- private BisInspMfdpqhRgstrService bisInspMfdpqhRgstrService;
- public BisInspMfdpqhTownServiceImpl(BisInspMfdpqhTownDao bisInspMfdpqhTownDao) {
- super(bisInspMfdpqhTownDao);
- this.bisInspMfdpqhTownDao = bisInspMfdpqhTownDao;
- }
- @Override
- public BisInspMfdpqhTown get(String key) {
- return Optional.ofNullable(super.get(key)).orElseGet(() -> {
- BisInspMfdpqhTown child = new BisInspMfdpqhTown();
- child.setState("1");
- child.setIsDuty("1");
- child.setIsPlan("1");
- child.setIsWarn("1");
- child.setIsLogo("1");
- child.setIsSend("1");
- child.setChkTm(new Date());
- return child;
- });
- }
- @Override
- public int insert(BisInspMfdpqhTown bisInspMfdpqhTown) {
- check(StringUtils.isNotBlank(bisInspMfdpqhTown.getRgstrId()), "rgstrId.no");
- BisInspMfdpqhTown checkRgstr = bisInspMfdpqhTownDao.get(bisInspMfdpqhTown.getRgstrId());
- if (checkRgstr != null) {
- bisInspMfdpqhTown.setId(checkRgstr.getId());
- return update(bisInspMfdpqhTown);
- }
- updateRgstrState(bisInspMfdpqhTown);
- String uuid = UuidUtil.uuid();
- bisInspMfdpqhTown.setId(uuid);
- bisInspMfdpqhTown.setIntm(new Date());
- bisInspMfdpqhTown.setUptm(new Date());
- bisInspMfdpqhTown.setDataStat("0");
- return this.bisInspMfdpqhTownDao.insert(bisInspMfdpqhTown);
- }
- @Override
- public int update(BisInspMfdpqhTown bisInspMfdpqhTown) {
- // 更新子表
- bisInspMfdpqhTown.setUptm(new Date());
- int ret = bisInspMfdpqhTownDao.update(bisInspMfdpqhTown);
- // 更新登记表状态
- updateRgstrState(bisInspMfdpqhTown);
- return ret;
- }
- private void updateRgstrState(BisInspMfdpqhTown bisInspMfdpqhTown) {
- Map<String, Object> map = new HashMap<>(3);
- map.put("rgstrId", bisInspMfdpqhTown.getRgstrId());
- map.put("param", "town");
- map.put("state", bisInspMfdpqhTown.getState());
- bisInspMfdpqhRgstrService.updateState(map);
- }
- @Override
- public int delete(String id) {
- return this.bisInspMfdpqhTownDao.delete(id);
- }
- }
|