Commit 5ddfd0fc by 焦凯

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

parents 3d463e66 6cb573eb
......@@ -277,4 +277,48 @@ public class DateTimeUtils {
return calendar.getTime();
}
/**
* 判断1个日期是否小于当前时间所在年
* eg: now = new Date 2021-04-16
* isLtNowYear(2020-12-31) true
* isLtNowYear(2021-01-01) false
* @return Boolean
*/
public static Boolean isLtNowYear(Date date) {
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(new Date());
return cal1.get(Calendar.YEAR) < cal2.get(Calendar.YEAR);
}
/**
* 判断2个日期是否同年
* eg: isSameYear(2020-12-31,2021-01-01) false
* isSameYear(2020-01-01,2020-12-31) true
* @return Boolean
*/
public static Boolean isSameYear(Date startDate , Date endDate) {
Calendar cal1 = Calendar.getInstance();
cal1.setTime(startDate);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(endDate);
return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR);
}
/**
* 判断2个日期是否同月
* eg: isSameYear(2020-12-31,2021-01-01) false
* isSameYear(2020-12-31,2020-12-01) true
* isSameYear(2020-12-31,2021-12-01) true
* @return Boolean
*/
public static Boolean isSameMonth(Date startDate , Date endDate) {
Calendar cal1 = Calendar.getInstance();
cal1.setTime(startDate);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(endDate);
return cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
}
}
\ No newline at end of file
......@@ -125,7 +125,11 @@ public class BaseBusinessWarn {
//2.当前存在执行中的预警记录,则修改预警执行信息
Date currentTime = new Date();
warnExeRecord.setRecentlyTime(currentTime);
if(!isWarning) {//2.1 如果没有处罚预警,则结束该预警记录
if(!isWarning) {//2.1 如果没有触发预警,则结束该预警记录
//如果预警已经结束,则不修改
if((WarnStateEnum.OVER.getValue()+"").equals(warnExeRecord.getWarnState())){
return true;
}
warnExeRecord.setEndTime(currentTime);
warnExeRecord.setWarnState(WarnStateEnum.OVER.getValue()+"");
}
......
......@@ -15,6 +15,8 @@ public class WarnSettingConstant {
/** 最近预警时间 */
public static final String RECENTLY_TIME = "recentlyTime";
public static final String WARN_STATE = "warnState";
/**
* 超采预警类型
......@@ -29,7 +31,18 @@ public class WarnSettingConstant {
/**
* 许可证船只进入告警区类型
*/
public static final String SAND_SHIP_WARN_BILL_TYPE = "采区船只预警";
public static final String SAND_SHIP_WARN_BILL_TYPE = "采区船只报警";
/**
* 许可证船只进入告警区指标-进入告警区
*/
public static final String SAND_SHIP_WARN_TARGET_ENTER_WARNING_AREA = "进入告警区";
/**
* 许可证船只进入告警区指标-非作业时间进入采砂区
*/
public static final String SAND_SHIP_WARN_TARGET_NO_OPERATING_HOURS = "非作业时间进入采砂区";
}
package com.xyst.dinas.biz.warn.dao;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import javax.persistence.Tuple;
import com.beecode.amino.core.Amino;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.util.JsonUtil;
import com.xyst.dinas.biz.constant.SandMiningAreaConstant;
import com.xyst.dinas.biz.enumeration.WarnStateEnum;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.HibernateException;
import org.hibernate.Session;
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.HibernateCallback;
import org.springframework.orm.hibernate5.HibernateOperations;
......@@ -24,6 +28,7 @@ import com.xyst.dinas.biz.warn.WarnExeRecord;
import com.xyst.dinas.biz.warn.WarnSetting;
import com.xyst.dinas.biz.warn.WarnSettingConstant;
import com.xyst.dinas.biz.warn.WarnSettingEntity;
import org.springframework.util.CollectionUtils;
@Repository
public class WarnSettingDao {
......@@ -49,13 +54,15 @@ public class WarnSettingDao {
/**
* 将一条预警执行记录改为结束状态
*
* @param warnRecord
*/
public void endWarnRecordState(KObject warnRecord) {
if(warnRecord==null) return;
if (warnRecord == null) return;
LocalDateTime now = LocalDateTime.now();
warnRecord.set(WarnSettingConstant.END_TIME, now);
warnRecord.set(WarnSettingConstant.RECENTLY_TIME, now);
warnRecord.set(WarnSettingConstant.WARN_STATE, WarnStateEnum.OVER.getValue() + "");
update(warnRecord);
}
......@@ -72,20 +79,20 @@ public class WarnSettingDao {
return template.execute(session -> {
StringBuilder hql = new StringBuilder(QUERY_HQL);
if(billId!=null) hql.append(" and billId =:billId");
if(target!=null) hql.append(" and target =:target");
if (billId != null) hql.append(" and billId =:billId");
if (target != null) hql.append(" and target =:target");
Query<KObject> query = session.createQuery(hql.toString(), KObject.class);//KObject
query.setParameter("billType", billType);
if(billId!=null) query.setParameter("billId", billId);
if(target!=null) query.setParameter("target", target);
KObject singleResult = query.getSingleResult();
return warnSettingToEntity(singleResult);
if (billId != null) query.setParameter("billId", billId);
if (target != null) query.setParameter("target", target);
Optional<KObject> kObject = query.uniqueResultOptional();
return warnSettingToEntity(kObject.orElse(null));
});
}
private WarnSetting warnSettingToEntity(KObject singleResult) {
if(singleResult==null) return null;
if (singleResult == null) return null;
UUID settingId = singleResult.getUuid("id");
UUID billId = singleResult.getUuid("billId");
String billType = singleResult.getString("billType");
......@@ -106,19 +113,20 @@ public class WarnSettingDao {
warnSettingEntity.setOpen(isOpen);
warnSettingEntity.setMemo(memo);
String[] personnelArray= personnel!=null && !personnel.isEmpty()?personnel.split(","):null;
String[] personnelArray = personnel != null && !personnel.isEmpty() ? personnel.split(",") : null;
warnSettingEntity.setPersonnel(personnelArray);
return warnSettingEntity;
}
/**
* 通过预警设置ID查询一条未结束的预警执行记录
*
* @param warnSettingId
* @return
*/
public KObject queryWarnExeRecordBySettingId(UUID warnSettingId) {
String QUERY_HQL = "from " + WarnSettingConstant.ENTITY_WARNINGEXE + " where endTime is null and warnSetting.id =:warnSettingId";
String QUERY_HQL = " from " + WarnSettingConstant.ENTITY_WARNINGEXE + " where endTime is null and warnSetting.id =:warnSettingId";
return template.execute(session -> {
......@@ -179,6 +187,7 @@ public class WarnSettingDao {
return template.execute(new HibernateCallback<List<String>>() {
//List<UUID> uuids = new ArrayList<>();
List<String> personnelIdList = new ArrayList<>();
@Override
public List<String> doInHibernate(Session session) throws HibernateException {
//List<Tuple> uuids1 = session.createSQLQuery(queryStaffSql).addEntity(Tuple.class).setParameter("postId", postId).list();
......@@ -199,4 +208,61 @@ public class WarnSettingDao {
}
public HashMap<String, Object> warnRecodeGroupInfo(List<UUID> regionalCompanyIds, List<String> targets) {
KClass bean = Amino.getStaticMetadataContext().getBean(WarnSettingConstant.ENTITY_WARNINGEXE, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
addFilters(regionalCompanyIds, targets, detachedCriteria);
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
//查询预警类型条数
detachedCriteria.setProjection(Projections.projectionList()
.add(Projections.alias(Projections.count("target"), "targetCount"))
.add(Projections.alias(Projections.groupProperty("target"), "target")));
detachedCriteria.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<?> byCriteria = template.findByCriteria(detachedCriteria);
for (Object byCriterion : byCriteria) {
if(byCriterion instanceof HashMap){
HashMap<String, Object> byCriterion1 = (HashMap<String, Object>) byCriterion;
stringObjectHashMap.put(byCriterion1.get("target").toString(),byCriterion1.get("targetCount"));
}
}
//查询预警状态条数
DetachedCriteria detachedCriteria1 = DetachedCriteria.forEntityName(bean.getName());
addFilters(regionalCompanyIds, targets, detachedCriteria1);
detachedCriteria1.setProjection(Projections.projectionList()
.add(Projections.alias(Projections.count("warnState"), "warnStateCount"))
.add(Projections.alias(Projections.groupProperty("warnState"), "warnStateValue")));
detachedCriteria1.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<?> byCriteria1 = template.findByCriteria(detachedCriteria1);
for (Object byCriterion : byCriteria1) {
if(byCriterion instanceof HashMap){
HashMap<String, Object> byCriterion1 = (HashMap<String, Object>) byCriterion;
stringObjectHashMap.put(byCriterion1.get("warnStateValue").toString(),byCriterion1.get("warnStateCount"));
}
}
//查询总条数
DetachedCriteria detachedCriteria2 = DetachedCriteria.forEntityName(bean.getName());
addFilters(regionalCompanyIds, targets, detachedCriteria2);
detachedCriteria2.setProjection(Projections.projectionList()
.add(Projections.alias(Projections.rowCount(), "sumCount")));
detachedCriteria2.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<HashMap<String,Object>> byCriteria2 = (List<HashMap<String,Object>>)template.findByCriteria(detachedCriteria2);
stringObjectHashMap.put("sumCount",byCriteria2.get(0).get("sumCount"));
return stringObjectHashMap;
}
private void addFilters(List<UUID> regionalCompanyIds, List<String> targets, DetachedCriteria detachedCriteria) {
if(!CollectionUtils.isEmpty(targets)){
detachedCriteria.add(Restrictions.in("target", targets));
}
if(!CollectionUtils.isEmpty(regionalCompanyIds)) {
Disjunction dis = Restrictions.disjunction();
detachedCriteria.createAlias("warnSetting","warnSetting");
for (UUID regionalCompanyId : regionalCompanyIds) {
dis.add(Restrictions.like("warnSetting.memo", regionalCompanyId.toString(),MatchMode.ANYWHERE));
}
detachedCriteria.add(dis);
}
}
}
package com.xyst.dinas.biz.warn.service;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
......@@ -20,6 +21,8 @@ public interface IWarningSettingService {
*/
public UUID insertWarnSetting(WarnSetting warnSetting) ;
void endWarnStateBySettingId(UUID warnSettingId);
WarnSetting getWarnSetting(@NonNull UUID warnSettingId);
WarnSetting getWarnSetting(@NonNull String billType, @Nullable UUID billId, @Nullable String target);
......@@ -36,6 +39,17 @@ public interface IWarningSettingService {
*/
void updateWarnSetting(UpdateWarnSetting warnSetting);
/**
* 删除预警设置
* @param warnSettingId
*/
void deleteWarnSetting(@NonNull UUID warnSettingId);
/**
* 删除预警设置
*/
void deleteWarnSetting(@NonNull String billType, @Nullable UUID billId, @Nullable String target);
/***************************************/
......@@ -59,4 +73,7 @@ public interface IWarningSettingService {
List<WarnExeRecord> queryWarnExeRecords(UUID warnSettingId);
void ignoreWarnExeRecord(UUID id);
HashMap<String, Object> warnRecodeGroupInfo(List<UUID> regionalCompanyIds, List<String> targets);
}
package com.xyst.dinas.biz.warn.service;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import com.xyst.dinas.biz.enumeration.WarnStateEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
......@@ -36,6 +38,8 @@ public class WarningSettingServiceImpl implements IWarningSettingService{
JsonNode json = JSONObjectUtils.toJson(warnSetting);
KObject object = JSONObjectUtils.toObject(json, type);
object.set(BaseConstants.CREATE_TIME, LocalDateTime.now());
object.set(BaseConstants.DEL,false);
object.set(BaseConstants.DISCARD,false);
return warnSettingDao.create(object);
}
......@@ -62,6 +66,7 @@ public class WarningSettingServiceImpl implements IWarningSettingService{
* 结束一条预警设置的预警执行记录
* @param warnSettingId
*/
@Override
public void endWarnStateBySettingId(UUID warnSettingId) {
KObject warnExeRecord = warnSettingDao.queryWarnExeRecordBySettingId(warnSettingId);
......@@ -89,6 +94,18 @@ public class WarningSettingServiceImpl implements IWarningSettingService{
}
@Override
public void ignoreWarnExeRecord(UUID id) {
KObject kObject = warnSettingDao.queryWarningExeById(id);
kObject.set(WarnSettingConstant.WARN_STATE, WarnStateEnum.IGNORE.getValue()+"");
warnSettingDao.update(kObject);
}
@Override
public HashMap<String, Object> warnRecodeGroupInfo(List<UUID> regionalCompanyIds, List<String> targets) {
return warnSettingDao.warnRecodeGroupInfo(regionalCompanyIds,targets);
}
@Override
public void updateWarnExe(WarnExeRecord warnExeRecord) {
KClass type = Amino.getApplicationMetadataContext().getBean(WarnSettingConstant.ENTITY_WARNINGEXE, KClass.class);
JsonNode json = JSONObjectUtils.toJson(warnExeRecord);
......@@ -126,10 +143,39 @@ public class WarningSettingServiceImpl implements IWarningSettingService{
warSettingIdObj.set("min", min);
String max = warnSetting.getMax();
warSettingIdObj.set("max", max);
warnSettingDao.update(warSettingIdObj);
}
/**
* 删除预警设置
*
* @param warnSettingId
*/
@Override
public void deleteWarnSetting(UUID warnSettingId) {
KObject kObject = warnSettingDao.queryWarnSettingById(warnSettingId);
kObject.set("del",true);
kObject.set("discard",true);
warnSettingDao.update(kObject);
}
/**
* 删除预警设置
*
* @param billType
* @param billId
* @param target
*/
@Override
public void deleteWarnSetting(String billType, UUID billId, String target) {
WarnSetting warnSetting = warnSettingDao.getWarnSetting(billType, billId, target);
KObject kObject = warnSettingDao.queryWarnSettingById(warnSetting.getSettingId());
kObject.set("del",true);
kObject.set("discard",true);
warnSettingDao.update(kObject);
}
private String UuidListToString(List<UUID> uuids) {
StringBuilder str = new StringBuilder();
......
......@@ -133,6 +133,26 @@ public class DinasCommonController {
* @param date
* @return
*/
@GetMapping("/sand/user/planningCycleObj/{planningCycle}/{date}")
public KObject getPlanningCycleObjBySand(@PathVariable String planningCycle,@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
PlanningCycleEnum planningCycleType = null;
if (PlanningCycleEnum.DAY.name().equalsIgnoreCase(planningCycle)) {
planningCycleType = PlanningCycleEnum.DAY;
}else if (PlanningCycleEnum.WEEK.name().equalsIgnoreCase(planningCycle)) {
planningCycleType = PlanningCycleEnum.WEEK;
}else {
return null;
}
return planningCycleService.getPlanningCycleObj(planningCycleType, date);
}
/**
* 获取指定日期和计划周期类型的计划周期实体
* @param planningCycleType 计划周期
* @param date
* @return
*/
@GetMapping("/planningCycleObj/{planningCycle}/{date}")
public KObject getPlanningCycleObj(@PathVariable String planningCycle,@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
......
......@@ -119,11 +119,11 @@ public class SandMiningAreaController {
return ResponseObj.success("预警设置更新成功");
}
//更新预警设置
@GetMapping("/warnRecode/ignore")//采区预警设置更新
public ResponseObj ignoreWarnExe(UUID id) {
warningSettingService.queryWarnExeRecord(id);
return ResponseObj.success("预警设置更新成功");
//忽略预警记录
@GetMapping("/warnRecode/ignore")
public ResponseObj ignoreWarnExe(@RequestParam("id")UUID id) {
warningSettingService.ignoreWarnExeRecord(id);
return ResponseObj.success("忽略成功");
}
......
......@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
......@@ -36,6 +38,12 @@ import com.beecode.bcp.biz.BusinessException;
import com.beecode.bcp.query.scene.ScenePrecidate;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.common.BatchDeleteItem;
import com.beecode.inz.common.BatchDiscardItem;
import com.beecode.inz.common.BatchUpdatePICItem;
import com.beecode.inz.common.enumeration.BatchOperationEnum;
import com.beecode.inz.common.service.CommonService;
import com.beecode.inz.common.service.FollowerService;
import com.beecode.inz.query.define.QueryDefinition;
import com.beecode.inz.query.entity.PaginationResult;
import com.beecode.inz.query.exception.QueryException;
......@@ -61,6 +69,15 @@ public class SandQueryController {
private PrivilegeService privilegeService;
@Autowired
private HttpServletRequest request;
@Autowired
private CommonService commonService;
@Autowired
private FollowerService followerService;
@Autowired
MultipartProperties multipartProperties;
......@@ -69,6 +86,95 @@ public class SandQueryController {
private static final ObjectMapper OBJECTMAPPER = new ObjectMapper();
@ResponseBody
@RequestMapping(value = "/sand/user/common/batch", method = RequestMethod.PUT)
public void batchOperation(@RequestBody String body){
String operation = request.getHeader("operation");
BatchOperationEnum oper = null;
try {
oper = BatchOperationEnum.valueOf(operation.toUpperCase());
} catch (Exception e) {
logger.error("not support common batch operation,operation: {}", operation);
throw new UnsupportedOperationException("not support common batch operation,operation: " + operation);
}
switch (oper) {
case BATCH_UPDATE_PIC:
BatchUpdatePICItem[] batchUpdatePICs = handleBatchUpdatePICInputs(body);
commonService.batchUpdatePIC(batchUpdatePICs);
//如果负责人已经在相关团队里面了,从相关团队里面移除
for (BatchUpdatePICItem batchUpdatePICItem : batchUpdatePICs) {
UUID[] entityIds = batchUpdatePICItem.getIds();
for (UUID entityID : entityIds) {
followerService.removeStaff(batchUpdatePICItem.getDatamodelName(), entityID, batchUpdatePICItem.getPic().getId());
}
}
return;
case BATCH_DISCARD:
BatchDiscardItem[] batchDiscards = handleBatchDiscardInputs(body);
commonService.batchDiscard(batchDiscards);
return;
case BATCH_DELETE:
BatchDeleteItem[] batchDeletes = handleBatchDeleteInputs(body);
commonService.batchDelete(batchDeletes);
return;
default:
logger.error("not support common batch operation,operation: {}", operation);
throw new UnsupportedOperationException("not support common batch operation,operation: " + operation);
}
}
private BatchUpdatePICItem[] handleBatchUpdatePICInputs(String body){
try{
List<BatchUpdatePICItem> list = new ArrayList<BatchUpdatePICItem>();
JSONArray arr = new JSONArray(body);
if(arr.length() == 0){
throw new RuntimeException("batch update PIC items must not be 0!");
}
for(int i = 0; i < arr.length(); i ++){
list.add(new BatchUpdatePICItem(arr.getJSONObject(i)));
};
return list.toArray(new BatchUpdatePICItem[0]);
}catch(Exception e){
logger.error("illegal Argument,body: {}", body);
throw new IllegalArgumentException("illegal Argument,body: " + body, e);
}
}
private BatchDiscardItem[] handleBatchDiscardInputs(String body){
try{
List<BatchDiscardItem> list = new ArrayList<BatchDiscardItem>();
JSONArray arr = new JSONArray(body);
if(arr.length() == 0){
throw new RuntimeException("batch discard items must not be 0!");
}
for(int i = 0; i < arr.length(); i ++){
list.add(new BatchDiscardItem(arr.getJSONObject(i)));
};
return list.toArray(new BatchDiscardItem[0]);
}catch(Exception e){
logger.error("illegal Argument,body: {}", body);
throw new IllegalArgumentException("illegal Argument,body: " + body, e);
}
}
private BatchDeleteItem[] handleBatchDeleteInputs(String body) {
try{
List<BatchDeleteItem> list = new ArrayList<BatchDeleteItem>();
JSONArray arr = new JSONArray(body);
if(arr.length() == 0){
throw new RuntimeException("batch delete items must not be 0!");
}
for(int i = 0; i < arr.length(); i ++){
list.add(new BatchDeleteItem(arr.getJSONObject(i)));
};
return list.toArray(new BatchDeleteItem[0]);
}catch(Exception e){
logger.error("illegal Argument,body: {}", body);
throw new IllegalArgumentException("illegal Argument,body: " + body, e);
}
}
@ResponseBody
@RequestMapping(value="/sand/user/common/config/getMaxFileSize", method = RequestMethod.GET, consumes = "application/json")
public String getMaxFileSize() {
JSONObject o = new JSONObject();
......
......@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
......@@ -36,6 +38,12 @@ import com.beecode.bcp.biz.BusinessException;
import com.beecode.bcp.query.scene.ScenePrecidate;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.common.BatchDeleteItem;
import com.beecode.inz.common.BatchDiscardItem;
import com.beecode.inz.common.BatchUpdatePICItem;
import com.beecode.inz.common.enumeration.BatchOperationEnum;
import com.beecode.inz.common.service.CommonService;
import com.beecode.inz.common.service.FollowerService;
import com.beecode.inz.query.define.QueryDefinition;
import com.beecode.inz.query.entity.PaginationResult;
import com.beecode.inz.query.exception.QueryException;
......@@ -61,6 +69,15 @@ public class WarehouseQueryController {
private PrivilegeService privilegeService;
@Autowired
private HttpServletRequest request;
@Autowired
private CommonService commonService;
@Autowired
private FollowerService followerService;
@Autowired
MultipartProperties multipartProperties;
......@@ -69,6 +86,95 @@ public class WarehouseQueryController {
private static final ObjectMapper OBJECTMAPPER = new ObjectMapper();
@ResponseBody
@RequestMapping(value = "/warehouse/api/common/batch", method = RequestMethod.PUT)
public void batchOperation(@RequestBody String body){
String operation = request.getHeader("operation");
BatchOperationEnum oper = null;
try {
oper = BatchOperationEnum.valueOf(operation.toUpperCase());
} catch (Exception e) {
logger.error("not support common batch operation,operation: {}", operation);
throw new UnsupportedOperationException("not support common batch operation,operation: " + operation);
}
switch (oper) {
case BATCH_UPDATE_PIC:
BatchUpdatePICItem[] batchUpdatePICs = handleBatchUpdatePICInputs(body);
commonService.batchUpdatePIC(batchUpdatePICs);
//如果负责人已经在相关团队里面了,从相关团队里面移除
for (BatchUpdatePICItem batchUpdatePICItem : batchUpdatePICs) {
UUID[] entityIds = batchUpdatePICItem.getIds();
for (UUID entityID : entityIds) {
followerService.removeStaff(batchUpdatePICItem.getDatamodelName(), entityID, batchUpdatePICItem.getPic().getId());
}
}
return;
case BATCH_DISCARD:
BatchDiscardItem[] batchDiscards = handleBatchDiscardInputs(body);
commonService.batchDiscard(batchDiscards);
return;
case BATCH_DELETE:
BatchDeleteItem[] batchDeletes = handleBatchDeleteInputs(body);
commonService.batchDelete(batchDeletes);
return;
default:
logger.error("not support common batch operation,operation: {}", operation);
throw new UnsupportedOperationException("not support common batch operation,operation: " + operation);
}
}
private BatchUpdatePICItem[] handleBatchUpdatePICInputs(String body){
try{
List<BatchUpdatePICItem> list = new ArrayList<BatchUpdatePICItem>();
JSONArray arr = new JSONArray(body);
if(arr.length() == 0){
throw new RuntimeException("batch update PIC items must not be 0!");
}
for(int i = 0; i < arr.length(); i ++){
list.add(new BatchUpdatePICItem(arr.getJSONObject(i)));
};
return list.toArray(new BatchUpdatePICItem[0]);
}catch(Exception e){
logger.error("illegal Argument,body: {}", body);
throw new IllegalArgumentException("illegal Argument,body: " + body, e);
}
}
private BatchDiscardItem[] handleBatchDiscardInputs(String body){
try{
List<BatchDiscardItem> list = new ArrayList<BatchDiscardItem>();
JSONArray arr = new JSONArray(body);
if(arr.length() == 0){
throw new RuntimeException("batch discard items must not be 0!");
}
for(int i = 0; i < arr.length(); i ++){
list.add(new BatchDiscardItem(arr.getJSONObject(i)));
};
return list.toArray(new BatchDiscardItem[0]);
}catch(Exception e){
logger.error("illegal Argument,body: {}", body);
throw new IllegalArgumentException("illegal Argument,body: " + body, e);
}
}
private BatchDeleteItem[] handleBatchDeleteInputs(String body) {
try{
List<BatchDeleteItem> list = new ArrayList<BatchDeleteItem>();
JSONArray arr = new JSONArray(body);
if(arr.length() == 0){
throw new RuntimeException("batch delete items must not be 0!");
}
for(int i = 0; i < arr.length(); i ++){
list.add(new BatchDeleteItem(arr.getJSONObject(i)));
};
return list.toArray(new BatchDeleteItem[0]);
}catch(Exception e){
logger.error("illegal Argument,body: {}", body);
throw new IllegalArgumentException("illegal Argument,body: " + body, e);
}
}
@ResponseBody
@RequestMapping(value="/warehouse/api/common/config/getMaxFileSize", method = RequestMethod.GET, consumes = "application/json")
public String getMaxFileSize() {
JSONObject o = new JSONObject();
......
package com.xyst.dinas.biz.web;
import java.util.UUID;
import org.json.JSONObject;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.xyst.dinas.biz.warn.service.IWarningSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.beecode.bcp.type.KObject;
import com.xyst.dinas.biz.request.UpdateWarnSetting;
import com.xyst.dinas.biz.warn.service.IWarningSettingService;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/**
* 预警
......@@ -43,5 +42,15 @@ public class WarnSettingController {
return warningSettingService.queryWarnSettingById(id);
}
//查询预警汇总信息
@GetMapping("/warnRecode/groupInfo")
public ResponseObj groupInfo(@RequestParam(name = "regionalCompanyIds") List<UUID> regionalCompanyIds, @RequestParam(name = "targets")List<String> targets) {
HashMap<String,Object> groupInfo = warningSettingService.warnRecodeGroupInfo(regionalCompanyIds,targets);
return ResponseObj.success("查询成功", groupInfo);
}
}
......@@ -46,6 +46,15 @@
</ref>
<description></description>
</field>
<field title='业务类型'>
<name>billType</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='预警指标'>
<name>target</name>
<type>string</type>
......
......@@ -60,6 +60,16 @@
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>billType</m:name>
<m:title>业务类型</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>target</m:name>
<m:title>预警指标</m:title>
<m:type>string</m:type>
......
......@@ -2,6 +2,7 @@ package com.xyst.dinas.production.internal.service;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KObject;
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.service.IWarningSettingService;
......@@ -39,7 +40,7 @@ public class SandMiningServiceImpl implements SandMiningService {
WarnSettingEntity warnSetting = new WarnSettingEntity();
warnSetting.setBillType(WarnSettingConstant.SAND_SHIP_WARN_BILL_TYPE);
warnSetting.setBillId(uuid);
warnSetting.setTarget("进入告警区");
warnSetting.setTarget(WarnSettingConstant.SAND_SHIP_WARN_TARGET_ENTER_WARNING_AREA);
warnSetting.setOpen(false);
warnSetting.setMemo(getSandShipInfo(kObject));
warningSettingService.insertWarnSetting(warnSetting);
......@@ -47,7 +48,7 @@ public class SandMiningServiceImpl implements SandMiningService {
WarnSettingEntity warnSetting1 = new WarnSettingEntity();
warnSetting1.setBillType(WarnSettingConstant.SAND_SHIP_WARN_BILL_TYPE);
warnSetting1.setBillId(uuid);
warnSetting1.setTarget("非作业时间采砂");
warnSetting1.setTarget(WarnSettingConstant.SAND_SHIP_WARN_TARGET_NO_OPERATING_HOURS);
warnSetting1.setOpen(false);
warnSetting1.setMemo(getSandShipInfo(kObject));
warningSettingService.insertWarnSetting(warnSetting1);
......@@ -84,6 +85,23 @@ public class SandMiningServiceImpl implements SandMiningService {
@Override
public void deleteById(UUID id) {
sandMiningDao.deleteById(id);
//删除预警设置 结束预警记录
//进入告警区的
WarnSetting warnSetting = warningSettingService.getWarnSetting(WarnSettingConstant.SAND_SHIP_WARN_BILL_TYPE, id, WarnSettingConstant.SAND_SHIP_WARN_TARGET_ENTER_WARNING_AREA);
if(null!=warnSetting){
warningSettingService.deleteWarnSetting(warnSetting.getSettingId());
warningSettingService.endWarnStateBySettingId(warnSetting.getSettingId());
}
//非作业时间采砂的
WarnSetting warnSetting1 = warningSettingService.getWarnSetting(WarnSettingConstant.SAND_SHIP_WARN_BILL_TYPE, id, WarnSettingConstant.SAND_SHIP_WARN_TARGET_NO_OPERATING_HOURS);
if(null!=warnSetting1){
warningSettingService.deleteWarnSetting(warnSetting1.getSettingId());
warningSettingService.endWarnStateBySettingId(warnSetting1.getSettingId());
}
}
@Override
......
......@@ -161,4 +161,16 @@ public class DischargingController {
return ResponseObj.success();
}
//接驳统计
// @RequestMapping(value = "groupInfoByYear", method = RequestMethod.GET)
// public ResponseObj groupInfo(
// @RequestParam(name = "regionalCompanyIds", required = false) List<UUID> regionalCompanyIds,
// @RequestParam(name = "year", required = false) List<UUID> regionalCompanyIds,
// ) throws Exception {
//
// return ResponseObj.success("查询成功", dischargingService.groupInfo(transportShipId,type,startDate,endDate,sandMiningAreaType,stationIds,sandMiningAreaId,sandMiningShipId,parentId));
// }
}
\ No newline at end of file
......@@ -35,7 +35,6 @@ public class SandMiningController {
@RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "sandMiningStatus", required = false) Integer sandMiningStatus
) throws Exception {
Page<KObject> objectPage = new Page<>();
objectPage.setPageNo(pageNo);
objectPage.setPageSize(pageSize);
......
......@@ -50,6 +50,16 @@
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>warnSetting.billType</m:name>
<m:title>预警指标</m:title>
<m:type>com.xyst.dinas.biz.datamodel.WarnSetting</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>startTime</m:name>
<m:title>开始时间</m:title>
<m:type>datetime</m:type>
......
......@@ -104,4 +104,16 @@ public class SalesPlanDao {
});
}
public List<KObject> querySalesPlanDetailsByMasterIdWarehouse(UUID salesPlanId, UUID stationId) {
return template.execute(session ->{
String hql = "from " + SalesPlanConstant.ENTITY_DETAIL + " where master.id =:salesPlanId and station.id =:stationId GROUP BY purchaseSandUnit.id, project.id, contract.id, id ";
Query<KObject> query = session.createQuery(hql, KObject.class);
query.setParameter("salesPlanId", salesPlanId);
query.setParameter("stationId", stationId);
List<KObject> resultList = query.getResultList();
return resultList;
});
}
}
......@@ -120,6 +120,14 @@ public class SalesPlanServiceImpl implements SalesPlanService{
return kObject;
}
@Override
public Object querySalesPlanDetailsByMasterIdWarehouse(UUID salesPlanId, UUID stationId) {
KObject kObject = salesPlanDao.load(salesPlanId);
List<KObject> details = salesPlanDao.querySalesPlanDetailsByMasterIdWarehouse(salesPlanId, stationId);
kObject.set("SalesPlanDetails", details);
return kObject;
}
......
......@@ -41,4 +41,6 @@ public interface SalesPlanService {
public Object querySalesPlanDetailsByMasterId(UUID fromString);
public Object querySalesPlanDetailsByMasterIdWarehouse(UUID fromString, UUID fromString2);
}
......@@ -74,8 +74,19 @@ public class SalesPlanController {
*/
@ResponseBody
@RequestMapping(value = "/salesplan/querySalesPlanDetailsByMasterId", method = RequestMethod.GET)
public Object verifyName(@RequestParam("saleaPlanId") String saleaPlanId) {
public Object querySalesPlanDetailsByMasterId(@RequestParam("saleaPlanId") String saleaPlanId) {
return ResponseObj.success("success", salesPlanService.querySalesPlanDetailsByMasterId(UUID.fromString(saleaPlanId)));
}
/**
* 根据销售计划id查询计划明细(分组)场站用户
* @param saleaPlanId
* @return
*/
@ResponseBody
@RequestMapping(value = "/warehouse/api/salesplan/querySalesPlanDetailsByMasterId", method = RequestMethod.GET)
public Object querySalesPlanDetailsByMasterIdWarehouse(@RequestParam("saleaPlanId") String saleaPlanId, @RequestParam("stationId") String stationId) {
return ResponseObj.success("success", salesPlanService.querySalesPlanDetailsByMasterIdWarehouse(UUID.fromString(saleaPlanId), UUID.fromString(stationId)));
}
}
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