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.BisInspWrwsRgstrDto; 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 BisInspWrwsRgstrServiceImpl extends AbstractCrudService implements BisInspWrwsRgstrService, BisInspObjStrategy { @Autowired private BisInspWrwsRgstrDao bisInspWrwsRgstrDao; @Autowired private AttAdBaseDao attAdBaseDao; @Autowired private BisInspWrwsRgstrSvwtcService bisInspWrwsRgstrSvwtcService; @Autowired private BisInspWrwsRgstrWgService bisInspWrwsRgstrWgService; @Autowired private BisInspWrwsRgstrWtupService bisInspWrwsRgstrWtupService; @Autowired private BisInspWrwsRgstrWtutService bisInspWrwsRgstrWtutService; @Autowired private BisInspPblmDao bisInspPblmDao; @Autowired private BisInspAllObjDao bisInspAllObjDao; public BisInspWrwsRgstrServiceImpl(BisInspWrwsRgstrDao bisInspWrwsRgstrDao) { super(bisInspWrwsRgstrDao); this.bisInspWrwsRgstrDao = bisInspWrwsRgstrDao; } @Override public int insert(BisInspWrwsRgstr bisInspWrwsRgstr) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspWrwsRgstr.setId(uuid); bisInspWrwsRgstr.setIntm(new Date()); bisInspWrwsRgstr.setUptm(new Date()); bisInspWrwsRgstr.setDataStat("0"); return this.bisInspWrwsRgstrDao.insert(bisInspWrwsRgstr); } @Override public int update(BisInspWrwsRgstr bisInspWrwsRgstr) { bisInspWrwsRgstr.setUptm(new Date()); return this.bisInspWrwsRgstrDao.update(bisInspWrwsRgstr); } @Override public int delete(String id) { return this.bisInspWrwsRgstrDao.delete(id); } @Override public void insertObj(BisInspAllObj bisInspAllObj, String persId) { BisInspWrwsRgstr b = new BisInspWrwsRgstr(); 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.bisInspWrwsRgstrDao.insert(b); /* 添加 子表 */ BisInspWrwsRgstrSvwtc bisInspWrwsRgstrSvwtc = new BisInspWrwsRgstrSvwtc(); bisInspWrwsRgstrSvwtc.setRgstrId(b.getId()); bisInspWrwsRgstrSvwtcService.insert(bisInspWrwsRgstrSvwtc); BisInspWrwsRgstrWg bisInspWrwsRgstrWg = new BisInspWrwsRgstrWg(); bisInspWrwsRgstrWg.setRgstrId(b.getId()); bisInspWrwsRgstrWgService.insert(bisInspWrwsRgstrWg); BisInspWrwsRgstrWtup bisInspWrwsRgstrWtup = new BisInspWrwsRgstrWtup(); bisInspWrwsRgstrWtup.setRgstrId(b.getId()); bisInspWrwsRgstrWtupService.insert(bisInspWrwsRgstrWtup); BisInspWrwsRgstrWtut bisInspWrwsRgstrWtut = new BisInspWrwsRgstrWtut(); bisInspWrwsRgstrWtut.setRgstrId(b.getId()); bisInspWrwsRgstrWtutService.insert(bisInspWrwsRgstrWtut); } @Override public String getType() { return BisInspEnum.WRWS.getValue(); } @Override public void cleanObjData(String objId) { BisInspWrwsRgstrParam rgstrParam = new BisInspWrwsRgstrParam(); rgstrParam.setObjId(objId); List list = this.bisInspWrwsRgstrDao.findList(rgstrParam); if (list.size() > 0) { String id = list.get(0).getId(); // 删除子表 BisInspWrwsRgstrSvwtcParam svwtcParam = new BisInspWrwsRgstrSvwtcParam(); svwtcParam.setRgstrId(id); bisInspWrwsRgstrSvwtcService.deleteBy(svwtcParam); BisInspWrwsRgstrWtutParam wtutParam = new BisInspWrwsRgstrWtutParam(); wtutParam.setRgstrId(id); bisInspWrwsRgstrWtutService.deleteBy(wtutParam); BisInspWrwsRgstrWgParam wgParam = new BisInspWrwsRgstrWgParam(); wgParam.setRgstrId(id); bisInspWrwsRgstrWgService.deleteBy(wgParam); BisInspWrwsRgstrWtupParam wtupParam = new BisInspWrwsRgstrWtupParam(); wtupParam.setRgstrId(id); bisInspWrwsRgstrWtupService.deleteBy(wtupParam); // 删除登记表 this.bisInspWrwsRgstrDao.delete(id); } // 删除问题 BisInspPblmParam bisInspPblmParam = new BisInspPblmParam(); bisInspPblmParam.setObjId(objId); bisInspPblmParam.setObjType(BisInspEnum.WRWS.getValue()); 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.bisInspWrwsRgstrDao.findPageList(typeParam); return (PageInfo) new PageInfo(list); } @Override public Object findObjListByType(TypeParam typeParam) { return this.bisInspWrwsRgstrDao.findPageList(typeParam); } }