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.AttWiuBaseParam; import cn.com.goldenwater.dcproj.param.BisInspAllObjParam; import cn.com.goldenwater.dcproj.service.GwComFileService; import cn.com.goldenwater.dcproj.service.SupervisionPlanService; 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/27 15:09 */ @Service @Transactional public class BisInspOffLineWiuProcess extends BisInspOffLineProcess { @Autowired BisInspAllObjDao bisInspAllObjDao; @Autowired BisInspPblmDao bisInspPblmDao;//督查问题 @Autowired BisInspWiuRgstrDao bisInspWiuRgstrDao; @Autowired BisInspWiuRgstrIntInfoDao bisInspWiuRgstrIntInfoDao; @Autowired AttWiuBaseDao attWiuBaseDao; @Autowired private GwComFileService gwComFileService;//文件操作 @Value("${getFile.prefix}") public String prefix; @Autowired SupervisionPlanService supervisionPlanService; @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); //解析水源地填报信息 BisInspOffLineWiuRgeister bisInspOffLineWiuRgeister = om.readValue(bisInspOffLineObj.getRegister(), BisInspOffLineWiuRgeister.class); //解析水源地对象 if (bisInspOffLineObj.getBase() != null) { /* if (null == bisInspOffLineObj.getReplace() || bisInspOffLineObj.getReplace()) { delRgstrData(bisInspOffLineObj); }*/ //添加到督查任务 String objId = UuidUtil.uuid(); String groupId = bisInspOffLineObj.getGroupId(); BisInspWiuRgstr bisInspWiuRgstr = new BisInspWiuRgstr(); String regId = UuidUtil.uuid(); String persId = bisInspOffLineObj.getPersId(); AttWiuBase attWiuBase = om.readValue(bisInspOffLineObj.getBase(), AttWiuBase.class); insertBisInspAllObj(bisInspOffLineObj, groupId, objId, attWiuBase); insertWiuRgstr(attWiuBase, groupId, objId, persId, regId, bisInspWiuRgstr); //取水口取水及监管情况 insertWiuIntInfo(bisInspOffLineWiuRgeister, regId, persId, bisInspWiuRgstr); //更新督查 字表状态 bisInspWiuRgstrDao.update(bisInspWiuRgstr); bisInspOffLineRet.setObjId(objId); bisInspOffLineRet.setRegId(regId); } 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 attSwhsBase */ public void insertBisInspAllObj(BisInspOffLineObj bisInspOffLineObj, String groupId, String objId, AttWiuBase attWiuBase) { BisInspAllObj bisInspAllObj = new BisInspAllObj(); bisInspAllObj.setId(groupId); bisInspAllObj.setObjId(objId); bisInspAllObj.setNm(attWiuBase.getWiuName()); bisInspAllObj.setCode(attWiuBase.getWiuCode());//非空字段 bisInspAllObj.setLgtd(attWiuBase.getWiuLong()); bisInspAllObj.setLttd(attWiuBase.getWiuLat()); bisInspAllObj.setOrgId(bisInspOffLineObj.getOrgId()); bisInspAllObj.setAdCode(bisInspOffLineObj.getProvince()); bisInspAllObj.setLgtdpc(attWiuBase.getGdX()); bisInspAllObj.setLttdpc(attWiuBase.getGdY()); bisInspAllObj.setPtype("12"); bisInspAllObjDao.insert(bisInspAllObj); } /** * 插入登记表信息 * * @param bisInspOffLineObj * @param objId * @param om * @param regId * @param bisInspWiuRgstr * @throws IOException */ public void insertWiuRgstr(AttWiuBase attWiuBase, String groupId, String objId, String persId, String regId, BisInspWiuRgstr bisInspWiuRgstr) throws IOException { bisInspWiuRgstr.setId(regId); bisInspWiuRgstr.setObjId(objId); bisInspWiuRgstr.setWiuId(attWiuBase.getWiuCode()); bisInspWiuRgstr.setWiuName(attWiuBase.getWiuName()); bisInspWiuRgstr.setAdName(attWiuBase.getAdName()); bisInspWiuRgstr.setAdCode(attWiuBase.getAdCode()); bisInspWiuRgstr.setWiuLoc(attWiuBase.getWintPos()); bisInspWiuRgstr.setWiuLong(attWiuBase.getWiuLong()); bisInspWiuRgstr.setWiuLat(attWiuBase.getWiuLat()); bisInspWiuRgstr.setGdX(attWiuBase.getGdX()); bisInspWiuRgstr.setGdY(attWiuBase.getGdY()); bisInspWiuRgstr.setWiuContact(attWiuBase.getWiuContact()); bisInspWiuRgstr.setWiuContactTel(attWiuBase.getWiuContactTel()); bisInspWiuRgstr.setState("1"); bisInspWiuRgstr.setDataStat("0"); bisInspWiuRgstr.setPersId(persId); bisInspWiuRgstr.setGroupId(groupId); bisInspWiuRgstr.setInTm(new Date()); bisInspWiuRgstr.setUpTm(new Date()); bisInspWiuRgstrDao.insert(bisInspWiuRgstr); } /** * 取水口取水及监管情况检查表 * * @param bisInspOffLineWiuRgeister * @param regId * @param bisInspOffLineObj * @param bisInspWiuRgstr */ public void insertWiuIntInfo(BisInspOffLineWiuRgeister bisInspOffLineWiuRgeister, String regId, String persId, BisInspWiuRgstr bisInspWiuRgstr) { //节水评价情况检查表 BisInspWiuRgstrIntInfo bisInspWiuRgstrIntInfo = new BisInspWiuRgstrIntInfo(); if (bisInspOffLineWiuRgeister.getBisInspWiuRgstrIntInfo() != null) { bisInspWiuRgstrIntInfo = bisInspOffLineWiuRgeister.getBisInspWiuRgstrIntInfo(); bisInspWiuRgstrIntInfo.setId(UuidUtil.uuid()); bisInspWiuRgstrIntInfo.setRgstrId(regId); bisInspWiuRgstrIntInfo.setInTm(new Date()); bisInspWiuRgstrIntInfo.setUpTm(new Date()); bisInspWiuRgstrIntInfo.setDataStat("0"); bisInspWiuRgstrIntInfo.setRecPersId(persId); bisInspWiuRgstrIntInfoDao.insert(bisInspWiuRgstrIntInfo); bisInspWiuRgstr.setIntInfoStat("2"); } else { bisInspWiuRgstrIntInfo.setId(UuidUtil.uuid()); bisInspWiuRgstrIntInfo.setRgstrId(regId); bisInspWiuRgstrIntInfo.setInTm(new Date()); bisInspWiuRgstrIntInfo.setUpTm(new Date()); bisInspWiuRgstrIntInfo.setDataStat("0"); bisInspWiuRgstrIntInfo.setRecPersId(persId); bisInspWiuRgstrIntInfoDao.insert(bisInspWiuRgstrIntInfo); bisInspWiuRgstr.setIntInfoStat("1"); } } @Override public BisInspOffLineRetBase getBaseInfo(BisInspOffLine bisInspOffLine) { BisInspOffLineRetBase bisInspOffLineRetBase = new BisInspOffLineRetBase(); AttWiuBaseParam attWiuBaseParam = new AttWiuBaseParam(); attWiuBaseParam.setWiuName(bisInspOffLine.getName()); attWiuBaseParam.setId(bisInspOffLine.getCode()); bisInspOffLineRetBase.setBase(attWiuBaseDao.findList(attWiuBaseParam)); return bisInspOffLineRetBase; } }