package cn.com.goldenwater.dcproj.service.impl.other; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.constValue.SplitValue; import cn.com.goldenwater.dcproj.dao.AttOtherBaseDao; import cn.com.goldenwater.dcproj.dao.BisInspAllObjDao; import cn.com.goldenwater.dcproj.dao.BisInspOtherRgstrDao; import cn.com.goldenwater.dcproj.dao.BisInspPblmDao; import cn.com.goldenwater.dcproj.dto.BisInspOtherRgstrDto; import cn.com.goldenwater.dcproj.model.AttOtherBase; import cn.com.goldenwater.dcproj.model.BisInspAllObj; import cn.com.goldenwater.dcproj.model.BisInspOtherRgstr; import cn.com.goldenwater.dcproj.param.BisInspAllObjParam; import cn.com.goldenwater.dcproj.param.BisInspOtherRgstrParam; import cn.com.goldenwater.dcproj.param.BisInspPblmParam; import cn.com.goldenwater.dcproj.param.TypeParam; import cn.com.goldenwater.dcproj.service.BisInspObjStrategy; import cn.com.goldenwater.dcproj.service.BisInspOtherRgstrService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.utils.BeanUtil; import cn.com.goldenwater.id.util.UuidUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; 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; /** * @author lune * @date 2019-7-19 */ @Service @Transactional public class BisInspOtherRgstrServiceImpl extends AbstractCrudService implements BisInspOtherRgstrService,BisInspObjStrategy { @Autowired private BisInspOtherRgstrDao bisInspOtherRgstrDao; @Autowired private AttOtherBaseDao attOtherBaseDao; @Autowired private BisInspPblmDao bisInspPblmDao; @Autowired private BisInspAllObjDao bisInspAllObjDao; public BisInspOtherRgstrServiceImpl(BisInspOtherRgstrDao bisInspOtherRgstrDao) { super(bisInspOtherRgstrDao); this.bisInspOtherRgstrDao = bisInspOtherRgstrDao; } @Override public void insertObj(BisInspAllObj bisInspAllObj, String persId) { AttOtherBase attOtherBase = attOtherBaseDao.get(bisInspAllObj.getCode()); BisInspOtherRgstr otherRgstr = new BisInspOtherRgstr(attOtherBase); otherRgstr.setId(UuidUtil.uuid()); otherRgstr.setObjId(bisInspAllObj.getObjId()); otherRgstr.setName(attOtherBase.getName()); otherRgstr.setAdmOrg(attOtherBase.getAdmOrg()); otherRgstr.setAdCode(attOtherBase.getAdCode()); otherRgstr.setLocation(attOtherBase.getLocation()); otherRgstr.setType(attOtherBase.getType()); otherRgstr.setCenterX(attOtherBase.getCenterX()); otherRgstr.setCenterY(attOtherBase.getCenterY()); otherRgstr.setGdX(attOtherBase.getGdX()); otherRgstr.setProvince(bisInspAllObj.getProvince()); otherRgstr.setGdY(attOtherBase.getGdY()); otherRgstr.setGroupId(bisInspAllObj.getId()); otherRgstr.setState("0"); otherRgstr.setDataStat("0"); otherRgstr.setInTm(new Date()); otherRgstr.setUpTm(new Date()); bisInspOtherRgstrDao.insert(otherRgstr); } @Override public String getType() { return BisInspEnum.OTHER.getValue(); } @Override public void cleanObjData(String objId) { BisInspOtherRgstrParam bisInspOtherRgstrParam = new BisInspOtherRgstrParam(); bisInspOtherRgstrParam.setObjId(objId); List list = bisInspOtherRgstrDao.findList(bisInspOtherRgstrParam); if (list.size() > 0) { String id = list.get(0).getId(); BisInspPblmParam bisInspPblmParam = new BisInspPblmParam(); bisInspPblmParam.setRegid(id); bisInspPblmParam.setObjType(BisInspEnum.OTHER.getValue()); this.bisInspPblmDao.deleteBy(bisInspPblmParam); BisInspOtherRgstr rgstr = bisInspOtherRgstrDao.get(id); bisInspOtherRgstrDao.delete(id); if (rgstr != null) { //删除督查对象 BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam(); bisInspAllObjParam.setObjId(objId); this.bisInspAllObjDao.deleteBy(bisInspAllObjParam); } } } @Override public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) { BisInspOtherRgstrParam bisInspFscRgstrParam=new BisInspOtherRgstrParam(); BeanUtil.copyObject1(typeParam,bisInspFscRgstrParam); return findPcPage(bisInspFscRgstrParam); } @Override public Object findObjListByType(TypeParam typeParam) { BisInspOtherRgstrParam bisInspFscRgstrParam=new BisInspOtherRgstrParam(); BeanUtil.copyObject1(typeParam,bisInspFscRgstrParam); List list = bisInspOtherRgstrDao.findPcPage(bisInspFscRgstrParam); setSsx(list); return null; } @Override public PageInfo findPcPage(BisInspOtherRgstrParam bisInspFscRgstrParam) { PageHelper.startPage(bisInspFscRgstrParam); List list = bisInspOtherRgstrDao.findPcPage(bisInspFscRgstrParam); setSsx(list); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } private void setSsx(List list){ if (list.size() > 0) { for (BisInspOtherRgstrDto 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()); } } } } } }