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.BisInspWrwxRgstrDto; 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.id.util.UuidUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; 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; /** * @author lhc * @date 2020-9-23 */ @Service @Transactional public class BisInspWrwxRgstrServiceImpl extends AbstractCrudService implements BisInspWrwxRgstrService, BisInspObjStrategy { @Autowired private BisInspWrwxRgstrDao bisInspWrwxRgstrDao; @Autowired private AttAdBaseDao attAdBaseDao; @Autowired private BisInspWrwxRgstrSvwtcService bisInspWrwxRgstrSvwtcService; @Autowired private BisInspWrwxRgstrWgService bisInspWrwxRgstrWgService; @Autowired private BisInspWrwxRgstrWtupService bisInspWrwxRgstrWtupService; @Autowired private BisInspWrwxRgstrWtutService bisInspWrwxRgstrWtutService; @Autowired private BisInspPblmDao bisInspPblmDao; @Autowired private BisInspAllObjDao bisInspAllObjDao; public BisInspWrwxRgstrServiceImpl(BisInspWrwxRgstrDao bisInspWrwxRgstrDao) { super(bisInspWrwxRgstrDao); this.bisInspWrwxRgstrDao = bisInspWrwxRgstrDao; } @Override public int insert(BisInspWrwxRgstr bisInspWrwxRgstr) { // 生成uuid String uuid = UuidUtil.uuid(); bisInspWrwxRgstr.setId(uuid); bisInspWrwxRgstr.setIntm(new Date()); bisInspWrwxRgstr.setUptm(new Date()); bisInspWrwxRgstr.setDataStat("0"); return this.bisInspWrwxRgstrDao.insert(bisInspWrwxRgstr); } @Override public int update(BisInspWrwxRgstr bisInspWrwxRgstr) { bisInspWrwxRgstr.setUptm(new Date()); return this.bisInspWrwxRgstrDao.update(bisInspWrwxRgstr); } @Override public int delete(String id) { return this.bisInspWrwxRgstrDao.delete(id); } @Override public void insertObj(BisInspAllObj bisInspAllObj, String persId) { BisInspWrwxRgstr b = new BisInspWrwxRgstr(); AttAdBase base = attAdBaseDao.get(bisInspAllObj.getCode()); BeanUtils.copyProperties(base, b); // 统一字段 rgstrId, objId b.setId(UuidUtil.uuid()); b.setObjId(bisInspAllObj.getObjId()); // 日期 Date d = new Date(); b.setIntm(d); b.setUptm(d); // 数据状态 默认为 0 b.setDataStat(CommonLabel.INIT_DATA); // 督查状态(0:未督查;1:督查中;2:已督查) b.setState(CommonLabel.INIT_DATA); // 子表状态(0:未督查;1:督查中;2:已督查) b.setSvwtcState(CommonLabel.INIT_DATA); b.setWgState(CommonLabel.INIT_DATA); b.setWtupState(CommonLabel.INIT_DATA); b.setWtutState(CommonLabel.INIT_DATA); // 创建人 b.setPersId(persId); /* 添加 登记表 */ this.bisInspWrwxRgstrDao.insert(b); /* 添加 子表 */ BisInspWrwxRgstrSvwtc bisInspWrwxRgstrSvwtc = new BisInspWrwxRgstrSvwtc(); bisInspWrwxRgstrSvwtc.setRgstrId(b.getId()); bisInspWrwxRgstrSvwtcService.insert(bisInspWrwxRgstrSvwtc); BisInspWrwxRgstrWg bisInspWrwxRgstrWg = new BisInspWrwxRgstrWg(); bisInspWrwxRgstrWg.setRgstrId(b.getId()); bisInspWrwxRgstrWgService.insert(bisInspWrwxRgstrWg); BisInspWrwxRgstrWtup bisInspWrwxRgstrWtup = new BisInspWrwxRgstrWtup(); bisInspWrwxRgstrWtup.setRgstrId(b.getId()); bisInspWrwxRgstrWtupService.insert(bisInspWrwxRgstrWtup); BisInspWrwxRgstrWtut bisInspWrwxRgstrWtut = new BisInspWrwxRgstrWtut(); bisInspWrwxRgstrWtut.setRgstrId(b.getId()); bisInspWrwxRgstrWtutService.insert(bisInspWrwxRgstrWtut); } @Override public String getType() { return BisInspEnum.WRWX.getValue(); } @Override public void cleanObjData(String objId) { BisInspWrwxRgstrParam rgstrParam = new BisInspWrwxRgstrParam(); rgstrParam.setObjId(objId); List list = this.bisInspWrwxRgstrDao.findList(rgstrParam); if (list.size() > 0) { String id = list.get(0).getId(); // 删除子表 BisInspWrwxRgstrSvwtcParam svwtcParam = new BisInspWrwxRgstrSvwtcParam(); svwtcParam.setRgstrId(id); bisInspWrwxRgstrSvwtcService.deleteBy(svwtcParam); BisInspWrwxRgstrWtutParam wtutParam = new BisInspWrwxRgstrWtutParam(); wtutParam.setRgstrId(id); bisInspWrwxRgstrWtutService.deleteBy(wtutParam); BisInspWrwxRgstrWgParam wgParam = new BisInspWrwxRgstrWgParam(); wgParam.setRgstrId(id); bisInspWrwxRgstrWgService.deleteBy(wgParam); BisInspWrwxRgstrWtupParam wtupParam = new BisInspWrwxRgstrWtupParam(); wtupParam.setRgstrId(id); bisInspWrwxRgstrWtupService.deleteBy(wtupParam); // 删除登记表 this.bisInspWrwxRgstrDao.delete(id); } // 删除问题 BisInspPblmParam bisInspPblmParam = new BisInspPblmParam(); bisInspPblmParam.setObjId(objId); bisInspPblmParam.setObjType(getType()); bisInspPblmDao.deleteBy(bisInspPblmParam); // 删除对象名录表 BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam(); bisInspAllObjParam.setObjId(objId); bisInspAllObjDao.deleteBy(bisInspAllObjParam); } @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 list = this.bisInspWrwxRgstrDao.findPageList(typeParam); return (PageInfo) new PageInfo(list); } @Override public Object findObjListByType(TypeParam typeParam) { return this.bisInspWrwxRgstrDao.findPageList(typeParam); } }