| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- package cn.com.goldenwater.dcproj.service.impl.ducha;
- 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.dao.BisInspHystpDao;
- import cn.com.goldenwater.dcproj.dto.BisInspHystpDto;
- import cn.com.goldenwater.dcproj.model.AttHystpBase;
- import cn.com.goldenwater.dcproj.model.BisInspAllObj;
- import cn.com.goldenwater.dcproj.model.BisInspHystp;
- import cn.com.goldenwater.dcproj.model.BisInspHystpBldflt;
- import cn.com.goldenwater.dcproj.model.BisInspHystpDuty;
- import cn.com.goldenwater.dcproj.model.BisInspHystpDvc;
- import cn.com.goldenwater.dcproj.model.BisInspHystpOthr;
- import cn.com.goldenwater.dcproj.model.BisInspHystpRun;
- import cn.com.goldenwater.dcproj.model.BisInspHystpSaf;
- import cn.com.goldenwater.dcproj.param.BisInspHystpBldfltParam;
- import cn.com.goldenwater.dcproj.param.BisInspHystpDutyParam;
- import cn.com.goldenwater.dcproj.param.BisInspHystpDvcParam;
- import cn.com.goldenwater.dcproj.param.BisInspHystpOthrParam;
- import cn.com.goldenwater.dcproj.param.BisInspHystpParam;
- import cn.com.goldenwater.dcproj.param.BisInspHystpRunParam;
- import cn.com.goldenwater.dcproj.param.BisInspHystpSafParam;
- import cn.com.goldenwater.dcproj.param.TypeParam;
- import cn.com.goldenwater.dcproj.service.AttHystpBaseService;
- import cn.com.goldenwater.dcproj.service.BisInspHystpBldfltService;
- import cn.com.goldenwater.dcproj.service.BisInspHystpDutyService;
- import cn.com.goldenwater.dcproj.service.BisInspHystpDvcService;
- import cn.com.goldenwater.dcproj.service.BisInspHystpOthrService;
- import cn.com.goldenwater.dcproj.service.BisInspHystpRunService;
- import cn.com.goldenwater.dcproj.service.BisInspHystpSafService;
- import cn.com.goldenwater.dcproj.service.BisInspHystpService;
- import cn.com.goldenwater.dcproj.service.BisInspPblmService;
- 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.lang.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- 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;
- import java.util.Optional;
- /**
- * @author lhc
- * @date 2022-3-23
- */
- @Service
- @Transactional
- public class BisInspHystpServiceImpl extends AbstractCrudService<BisInspHystp, BisInspHystpParam> implements BisInspHystpService {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private BisInspHystpDao bisInspHystpDao;
- @Autowired
- private AttHystpBaseService attHystpBaseService;
- @Autowired
- private BisInspHystpBldfltService bisInspHystpBldfltService;
- @Autowired
- private BisInspHystpDvcService bisInspHystpDvcService;
- @Autowired
- private BisInspHystpSafService bisInspHystpSafService;
- @Autowired
- private BisInspHystpRunService bisInspHystpRunService;
- @Autowired
- private BisInspHystpOthrService bisInspHystpOthrService;
- @Autowired
- private BisInspHystpDutyService bisInspHystpDutyService;
- @Autowired
- private BisInspPblmService bisInspPblmService;
- public BisInspHystpServiceImpl(BisInspHystpDao bisInspHystpDao) {
- super(bisInspHystpDao);
- this.bisInspHystpDao = bisInspHystpDao;
- }
- @Override
- public int insert(BisInspHystp bisInspHystp) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- bisInspHystp.setId(uuid);
- bisInspHystp.setIntm(new Date());
- bisInspHystp.setUptm(new Date());
- bisInspHystp.setDataStat("0");
- bisInspHystp.setState("0");
- bisInspHystp.setBldfltState("0");
- bisInspHystp.setDvcState("0");
- bisInspHystp.setDutyState("0");
- bisInspHystp.setSafState("0");
- bisInspHystp.setOthrState("0");
- bisInspHystp.setRunState("0");
- this.bisInspHystpBldfltService.insert(Builder.of(BisInspHystpBldflt::new)
- .with(BisInspHystpBldflt::setRgstrId, uuid)
- .build());
- this.bisInspHystpDvcService.insert(Builder.of(BisInspHystpDvc::new)
- .with(BisInspHystpDvc::setRgstrId, uuid)
- .build());
- this.bisInspHystpSafService.insert(Builder.of(BisInspHystpSaf::new)
- .with(BisInspHystpSaf::setRgstrId, uuid)
- .build());
- this.bisInspHystpRunService.insert(Builder.of(BisInspHystpRun::new)
- .with(BisInspHystpRun::setRgstrId, uuid)
- .build());
- this.bisInspHystpDutyService.insert(Builder.of(BisInspHystpDuty::new)
- .with(BisInspHystpDuty::setRgstrId, uuid)
- .build());
- this.bisInspHystpOthrService.insert(Builder.of(BisInspHystpOthr::new)
- .with(BisInspHystpOthr::setRgstrId, uuid)
- .build());
- return this.bisInspHystpDao.insert(bisInspHystp);
- }
- @Override
- public int update(BisInspHystp bisInspHystp) {
- if(StringUtils.isNotBlank(bisInspHystp.getObjId())){
- updateBase(bisInspHystp);
- }
- bisInspHystp.setUptm(new Date());
- // 更新登记表状态
- int rows = this.bisInspHystpDao.update(bisInspHystp);
- // 更新问题状态
- updatePblmState(bisInspHystp);
- return rows;
- }
- private void updatePblmState(BisInspHystp rgstr) {
- BisInspHystp r = get(rgstr.getId());
- if (r == null) {
- return;
- }
- logger.info("BisInspHystp:" + r.toString());
- bisInspPblmService.updateStateByObjId(r.getObjId(), rgstr.getState());
- }
- /**
- * 更新基础表
- */
- void updateBase(BisInspHystp bisInspHystp) {
- AttHystpBase base = attHystpBaseService.getObjId(bisInspHystp.getObjId());
- Optional.ofNullable(base).ifPresent(b -> {
- String id = b.getId();
- BeanUtils.copyProperties(bisInspHystp, b);
- b.setId(id);
- b.setIntm(null);
- attHystpBaseService.update(b);
- });
- }
- @Override
- public int delete(String id) {
- return this.bisInspHystpDao.delete(id);
- }
- @Override
- public void updateState(Map<String, Object> map) {
- BisInspHystp rgstr = get(MapUtils.getString(map, "rgstrId"));
- if (!Constant.STRING_TWO.equals(rgstr.getState())) {
- rgstr.setUptm(new Date());
- rgstr.setState(Constant.STRING_ONE);
- if ("bldflt".equals(MapUtils.getString(map, "param"))) {
- if (StringUtils.isBlank(rgstr.getBldfltState()) &&
- !"2".equals(MapUtils.getString(map, "state"))) {
- map.put("state", "1");
- }
- if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
- rgstr.setBldfltState(MapUtils.getString(map, "state"));
- }
- }
- if ("duty".equals(MapUtils.getString(map, "param"))) {
- if (StringUtils.isBlank(rgstr.getDutyState()) &&
- !"2".equals(MapUtils.getString(map, "state"))) {
- map.put("state", "1");
- }
- if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
- rgstr.setDutyState(MapUtils.getString(map, "state"));
- }
- }
- if ("dvc".equals(MapUtils.getString(map, "param"))) {
- if (StringUtils.isBlank(rgstr.getDvcState()) &&
- !"2".equals(MapUtils.getString(map, "state"))) {
- map.put("state", "1");
- }
- if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
- rgstr.setDvcState(MapUtils.getString(map, "state"));
- }
- }
- if ("run".equals(MapUtils.getString(map, "param"))) {
- if (StringUtils.isBlank(rgstr.getRunState()) &&
- !"2".equals(MapUtils.getString(map, "state"))) {
- map.put("state", "1");
- }
- if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
- rgstr.setRunState(MapUtils.getString(map, "state"));
- }
- }
- if ("saf".equals(MapUtils.getString(map, "param"))) {
- if (StringUtils.isBlank(rgstr.getSafState()) &&
- !"2".equals(MapUtils.getString(map, "state"))) {
- map.put("state", "1");
- }
- if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
- rgstr.setSafState(MapUtils.getString(map, "state"));
- }
- }
- if ("othr".equals(MapUtils.getString(map, "param"))) {
- if (StringUtils.isBlank(rgstr.getOthrState()) &&
- !"2".equals(MapUtils.getString(map, "state"))) {
- map.put("state", "1");
- }
- if (StringUtils.isNotBlank(MapUtils.getString(map, "state"))) {
- rgstr.setOthrState(MapUtils.getString(map, "state"));
- }
- }
- update(rgstr);
- }
- }
- @Override
- public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
- BisInspHystp b = new BisInspHystp();
- AttHystpBase base = attHystpBaseService.get(bisInspAllObj.getCode());
- BeanUtils.copyProperties(base, b);
- b.setObjId(bisInspAllObj.getObjId());
- // b.setPersId(bisInspAllObj.getPersId());
- // 添加 登记表
- insert(b);
- }
- @Override
- public String getType() {
- return BisInspEnum.HYSTP.getValue();
- }
- @Override
- public void cleanObjData(String objId) {
- BisInspHystpParam rgstrParam = new BisInspHystpParam();
- rgstrParam.setObjId(objId);
- List<BisInspHystp> list = this.bisInspHystpDao.findList(rgstrParam);
- if (list.size() > 0) {
- String id = list.get(0).getId();
- // 删除子表
- this.bisInspHystpBldfltService.deleteBy(Builder.of(BisInspHystpBldfltParam::new).with(BisInspHystpBldfltParam::setRgstrId, id).build());
- this.bisInspHystpDvcService.deleteBy(Builder.of(BisInspHystpDvcParam::new).with(BisInspHystpDvcParam::setRgstrId, id).build());
- this.bisInspHystpSafService.deleteBy(Builder.of(BisInspHystpSafParam::new).with(BisInspHystpSafParam::setRgstrId, id).build());
- this.bisInspHystpRunService.deleteBy(Builder.of(BisInspHystpRunParam::new).with(BisInspHystpRunParam::setRgstrId, id).build());
- this.bisInspHystpOthrService.deleteBy(Builder.of(BisInspHystpOthrParam::new).with(BisInspHystpOthrParam::setRgstrId, id).build());
- this.bisInspHystpDutyService.deleteBy(Builder.of(BisInspHystpDutyParam::new).with(BisInspHystpDutyParam::setRgstrId, id).build());
- // 删除登记表
- this.bisInspHystpDao.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);
- List<BisInspHystpDto> list = this.bisInspHystpDao.findPageList(typeParam);
- if (list != null && list.size() > 0) {
- list.forEach(rgstrDto -> {
- if (StringUtils.isNotBlank(rgstrDto.getAdFullName())) {
- String[] adFullNames = rgstrDto.getAdFullName().split("-");
- rgstrDto.setProName(adFullNames[0]);
- if (adFullNames.length > 1) {
- rgstrDto.setCityName(adFullNames[1]);
- }
- if (adFullNames.length > 2) {
- rgstrDto.setCountyName(adFullNames[2]);
- }
- }
- });
- }
- return new PageInfo<>(list);
- }
- @Override
- public Object findObjListByType(TypeParam typeParam) {
- return null;
- }
- }
|