| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- package cn.com.goldenwater.dcproj.service.impl.rsml;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
- import cn.com.goldenwater.dcproj.constValue.RsvrEnum;
- 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.dto.BisInspRsmlRgstrDto;
- import cn.com.goldenwater.dcproj.model.AttRsBase;
- import cn.com.goldenwater.dcproj.model.BisInspAllObj;
- import cn.com.goldenwater.dcproj.model.BisInspRsmlRgstr;
- import cn.com.goldenwater.dcproj.param.*;
- import cn.com.goldenwater.dcproj.service.BisInspObjStrategy;
- import cn.com.goldenwater.dcproj.service.BisInspRsmlRgstrService;
- import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
- import cn.com.goldenwater.id.util.UuidUtil;
- 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 javax.servlet.http.HttpServletResponse;
- import java.util.Date;
- import java.util.List;
- import java.util.Optional;
- /**
- * @author lune
- * @date 2020-3-9
- */
- @Service
- @Transactional
- public class BisInspRsmlRgstrServiceImpl extends AbstractCrudService<BisInspRsmlRgstr, BisInspRsmlRgstrParam> implements BisInspRsmlRgstrService, BisInspObjStrategy {
- @Autowired
- private BisInspRsmlRgstrDao bisInspRsmlRgstrDao;
- @Autowired
- private BisInspAllObjDao bisInspAllObjDao;
- @Autowired
- private AttRsBaseDao attRsBaseDao;
- @Autowired
- private BisInspRsmlRgstrProjectDao bisInspRsmlRgstrProjectDao;
- @Autowired
- private BisInspRsmlRgstrRunManageDao bisInspRsmlRgstrRunManageDao;
- @Autowired
- private BisInspRsmlRgstrPresDao bisInspRsmlRgstrPresDao;
- public BisInspRsmlRgstrServiceImpl(BisInspRsmlRgstrDao bisInspRsmlRgstrDao) {
- super(bisInspRsmlRgstrDao);
- this.bisInspRsmlRgstrDao = bisInspRsmlRgstrDao;
- }
- @Override
- public BisInspRsmlRgstr getBy(BisInspRsmlRgstrParam param) {
- BisInspRsmlRgstr rgstr = super.getBy(param);
- Optional.ofNullable(rgstr).map(BisInspRsmlRgstr::getObjId).ifPresent(objId -> {
- AttRsBase base = attRsBaseDao.getObjId(objId);
- Optional.ofNullable(base).map(AttRsBase::getCompDateStr).ifPresent(rgstr::setCompDateStr);
- });
- return rgstr;
- }
- @Override
- public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
- AttRsBaseParam baseParam = new AttRsBaseParam();
- baseParam.setRsCode(bisInspAllObj.getCode());
- AttRsBase attRsBase = attRsBaseDao.getBy(baseParam);
- BisInspRsmlRgstr rgstr = new BisInspRsmlRgstr();
- rgstr.setId(UuidUtil.uuid());
- rgstr.setObjId(bisInspAllObj.getObjId());
- rgstr.setRsCode(attRsBase.getRsCode());
- rgstr.setRsName(bisInspAllObj.getNm());
- rgstr.setAdCode(attRsBase.getAdmDiv());
- rgstr.setOrgId(bisInspAllObj.getOrgId());
- rgstr.setRsAdmCode(attRsBase.getRsAdmCode());
- rgstr.setRsAdmName(attRsBase.getRsAdmName());
- rgstr.setDamSizeHig(attRsBase.getDamSizeHig());
- rgstr.setEngScal(attRsBase.getEngScal());
- rgstr.setLocation(attRsBase.getLocation());
- rgstr.setDamType(attRsBase.getDamType());
- rgstr.setTotCap(attRsBase.getTotCap());
- rgstr.setDesFlStag(attRsBase.getDesFlStag());
- rgstr.setImpdDt(attRsBase.getImpdDt());
- rgstr.setRnfcImpdDt(attRsBase.getRnfcImpdDt());
- rgstr.setResCreateTime(attRsBase.getCompDate());
- rgstr.setPresState(StateEnum.NOWASTSTATE.getKey());
- rgstr.setProjectState(StateEnum.NOWASTSTATE.getKey());
- rgstr.setRunManageState(StateEnum.NOWASTSTATE.getKey());
- rgstr.setSafeStat(StateEnum.NOWASTSTATE.getKey());
- rgstr.setHasDamRegCode("1");
- rgstr.setDamRegCode(attRsBase.getRegCode());
- rgstr.setHystSite(attRsBase.getRsLoc());
- if (attRsBase.getCenterX() != null) {
- rgstr.setCenterX(Double.parseDouble(attRsBase.getCenterX()));
- }
- if (attRsBase.getCenterY() != null) {
- rgstr.setCenterY(Double.parseDouble(attRsBase.getCenterY()));
- }
- if (attRsBase.getCenterXGd() != null) {
- rgstr.setGdX(Double.parseDouble(attRsBase.getCenterXGd()));
- }
- if (attRsBase.getCenterYGd() != null) {
- rgstr.setGdY(Double.parseDouble(attRsBase.getCenterYGd()));
- }
- rgstr.setRsClass(attRsBase.getRsClass());
- rgstr.setState(StateEnum.NOWASTSTATE.getKey());
- Date date = new Date();
- rgstr.setIntm(date);
- rgstr.setUptm(date);
- bisInspRsmlRgstrDao.insert(rgstr);
- }
- @Override
- public String getType() {
- return BisInspEnum.RSML.getValue();
- }
- @Override
- public void cleanObjData(String objId) {
- BisInspRsmlRgstrParam param = new BisInspRsmlRgstrParam();
- param.setObjId(objId);
- List<BisInspRsmlRgstr> list = bisInspRsmlRgstrDao.findList(param);
- if (list.size() > 0) {
- String id = list.get(0).getId();
- bisInspRsmlRgstrDao.delete(id);
- BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
- if (StringUtils.isNotBlank(objId)) {
- bisInspAllObjParam.setObjId(objId);
- BisInspRsmlRgstrProjectParam bisInspRsmlRgstrProjectParam = new BisInspRsmlRgstrProjectParam();
- bisInspRsmlRgstrProjectParam.setRgstrId(id);
- bisInspRsmlRgstrProjectDao.deleteBy(bisInspRsmlRgstrProjectParam);
- BisInspRsmlRgstrRunManageParam bisInspRsmlRgstrRunManageParam = new BisInspRsmlRgstrRunManageParam();
- bisInspRsmlRgstrRunManageParam.setRgstrId(id);
- bisInspRsmlRgstrRunManageDao.deleteBy(bisInspRsmlRgstrRunManageParam);
- BisInspRsmlRgstrPresParam bisInspRsmlRgstrPresParam = new BisInspRsmlRgstrPresParam();
- bisInspRsmlRgstrPresParam.setRgstrId(id);
- bisInspRsmlRgstrPresDao.deleteBy(bisInspRsmlRgstrPresParam);
- this.bisInspAllObjDao.deleteBy(bisInspAllObjParam);
- }
- }
- }
- @Override
- public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
- return findRsmlPage(typeParam, response);
- }
- @Override
- public Object findObjListByType(TypeParam typeParam) {
- return findRsmlList(typeParam);
- }
- @Override
- public PageInfo<BisInspRsmlRgstrDto> getRsmlPage(BisInspRsmlRgstrParam bisInspRsmlRgstrParam) {
- PageHelper.startPage(bisInspRsmlRgstrParam);
- List<BisInspRsmlRgstrDto> list = bisInspRsmlRgstrDao.getRsmlList(bisInspRsmlRgstrParam);
- if (list.size() > 0) {
- for (BisInspRsmlRgstrDto b : list) {
- if (b.getAdFullName() != null) {
- if (b.getAdFullName().contains(SplitValue.HENG_SPLIT)) {
- String[] split = b.getAdFullName().split(SplitValue.HENG_SPLIT);
- if (split.length == 3) {
- b.setProvince(split[0]);
- b.setCity(split[1]);
- b.setCounty(split[2]);
- }
- if (split.length == 2) {
- b.setProvince(split[0]);
- b.setCity(split[1]);
- b.setCounty("");
- }
- } else {
- b.setProvince(b.getAdFullName());
- }
- }
- }
- }
- PageInfo<BisInspRsmlRgstrDto> pageInfo = new PageInfo<>(list);
- return pageInfo;
- }
- @Override
- public PageInfo<BisInspRgstrDto> findRsmlPage(TypeParam typeParam, HttpServletResponse response) {
- if (StringUtils.isNotBlank(typeParam.getAdCode())) {
- typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
- }
- PageHelper.startPage(typeParam);
- List<BisInspRgstrDto> list = bisInspRsmlRgstrDao.findRsmlList(typeParam);
- list = changeList(list);
- return new PageInfo<BisInspRgstrDto>(list);
- }
- private List<BisInspRgstrDto> changeList(List<BisInspRgstrDto> list) {
- if (list.size() > 0) {
- for (BisInspRgstrDto rgstrDto : list) {
- String adFullName = rgstrDto.getAdName();
- if (StringUtils.isBlank(adFullName)) {
- continue;
- }
- if (adFullName.contains(SplitValue.HENG_SPLIT)) {
- String[] split = adFullName.split(SplitValue.HENG_SPLIT);
- if (split.length == 3) {
- rgstrDto.setProvince(split[0]);
- rgstrDto.setCity(split[1]);
- rgstrDto.setCountry(split[2]);
- }
- if (split.length == 2) {
- rgstrDto.setProvince(split[0]);
- rgstrDto.setCity(split[1]);
- rgstrDto.setCountry("");
- }
- } else {
- rgstrDto.setProvince(adFullName);
- }
- }
- }
- return list;
- }
- @Override
- public List findRsmlList(TypeParam typeParam) {
- if (StringUtils.isNotBlank(typeParam.getAdCode())) {
- typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
- }
- List<BisInspRgstrDto> list = bisInspRsmlRgstrDao.findRsmlList(typeParam);
- return changeList(list);
- }
- @Override
- public void updateRsvr(String rgstrId, String status, String input) {
- if (StringUtils.isBlank(rgstrId)) {
- return;
- }
- BisInspRsmlRgstr rgstr = bisInspRsmlRgstrDao.get(rgstrId);
- if (StringUtils.isBlank(status)) {
- status = "2";
- }
- RsvrEnum rsvrEnum = RsvrEnum.getByValue(input);
- if (rsvrEnum == null) {
- return;
- }
- switch (rsvrEnum) {
- case PERSSAFE:
- rgstr.setSafeStat(status);
- break;
- default:
- }
- if (StringUtils.isBlank(rgstr.getState()) ||
- StateEnum.NOWASTSTATE.getKey().equals(rgstr.getState())) {
- rgstr.setState(StateEnum.EXWASTSTATE.getKey());
- } else {
- rgstr.setState(rgstr.getState());
- }
- bisInspRsmlRgstrDao.update(rgstr);
- }
- }
|