package cn.com.goldenwater.dcproj.service.impl.stnd; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.constValue.SplitValue; import cn.com.goldenwater.dcproj.constValue.StateEnum; import cn.com.goldenwater.dcproj.dao.*; import cn.com.goldenwater.dcproj.dto.BisInspRgstrDto; import cn.com.goldenwater.dcproj.model.AttRsBase; import cn.com.goldenwater.dcproj.model.BisInspAllObj; import cn.com.goldenwater.dcproj.model.BisInspStndRgstr; import cn.com.goldenwater.dcproj.param.*; import cn.com.goldenwater.dcproj.service.BisInspObjStrategy; import cn.com.goldenwater.dcproj.service.BisInspStndRgstrService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; 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 cn.com.goldenwater.id.util.UuidUtil; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Date; /** * @author lhc * @date 2020-3-25 */ @Service @Transactional public class BisInspStndRgstrServiceImpl extends AbstractCrudService implements BisInspStndRgstrService, BisInspObjStrategy { @Autowired private BisInspStndRgstrDao bisInspStndRgstrDao; @Autowired private AttRsBaseDao attRsBaseDao; @Autowired private BisInspAllObjDao bisInspAllObjDao; @Autowired private BisInspPblmDao bisInspPblmDao; @Autowired private BisInspStndDtyminDao bisInspStndDtyminDao; @Autowired private BisInspStndMgamtDao bisInspStndMgamtDao; @Autowired private BisInspStndPlrdDao bisInspStndPlrdDao; public BisInspStndRgstrServiceImpl(BisInspStndRgstrDao bisInspStndRgstrDao) { super(bisInspStndRgstrDao); this.bisInspStndRgstrDao = bisInspStndRgstrDao; } @Override public int insert(BisInspStndRgstr bisInspStndRgstr) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspStndRgstr.setId(uuid); bisInspStndRgstr.setIntm(new Date()); bisInspStndRgstr.setUptm(new Date()); bisInspStndRgstr.setDataStat("0"); return this.bisInspStndRgstrDao.insert(bisInspStndRgstr); } @Override public int update(BisInspStndRgstr bisInspStndRgstr) { bisInspStndRgstr.setUptm(new Date()); return this.bisInspStndRgstrDao.update(bisInspStndRgstr); } @Override public int delete(String id) { return this.bisInspStndRgstrDao.delete(id); } @Override public PageInfo findStndRgstrPage(TypeParam typeParam, HttpServletResponse response) { PageHelper.startPage(typeParam); return new PageInfo(setSsx(typeParam)); } private List setSsx(TypeParam typeParam) { if (StringUtils.isNotBlank(typeParam.getAdCode())) { typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD))); } List list = bisInspStndRgstrDao.findStndRgstrPage(typeParam); if (list.size() > 0) { for (BisInspRgstrDto b : list) { if (b.getLocation() != null) { if (b.getLocation().contains(SplitValue.HENG_SPLIT)) { String[] split = b.getLocation().split(SplitValue.HENG_SPLIT); if (split.length == 3) { b.setProvince(split[0]); b.setCity(split[1]); b.setCountry(split[2]); } if (split.length == 2) { b.setProvince(split[0]); b.setCity(split[1]); b.setCountry(""); } } else { b.setProvince(b.getLocation()); } } } } return list; } @Override public void insertObj(BisInspAllObj bisInspAllObj, String persId) { String rsraqgRgstrId = UuidUtil.uuid(); //获取小水库信息 AttRsBaseParam baseParam = new AttRsBaseParam(); baseParam.setRsCode(bisInspAllObj.getCode()); AttRsBase attRsBase = attRsBaseDao.getBy(baseParam); BisInspStndRgstr b = new BisInspStndRgstr(); b.setRgstrId(rsraqgRgstrId); b.setOrgId(bisInspAllObj.getOrgId()); b.setObjId(bisInspAllObj.getObjId()); b.setRsCode(attRsBase.getRsCode()); b.setRsvrNm(bisInspAllObj.getNm()); b.setAdCode(attRsBase.getAdmDiv()); b.setResCreateTime(attRsBase.getCompDate()); b.setEngScal(attRsBase.getEngScal()); b.setTotCap(attRsBase.getTotCap()); b.setHystSite(attRsBase.getRsLoc()); b.setDamRegCode(attRsBase.getRegCode()); b.setDamType(attRsBase.getDamType()); b.setHasDamRegCode(StringUtils.isNotBlank(attRsBase.getRegCode()) ? "1" : "2"); b.setResCreateTimeNote(attRsBase.getCompDateStr()); Date date = new Date(); b.setIntm(date); b.setUptm(date); b.setGroupId(bisInspAllObj.getId()); b.setPersId(persId); b.setState(StateEnum.NOWASTSTATE.getKey()); b.setDataStat(StateEnum.NOWASTSTATE.getKey()); b.setJxDuty(attRsBase.getJxDuty()); b.setJxDutyPhone(attRsBase.getJxDutyPhone()); b.setJxRsvrStndLev(attRsBase.getJxRsvrStndLev()); b.setJxRsvrType(attRsBase.getJxRsvrType()); b.setRsAdmCode(attRsBase.getRsAdmCode()); b.setRsAdmName(attRsBase.getRsAdmName()); b.setAdNm(attRsBase.getLocation()); b.setCenterX(attRsBase.getCenterX() == null ? null : Double.parseDouble(attRsBase.getCenterX())); b.setCenterY(attRsBase.getCenterY() == null ? null : Double.parseDouble(attRsBase.getCenterY())); b.setCenterXGd(attRsBase.getCenterXGd() == null ? null : Double.parseDouble(attRsBase.getCenterXGd())); b.setCenterYGd(attRsBase.getCenterYGd() == null ? null : Double.parseDouble(attRsBase.getCenterYGd())); b.setDamSizeHig(attRsBase.getDamSizeHig()); bisInspStndRgstrDao.insert(b); } @Override public String getType() { return BisInspEnum.STND.getValue(); } @Override public void cleanObjData(String objId) { BisInspStndRgstrParam param = new BisInspStndRgstrParam(); param.setObjId(objId); List list = bisInspStndRgstrDao.findList(param); if (list.size() > 0) { String id = list.get(0).getId(); bisInspStndRgstrDao.delete(id); BisInspPblmParam bisInspPblmParam = new BisInspPblmParam(); bisInspPblmParam.setRegid(id); BisInspStndPlrdParam bisInspStndPlrdParam = new BisInspStndPlrdParam(); bisInspStndPlrdParam.setRgstrId(id); bisInspStndPlrdDao.deleteBy(bisInspStndPlrdParam); BisInspStndMgamtParam bisInspStndMgamtParam = new BisInspStndMgamtParam(); bisInspStndMgamtParam.setRgstrId(id); bisInspStndMgamtDao.deleteBy(bisInspStndMgamtParam); BisInspStndDtyminParam bisInspStndDtyminParam = new BisInspStndDtyminParam(); bisInspStndDtyminParam.setRgstrId(id); bisInspStndDtyminDao.deleteBy(bisInspStndDtyminParam); bisInspPblmParam.setObjType(BisInspEnum.ECOFRD.getValue()); this.bisInspPblmDao.deleteBy(bisInspPblmParam); this.bisInspAllObjDao.delete(objId); } } @Override public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) { return findStndRgstrPage(typeParam, response); } @Override public Object findObjListByType(TypeParam typeParam) { return setSsx(typeParam); } }