package cn.com.goldenwater.dcproj.service.impl.offline; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.dao.*; import cn.com.goldenwater.dcproj.model.*; import cn.com.goldenwater.dcproj.param.BisInspAllObjParam; import cn.com.goldenwater.dcproj.param.BisInspWintRgstrParam; import cn.com.goldenwater.dcproj.service.GwComFileService; import cn.com.goldenwater.dcproj.service.SupervisionPlanService; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; import cn.com.goldenwater.id.util.UuidUtil; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** * 分水及管控离线填报 * * @author zhangcheng * @date 2019/11/25 17:33 */ @Service @Transactional public class BisInspOffLineWintProcess extends BisInspOffLineProcess { @Autowired BisInspAllObjDao bisInspAllObjDao; @Autowired BisInspPblmDao bisInspPblmDao;//督查问题 @Autowired BisInspWintRgstrIntInfoDao bisInspWintRgstrIntInfoDao; @Autowired BisInspWintRgstrDao bisInspWintRgstrDao; @Autowired AttAdBaseDao attAdBaseDao; @Autowired SupervisionPlanService supervisionPlanService; @Autowired private GwComFileService gwComFileService;//文件操作 @Value("${getFile.prefix}") public String prefix; @Override public BisInspOffLineRet process(BisInspOffLineObj bisInspOffLineObj, String fileDir) throws IOException { BisInspOffLineRet bisInspOffLineRet = new BisInspOffLineRet(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); ObjectMapper om = new ObjectMapper(); om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //解析分水及管控填报信息 BisInspOffLineWintRgeister bisInspOffLineWintRgeister = om.readValue(bisInspOffLineObj.getRegister(), BisInspOffLineWintRgeister.class); //解析分水及管控基本信息对象 if (bisInspOffLineObj.getBase() != null) { /* if (null == bisInspOffLineObj.getReplace() || bisInspOffLineObj.getReplace()) { delRgstrData(bisInspOffLineObj); }*/ //添加到督查任务 String objId = UuidUtil.uuid(); String groupId = bisInspOffLineObj.getGroupId(); BisInspWintRgstr bisInspWintRgstr = new BisInspWintRgstr(); String regId = objId; String persId = bisInspOffLineObj.getPersId(); BisInspWintRgstr bisInspWiuRgstrBase = om.readValue(bisInspOffLineObj.getBase(), BisInspWintRgstr.class); insertBisInspAllObj(bisInspOffLineObj, groupId, objId, bisInspWiuRgstrBase); insertWintRgstr(bisInspWiuRgstrBase, groupId, objId, persId, regId, bisInspWintRgstr); //年度水量分配及取用水管控情况抽查表 insertWintIntInfo(bisInspOffLineWintRgeister, regId, persId, bisInspWintRgstr); //更新督查 字表状态 bisInspWintRgstrDao.update(bisInspWintRgstr); bisInspOffLineRet.setRegId(regId); bisInspOffLineRet.setObjId(objId); } return bisInspOffLineRet; } /** * 删除任务及登记表信息 * * @param groupId * @param nm */ public void delRgstrData(BisInspOffLineObj bisInspOffLineObj) { //登记表查找重复数据,然后删除 BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam(); bisInspAllObjParam.setId(bisInspOffLineObj.getGroupId()); bisInspAllObjParam.setNm(bisInspOffLineObj.getNm()); List bisInspAllObjs = bisInspAllObjDao.findList(bisInspAllObjParam); for (BisInspAllObj bisInspAllObj : bisInspAllObjs) { //删除登记表 //删除登记表关联的各个填报表数据 supervisionPlanService.cleanObjDataByObjId(BisInspEnum.WIU.getValue(), bisInspAllObj.getObjId()); } } /** * 添加到督查任务 * * @param groupId * @param objId * @param bisInspWintRgstr */ public void insertBisInspAllObj(BisInspOffLineObj bisInspOffLineObj, String groupId, String objId, BisInspWintRgstr bisInspWintRgstr) { BisInspAllObj bisInspAllObj = new BisInspAllObj(); bisInspAllObj.setId(groupId); bisInspAllObj.setObjId(objId); bisInspAllObj.setNm(bisInspWintRgstr.getAdName()); bisInspAllObj.setCode(bisInspWintRgstr.getAdCode());//非空字段 bisInspAllObj.setPtype("14"); bisInspAllObj.setOrgId(bisInspOffLineObj.getOrgId()); bisInspAllObj.setAdCode(bisInspOffLineObj.getProvince()); bisInspAllObj.setLgtd(bisInspWintRgstr.getPcX()); bisInspAllObj.setLttd(bisInspWintRgstr.getPcY()); bisInspAllObj.setLgtdpc(bisInspWintRgstr.getGdX()); bisInspAllObj.setLttdpc(bisInspWintRgstr.getGdY()); bisInspAllObjDao.insert(bisInspAllObj); } /** * 插入登记表信息 * * @param bisInspOffLineObj * @param objId * @param om * @param regId * @param bisInspWintRgstr * @throws IOException */ public void insertWintRgstr(BisInspWintRgstr bisInspWintRgstrBase, String groupId, String objId, String persId, String regId, BisInspWintRgstr bisInspWintRgstr) throws IOException { bisInspWintRgstr.setId(regId); bisInspWintRgstr.setObjId(objId); bisInspWintRgstr.setAdName(bisInspWintRgstrBase.getAdName()); bisInspWintRgstr.setAdCode(bisInspWintRgstrBase.getAdCode()); bisInspWintRgstr.setLoc(bisInspWintRgstrBase.getLoc()); bisInspWintRgstr.setBChkUnit(bisInspWintRgstrBase.getBChkUnit()); bisInspWintRgstr.setContact(bisInspWintRgstrBase.getContact()); bisInspWintRgstr.setContactTel(bisInspWintRgstrBase.getContactTel()); bisInspWintRgstr.setPrincipal(bisInspWintRgstrBase.getPrincipal()); bisInspWintRgstr.setPrincipalTel(bisInspWintRgstrBase.getPrincipalTel()); bisInspWintRgstr.setNote(bisInspWintRgstrBase.getNote()); bisInspWintRgstr.setChkUnit(bisInspWintRgstrBase.getChkUnit()); bisInspWintRgstr.setChkPers(bisInspWintRgstrBase.getChkPers()); bisInspWintRgstr.setChkTm(bisInspWintRgstrBase.getChkTm()); bisInspWintRgstr.setState("1"); bisInspWintRgstr.setDataStat("0"); bisInspWintRgstr.setPersId(persId); bisInspWintRgstr.setGroupId(groupId); bisInspWintRgstr.setGdX(bisInspWintRgstrBase.getGdX()); bisInspWintRgstr.setGdY(bisInspWintRgstrBase.getGdY()); bisInspWintRgstr.setPcX(bisInspWintRgstrBase.getPcX()); bisInspWintRgstr.setPcY(bisInspWintRgstrBase.getPcY()); bisInspWintRgstr.setInTm(new Date()); bisInspWintRgstr.setUpTm(new Date()); bisInspWintRgstrDao.insert(bisInspWintRgstr); } /** * 插入水量分配及取用水管控情况 * * @param bisInspOffLineWintRgeister * @param regId * @param bisInspOffLineObj * @param bisInspWintRgstr */ public void insertWintIntInfo(BisInspOffLineWintRgeister bisInspOffLineWintRgeister, String regId, String persId, BisInspWintRgstr bisInspWintRgstr) { //水量分配及取用水管控情况 BisInspWintRgstrIntInfo bisInspWintRgstrIntInfo = new BisInspWintRgstrIntInfo(); if (bisInspOffLineWintRgeister.getBisInspWintRgstrIntInfo() != null) { bisInspWintRgstrIntInfo = bisInspOffLineWintRgeister.getBisInspWintRgstrIntInfo(); bisInspWintRgstrIntInfo.setId(UuidUtil.uuid()); bisInspWintRgstrIntInfo.setRgstrId(regId); bisInspWintRgstrIntInfo.setInTm(new Date()); bisInspWintRgstrIntInfo.setUpTm(new Date()); bisInspWintRgstrIntInfo.setDataStat("0"); bisInspWintRgstrIntInfo.setPersId(persId); bisInspWintRgstrIntInfoDao.insert(bisInspWintRgstrIntInfo); bisInspWintRgstr.setIntInfoStat("2"); } else { bisInspWintRgstrIntInfo.setId(UuidUtil.uuid()); bisInspWintRgstrIntInfo.setRgstrId(regId); bisInspWintRgstrIntInfo.setInTm(new Date()); bisInspWintRgstrIntInfo.setUpTm(new Date()); bisInspWintRgstrIntInfo.setDataStat("0"); bisInspWintRgstrIntInfo.setPersId(persId); bisInspWintRgstrIntInfoDao.insert(bisInspWintRgstrIntInfo); bisInspWintRgstr.setIntInfoStat("1"); } } @Override public BisInspOffLineRetBase getBaseInfo(BisInspOffLine bisInspOffLine) { BisInspOffLineRetBase bisInspOffLineRetBase = new BisInspOffLineRetBase(); BisInspWintRgstrParam bisInspWintRgstrParam = new BisInspWintRgstrParam(); bisInspWintRgstrParam.setAdName(bisInspOffLine.getName()); bisInspWintRgstrParam.setAdCode(AdLevelUtil.getAddvcd(bisInspOffLine.getAddvcd())); bisInspOffLineRetBase.setBase(bisInspWintRgstrDao.findList(bisInspWintRgstrParam)); return bisInspOffLineRetBase; } }