package cn.com.goldenwater.dcproj.service.impl; import cn.com.goldenwater.dcproj.dao.BisInspWtuntRgstrDao; import cn.com.goldenwater.dcproj.dao.BisInspWtuntRgstrSteelDao; import cn.com.goldenwater.dcproj.dao.BisInspWtuntRgstrSteelReoDao; import cn.com.goldenwater.dcproj.model.BisInspWtuntRgstr; import cn.com.goldenwater.dcproj.model.BisInspWtuntRgstrSteel; import cn.com.goldenwater.dcproj.model.BisInspWtuntRgstrSteelReo; import cn.com.goldenwater.dcproj.model.BisInspWtuntRgstrVo; import cn.com.goldenwater.dcproj.param.BisInspWtuntRgstrSteelParam; import cn.com.goldenwater.dcproj.param.BisInspWtuntRgstrSteelReoParam; import cn.com.goldenwater.dcproj.service.BisInspWtuntRgstrService; import cn.com.goldenwater.dcproj.service.BisInspWtuntRgstrSteelReoService; import cn.com.goldenwater.dcproj.service.BisInspWtuntRgstrSteelService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.utils.Constant; import cn.com.goldenwater.id.util.UuidUtil; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; /** * @author lune * @date 2020-8-17 */ @Service @Transactional(rollbackFor = Exception.class) public class BisInspWtuntRgstrSteelServiceImpl extends AbstractCrudService implements BisInspWtuntRgstrSteelService { @Autowired private BisInspWtuntRgstrSteelDao bisInspWtuntRgstrSteelDao; @Autowired private BisInspWtuntRgstrDao bisInspWtuntRgstrDao; @Autowired private BisInspWtuntRgstrSteelReoDao bisInspWtuntRgstrSteelReoDao; public BisInspWtuntRgstrSteelServiceImpl(BisInspWtuntRgstrSteelDao bisInspWtuntRgstrSteelDao) { super(bisInspWtuntRgstrSteelDao); this.bisInspWtuntRgstrSteelDao = bisInspWtuntRgstrSteelDao; } @Override public void insertSteel(BisInspWtuntRgstrVo bisInspWtuntRgstrVo) { //钢铁 BisInspWtuntRgstrSteel bisInspWtuntRgstrSteel = bisInspWtuntRgstrVo.getBisInspWtuntRgstrSteel(); String rgstrId = bisInspWtuntRgstrSteel.getRgstrId(); bisInspWtuntRgstrSteel.setUptm(new Date()); if (StringUtils.isBlank(bisInspWtuntRgstrSteel.getId())) { BisInspWtuntRgstrSteelParam steelParam = new BisInspWtuntRgstrSteelParam(); steelParam.setRgstrId(rgstrId); List list = bisInspWtuntRgstrSteelDao.findList(steelParam); if (CollectionUtils.isEmpty(list)) { bisInspWtuntRgstrSteel.setId(UuidUtil.uuid()); bisInspWtuntRgstrSteel.setIntm(new Date()); bisInspWtuntRgstrSteelDao.insert(bisInspWtuntRgstrSteel); } else { bisInspWtuntRgstrSteel.setId(list.get(0).getId()); bisInspWtuntRgstrSteelDao.update(bisInspWtuntRgstrSteel); } } else { bisInspWtuntRgstrSteelDao.update(bisInspWtuntRgstrSteel); } List bisInspWtuntRgstrSteelReoList = bisInspWtuntRgstrVo.getBisInspWtuntRgstrSteelReo(); for (BisInspWtuntRgstrSteelReo bisInspWtuntRgstrSteelReo : bisInspWtuntRgstrSteelReoList) { bisInspWtuntRgstrSteelReo.setUptm(new Date()); //主要责任 if (StringUtils.isBlank(bisInspWtuntRgstrSteelReo.getId())) { bisInspWtuntRgstrSteelReo.setId(UuidUtil.uuid()); bisInspWtuntRgstrSteelReo.setRgstrId(rgstrId); bisInspWtuntRgstrSteelReo.setIntm(new Date()); bisInspWtuntRgstrSteelReoDao.insert(bisInspWtuntRgstrSteelReo); } else { bisInspWtuntRgstrSteelReoDao.update(bisInspWtuntRgstrSteelReo); } } //修改登记表督查状态 if (StringUtils.isNotBlank(rgstrId)) { BisInspWtuntRgstr wtuntRgstr = bisInspWtuntRgstrDao.get(rgstrId); if (!Constant.STRING_TWO.equals(wtuntRgstr.getState())) { wtuntRgstr.setUptm(new Date()); wtuntRgstr.setState(Constant.STRING_ONE); wtuntRgstr.setWtuntStat(bisInspWtuntRgstrSteel.getStatus()); bisInspWtuntRgstrDao.update(wtuntRgstr); } } } }