Commit c48de871 by 高晓磊

采砂许可证删除场站不生效的问题

parent f3a1b448
......@@ -5,6 +5,7 @@ import com.beecode.bcp.type.KObject;
import com.xyst.dinas.biz.dao.SandMiningAreaDao;
import com.xyst.dinas.biz.service.SandMiningAreaService;
import com.xyst.dinas.biz.warn.WarnSetting;
import com.xyst.dinas.biz.warn.WarnSettingConstant;
import com.xyst.dinas.biz.warn.WarnSettingEntity;
import com.xyst.dinas.biz.warn.WarnTargetTypeEnum;
import com.xyst.dinas.biz.warn.service.IWarningSettingService;
......@@ -75,9 +76,9 @@ public class SandMiningAreaServiceImpl implements SandMiningAreaService {
if(2==kobject.getInt("status")){
//新建采区后同步新建一条预警设置
WarnSettingEntity warnSetting = new WarnSettingEntity();
warnSetting.setBillType("采区超采预警");
warnSetting.setBillType(WarnSettingConstant.SAND_MINING_AREA_BILL_TYPE);
warnSetting.setBillId(kobject.getUuid("id"));
warnSetting.setTarget("开采量");
warnSetting.setTarget(WarnSettingConstant.SAND_MINING_AREA_WARN_TARGET);
warnSetting.setTargetType(WarnTargetTypeEnum.NUMBER_TYPE.getCode());
warnSetting.setOpen(false);
warnSetting.setMemo(getAreaWarningInfo(kobject));
......
......@@ -22,9 +22,9 @@ public class WarnSettingConstant {
public static final String SAND_MINING_AREA_BILL_TYPE = "采区超采预警";
/**
* 超采预警指标
* 超采预警指标 -开采量
*/
public static final String SAND_MINING_AREA_WARN_TARGET = "采区超采预警";
public static final String SAND_MINING_AREA_WARN_TARGET = "开采量";
/**
* 许可证船只进入告警区类型
......
......@@ -35,6 +35,7 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
@Autowired
private DinasTypeDao dinasTypeDao;
@Override
public KObject load(UUID id) {
return (KObject) template.load(ENTITY, id);
......@@ -45,7 +46,7 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
KClass bean = Amino.getStaticMetadataContext().getBean(SandMiningConstant.ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
detachedCriteria.add(Restrictions.eq("del", false));
if(null!=sandMiningStatus){
if (null != sandMiningStatus) {
detachedCriteria.add(Restrictions.eq("status", sandMiningStatus));
}
dinasTypeDao.addRegionalCompanyFilter(detachedCriteria);
......@@ -53,7 +54,7 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
detachedCriteria.addOrder(Order.desc("createTime"));
int offset = page.getPageSize() * (page.getPageNo() - 1);
page.setTotal(template.findByCriteria(detachedCriteria).size());
List<KObject> list = (List<KObject>) template.findByCriteria(detachedCriteria,offset,page.getPageSize());
List<KObject> list = (List<KObject>) template.findByCriteria(detachedCriteria, offset, page.getPageSize());
page.setDatas(list);
return page;
}
......@@ -67,7 +68,7 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
detachedCriteria.add(Restrictions.eq("del", false));
detachedCriteria.add(Restrictions.eq("permitCode", permitCode));
if(id!=null){
if (id != null) {
detachedCriteria.add(Restrictions.ne("id", id));
}
......@@ -80,37 +81,44 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
// kobject.set(BaseConstants.CREATE_TIME,id.getDate(BaseConstants.CREATE_TIME));
KObject staff = AminoContextHolder.getContext().getStaff();
kobject.set("regionalCompany", dinasTypeDao.getCurrentLoginRegionalCompany());
kobject.set(BaseConstants.MODIFY_TIME,new Date());
kobject.set(BaseConstants.MODIFIER,staff);
kobject.set("del",false);
kobject.setNull("stationDetails");
kobject.set("ship", template.load(ShipInfoConstant.ENTITY,kobject.get("ship").getUuid("id")));
kobject.set("sandMiningArea", template.load(SandMiningAreaConstant.ENTITY,kobject.get("sandMiningArea").getUuid("id")));
kobject.set(BaseConstants.MODIFY_TIME, new Date());
kobject.set(BaseConstants.MODIFIER, staff);
kobject.set("del", false);
// kobject.setNull("stationDetails");
kobject.set("ship", template.load(ShipInfoConstant.ENTITY, kobject.get("ship").getUuid("id")));
kobject.set("sandMiningArea", template.load(SandMiningAreaConstant.ENTITY, kobject.get("sandMiningArea").getUuid("id")));
template.update(kobject);
KObject id = load(kobject.getUuid("id"));
template.deleteAll(id.get("stationDetails").toCollection());
deleteSandMiningStationDetail(kobject.getUuid("id"));
KObject[] stationDetails = kobject.get("stationDetails").toArray();
for (KObject stationDetail : stationDetails) {
stationDetail.set("master",kobject);
stationDetail.set("station",template.load(StationConstant.ENTITY,stationDetail.get("station").getUuid("id")));
template.save(STATION_DETAIL_ENTITY,stationDetail);
stationDetail.set("master", kobject);
stationDetail.set("station", template.load(StationConstant.ENTITY, stationDetail.get("station").getUuid("id")));
template.save(STATION_DETAIL_ENTITY, stationDetail);
}
}
private void deleteSandMiningStationDetail(UUID id) {
template.execute(session -> {
Query query = session.createQuery("delete from " + STATION_DETAIL_ENTITY + " where master.id = :id");
query.setParameter("id", id);
return query.executeUpdate();
});
}
@Override
public void updateSandMiningStatus() {
//1.将未开始但时间已到的修改为已开始
template.execute(session -> {
Query query = session.createQuery("update " + ENTITY + " as a set a.status =1 where a.sandMiningStart >= :startDate and a.status = 0 and a.del=false");
query.setParameter("startDate",new Date());
query.setParameter("startDate", new Date());
return query;
});
//2.将已开始但超时的修改为已过期
template.execute(session -> {
Query query = session.createQuery("update " + ENTITY + " as a set a.status =2 where a.sandMiningEnd >= :endDate and a.status = 1 and a.del=false");
query.setParameter("endDate",new Date());
query.setParameter("endDate", new Date());
return query;
});
}
......@@ -120,24 +128,24 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
public UUID create(KObject kObject) {
KObject staff = AminoContextHolder.getContext().getStaff();
UUID uuid = UUID.randomUUID();
if(null==kObject.getUuid("id")){
kObject.set("id",uuid);
if (null == kObject.getUuid("id")) {
kObject.set("id", uuid);
}
kObject.set("ship", template.load(ShipInfoConstant.ENTITY,kObject.get("ship").getUuid("id")));
kObject.set("sandMiningArea", template.load(SandMiningAreaConstant.ENTITY,kObject.get("sandMiningArea").getUuid("id")));
kObject.set("ship", template.load(ShipInfoConstant.ENTITY, kObject.get("ship").getUuid("id")));
kObject.set("sandMiningArea", template.load(SandMiningAreaConstant.ENTITY, kObject.get("sandMiningArea").getUuid("id")));
kObject.set("regionalCompany", dinasTypeDao.getCurrentLoginRegionalCompany());
kObject.set(BaseConstants.CREATOR,staff);
kObject.set(BaseConstants.CREATOR, staff);
kObject.set(BaseConstants.CREATE_TIME, new Date());
kObject.set("del",false);
kObject.set("del", false);
UUID save = (UUID) template.save(kObject);
KObject[] stationDetails = kObject.get("stationDetails").toArray();
for (KObject stationDetail : stationDetails) {
stationDetail.set("master",kObject);
stationDetail.set("station",template.load(StationConstant.ENTITY,stationDetail.get("station").getUuid("id")));
template.save(STATION_DETAIL_ENTITY,stationDetail);
stationDetail.set("master", kObject);
stationDetail.set("station", template.load(StationConstant.ENTITY, stationDetail.get("station").getUuid("id")));
template.save(STATION_DETAIL_ENTITY, stationDetail);
}
return save;
}
......@@ -146,9 +154,9 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
public void deleteById(UUID id) {
KObject staff = AminoContextHolder.getContext().getStaff();
KObject kobject = (KObject) template.load(ENTITY, id);
kobject.set("modifyTime",new Date());
kobject.set(BaseConstants.MODIFIER,staff);
kobject.set("del",true);
kobject.set("modifyTime", new Date());
kobject.set(BaseConstants.MODIFIER, staff);
kobject.set("del", true);
template.update(kobject);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment