| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- package cn.com.goldenwater.dcproj.service.impl;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- 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.dto.BisInspWintuRgstrVo;
- import cn.com.goldenwater.dcproj.model.*;
- import cn.com.goldenwater.dcproj.param.*;
- import cn.com.goldenwater.dcproj.service.BisInspObjStrategy;
- import cn.com.goldenwater.dcproj.service.BisInspWintuRgstrService;
- import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
- import cn.com.goldenwater.dcproj.utils.GeoUtil;
- import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
- import cn.com.goldenwater.dcproj.utils.impexcel.WintuFieldFromatExp;
- import cn.com.goldenwater.id.util.UuidUtil;
- import cn.com.goldenwater.util.common.InspPblmUtils;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.apache.commons.collections.CollectionUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import javax.servlet.http.HttpServletResponse;
- import java.io.File;
- import java.util.*;
- import static cn.com.goldenwater.dcproj.utils.impexcel.field.ExcelFieldLists.bisInspRgstrArrays;
- import static cn.com.goldenwater.dcproj.utils.impexcel.field.ExcelFieldLists.bisInspWintuMendLiftArrays;
- /**
- * @author lune
- * @date 2020-7-15
- */
- @Service
- @Transactional(rollbackFor = Exception.class)
- public class BisInspWintuRgstrServiceImpl extends AbstractCrudService<BisInspWintuRgstr, BisInspWintuRgstrParam> implements BisInspWintuRgstrService, BisInspObjStrategy {
- @Autowired
- private BisInspWintuRgstrDao bisInspWintuRgstrDao;
- @Autowired
- private AttWintBaseDao attWintBaseDao;
- @Autowired
- private BisInspPblmDao bisInspPblmDao;
- @Autowired
- private BisInspAllObjDao bisInspAllObjDao;
- @Autowired
- private BisInspWintRgstrMendLiftDao bisInspWintRgstrMendLiftDao;
- @Autowired
- private BisInspWintRgstrChkInDao bisInspWintRgstrChkInDao;
- @Value("${export.templatePath}")
- private String templatePath;
- public BisInspWintuRgstrServiceImpl(BisInspWintuRgstrDao bisInspWintuRgstrDao) {
- super(bisInspWintuRgstrDao);
- this.bisInspWintuRgstrDao = bisInspWintuRgstrDao;
- }
- public String getAdCode(String regid) {
- return null;
- }
- @Override
- public PageInfo<BisInspRgstrDto> findWintuPage(TypeParam param) {
- if (StringUtils.isNotBlank(param.getAdCode())) {
- param.setAdCode(String.valueOf(AdLevelUtil.SubAd(param.getAdCode()).get(SplitValue.SUBAD)));
- }
- if (StringUtils.isNotBlank(param.getAdCodes())) {
- param.setAdCodes(AdLevelUtil.getListAddvcd(param.getAdCodes()));
- }
- PageHelper.startPage(param);
- List<BisInspRgstrDto> list = bisInspWintuRgstrDao.findWintuPage(param);
- list = InspPblmUtils.changeList(list);
- return new PageInfo(list);
- }
- @Override
- public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
- return this.findWintuPage(typeParam);
- }
- @Override
- public Object findObjListByType(TypeParam typeParam) {
- List<BisInspRgstrDto> list = bisInspWintuRgstrDao.findWintuPage(typeParam);
- return InspPblmUtils.changeList(list);
- }
- @Override
- public String getType() {
- return BisInspEnum.WINTU.getValue();
- }
- @Override
- public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
- AttWintBase attWintBase = attWintBaseDao.get(bisInspAllObj.getCode());
- BisInspWintuRgstr rgstr = new BisInspWintuRgstr();
- BeanUtils.copyProperties(attWintBase, rgstr);
- rgstr.setId(UuidUtil.uuid());
- rgstr.setWinId(attWintBase.getId());
- rgstr.setWinName(attWintBase.getWintName());
- rgstr.setObjId(bisInspAllObj.getObjId());
- rgstr.setInTm(new Date());
- rgstr.setUpTm(new Date());
- rgstr.setChkInStat(StateEnum.NOWASTSTATE.getKey());
- rgstr.setMendLiftStat(StateEnum.NOWASTSTATE.getKey());
- rgstr.setWiuLoc(attWintBase.getWintPos());
- rgstr.setCenterX(attWintBase.getWainLong());
- rgstr.setCenterY(attWintBase.getWainLat());
- if (rgstr.getCenterX() != null && rgstr.getCenterY() != null) {
- Map<String, Double> map = GeoUtil.wgs84togcj02(rgstr.getCenterX(), rgstr.getCenterY());
- rgstr.setGdX(map.get("lon"));
- rgstr.setGdY(map.get("lat"));
- }
- rgstr.setPersId(persId);
- bisInspWintuRgstrDao.insert(rgstr);
- }
- @Override
- public void cleanObjData(String objId) {
- BisInspWintuRgstrParam wintuRgstrParam = new BisInspWintuRgstrParam();
- wintuRgstrParam.setObjId(objId);
- List<BisInspWintuRgstr> list = this.bisInspWintuRgstrDao.findList(wintuRgstrParam);
- if (CollectionUtils.isNotEmpty(list)) {
- String id = list.get(0).getId();
- //删除问题
- BisInspPblmParam bisInspPblmParam = new BisInspPblmParam();
- bisInspPblmParam.setObjId(objId);
- bisInspPblmParam.setObjType(BisInspEnum.WINTU.getValue());
- this.bisInspPblmDao.deleteBy(bisInspPblmParam);
- //删除对象名录表
- BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
- bisInspAllObjParam.setObjId(objId);
- this.bisInspAllObjDao.deleteBy(bisInspAllObjParam);
- BisInspWintRgstrMendLiftParam mendLiftParam = new BisInspWintRgstrMendLiftParam();
- mendLiftParam.setRgstrId(id);
- bisInspWintRgstrMendLiftDao.deleteBy(mendLiftParam);
- BisInspWintRgstrChkInParam chkInParam = new BisInspWintRgstrChkInParam();
- chkInParam.setRgstrId(id);
- bisInspWintRgstrChkInDao.deleteBy(chkInParam);
- }
- }
- /**
- * 获取取水许可信息
- *
- * @param id 登记表ID
- * @return
- */
- @Override
- public Aqsxkspqk findPermissionInfo(String id) {
- return bisInspWintuRgstrDao.findPermissionInfo(id);
- }
- /**
- * 获取问题信息
- *
- * @param id 登记表ID
- * @return
- */
- @Override
- public Aqsxkspqk findIssueInfo(String id) {
- return bisInspWintuRgstrDao.findIssueInfo(id);
- }
- @Override
- public void downloadTemplate(HttpServletResponse response, TypeParam param) throws Exception {
- List<BisInspWintuRgstrVo> bisInspWintuRgstrVos = new ArrayList();
- // 模板路径
- String filePath = templatePath + File.separator + "pblmQysdc_tb.xls";
- // SHEET名称
- String sheetName = "取用水督查填报";
- // startRow
- int startRow = 2;
- if (StringUtils.isBlank(param.getPlnaId())) {
- List<Map<String, Object>> list = new ArrayList<>();
- ExpAndImpUtil.download(response, list, filePath, startRow, sheetName);
- }
- List<BisInspRgstrDto> list = bisInspWintuRgstrDao.findWintuPage(param);
- list = InspPblmUtils.changeList(list);
- for (BisInspRgstrDto bisInspRgstrDto : list) {
- BisInspWintuRgstrVo vo = new BisInspWintuRgstrVo();
- //登记表
- vo.setBisInspRgstrDto(bisInspRgstrDto);
- String rgstrId = bisInspRgstrDto.getRgstrId();
- //整改提升
- BisInspWintRgstrMendLiftParam mendLiftParam = new BisInspWintRgstrMendLiftParam();
- mendLiftParam.setRgstrId(rgstrId);
- BisInspWintRgstrMendLift mendLift = bisInspWintRgstrMendLiftDao.getBy(mendLiftParam);
- vo.setBisInspWintRgstrMendLift(mendLift);
- bisInspWintuRgstrVos.add(vo);
- }
- List<Map<String, Object>> dataList = new LinkedList<>();
- for (BisInspWintuRgstrVo vo : bisInspWintuRgstrVos) {
- Map<String, Object> map = new HashMap<>();
- BisInspRgstrDto bisInspRgstrDto = vo.getBisInspRgstrDto();
- ExpAndImpUtil.convertBeanToMap(bisInspRgstrDto, bisInspRgstrArrays, map, WintuFieldFromatExp.class);
- //整改提升
- BisInspWintRgstrMendLift bisInspWintRgstrMendLift = vo.getBisInspWintRgstrMendLift();
- ExpAndImpUtil.convertBeanToMap(bisInspWintRgstrMendLift, bisInspWintuMendLiftArrays, map, WintuFieldFromatExp.class);
- dataList.add(map);
- }
- ExpAndImpUtil.download(response, dataList, filePath, startRow, sheetName);
- }
- @Override
- public void insertIntoData(List<LinkedHashMap<String, Object>> showDataList, FileParam param) throws Exception {
- String persId = param.getPersId();
- for (LinkedHashMap<String, Object> map : showDataList) {
- String rgstrId = "";
- BisInspRgstrDto bisInspRgstrDto = (BisInspRgstrDto) ExpAndImpUtil.convertMapToBean(BisInspRgstrDto.class, map);
- if (StringUtils.isNotBlank(bisInspRgstrDto.getRgstrId())) {
- rgstrId = bisInspRgstrDto.getRgstrId();
- BisInspWintuRgstr wintuRgstr = new BisInspWintuRgstr();
- BeanUtils.copyProperties(bisInspRgstrDto, wintuRgstr);
- wintuRgstr.setPersId(persId);
- wintuRgstr.setUpTm(new Date());
- wintuRgstr.setId(rgstrId);
- bisInspWintuRgstrDao.update(wintuRgstr);
- } else {
- String id = UuidUtil.uuid();
- rgstrId = id;
- BisInspWintuRgstr wintuRgstr = new BisInspWintuRgstr();
- BeanUtils.copyProperties(bisInspRgstrDto, wintuRgstr);
- AttWintBaseParam attWintBaseParam = new AttWintBaseParam();
- attWintBaseParam.setWintName(bisInspRgstrDto.getNm());
- List<AttWintBase> attWintBases = attWintBaseDao.findList(attWintBaseParam);
- if (CollectionUtils.isEmpty(attWintBases)) {
- continue;
- }
- AttWintBase attWintBase = attWintBases.get(0);
- BeanUtils.copyProperties(attWintBase, wintuRgstr);
- String ObjUuid = UuidUtil.uuid();
- BisInspAllObj bisInspAllObj = new BisInspAllObj();
- bisInspAllObj.setCode(attWintBase.getId());
- bisInspAllObj.setId(param.getGroupId());
- bisInspAllObj.setNm(attWintBase.getWintName());
- bisInspAllObj.setLgtd(attWintBase.getWainLong());
- bisInspAllObj.setLttd(attWintBase.getWainLat());
- bisInspAllObj.setObjId(ObjUuid);
- bisInspAllObj.setPtype("31");
- bisInspAllObjDao.insert(bisInspAllObj);
- wintuRgstr.setId(rgstrId);
- wintuRgstr.setWinName(bisInspRgstrDto.getNm());
- wintuRgstr.setPersId(persId);
- wintuRgstr.setInTm(new Date());
- wintuRgstr.setUpTm(new Date());
- wintuRgstr.setObjId(ObjUuid);
- bisInspWintuRgstrDao.insert(wintuRgstr);
- }
- if (StringUtils.isBlank(rgstrId)) {
- continue;
- }
- BisInspWintRgstrMendLift mendLift = (BisInspWintRgstrMendLift) ExpAndImpUtil.convertMapToBean(BisInspWintRgstrMendLift.class, map);
- BisInspWintRgstrMendLiftParam mendLiftParam = new BisInspWintRgstrMendLiftParam();
- mendLiftParam.setRgstrId(rgstrId);
- List<BisInspWintRgstrMendLift> mendLiftList = bisInspWintRgstrMendLiftDao.findList(mendLiftParam);
- if (CollectionUtils.isNotEmpty(mendLiftList)) {
- mendLift.setId(mendLiftList.get(0).getId());
- mendLift.setUptm(new Date());
- mendLift.setRecPersId(persId);
- bisInspWintRgstrMendLiftDao.update(mendLift);
- } else {
- mendLift.setId(UuidUtil.uuid());
- mendLift.setUptm(new Date());
- mendLift.setIntm(new Date());
- mendLift.setRecPersId(persId);
- bisInspWintRgstrMendLiftDao.insert(mendLift);
- }
- }
- }
- }
|