| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- 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.CommonLabel;
- import cn.com.goldenwater.dcproj.constValue.SplitValue;
- import cn.com.goldenwater.dcproj.dao.*;
- import cn.com.goldenwater.dcproj.dto.AttCountryDto;
- import cn.com.goldenwater.dcproj.dto.BisInspVillqhRgstrDto;
- import cn.com.goldenwater.dcproj.model.*;
- import cn.com.goldenwater.dcproj.param.*;
- import cn.com.goldenwater.dcproj.service.*;
- import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
- import cn.com.goldenwater.dcproj.utils.Builder;
- import cn.com.goldenwater.dcproj.utils.Constant;
- import cn.com.goldenwater.id.util.UuidUtil;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.apache.commons.collections.MapUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- 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.*;
- /**
- * @author lhc
- * @date 2021-2-1
- */
- @Service
- @Transactional
- public class BisInspVillqhRgstrServiceImpl extends AbstractCrudService<BisInspVillqhRgstr, BisInspVillqhRgstrParam> implements BisInspVillqhRgstrService, BisInspObjStrategy {
- @Autowired
- private BisInspVillqhRgstrDao bisInspVillqhRgstrDao;
- @Autowired
- private AttAdXBaseDao attAdXBaseDao;
- @Autowired
- private BisInspVillqhFeeService feeService;
- @Autowired
- private BisInspVillqhPoorService poorService;
- @Autowired
- private BisInspVillqhRgstrRelVillService relVillService;
- @Autowired
- private BisInspPblmDao bisInspPblmDao;
- @Autowired
- private BisInspAllObjDao bisInspAllObjDao;
- @Autowired
- private BisInspAllRlationDao bisInspAllRlationDao;
- public BisInspVillqhRgstrServiceImpl(BisInspVillqhRgstrDao bisInspVillqhRgstrDao) {
- super(bisInspVillqhRgstrDao);
- this.bisInspVillqhRgstrDao = bisInspVillqhRgstrDao;
- }
- @Override
- public int insert(BisInspVillqhRgstr bisInspVillqhRgstr) {
- bisInspVillqhRgstr.setId(UuidUtil.uuid());
- Date now = new Date();
- bisInspVillqhRgstr.setIntm(now);
- bisInspVillqhRgstr.setUptm(now);
- // 数据状态 默认为 0
- // 督查状态(0:未督查;1:督查中;2:已督查)
- bisInspVillqhRgstr.setState(CommonLabel.INIT_DATA);
- // 子表状态(0:未督查;1:督查中;2:已督查)
- bisInspVillqhRgstr.setFeeState(CommonLabel.INIT_DATA);
- bisInspVillqhRgstr.setPoorState(CommonLabel.INIT_DATA);
- return this.bisInspVillqhRgstrDao.insert(bisInspVillqhRgstr);
- }
- @Override
- public int update(BisInspVillqhRgstr bisInspVillqhRgstr) {
- bisInspVillqhRgstr.setUptm(new Date());
- return this.bisInspVillqhRgstrDao.update(bisInspVillqhRgstr);
- }
- @Override
- public int delete(String id) {
- return this.bisInspVillqhRgstrDao.delete(id);
- }
- @Override
- public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
- BisInspVillqhRgstr b = new BisInspVillqhRgstr();
- AttAdXBase base = attAdXBaseDao.get(bisInspAllObj.getCode());
- BeanUtils.copyProperties(base, b);
- b.setObjId(bisInspAllObj.getObjId());
- // 创建人
- b.setPersId(persId);
- /* 添加 登记表 */
- insert(b);
- }
- @Override
- public String getType() {
- return BisInspEnum.VILLQH.getValue();
- }
- @Override
- public void cleanObjData(String objId) {
- BisInspVillqhRgstrParam rgstrParam = new BisInspVillqhRgstrParam();
- rgstrParam.setObjId(objId);
- List<BisInspVillqhRgstr> list = this.bisInspVillqhRgstrDao.findList(rgstrParam);
- if (list.size() > 0) {
- String id = list.get(0).getId();
- // 删除子表
- BisInspVillqhRgstrRelVillParam relVillParam = new BisInspVillqhRgstrRelVillParam();
- relVillParam.setRegstrId(id);
- relVillService.deleteBy(relVillParam);
- // 删除登记表
- this.bisInspVillqhRgstrDao.delete(id);
- }
- }
- @Override
- public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
- if (StringUtils.isNotBlank(typeParam.getAdCode())) {
- typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
- }
- PageHelper.startPage(typeParam);
- String[] groupIds = bisInspAllRlationDao.getIdByPersid(Builder
- .of(BisInspAllRlationParam::new)
- .with(BisInspAllRlationParam::setPersid, typeParam.getPresId())
- .with(BisInspAllRlationParam::setpType, typeParam.getpType())
- .build());
- typeParam.setGroupIds(groupIds);
- List<BisInspVillqhRgstrDto> list = this.bisInspVillqhRgstrDao.findPageList(typeParam);
- return (PageInfo<BisInspVillqhRgstrDto>) new PageInfo(list);
- }
- @Override
- public Object findObjListByType(TypeParam typeParam) {
- return this.bisInspVillqhRgstrDao.findPageList(typeParam);
- }
- @Override
- public Map<String, Object> findNode(String adCode, String regstrId) {
- Map<String, Object> map = new HashMap<>(2);
- adCode = AdLevelUtil.getAddvcd(adCode);
- // 获取工程暗访情况
- BisInspVillqhFeeParam feeParam = Builder.of(BisInspVillqhFeeParam::new)
- .with(BisInspVillqhFeeParam::setRegstrId, regstrId)
- .with(BisInspVillqhFeeParam::setAdCode, adCode)
- .build();
- List<BisInspVillqhFee> feeList = feeService.findList(feeParam);
- // 获取农牧民情况
- BisInspVillqhPoorParam poorParam = Builder.of(BisInspVillqhPoorParam::new)
- .with(BisInspVillqhPoorParam::setRegstrId, regstrId)
- .with(BisInspVillqhPoorParam::setAdCode, adCode)
- .build();
- List<BisInspVillqhPoor> poorList = poorService.findList(poorParam);
- map.put("poor", poorList);
- map.put("fee", feeList);
- return map;
- }
- @Override
- public List<AttCountryDto> findCheckTree(String code, String regstrId) {
- // 获取镇信息
- List<AttCountryDto> zhenDtoList = attAdXBaseDao.findXZCZhenList(code);
- // 获取村信息
- List<AttCountryDto> countryDtoList = attAdXBaseDao.findXZCCunList(code, regstrId, BisInspEnum.VILLQH.getValue());
- for (AttCountryDto attCountryDto : zhenDtoList) {
- String adCode = attCountryDto.getAdCode().replace("000", "");
- List<AttCountryDto> childList = new ArrayList<>();
- for (AttCountryDto countryDto : countryDtoList) {
- if (countryDto.getAdCode().startsWith(adCode)) {
- childList.add(countryDto);
- }
- }
- attCountryDto.setAttCountryDtoList(childList);
- }
- return zhenDtoList;
- }
- @Override
- public void updateState(Map<String, Object> map) {
- BisInspVillqhRgstr rgstr = get(MapUtils.getString(map, "rgstrId"));
- if (!Constant.STRING_TWO.equals(rgstr.getState()) &&
- StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
- rgstr.setUptm(new Date());
- rgstr.setState(Constant.STRING_ONE);
- switch (MapUtils.getString(map, "param")) {
- case "fee":
- rgstr.setFeeState(MapUtils.getString(map, "state"));
- break;
- case "poor":
- rgstr.setPoorState(MapUtils.getString(map, "state"));
- break;
- default:
- }
- update(rgstr);
- }
- }
- }
|