Commit 3bcf137f by 高晓磊

生产专题趋势图接口

parent 33283599
......@@ -9,6 +9,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/**
* @author scol
*/
public interface DischargingDao extends BaseDao {
KObject load(UUID id);
......@@ -20,7 +23,7 @@ public interface DischargingDao extends BaseDao {
void deleteById(UUID id);
List<HashMap<String, Object>> groupInfo(List<UUID> regionalCompanyIds, Integer year, Boolean isGroupByMonth, Boolean isGroupByRegionalCompany, Boolean isGroupBySandMiningArea);
List<HashMap<String, Object>> groupInfo(List<UUID> stationIds,List<UUID> regionalCompanyIds, Date startDate,Date endDate, Integer type,Boolean isGroupByMonth, Boolean isGroupByRegionalCompany, Boolean isGroupBySandMiningArea,Boolean isGroupByDay,Boolean isGroupByStationId);
List<KObject> getByCodeNum(String name, UUID id);
......
......@@ -6,6 +6,7 @@ import com.beecode.inz.basis.dao.BaseDao;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public interface ProductionPlanReportDao extends BaseDao {
......@@ -35,4 +36,8 @@ public interface ProductionPlanReportDao extends BaseDao {
List<KObject> getNoWareHousing(UUID productionPlanId);
List<Map<String, Object>> getProductionGroup(Date startDate, Date endDate, List<UUID> ids, List<UUID> stationIds, Boolean isGroupByProductionLine, Boolean isGroupByRegionalCompany, Boolean isGroupByStation);
List<Map<String, Object>> getProductionByDinasTypeAndProductionLine(Date startDate, Date endDate, List<UUID> stationIds, List<UUID> ids);
}
package com.xyst.dinas.production.entity;
import java.util.List;
import java.util.UUID;
/**
* @author scol
*/
public class DinasTypeParent {
private UUID dinasTypeId;
private String dinasTypeName;
private List<TimeValueParentEntity> timeValueParentEntityList;
public UUID getDinasTypeId() {
return dinasTypeId;
}
public void setDinasTypeId(UUID dinasTypeId) {
this.dinasTypeId = dinasTypeId;
}
public String getDinasTypeName() {
return dinasTypeName;
}
public void setDinasTypeName(String dinasTypeName) {
this.dinasTypeName = dinasTypeName;
}
public List<TimeValueParentEntity> getTimeValueParentEntityList() {
return timeValueParentEntityList;
}
public void setTimeValueParentEntityList(List<TimeValueParentEntity> timeValueParentEntityList) {
this.timeValueParentEntityList = timeValueParentEntityList;
}
}
package com.xyst.dinas.production.entity;
import java.util.Date;
import java.util.UUID;
public class TimeValue {
private UUID id;
private Date time;
private Double value;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public Double getValue() {
return value;
}
public void setValue(Double value) {
this.value = value;
}
public TimeValue(UUID id, Date time, Double value) {
this.id = id;
this.time = time;
this.value = value;
}
public TimeValue() {
}
}
package com.xyst.dinas.production.entity;
import java.util.List;
import java.util.UUID;
public class TimeValueParentEntity {
private String parentName;
private UUID parentId;
private List<TimeValue> timeValues;
public List<TimeValue> getTimeValues() {
return timeValues;
}
public void setTimeValues(List<TimeValue> timeValues) {
this.timeValues = timeValues;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public UUID getParentId() {
return parentId;
}
public void setParentId(UUID parentId) {
this.parentId = parentId;
}
}
\ No newline at end of file
......@@ -112,11 +112,13 @@ public class DischargingDaoImpl extends AbstractBaseDao implements DischargingDa
return page;
}
@Override
public List<HashMap<String, Object>> groupInfo(List<UUID> regionalCompanyIds, Integer year, Boolean isGroupByMonth, Boolean isGroupByRegionalCompany, Boolean isGroupBySandMiningArea) {
DetachedCriteria detachedCriteria = getDetachedCriteria(null, null, DateTimeUtils.getYearStart(year), DateTimeUtils.getYearEnd(year), null, null, null, null, null, regionalCompanyIds);
public List<HashMap<String, Object>> groupInfo(List<UUID> stationIds,List<UUID> regionalCompanyIds, Date startDate,Date endDate,Integer type, Boolean isGroupByMonth, Boolean isGroupByRegionalCompany, Boolean isGroupBySandMiningArea,Boolean isGroupByDay,Boolean isGroupByStationId) {
DetachedCriteria detachedCriteria = getDetachedCriteria(type, null, startDate, endDate, null, stationIds, null, null, null, regionalCompanyIds);
ProjectionList add = Projections.projectionList()
.add(Projections.alias(Projections.sum("dischargingWeight"), "sumDischargingWeight"))
.add(Projections.alias(Projections.property("dischargingTime"), "dischargingTime"))
.add(Projections.alias(Projections.sqlGroupProjection(" year({alias}.discharging_time) as year", " year({alias}.discharging_time)", new String[]{"year"}, new Type[]{StandardBasicTypes.INTEGER}), "year"));
if (isGroupByMonth) {
add.add(Projections.alias(
......@@ -126,11 +128,42 @@ public class DischargingDaoImpl extends AbstractBaseDao implements DischargingDa
new Type[]{StandardBasicTypes.INTEGER}), "month"));
}
if (isGroupByDay) {
add.add(Projections.alias(
Projections.sqlGroupProjection("day({alias}.discharging_time) as day",
"day({alias}.discharging_time)",
new String[]{"day"},
new Type[]{StandardBasicTypes.INTEGER}), "day"));
}
if (isGroupByRegionalCompany) {
detachedCriteria.createCriteria("regionalCompany","company");
add.add(Projections.alias(Projections.groupProperty("regionalCompany.id"), "regionalCompany"));
add.add(Projections.alias(Projections.property("company.name"), "companyName"))
.add(Projections.alias(Projections.property("company.id"), "companyId"));
//图表用,起个别名
add.add(Projections.alias(Projections.property("company.name"), "parentName"))
.add(Projections.alias(Projections.property("company.id"), "parentId"));
}
if (isGroupBySandMiningArea) {
add.add(Projections.alias(Projections.groupProperty("sandMiningArea.id"), "sandMiningArea"));
detachedCriteria.createCriteria("sandMiningArea","area");
add.add(Projections.alias(Projections.groupProperty("area.id"), "sandMiningArea"));
add.add(Projections.alias(Projections.property("area.sandMiningAreaName"), "sandMiningAreaName"))
.add(Projections.alias(Projections.property("area.id"), "sandMiningAreaId"))
//图表用,起个别名
.add(Projections.alias(Projections.property("area.sandMiningAreaName"), "parentName"))
.add(Projections.alias(Projections.property("area.id"), "parentId"))
;
}
if (isGroupByStationId) {
detachedCriteria.createCriteria("station","station");
add.add(Projections.alias(Projections.groupProperty("station.id"), "stationId"));
add.add(Projections.alias(Projections.property("station.stationName"), "stationName"));
//图表用,起个别名
add.add(Projections.alias(Projections.property("station.stationName"), "parentName"));
add.add(Projections.alias(Projections.property("station.id"), "parentId"));
}
detachedCriteria.setProjection(add);
// projL.add(Projections.sqlGroupProjection("day({alias}.dataHoraEnt) as day, month({alias}.dataHoraEnt) as month, year({alias}.dataHoraEnt) as year", "day({alias}.dataHoraEnt), month({alias}.dataHoraEnt), year({alias}.dataHoraEnt)", new String[]{"day","month", "year"}, (org.hibernate.type.Type[]) new Type[]{Hibernate.INTEGER, Hibernate.INTEGER, Hibernate.INTEGER}));
......@@ -169,7 +202,7 @@ public class DischargingDaoImpl extends AbstractBaseDao implements DischargingDa
if (null != sandMiningAreaType) {
criteria.add(Restrictions.eq("sandMiningArea.sandMiningAreaType", sandMiningAreaType));
}
if (null != stationIds) {
if (!CollectionUtils.isEmpty(stationIds)) {
criteria.add(Restrictions.in("station.id", stationIds));
}
if (null != sandMiningAreaId) {
......
......@@ -11,20 +11,14 @@ import com.beecode.inz.common.util.DateTimeUtils;
import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.production.constant.ProductionPlanReportConstant;
import com.xyst.dinas.production.dao.ProductionPlanReportDao;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.*;
import org.hibernate.query.Query;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* @author scol
......@@ -75,28 +69,26 @@ public class ProductionPlanReportDaoImpl extends AbstractBaseDao implements Prod
private ArrayList<KObject> removeBaseFiled(List<KObject> list) {
ArrayList<KObject> kObjects = new ArrayList<>();
KObject dinasTypeDetailsKObj;
KObject dinasTypeDetailsKobj;
KObject[] dinasTypeDetails;
for (KObject kObject : list) {
KObject clone = kObject.clone();
// clone.setNull(BaseConstants.CREATOR);
// clone.setNull(BaseConstants.MODIFIER);
clone.setNull("regionalCompany");
KObject station = clone.get("station").clone();
station.setNull(BaseConstants.CREATOR);
station.setNull(BaseConstants.MODIFIER);
station.setNull("regionalCompany");
clone.set("station",station);
dinasTypeDetailsKObj = clone.get("dinasTypeDetails").clone();
if(null!=dinasTypeDetailsKObj){
dinasTypeDetails = dinasTypeDetailsKObj.toArray();
clone.set("station", station);
dinasTypeDetailsKobj = clone.get("dinasTypeDetails").clone();
if (null != dinasTypeDetailsKobj) {
dinasTypeDetails = dinasTypeDetailsKobj.toArray();
for (KObject dinasTypeDetail : dinasTypeDetails) {
dinasTypeDetail.get("dinasType").setNull(BaseConstants.CREATOR);
dinasTypeDetail.get("dinasType").setNull(BaseConstants.MODIFIER);
dinasTypeDetail.get("dinasType").setNull("regionalCompany");
}
}
clone.set("dinasTypeDetails",dinasTypeDetailsKObj);
clone.set("dinasTypeDetails", dinasTypeDetailsKobj);
kObjects.add(clone);
}
return kObjects;
......@@ -163,8 +155,8 @@ public class ProductionPlanReportDaoImpl extends AbstractBaseDao implements Prod
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
detachedCriteria.createAlias("master", "master");
detachedCriteria.createAlias("dinasType", "dinasType");
detachedCriteria.add(Restrictions.eq("dinasType.del",false));
detachedCriteria.add(Restrictions.eq("master.del",false));
detachedCriteria.add(Restrictions.eq("dinasType.del", false));
detachedCriteria.add(Restrictions.eq("master.del", false));
if (null != stationId) {
detachedCriteria.add(Restrictions.eq("master.station.id", stationId));
}
......@@ -239,17 +231,90 @@ public class ProductionPlanReportDaoImpl extends AbstractBaseDao implements Prod
public List<KObject> getNoWareHousing(UUID productionPlanId) {
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(ENTITY);
detachedCriteria.add(Restrictions.eq(BaseConstants.DEL, false));
if (null==productionPlanId) {
if (null == productionPlanId) {
detachedCriteria.add(Restrictions.le("productionPlanDate", DateTimeUtils.getStartDateTimeOfDay(new Date())));
} else {
//根据单条生产计划id查询该场站今天所有的生产计划
List<UUID> ids= getAllByOne(productionPlanId);
List<UUID> ids = getAllByOne(productionPlanId);
detachedCriteria.add(Restrictions.in("id", ids));
}
detachedCriteria.add(Restrictions.eq("warehousingStatus", false));
return (List<KObject>) template.findByCriteria(detachedCriteria);
}
@Override
public List<Map<String, Object>> getProductionGroup(Date startDate, Date endDate, List<UUID> ids, List<UUID> stationIds, Boolean isGroupByProductionLine, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) {
DetachedCriteria detachedCriteria = getProductionGroup(ids, stationIds, isGroupByProductionLine, isGroupByRegionalCompany, isGroupByStation, false, true);
detachedCriteria.add(Restrictions.ge(BaseConstants.MASTER +".productionPlanDate",startDate))
.add(Restrictions.lt(BaseConstants.MASTER +".productionPlanDate",endDate));
return (List<Map<String, Object>>) template.findByCriteria(detachedCriteria);
}
private DetachedCriteria getProductionGroup(List<UUID> ids, List<UUID> stationIds, Boolean isGroupByProductionLine, Boolean isGroupByRegionalCompany, Boolean isGroupByStation, Boolean isGroupByDinasType, Boolean isGroupByDay) {
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(DETAIL_ENTITY);
ProjectionList add = Projections.projectionList();
detachedCriteria.createCriteria(BaseConstants.MASTER, BaseConstants.MASTER);
detachedCriteria.createAlias(BaseConstants.MASTER + ".regionalCompany", "regionalCompany");
detachedCriteria.createAlias(BaseConstants.MASTER + ".station", "station");
detachedCriteria.add(Restrictions.eq(BaseConstants.MASTER + "." + BaseConstants.DEL, false));
if (isGroupByDay) {
add.add(Projections.alias(
Projections.property(BaseConstants.MASTER + ".productionPlanDate"), "productionPlanDate"));
add.add(Projections.alias(
Projections.groupProperty(BaseConstants.MASTER + ".productionPlanDate"), "productionPlanDate"));
}
if (isGroupByDinasType) {
detachedCriteria.createCriteria("dinasType", "dinasType");
add.add(Projections.alias(Projections.groupProperty("dinasType.dinasTypeName"), "dinasTypeName"));
add.add(Projections.alias(
Projections.groupProperty("dinasType.id"), "dinasTypeId"));
}
if (!CollectionUtils.isEmpty(ids)) {
detachedCriteria.add(Restrictions.in("regionalCompany.id", ids));
}
if (!CollectionUtils.isEmpty(stationIds)) {
detachedCriteria.add(Restrictions.in("station.id", stationIds));
}
if (isGroupByRegionalCompany) {
add.add(Projections.alias(Projections.groupProperty("regionalCompany.id"), "regionalCompanyId"));
//图表用,起个别名
add.add(Projections.alias(Projections.property("regionalCompany.name"), "parentName"))
.add(Projections.alias(Projections.property("regionalCompany.id"), "parentId"));
}
if (isGroupByStation) {
add.add(Projections.alias(Projections.groupProperty("station.id"), "stationId"));
//图表用,起个别名
add.add(Projections.alias(Projections.property("station.stationName"), "parentName"))
.add(Projections.alias(Projections.property("station.id"), "parentId"));
}
if (isGroupByProductionLine) {
detachedCriteria.createCriteria(BaseConstants.MASTER + ".productionLine", "productionLine");
add.add(Projections.alias(Projections.groupProperty("productionLine.id"), "productionLineId"));
add.add(Projections.alias(Projections.groupProperty("productionLine.name"), "productionLineName"));
//图表用,起个别名
add.add(Projections.alias(Projections.property("productionLine.name"), "parentName"))
.add(Projections.alias(Projections.property("productionLine.id"), "parentId"));
}
add.add(Projections.alias(Projections.sum("dinasWeight"), "sumDinasWeight"));
detachedCriteria.setProjection(add);
detachedCriteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
return detachedCriteria;
}
@Override
public List<Map<String, Object>> getProductionByDinasTypeAndProductionLine(Date startDate, Date endDate, List<UUID> stationIds, List<UUID> ids) {
DetachedCriteria detachedCriteria = getProductionGroup(ids, stationIds, true, false, false, true, false);
detachedCriteria.add(Restrictions.ge(BaseConstants.MASTER +".productionPlanDate",startDate))
.add(Restrictions.lt(BaseConstants.MASTER +".productionPlanDate",endDate));
return (List<Map<String, Object>>)template.findByCriteria(detachedCriteria);
}
private List<UUID> getAllByOne(UUID productionPlanId) {
KObject load = load(productionPlanId);
......@@ -258,7 +323,7 @@ public class ProductionPlanReportDaoImpl extends AbstractBaseDao implements Prod
detachedCriteria.add(Restrictions.eq("productionPlanDate", load.getDate("productionPlanDate")));
detachedCriteria.add(Restrictions.eq("station.id", load.get("station").getUuid("id")));
detachedCriteria.setProjection(Projections.projectionList().add(Projections.distinct(Projections.property("id"))));
return (List<UUID>)template.findByCriteria(detachedCriteria);
return (List<UUID>) template.findByCriteria(detachedCriteria);
}
......
package com.xyst.dinas.production.internal.service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.xyst.dinas.production.entity.TimeValueParentEntity;
import com.xyst.dinas.production.entity.TimeValue;
import com.xyst.dinas.production.service.ProductionPlanReportService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
......@@ -16,7 +25,6 @@ import com.xyst.dinas.biz.constant.SandMiningAreaConstant;
import com.xyst.dinas.biz.dao.ShipInfoDao;
import com.xyst.dinas.biz.dao.StationDao;
import com.xyst.dinas.biz.warn.BaseBusinessWarn;
import com.xyst.dinas.biz.warn.WarnSettingConstant;
import com.xyst.dinas.biz.warn.service.WarningService;
import com.xyst.dinas.production.dao.DischargingDao;
import com.xyst.dinas.production.enumeration.DischargingTypeEnum;
......@@ -28,6 +36,8 @@ public class DischargingServiceImpl implements DischargingService {
@Autowired
private DischargingDao dischargingDao;
@Autowired
private ProductionPlanReportService planReportService;
@Autowired
private WarningService warningService;
......@@ -61,12 +71,154 @@ public class DischargingServiceImpl implements DischargingService {
@Override
public List<HashMap<String, Object>> groupInfoByYear(List<UUID> regionalCompanyIds, Integer year, Boolean isGroupByMonth, Boolean isGroupByRegionalCompany, Boolean isGroupBySandMiningArea) {
return dischargingDao.groupInfo(regionalCompanyIds, year, isGroupByMonth, isGroupByRegionalCompany, isGroupBySandMiningArea);
return dischargingDao.groupInfo(null,regionalCompanyIds, DateTimeUtils.getYearStart(year), DateTimeUtils.getYearEnd(year), null, isGroupByMonth, isGroupByRegionalCompany, isGroupBySandMiningArea, false, false);
}
@Override
public Page<KObject> queryPagingByCreator(Page<KObject> objectPage, Date startDate, Date endDate, UUID creatorId) {
return dischargingDao.queryPagingByCreator(objectPage,startDate,endDate,creatorId);
return dischargingDao.queryPagingByCreator(objectPage, startDate, endDate, creatorId);
}
/**
* 根据采区查询进30天 每天接接驳量
* 如果是2月份的话 近30天的时间可能 跨2个月 为1 2 3
* 分批处理,先获取时间范围内的修正数据
*
* @param startDate
* @param endDate
* @param regionalCompanyIds
* @param stationIds
* @param showType
* @return
*/
@Override
public List<TimeValueParentEntity> getDischargingGroup(Date startDate, Date endDate, List<UUID> stationIds,List<UUID> regionalCompanyIds, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation, Integer showType) {
Date startDateTimeOfMonth = DateTimeUtils.getStartDateTimeOfMonth(startDate);
Date endDateTimeOfMonth = DateTimeUtils.getEndDateTimeOfMonth(endDate);
LocalDateTime localStartDate = LocalDateTime.ofInstant(startDate.toInstant(), ZoneId.systemDefault());
LocalDateTime localEndDate = LocalDateTime.ofInstant(endDate.toInstant(), ZoneId.systemDefault());
Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap = new HashMap<>(12);
List<TimeValueParentEntity> timeValueParentEntities = new ArrayList<>();
//处理时间.首先获取时间范围内所有修正数据
groupByRevise(stationIds,regionalCompanyIds, startDateTimeOfMonth, endDateTimeOfMonth, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities,isGroupByArea,isGroupByRegionalCompany,isGroupByStation);
//对非修正数据进行补充
groupByNormal(startDate, endDate, stationIds,regionalCompanyIds, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities,isGroupByArea,isGroupByRegionalCompany,isGroupByStation);
//对数据做补充,没有的日期填充0
for (TimeValueParentEntity miningAreaTimeValueEntity : timeValueParentEntities) {
List<TimeValue> timeValues = miningAreaTimeValueEntity.getTimeValues();
long distance = ChronoUnit.DAYS.between(localStartDate, localEndDate);
planReportService.setEveryDayValue(localStartDate, distance, timeValues);
miningAreaTimeValueEntity.setTimeValues(timeValues);
}
return replaceShowType(showType, timeValueParentEntities);
}
@Override
public List<TimeValueParentEntity> replaceShowType(Integer showType, List<TimeValueParentEntity> timeValueParentEntities) {
if(null==showType || 0==showType){
return timeValueParentEntities;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
if(2==showType){
dateFormat= new SimpleDateFormat("yyyy");
}
SimpleDateFormat finalDateFormat = dateFormat;
for (TimeValueParentEntity valueParentEntity : timeValueParentEntities) {
List<TimeValue> timeValues = valueParentEntity.getTimeValues();
ArrayList<TimeValue> timeValues2 = new ArrayList<>();
Map<String, List<TimeValue>> collect = timeValues.stream().collect(Collectors.groupingBy(timeValue -> finalDateFormat.format(timeValue.getTime())));
collect.forEach((s, timeValues1) -> {
try {
timeValues2.add(new TimeValue(UUID.randomUUID(),finalDateFormat.parse(s),timeValues1.stream().mapToDouble(TimeValue::getValue).summaryStatistics().getSum()));
} catch (ParseException e) {
e.printStackTrace();
}
});
timeValues2.sort(Comparator.comparing(TimeValue::getTime));
valueParentEntity.setTimeValues(timeValues2);
}
return timeValueParentEntities;
}
private void groupByNormal(Date startDate, Date endDate, List<UUID> stationIds,List<UUID> regionalCompanyIds,
Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap,
List<TimeValueParentEntity> timeValueParentEntityList, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) {
TimeValueParentEntity timeValueParentEntity;
//查询时间段内的非修正数据
List<HashMap<String, Object>> dischargingNormalDataList = dischargingDao.groupInfo(stationIds,regionalCompanyIds, startDate, endDate,
DischargingTypeEnum.NORMAL_DATA.getValue(),
true, isGroupByRegionalCompany, isGroupByArea, Boolean.TRUE, isGroupByStation);
//将修正数据平均到每一天的数据与非修正数据相加
for (HashMap<String, Object> stringObjectHashMap : dischargingNormalDataList) {
Double dischargingWeight = Double.parseDouble(stringObjectHashMap.get("sumDischargingWeight").toString());
Date dischargingTime = (Date) stringObjectHashMap.get("dischargingTime");
UUID sandMiningAreaId = setSandMiningAreaTimeValueEntityHashMap(sandMiningAreaTimeValueEntityHashMap, timeValueParentEntityList, stringObjectHashMap);
timeValueParentEntity = sandMiningAreaTimeValueEntityHashMap.get(sandMiningAreaId);
List<TimeValue> timeValues = timeValueParentEntity.getTimeValues();
List<TimeValue> timeValueNew = new ArrayList<>();
if (timeValues.size() > 0) {
for (TimeValue timeValue : timeValues) {
//如果修正数据中有非修正数据的天数,加起来
if (DateUtils.isSameDay(timeValue.getTime(), dischargingTime)) {
timeValue.setValue(timeValue.getValue() + dischargingWeight);
}
}
} else {
timeValues.add(new TimeValue(UUID.randomUUID(), dischargingTime, dischargingWeight));
}
for (TimeValue timeValue : timeValues) {
if (!timeValue.getTime().after(endDate) && !timeValue.getTime().before(startDate)) {
timeValueNew.add(timeValue);
}
}
timeValueNew.sort(Comparator.comparing(TimeValue::getTime));
timeValueParentEntity.setTimeValues(timeValueNew);
}
}
private void groupByRevise(List<UUID> stationIds,List<UUID> regionalCompanyIds, Date startDateTimeOfMonth, Date endDateTimeOfMonth,
Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap,
List<TimeValueParentEntity> timeValueParentEntityList, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) {
//查询修正数据
List<HashMap<String, Object>> dischargingReviseList = dischargingDao.groupInfo(stationIds,regionalCompanyIds, startDateTimeOfMonth, endDateTimeOfMonth,
DischargingTypeEnum.REVISE_DATA.getValue(),
true, isGroupByRegionalCompany, isGroupByArea, false, isGroupByStation);
//组装数据 改成 采区-> {时间,值} 格式
TimeValueParentEntity timeValueParentEntity;
for (HashMap<String, Object> stringObjectHashMap : dischargingReviseList) {
UUID sandMiningAreaId = setSandMiningAreaTimeValueEntityHashMap(sandMiningAreaTimeValueEntityHashMap, timeValueParentEntityList, stringObjectHashMap);
timeValueParentEntity = sandMiningAreaTimeValueEntityHashMap.get(sandMiningAreaId);
List<TimeValue> timeValues = timeValueParentEntity.getTimeValues();
//获取当前数据所在月有多少天,并分解成每天的数据
Date dischargingTime = (Date) stringObjectHashMap.get("dischargingTime");
LocalDate localDate = LocalDateTime.ofInstant(DateTimeUtils.getStartDateTimeOfDay(dischargingTime).toInstant(), ZoneId.systemDefault()).toLocalDate();
int daysOfMonth = DateTimeUtils.getDaysOfMonth(dischargingTime);
double dischargingValue = Double.parseDouble(stringObjectHashMap.get("sumDischargingWeight").toString());
double v = dischargingValue / daysOfMonth;
Stream.iterate(localDate, a -> a.plusDays(1)).limit(daysOfMonth).forEach(
f -> timeValues.add(new TimeValue(UUID.randomUUID(), Date.from(f.atStartOfDay(ZoneId.systemDefault()).toInstant()), v))
);
timeValueParentEntity.setTimeValues(timeValues);
}
}
private UUID setSandMiningAreaTimeValueEntityHashMap(Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap, List<TimeValueParentEntity> timeValueParentEntityList, HashMap<String, Object> stringObjectHashMap) {
TimeValueParentEntity timeValueParentEntity;
UUID sandMiningAreaId = UUID.fromString(stringObjectHashMap.get("parentId").toString());
if (!sandMiningAreaTimeValueEntityHashMap.containsKey(sandMiningAreaId)) {
timeValueParentEntity = new TimeValueParentEntity();
timeValueParentEntity.setParentId(sandMiningAreaId);
timeValueParentEntity.setParentName(stringObjectHashMap.get("parentName").toString());
timeValueParentEntity.setTimeValues(new ArrayList<>());
sandMiningAreaTimeValueEntityHashMap.put(sandMiningAreaId, timeValueParentEntity);
timeValueParentEntityList.add(timeValueParentEntity);
}
return sandMiningAreaId;
}
@Override
......
......@@ -14,15 +14,24 @@ import com.xyst.dinas.biz.dao.ProductionLineDao;
import com.xyst.dinas.biz.dao.StationDao;
import com.xyst.dinas.production.constant.ProductionPlanReportConstant;
import com.xyst.dinas.production.dao.ProductionPlanReportDao;
import com.xyst.dinas.production.entity.DinasTypeParent;
import com.xyst.dinas.production.entity.TimeValue;
import com.xyst.dinas.production.entity.TimeValueParentEntity;
import com.xyst.dinas.production.service.DischargingService;
import com.xyst.dinas.production.service.ProductionPlanReportService;
import com.xyst.dinas.sales.service.InventoryService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Stream;
@Transactional(rollbackFor = Exception.class)
public class ProductionPlanReportServiceImpl implements ProductionPlanReportService {
......@@ -37,6 +46,8 @@ public class ProductionPlanReportServiceImpl implements ProductionPlanReportServ
private ProductionLineDao productionLineDao;
@Autowired
private InventoryService inventoryService;
@Autowired
private DischargingService dischargingService;
@Override
public Page<KObject> queryByPaging(Page<KObject> page, UUID stationId, UUID productionLineId, Date startDate, Date endDate) throws Exception {
......@@ -173,7 +184,6 @@ public class ProductionPlanReportServiceImpl implements ProductionPlanReportServ
List<KObject> a = productionPlanReportDao.getNoWareHousing(productionLineIds);
JSONObject params = new JSONObject();
// JSONArray regionalCompanyList = params.getJSONArray("datas");
for (KObject kObject : a) {
UUID regionalCompanyId = kObject.get("regionalCompany").getUuid("id");
......@@ -208,6 +218,116 @@ public class ProductionPlanReportServiceImpl implements ProductionPlanReportServ
}
@Override
public List<TimeValueParentEntity> getProductionGroup(Date startDate, Date endDate,
List<UUID> ids, List<UUID> stationIds,
Boolean isGroupByProductionLine,
Boolean isGroupByRegionalCompany,
Boolean isGroupByStation,
Integer showType) {
List<Map<String, Object>> productionList = productionPlanReportDao.getProductionGroup(startDate, endDate, ids, stationIds, isGroupByProductionLine, isGroupByRegionalCompany, isGroupByStation);
LocalDateTime localStartDate = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
LocalDateTime localEndDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
long distance = ChronoUnit.DAYS.between(localStartDate, localEndDate);
HashMap<UUID, TimeValueParentEntity> stringTimeValueParentEntityHashMap = new HashMap<>(12);
List<TimeValueParentEntity> timeValueParentEntities = new ArrayList<>();
TimeValueParentEntity timeValueParentEntity;
for (Map<String, Object> stringObjectMap : productionList) {
UUID parentId = UUID.fromString(stringObjectMap.get("parentId").toString());
Date productionPlanDate = (Date) stringObjectMap.get("productionPlanDate");
double sumDinasWeight = Double.parseDouble(stringObjectMap.get("sumDinasWeight").toString());
if(!stringTimeValueParentEntityHashMap.containsKey(parentId)){
timeValueParentEntity= new TimeValueParentEntity();
timeValueParentEntity.setParentId(parentId);
timeValueParentEntity.setParentName(stringObjectMap.get("parentName").toString());
timeValueParentEntity.setTimeValues(new ArrayList<>());
timeValueParentEntities.add(timeValueParentEntity);
stringTimeValueParentEntityHashMap.put(parentId,timeValueParentEntity);
}
timeValueParentEntity = stringTimeValueParentEntityHashMap.get(parentId);
List<TimeValue> timeValues = timeValueParentEntity.getTimeValues();
timeValues.add(new TimeValue(UUID.randomUUID(),productionPlanDate,sumDinasWeight));
}
for (TimeValueParentEntity valueParentEntity : timeValueParentEntities) {
List<TimeValue> timeValues = valueParentEntity.getTimeValues();
setEveryDayValue(localStartDate, distance, timeValues);
}
return dischargingService.replaceShowType(showType, timeValueParentEntities);
}
@Override
public void setEveryDayValue(LocalDateTime localStartDate, long distance, List<TimeValue> timeValues) {
Stream.iterate(localStartDate, a -> a.plusDays(1)).limit(distance+1).forEach(
localTime -> {
Date from = Date.from(localTime.atZone(ZoneId.systemDefault()).toInstant());
boolean canAdd = true;
for (TimeValue timeValue : timeValues) {
if (DateUtils.isSameDay(from, timeValue.getTime())) {
canAdd = false;
}
}
if (canAdd) {
timeValues.add(new TimeValue(UUID.randomUUID(), from, 0.0d));
}
}
);
timeValues.sort(Comparator.comparing(TimeValue::getTime));
}
@Override
public Map<String, Object> getProductionDinasTypeGroup(List<UUID> stationIds, List<UUID> ids, Date startDate, Date endDate) {
Map<String, String> productionLineNameMap;
Set<Map<String, String>> productionLineNameSet = new HashSet<>();
Map<UUID, DinasTypeParent> dinasTypeMap = new HashMap<>(12);
List<DinasTypeParent> dinasTypeParents = new ArrayList<>();
Map<String, TimeValueParentEntity> productionLineMap = new HashMap<>(12);
List<TimeValueParentEntity> timeValueParentEntityList;
//根据生产线和砂石类型分组
List<Map<String, Object>> productionByDinasTypeAndProductionLine = productionPlanReportDao.getProductionByDinasTypeAndProductionLine(startDate, endDate, stationIds, ids);
for (Map<String, Object> stringObjectMap : productionByDinasTypeAndProductionLine) {
UUID productionLineId = UUID.fromString(stringObjectMap.get("productionLineId").toString());
UUID dinasTypeId = UUID.fromString(stringObjectMap.get("dinasTypeId").toString());
String dinasTypeName = stringObjectMap.get("dinasTypeName").toString();
String productionLineName = stringObjectMap.get("productionLineName").toString();
Double sumDinasWeight = Double.parseDouble(stringObjectMap.get("sumDinasWeight").toString());
productionLineNameMap=new HashMap<>(12);
productionLineNameMap.put("id",productionLineId.toString());
productionLineNameMap.put("name",productionLineName);
productionLineNameSet.add(productionLineNameMap);
if(!dinasTypeMap.containsKey(dinasTypeId)){
DinasTypeParent productionLineEchart = new DinasTypeParent();
productionLineEchart.setDinasTypeId(dinasTypeId);
productionLineEchart.setDinasTypeName(dinasTypeName);
productionLineEchart.setTimeValueParentEntityList(new ArrayList<>());
dinasTypeMap.put(dinasTypeId,productionLineEchart);
dinasTypeParents.add(productionLineEchart);
}
DinasTypeParent dinasTypeParent = dinasTypeMap.get(dinasTypeId);
timeValueParentEntityList = dinasTypeParent.getTimeValueParentEntityList();
if(!productionLineMap.containsKey(productionLineId.toString()+ dinasTypeId)){
TimeValueParentEntity timeValueParentEntity = new TimeValueParentEntity();
timeValueParentEntity.setParentId(productionLineId);
timeValueParentEntity.setParentName(productionLineName);
timeValueParentEntity.setTimeValues(new ArrayList<>());
timeValueParentEntityList.add(timeValueParentEntity);
productionLineMap.put(productionLineId.toString()+ dinasTypeId,timeValueParentEntity);
}
TimeValueParentEntity timeValueParentEntity = productionLineMap.get(productionLineId.toString() + dinasTypeId);
List<TimeValue> timeValues = timeValueParentEntity.getTimeValues();
timeValues.add(new TimeValue(UUID.randomUUID(),null,sumDinasWeight));
}
Map<String, Object> returnMap = new HashMap<>(2);
returnMap.put("productionLineNameSet",productionLineNameSet);
returnMap.put("dinasTypeParents",dinasTypeParents);
return returnMap;
}
@Override
public List<KObject> listByStationAndDate(UUID stationId, Date date) {
return productionPlanReportDao.listByStationAndDate(stationId,date, null);
}
......
......@@ -2,6 +2,7 @@ package com.xyst.dinas.production.service;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KObject;
import com.xyst.dinas.production.entity.TimeValueParentEntity;
import java.util.Date;
import java.util.List;
......@@ -10,6 +11,8 @@ import java.util.UUID;
public interface DischargingService {
List<TimeValueParentEntity> replaceShowType(Integer showType, List<TimeValueParentEntity> timeValueParentEntities);
UUID addDischarging(KObject kObject);
......@@ -33,4 +36,6 @@ public interface DischargingService {
Page<KObject> queryPagingByCreator(Page<KObject> objectPage, Date startDate, Date endDate, UUID creatorId);
List<TimeValueParentEntity> getDischargingGroup(Date startDate, Date endDate, List<UUID> stationIds,List<UUID> regionalCompanyIds, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation, Integer showType);
}
......@@ -3,9 +3,13 @@ package com.xyst.dinas.production.service;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.xyst.dinas.production.entity.TimeValue;
import com.xyst.dinas.production.entity.TimeValueParentEntity;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public interface ProductionPlanReportService {
......@@ -40,4 +44,9 @@ public interface ProductionPlanReportService {
void warehousing(UUID productionLineIds);
List<TimeValueParentEntity> getProductionGroup(Date startDate, Date endDate, List<UUID> ids, List<UUID> stationIds, Boolean isGroupByProductionLine, Boolean isGroupByRegionalCompany, Boolean isGroupByStation,Integer showType);
void setEveryDayValue(LocalDateTime localStartDate, long distance, List<TimeValue> timeValues);
Map<String,Object> getProductionDinasTypeGroup(List<UUID> stationIds, List<UUID> ids, Date startDate, Date endDate);
}
......@@ -6,7 +6,7 @@ import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.nlib.utils.StringUtils;
import com.beecode.inz.common.BaseConstants;
import com.xyst.dinas.production.constant.DischargingConstant;
import com.xyst.dinas.production.service.DischargingService;
import org.slf4j.Logger;
......@@ -94,7 +94,7 @@ public class DischargingController {
public ResponseObj create(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(DischargingConstant.ENTITY, KClass.class));
if(kobject.getUuid("id") == null){
if(kobject.getUuid(BaseConstants.ID) == null){
return ResponseObj.error(400,"'id' must be not null!");
}
UUID id = dischargingService.addDischarging(kobject);
......@@ -109,7 +109,7 @@ public class DischargingController {
@PutMapping
public ResponseObj update(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(DischargingConstant.ENTITY, KClass.class));
if(kobject.getUuid("id") == null){
if(kobject.getUuid(BaseConstants.ID) == null){
return ResponseObj.error(400,"'id' must be not null!");
}
dischargingService.update(kobject);
......@@ -192,4 +192,28 @@ public class DischargingController {
}
/**
* 获取近xx天内xx的接驳量
* @param startDate 开始时间
* @param endDate yyyy-mm-dd 结束时间
* @param ids 区域公司id
* @return
*/
@GetMapping("/getDischargingGroupByDataChartLine")
public ResponseObj getDischargingGroupByDataChartLine( @DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("startDate") Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("endDate") Date endDate,
@RequestParam(value = "ids",required = false) List<UUID> ids,
@RequestParam(value = "stationIds",required = false) List<UUID> stationIds,
@RequestParam(value = "isGroupByArea",required = false,defaultValue = "true") Boolean isGroupByArea,
@RequestParam(value = "isGroupByRegionalCompany",required = false,defaultValue = "false") Boolean isGroupByRegionalCompany,
@RequestParam(value = "isGroupByStation",required = false,defaultValue = "false") Boolean isGroupByStation,
@RequestParam(value = "showType",required = false,defaultValue = "0") Integer showType
){
return ResponseObj.success("查询成功",dischargingService.getDischargingGroup(startDate,endDate,stationIds,ids,isGroupByArea,isGroupByRegionalCompany,isGroupByStation,showType));
}
}
\ No newline at end of file
......@@ -23,61 +23,62 @@ import java.util.UUID;
* @author scol
*/
@RestController()
@RequestMapping(value="/production/productionPlanReport")
@RequestMapping(value = "/production/productionPlanReport")
public class ProductionPlanReportController {
@Autowired
private ProductionPlanReportService productionPlanReportService;
private ProductionPlanReportService productionPlanReportService;
@RequestMapping(value = "list/page", method = RequestMethod.GET)
public ResponseObj getListPage(
@RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "stationId", required = false) UUID stationId,
@RequestParam(name = "productionLineId", required = false) UUID productionLineId,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@RequestParam(name = "startDate", required = false) Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@RequestParam(name = "endDate", required = false) Date endDate
) throws Exception {
@RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "stationId", required = false) UUID stationId,
@RequestParam(name = "productionLineId", required = false) UUID productionLineId,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(name = "startDate", required = false) Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(name = "endDate", required = false) Date endDate
) throws Exception {
Page<KObject> objectPage = new Page<>();
objectPage.setPageNo(pageNo);
objectPage.setPageSize(pageSize);
return ResponseObj.success("查询成功", productionPlanReportService.queryByPaging(objectPage, stationId,productionLineId,startDate,endDate));
return ResponseObj.success("查询成功", productionPlanReportService.queryByPaging(objectPage, stationId, productionLineId, startDate, endDate));
}
@RequestMapping(value = "list/groupInfo", method = RequestMethod.GET)
public ResponseObj groupInfo(
@RequestParam(name = "stationId", required = false) UUID stationId,
@RequestParam(name = "productionLineId", required = false) UUID productionLineId,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@RequestParam(name = "startDate", required = false) Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")@RequestParam(name = "endDate", required = false) Date endDate
) {
@RequestParam(name = "stationId", required = false) UUID stationId,
@RequestParam(name = "productionLineId", required = false) UUID productionLineId,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(name = "startDate", required = false) Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(name = "endDate", required = false) Date endDate
) {
return ResponseObj.success("查询成功", productionPlanReportService.groupInfo( stationId,productionLineId,startDate,endDate));
return ResponseObj.success("查询成功", productionPlanReportService.groupInfo(stationId, productionLineId, startDate, endDate));
}
@RequestMapping(value = "warehousing", method = RequestMethod.GET)
public ResponseObj warehousing(
@RequestParam(name = "productionPlanId", required = false) UUID productionPlanId
) {
) {
productionPlanReportService.warehousing(productionPlanId);
return ResponseObj.success("入库成功");
}
/**
* 新建生产计划
*
* @param body json
* @return ResponseObj
*/
@PostMapping
public ResponseObj create(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(ProductionPlanReportConstant.ENTITY, KClass.class));
public ResponseObj create(@RequestBody String body) {
KObject kobject = JSONObjectUtils.toObject(body, Amino.getApplicationMetadataContext().getBean(ProductionPlanReportConstant.ENTITY, KClass.class));
if(kobject.getUuid(BaseConstants.ID) == null){
return ResponseObj.error(400,"'id' must be not null!");
if (kobject.getUuid(BaseConstants.ID) == null) {
return ResponseObj.error(400, "'id' must be not null!");
}
UUID id = productionPlanReportService.addProductionPlanReport(kobject);
return ResponseObj.success("保存成功", id);
......@@ -85,11 +86,12 @@ public class ProductionPlanReportController {
/**
* 新建生产计划
*
* @param body json
* @return ResponseObj
*/
@PostMapping("createList")
public ResponseObj createList(@RequestBody String body){
public ResponseObj createList(@RequestBody String body) {
JsonNode jsonNode = JSONObjectUtils.toJson(body);
productionPlanReportService.addProductionPlanReportList(jsonNode);
return ResponseObj.success("保存成功");
......@@ -97,11 +99,12 @@ public class ProductionPlanReportController {
/**
* 新建生产计划
*
* @param body json
* @return ResponseObj
*/
@PostMapping("updateList")
public ResponseObj updateList(@RequestBody String body){
public ResponseObj updateList(@RequestBody String body) {
JsonNode jsonNode = JSONObjectUtils.toJson(body);
productionPlanReportService.updateProductionPlanReportList(jsonNode);
return ResponseObj.success("修改成功");
......@@ -109,51 +112,54 @@ public class ProductionPlanReportController {
/**
* 修改生产计划
*
* @param body 生产计划json
* @return 修改成功
*/
@PutMapping
public ResponseObj update(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(ProductionPlanReportConstant.ENTITY, KClass.class));
public ResponseObj update(@RequestBody String body) {
KObject kobject = JSONObjectUtils.toObject(body, Amino.getApplicationMetadataContext().getBean(ProductionPlanReportConstant.ENTITY, KClass.class));
productionPlanReportService.update(kobject);
return ResponseObj.success("修改成功");
}
/**
* 根据id获取生产计划
*
* @param id id
* @return 获取成功
*/
@GetMapping("/{id}")
public ResponseObj getById(@PathVariable("id") UUID id){
if(id == null){
return ResponseObj.error(400,"'id' must be not null!");
public ResponseObj getById(@PathVariable("id") UUID id) {
if (id == null) {
return ResponseObj.error(400, "'id' must be not null!");
}
KObject productionPlanReport = productionPlanReportService.getById(id);
return ResponseObj.success("获取成功",productionPlanReport);
KObject productionPlanReport = productionPlanReportService.getById(id);
return ResponseObj.success("获取成功", productionPlanReport);
}
/**
* 根据场站id和时间获取生产计划
*
* @param stationId 场站id
* @param date 时间
* @param date 时间
* @return 获取成功
*/
@GetMapping("getByStationAndDate")
public ResponseObj getByStationAndDate(@RequestParam UUID stationId ,String date){
return ResponseObj.success("获取成功",productionPlanReportService.listByStationAndDate(stationId, DateUtil.convertStringToDate1(date)));
public ResponseObj getByStationAndDate(@RequestParam UUID stationId, String date) {
return ResponseObj.success("获取成功", productionPlanReportService.listByStationAndDate(stationId, DateUtil.convertStringToDate1(date)));
}
/**
* 根据场站id和时间删除生产计划
*
* @param stationId 场站id
* @param date 时间
* @param date 时间
* @return 获取成功
*/
@DeleteMapping("deleteByStationAndDate")
public ResponseObj deleteByStationAndDate(@RequestParam UUID stationId ,String date){
public ResponseObj deleteByStationAndDate(@RequestParam UUID stationId, String date) {
productionPlanReportService.deleteByStationAndDate(stationId, DateUtil.convertStringToDate1(date));
return ResponseObj.success("删除成功");
}
......@@ -161,22 +167,65 @@ public class ProductionPlanReportController {
/**
* 查询是否有重名
*
* @param stationId 场站id
* @param date yyyy-mm-dd 时间
* @param date yyyy-mm-dd 时间
* @return 生产计划该场站今日是否已存在
*/
@GetMapping("/validateByStationAndDate")
public ResponseObj validateByStationAndDate(@RequestParam("stationId") UUID stationId ,@RequestParam("date") String date,@RequestParam(value = "ids",required = false) List<UUID> ids){
if(stationId == null){
return ResponseObj.error(400,"'id' must be not null!");
}if(date == null){
return ResponseObj.error(400,"'date' must be not null!");
public ResponseObj validateByStationAndDate(@RequestParam("stationId") UUID stationId, @RequestParam("date") String date, @RequestParam(value = "ids", required = false) List<UUID> ids) {
if (stationId == null) {
return ResponseObj.error(400, "'id' must be not null!");
}
if (date == null) {
return ResponseObj.error(400, "'date' must be not null!");
}
KObject kObject = productionPlanReportService.getByStationAndDate(stationId,date,ids);
if(kObject != null){
KObject kObject = productionPlanReportService.getByStationAndDate(stationId, date, ids);
if (kObject != null) {
return ResponseObj.error("生产计划该场站今日已存在!");
}
return ResponseObj.success();
}
/**
* 获取近xx天内xx的生产
*
* @param startDate 开始时间
* @param endDate yyyy-mm-dd 结束时间
* @param ids 区域公司id
* @param stationIds 场站id
* @param isGroupByProductionLine 是否根据生产线分组
* @param isGroupByRegionalCompany 是否根据区域公司分组
* @param isGroupByStation 是否根据场站分组
* @param showType 显示类型 0日 1月 2年
*/
@GetMapping("/getProductionGroupByDataChartLine")
public ResponseObj getProductionGroupByDataChartLine(@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("startDate") Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("endDate") Date endDate,
@RequestParam(value = "ids", required = false) List<UUID> ids,
@RequestParam(value = "stationIds", required = false) List<UUID> stationIds,
@RequestParam(value = "isGroupByProductionLine", required = false, defaultValue = "true") Boolean isGroupByProductionLine,
@RequestParam(value = "isGroupByRegionalCompany", required = false, defaultValue = "false") Boolean isGroupByRegionalCompany,
@RequestParam(value = "isGroupByStation", required = false, defaultValue = "false") Boolean isGroupByStation,
@RequestParam(value = "showType", required = false, defaultValue = "0") Integer showType
) {
return ResponseObj.success("查询成功", productionPlanReportService.getProductionGroup(startDate, endDate, ids, stationIds, isGroupByProductionLine, isGroupByRegionalCompany, isGroupByStation,showType));
}
/**
* 获取多条柱状图-砂石种类统计
*/
@GetMapping("/getProductionDinasTypeGroup")
public ResponseObj getProductionDinasTypeGroup( @DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("startDate") Date startDate,
@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam("endDate") Date endDate,
@RequestParam(value = "ids",required = false) List<UUID> ids,
@RequestParam(value = "stationIds",required = false) List<UUID> stationIds
){
return ResponseObj.success("查询成功",productionPlanReportService.getProductionDinasTypeGroup(stationIds,ids,startDate,endDate));
}
}
\ No newline at end of file
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