| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- 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.BisInspAllRlationDao;
- import cn.com.goldenwater.dcproj.dao.BisInspRsfcoqhRgstrDao;
- import cn.com.goldenwater.dcproj.dto.BisInspRsfcoqhRgstrDto;
- import cn.com.goldenwater.dcproj.model.AttRsBase;
- import cn.com.goldenwater.dcproj.model.BisInspAllObj;
- import cn.com.goldenwater.dcproj.model.BisInspRsfcoqhRgstr;
- import cn.com.goldenwater.dcproj.param.BisInspAllRlationParam;
- import cn.com.goldenwater.dcproj.param.BisInspRsfcoqhRgstrParam;
- import cn.com.goldenwater.dcproj.param.TypeParam;
- import cn.com.goldenwater.dcproj.service.AttAdXBaseService;
- import cn.com.goldenwater.dcproj.service.AttRsBaseService;
- import cn.com.goldenwater.dcproj.service.BisInspObjStrategy;
- import cn.com.goldenwater.dcproj.service.BisInspRsfcoqhRgstrService;
- 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.Date;
- import java.util.List;
- import java.util.Map;
- /**
- * @author lhc
- * @date 2021-6-10
- */
- @Service
- @Transactional
- public class BisInspRsfcoqhRgstrServiceImpl extends AbstractCrudService<BisInspRsfcoqhRgstr, BisInspRsfcoqhRgstrParam> implements BisInspRsfcoqhRgstrService, BisInspObjStrategy {
- @Autowired
- private BisInspRsfcoqhRgstrDao bisInspRsfcoqhRgstrDao;
- @Autowired
- private AttAdXBaseService attAdXBaseService;
- @Autowired
- private AttRsBaseService attRsBaseService;
- @Autowired
- private BisInspAllRlationDao bisInspAllRlationDao;
- public BisInspRsfcoqhRgstrServiceImpl(BisInspRsfcoqhRgstrDao bisInspRsfcoqhRgstrDao) {
- super(bisInspRsfcoqhRgstrDao);
- this.bisInspRsfcoqhRgstrDao = bisInspRsfcoqhRgstrDao;
- }
- @Override
- public int insert(BisInspRsfcoqhRgstr bisInspRsfcoqhRgstr) {
- String uuid = UuidUtil.uuid();
- bisInspRsfcoqhRgstr.setId(uuid);
- // 日期
- Date d = new Date();
- bisInspRsfcoqhRgstr.setIntm(d);
- bisInspRsfcoqhRgstr.setUptm(d);
- // 数据状态 默认为 0
- bisInspRsfcoqhRgstr.setDataStat(CommonLabel.INIT_DATA);
- // 督查状态(0:未督查;1:督查中;2:已督查)
- bisInspRsfcoqhRgstr.setState(CommonLabel.INIT_DATA);
- return this.bisInspRsfcoqhRgstrDao.insert(bisInspRsfcoqhRgstr);
- }
- @Override
- public int update(BisInspRsfcoqhRgstr bisInspRsfcoqhRgstr) {
- bisInspRsfcoqhRgstr.setUptm(new Date());
- return this.bisInspRsfcoqhRgstrDao.update(bisInspRsfcoqhRgstr);
- }
- @Override
- public int delete(String id) {
- return this.bisInspRsfcoqhRgstrDao.delete(id);
- }
- @Override
- public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
- BisInspRsfcoqhRgstr b = new BisInspRsfcoqhRgstr();
- AttRsBase base = attRsBaseService.get(bisInspAllObj.getCode());
- BeanUtils.copyProperties(base, b);
- b.setObjId(bisInspAllObj.getObjId());
- b.setAdName(base.getAdmDivName());
- b.setDamType(base.getDamType());
- b.setGdX(StringUtils.isNotBlank(base.getCenterXGd()) ? Double.parseDouble(base.getCenterXGd()) : null);
- b.setGdY(StringUtils.isNotBlank(base.getCenterYGd()) ? Double.parseDouble(base.getCenterYGd()) : null);
- b.setDamRegCode(base.getRegCode());
- b.setHasDamRegCode(StringUtils.isBlank(base.getRegCode()) ? "2" : "1");
- b.setAdCode(base.getAdmDiv());
- /* 添加 登记表 */
- insert(b);
- }
- @Override
- public String getType() {
- return BisInspEnum.RSFCOQH.getValue();
- }
- @Override
- public void cleanObjData(String objId) {
- BisInspRsfcoqhRgstrParam rgstrParam = new BisInspRsfcoqhRgstrParam();
- rgstrParam.setObjId(objId);
- List<BisInspRsfcoqhRgstr> list = this.bisInspRsfcoqhRgstrDao.findList(rgstrParam);
- if (list.size() > 0) {
- String id = list.get(0).getId();
- // 删除登记表
- this.bisInspRsfcoqhRgstrDao.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<BisInspRsfcoqhRgstrDto> list = this.bisInspRsfcoqhRgstrDao.findPageList(typeParam);
- return (PageInfo<BisInspRsfcoqhRgstrDto>) new PageInfo(list);
- }
- @Override
- public void updateState(Map<String, Object> map) {
- BisInspRsfcoqhRgstr 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);
- if ("pres".equals(MapUtils.getString(map, "param"))) {
- rgstr.setPresState(MapUtils.getString(map, "state"));
- }
- update(rgstr);
- }
- }
- @Override
- public Object findObjListByType(TypeParam typeParam) {
- return this.bisInspRsfcoqhRgstrDao.findPageList(typeParam);
- }
- }
|