Commit 04eddef4 by shiwenbo

库存查询排除掉已停业的场站

parent 13ebde71
...@@ -7,7 +7,7 @@ import com.beecode.bcp.type.KObject; ...@@ -7,7 +7,7 @@ import com.beecode.bcp.type.KObject;
public interface InventoryDao { public interface InventoryDao {
List<KObject> listAllByRegionalCompany(UUID regionalCompany, boolean includeDiscard); List<KObject> listAllByRegionalCompany(UUID regionalCompany, boolean includeDiscard, boolean includeStopBusiness);
void update(KObject kobj); void update(KObject kobj);
......
...@@ -20,18 +20,30 @@ public class InventoryDaoImpl implements InventoryDao { ...@@ -20,18 +20,30 @@ public class InventoryDaoImpl implements InventoryDao {
private HibernateOperations template; private HibernateOperations template;
@Override @Override
public List<KObject> listAllByRegionalCompany(UUID regionalCompany, boolean includeDiscard) { public List<KObject> listAllByRegionalCompany(UUID regionalCompany, boolean includeDiscard, boolean includeStopBusiness) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() { return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() {
@Override @Override
public List<KObject> doInHibernate(Session session) throws HibernateException { public List<KObject> doInHibernate(Session session) throws HibernateException {
if(includeDiscard) { if(includeDiscard) {
if(includeStopBusiness) {
Query<KObject> query = session.createQuery("from " + InventoryConstant.INVENTORY_ENTITY + " where regionalCompany.id =:regionalCompany", KObject.class); Query<KObject> query = session.createQuery("from " + InventoryConstant.INVENTORY_ENTITY + " where regionalCompany.id =:regionalCompany", KObject.class);
query.setParameter("regionalCompany", regionalCompany); query.setParameter("regionalCompany", regionalCompany);
return query.getResultList(); return query.getResultList();
} else { } else {
Query<KObject> query = session.createQuery("from " + InventoryConstant.INVENTORY_ENTITY + " where regionalCompany.id =:regionalCompany and station.stationStatus = 1", KObject.class);
query.setParameter("regionalCompany", regionalCompany);
return query.getResultList();
}
} else {
if(includeStopBusiness) {
Query<KObject> query = session.createQuery("from " + InventoryConstant.INVENTORY_ENTITY + " where (discard is null or discard = 0) and regionalCompany.id =:regionalCompany", KObject.class); Query<KObject> query = session.createQuery("from " + InventoryConstant.INVENTORY_ENTITY + " where (discard is null or discard = 0) and regionalCompany.id =:regionalCompany", KObject.class);
query.setParameter("regionalCompany", regionalCompany); query.setParameter("regionalCompany", regionalCompany);
return query.getResultList(); return query.getResultList();
} else {
Query<KObject> query = session.createQuery("from " + InventoryConstant.INVENTORY_ENTITY + " where (discard is null or discard = 0) and regionalCompany.id =:regionalCompany and station.stationStatus = 1", KObject.class);
query.setParameter("regionalCompany", regionalCompany);
return query.getResultList();
}
} }
} }
}); });
......
...@@ -76,7 +76,7 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -76,7 +76,7 @@ public class InventoryServiceImpl implements InventoryService {
@Transactional @Transactional
public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany) { public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany) {
updateInventoryBaseInfo(regionalCompany); updateInventoryBaseInfo(regionalCompany);
List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, false); List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, false, false);
List<StationDinasTypeRelation> result = new ArrayList<StationDinasTypeRelation>(); List<StationDinasTypeRelation> result = new ArrayList<StationDinasTypeRelation>();
for(KObject item : inventory) { for(KObject item : inventory) {
StationDinasTypeRelation r = new StationDinasTypeRelation(); StationDinasTypeRelation r = new StationDinasTypeRelation();
...@@ -160,7 +160,7 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -160,7 +160,7 @@ public class InventoryServiceImpl implements InventoryService {
public void updateInventoryBaseInfo(UUID regionalCompany) { public void updateInventoryBaseInfo(UUID regionalCompany) {
List<StationDinasTypeRelation> relation = getStationAndDinasTypeRel(regionalCompany); List<StationDinasTypeRelation> relation = getStationAndDinasTypeRel(regionalCompany);
//根据最新的区域公司与砂石对应关系,更新库中的数据。添加新的砂石类型,废弃没用的砂石类型 //根据最新的区域公司与砂石对应关系,更新库中的数据。添加新的砂石类型,废弃没用的砂石类型
List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, true); List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, true, true);
for(StationDinasTypeRelation r : relation) { for(StationDinasTypeRelation r : relation) {
UUID stationId = r.getStationId(); UUID stationId = r.getStationId();
UUID dinasTypeId = r.getDinasTypeId(); UUID dinasTypeId = r.getDinasTypeId();
...@@ -243,7 +243,7 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -243,7 +243,7 @@ public class InventoryServiceImpl implements InventoryService {
public List<InventoryLog> queryLog(UUID regionalCompany) { public List<InventoryLog> queryLog(UUID regionalCompany) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<InventoryLog> result = new ArrayList<InventoryLog>(); List<InventoryLog> result = new ArrayList<InventoryLog>();
List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, false); List<KObject> inventory = inventoryDao.listAllByRegionalCompany(regionalCompany, false, true);
List<String> businessObjectId = new ArrayList<String>(); List<String> businessObjectId = new ArrayList<String>();
for(KObject i : inventory) { for(KObject i : inventory) {
businessObjectId.add(i.getUuid("id").toString()); businessObjectId.add(i.getUuid("id").toString());
......
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