Commit 1323fe51 by wukaiqiang

Merge branch 'develop' of gitlab.beecode.cn:kunlun/xyst_dinas/xyst_dinas_backend into develop

parents c7a9036b aede7c9e
......@@ -65,7 +65,7 @@ public class FollowerServiceImpl extends ApplicationMetadataObjectSupport implem
KObject kobject = type.newInstance();
kobject.set("role", body.getRole());
kobject.set("member", staff);
if(!body.getAttachRole().equals("")) {
if(body.getAttachRole() != null && !body.getAttachRole().equals("")) {
Optional<Role> role = roleService.get(UUID.fromString(body.getAttachRole()));
kobject.set("attachRole", role.get().getId());
}
......
......@@ -27,4 +27,6 @@ public interface SandMiningDao extends BaseDao {
List<KObject> queryByShipId(UUID fromString);
List<KObject> getListByShipAndWorkDate(KObject kobject);
}
......@@ -14,6 +14,7 @@ import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.production.constant.SandMiningConstant;
import com.xyst.dinas.production.dao.SandMiningDao;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.LogicalExpression;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.query.Query;
......@@ -135,6 +136,21 @@ public class SandMiningDaoImpl extends AbstractBaseDao implements SandMiningDao,
return (List<KObject>) template.findByCriteria(detachedCriteria);
}
@Override
public List<KObject> getListByShipAndWorkDate(KObject kobject) {
DetachedCriteria detachedCriteria = getDetachedCriteria();
detachedCriteria.add(Restrictions.eq("ship.id",kobject.get("ship").getUuid("id")));
//判断时间是否有交叉
//俩时间段1-2 A-B 如果1晚于B或者2早于A则说明时间没有交叉 反之如果1早于B并且2晚于A则交叉
detachedCriteria.add(Restrictions.ge("sandMiningEnd",kobject.getDate("sandMiningStart")));
detachedCriteria.add(Restrictions.le("sandMiningStart",kobject.getDate("sandMiningEnd")));
if(null!=kobject.getUuid("id")){
detachedCriteria.add(Restrictions.ne("id",kobject.getUuid("id")));
}
return (List<KObject>) template.findByCriteria(detachedCriteria);
}
@Override
public UUID create(KObject kObject) {
......
......@@ -94,15 +94,20 @@ public class DischargingServiceImpl implements DischargingService {
@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);
//对时间进行处理,如果是按月查询则为月初至月末,不按照查询时间操作
if(showType==1){
startDate=DateTimeUtils.getStartDateTimeOfMonth(startDate);
endDate=DateTimeUtils.getEndDateTimeOfMonth(endDate);
}else if (showType==2){
startDate=DateTimeUtils.getYearStart(startDate);
endDate=DateTimeUtils.getYearEnd(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);
groupByRevise(stationIds, regionalCompanyIds, startDate, endDate, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities, isGroupByArea, isGroupByRegionalCompany, isGroupByStation);
//对非修正数据进行补充
groupByNormal(startDate, endDate, stationIds, regionalCompanyIds, sandMiningAreaTimeValueEntityHashMap, timeValueParentEntities, isGroupByArea, isGroupByRegionalCompany, isGroupByStation);
......@@ -154,12 +159,14 @@ public class DischargingServiceImpl implements DischargingService {
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<>();
boolean isAdd = false;
for (TimeValue timeValue : timeValues) {
......@@ -183,9 +190,12 @@ public class DischargingServiceImpl implements DischargingService {
}
}
private void groupByRevise(List<UUID> stationIds, List<UUID> regionalCompanyIds, Date startDateTimeOfMonth, Date endDateTimeOfMonth,
private void groupByRevise(List<UUID> stationIds, List<UUID> regionalCompanyIds, Date startDate, Date endDate,
Map<UUID, TimeValueParentEntity> sandMiningAreaTimeValueEntityHashMap,
List<TimeValueParentEntity> timeValueParentEntityList, Boolean isGroupByArea, Boolean isGroupByRegionalCompany, Boolean isGroupByStation) {
Date startDateTimeOfMonth = DateTimeUtils.getStartDateTimeOfMonth(startDate);
Date endDateTimeOfMonth = DateTimeUtils.getEndDateTimeOfMonth(endDate);
//查询修正数据
List<HashMap<String, Object>> dischargingReviseList = dischargingDao.groupInfo(stationIds, regionalCompanyIds, startDateTimeOfMonth, endDateTimeOfMonth,
DischargingTypeEnum.REVISE_DATA.getValue(),
......@@ -200,10 +210,17 @@ public class DischargingServiceImpl implements DischargingService {
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))
LocalDateTime localStartTime = LocalDateTime.ofInstant(startDate.toInstant(), ZoneId.systemDefault());
LocalDateTime localEndTime1 = LocalDateTime.ofInstant(endDate.toInstant(), ZoneId.systemDefault());
long distance = ChronoUnit.DAYS.between(localStartTime,localEndTime1);
if (distance < 1) {
continue;
}
Stream.iterate(localStartTime, a -> a.plusDays(1)).limit(distance).forEach(
f -> timeValues.add(new TimeValue(UUID.randomUUID(), Date.from(f.atZone(ZoneId.systemDefault()).toInstant()), v))
);
timeValueParentEntity.setTimeValues(timeValues);
}
......
......@@ -7,6 +7,7 @@ import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.common.BaseConstants;
import com.beecode.inz.common.util.DateTimeUtils;
import com.beecode.util.DateUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.xyst.dinas.biz.dao.DinasTypeDao;
......@@ -224,6 +225,15 @@ public class ProductionPlanReportServiceImpl implements ProductionPlanReportServ
Boolean isGroupByRegionalCompany,
Boolean isGroupByStation,
Integer showType) {
//对时间进行处理,如果是按月查询则为月初至月末,不按照查询时间操作
if(showType==1){
startDate= DateTimeUtils.getStartDateTimeOfMonth(startDate);
endDate=DateTimeUtils.getEndDateTimeOfMonth(endDate);
}else if (showType==2){
startDate=DateTimeUtils.getYearStart(startDate);
endDate=DateTimeUtils.getYearEnd(endDate);
}
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();
......@@ -276,6 +286,7 @@ public class ProductionPlanReportServiceImpl implements ProductionPlanReportServ
@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);
......
......@@ -248,6 +248,11 @@ public class SandMiningServiceImpl implements SandMiningService {
}
@Override
public List<KObject> getListByShipAndWorkDate(KObject kobject) {
return sandMiningDao.getListByShipAndWorkDate(kobject);
}
@Override
public List<Map<String, Object>> queryByShip(List<Map<String, Object>> shipsTracking) {
for (Map<String, Object> stringObjectMap : shipsTracking) {
Object shipInfoId = stringObjectMap.get("shipInfoId");
......
......@@ -37,4 +37,6 @@ public interface SandMiningService {
Map<String, Object> setAreaMap(KObject sandMiningArea);
List<KObject> getListByShipAndWorkDate(KObject kobject);
}
......@@ -223,9 +223,18 @@ public class ProductionPlanReportController {
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
@RequestParam(value = "stationIds",required = false) List<UUID> stationIds,
@RequestParam(value = "showType",required = false) Integer showType
){
return ResponseObj.success("查询成功",productionPlanReportService.getProductionDinasTypeGroup(stationIds,ids,DateTimeUtils.getStartDateTimeOfDay(startDate),DateTimeUtils.getEndDateTimeOfDay( endDate)));
if(1==showType){
startDate=DateTimeUtils.getStartDateTimeOfMonth(startDate);
endDate=DateTimeUtils.getEndDateTimeOfMonth(endDate);
}else if(2==showType){
startDate=DateTimeUtils.getYearStart(startDate);
endDate=DateTimeUtils.getYearEnd(endDate);
}
return ResponseObj.success("查询成功",productionPlanReportService.getProductionDinasTypeGroup(stationIds,ids,DateTimeUtils.getStartDateTimeOfDay(startDate),DateTimeUtils.getEndDateTimeOfDay( endDate)));
}
......
......@@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
/**
......@@ -51,9 +52,14 @@ public class SandMiningController {
public ResponseObj create(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(SandMiningConstant.ENTITY, KClass.class));
//根据船只id查询时间段内有没有相同的
if(kobject.getUuid("id") == null){
return ResponseObj.error(400,"'id' must be not null!");
}
List<KObject> a = sandMiningService.getListByShipAndWorkDate(kobject);
if(a.size()>0){
return ResponseObj.error("500", "该许可证下的船只许可时间与已有数据交叉,请选择其他船只");
}
UUID id = sandMiningService.addSandMining(kobject);
return ResponseObj.success("保存成功", id);
}
......@@ -66,6 +72,10 @@ public class SandMiningController {
@PutMapping
public ResponseObj update(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(SandMiningConstant.ENTITY, KClass.class));
List<KObject> a = sandMiningService.getListByShipAndWorkDate(kobject);
if(a.size()>0){
return ResponseObj.error("500", "该许可证下的船只许可时间与已有数据交叉,请选择其他船只");
}
sandMiningService.update(kobject);
return ResponseObj.success("修改成功");
}
......
......@@ -17,6 +17,7 @@
<dependency>com.xyst.dinas.biz.datamodel.xystOrganization</dependency>
<dependency>javax.persistence.Column</dependency>
<dependency>javax.persistence.Table</dependency>
<dependency>com.xyst.dinas.biz.datamodel.Station</dependency>
<dependency>com.beecode.bap.staff.datamodel.Staff</dependency>
<dependency>com.beecode.bap.biztrait.datamodel.BasicBillRequirement</dependency>
<dependency>com.xyst.dinas.safe.datamodel.SafeLogAssociatedStaffDetail</dependency>
......@@ -70,6 +71,32 @@
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>javax.persistence.ManyToOne</m:type>
</m:annotation>
<m:annotation>
<m:type>javax.persistence.JoinColumn</m:type>
<m:properties>
<m:property>
<m:key>name</m:key>
<m:value>station_id</m:value>
</m:property>
<m:property>
<m:key>referencedColumnName</m:key>
<m:value>ID</m:value>
</m:property>
</m:properties>
</m:annotation>
</m:annotations>
<m:id>55d6b108-a847-47fe-8342-c8f2104fe512</m:id>
<m:name>station</m:name>
<m:title>所属场站</m:title>
<m:type>com.xyst.dinas.biz.datamodel.Station</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>javax.persistence.Column</m:type>
<m:properties>
<m:property>
......
......@@ -51,6 +51,26 @@
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>station.id</m:name>
<m:title></m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name>com.xyst.dinas.biz.datamodel.Station</m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>station.stationName</m:name>
<m:title></m:title>
<m:type>string</m:type>
<m:ref>
<m:name>com.xyst.dinas.biz.datamodel.Station</m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>id</m:name>
<m:title>id</m:title>
<m:type>uuid</m:type>
......
......@@ -21,6 +21,9 @@
<many-to-one name="modifier" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="modifier_id" not-null="false"/>
</many-to-one>
<many-to-one name="station" entity-name="com.xyst.dinas.biz.datamodel.Station" fetch="select">
<column name="station_id" not-null="false"/>
</many-to-one>
<property name="billState" type="nstring" not-null="false">
<column name="bill_state" length="100"/>
</property>
......
......@@ -31,7 +31,6 @@
AND bsi.del = 0
and dpd.type = 0
AND psm.STATUS = 1
and psm.sandMiningAreaType in (1,3,4)
GROUP BY
psm.id
</sql>
......
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