Commit 64bba6ca by 高晓磊

散客预警人员修改添加&场站的合同依赖去掉&违规类型修改为取值name

parent 738a6cfd
......@@ -3,6 +3,7 @@ package com.xyst.dinas.biz.internal.service;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.beecode.inz.common.BaseConstants;
import com.xyst.dinas.biz.constant.RetailInfoConstant;
import com.xyst.dinas.biz.dao.DinasTypeDao;
......@@ -10,12 +11,11 @@ import com.xyst.dinas.biz.dao.RetailInfoDao;
import com.xyst.dinas.biz.processor.RetailInfoBuyAmountWarningCalculate;
import com.xyst.dinas.biz.processor.RetailInfoBuyCountWarningCalculate;
import com.xyst.dinas.biz.service.RetailInfoService;
import com.xyst.dinas.biz.warn.BaseBusinessWarn;
import com.xyst.dinas.biz.warn.WarnSetting;
import com.xyst.dinas.biz.warn.WarnSettingEntity;
import com.xyst.dinas.biz.warn.WarnTargetTypeEnum;
import com.xyst.dinas.biz.warn.*;
import com.xyst.dinas.biz.warn.service.WarningService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
......@@ -23,6 +23,7 @@ import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class)
public class RetailInfoServiceImpl implements RetailInfoService {
......@@ -34,6 +35,9 @@ public class RetailInfoServiceImpl implements RetailInfoService {
private DinasTypeDao dinasTypeDao;
@Autowired
private WarningService warningService;
@Autowired
private WarehouseUserService warehouseUserService;
@Override
public Page<KObject> queryByPaging(Page<KObject> page, Integer retailInfoStatus) throws Exception {
......@@ -78,6 +82,7 @@ public class RetailInfoServiceImpl implements RetailInfoService {
} else {
setWarningSettingEntity(newKobject, uuid, RetailInfoConstant.RETAIL_INFO_WARN_BUY_COUNT, RetailInfoConstant.RETAIL_INFO_BUY_COUNT_WARNING_CALCULATOR,templateCount.getMax(),false,true);
}
//购买重量预警
//查询场站是否有对应的预警模板
templateCount = warningService.queryOneWarnSettingsByMemoAndType(RetailInfoConstant.RETAIL_INFO_WARN_BUY_AMOUNT, station.toString(),"template");
......@@ -95,6 +100,7 @@ public class RetailInfoServiceImpl implements RetailInfoService {
}
private WarnSettingEntity setWarningSettingEntity(KObject kObject, UUID uuid,String target,String warnCalculator,String max,boolean isTemplate,boolean isOpen) {
String stationId = kObject.get("station").getString(BaseConstants.ID);
WarnSettingEntity warnSettingEntity = new WarnSettingEntity();
warnSettingEntity.setBillType(RetailInfoConstant.RETAIL_INFO_WARN_BILL_TYPE);
warnSettingEntity.setBillId(uuid);
......@@ -103,7 +109,7 @@ public class RetailInfoServiceImpl implements RetailInfoService {
warnSettingEntity.setTargetType(WarnTargetTypeEnum.INT_TYPE.name());
warnSettingEntity.setOpen(isOpen);
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("stationId", kObject.get("station").getString(BaseConstants.ID));
stringStringHashMap.put("stationId",stationId );
if(isTemplate){
stringStringHashMap.put("template", "template");
}else{
......@@ -111,6 +117,8 @@ public class RetailInfoServiceImpl implements RetailInfoService {
stringStringHashMap.put("retailInfoName", kObject.getString("retailInfoName"));
}
warnSettingEntity.setMemo(JSONObjectUtils.toJson(stringStringHashMap).toString());
List<KObject> allByStationId = warehouseUserService.getAllByStationId(UUID.fromString(stationId));
warnSettingEntity.setPersonnel(allByStationId.stream().map(a -> a.getString("id")).toArray(String[]::new));
warnSettingEntity.setWarnCalculator(warnCalculator);
warningService.insertWarnSettingToIsNotice(warnSettingEntity,false);
return warnSettingEntity;
......@@ -127,6 +135,8 @@ public class RetailInfoServiceImpl implements RetailInfoService {
}
}
@Override
public KObject getById(UUID id) {
return retailInfoDao.load(id);
......@@ -177,7 +187,6 @@ public class RetailInfoServiceImpl implements RetailInfoService {
@Override
public Long selectBuyCountByIdCard(String idCard, UUID uuid) {
return retailInfoDao.selectBuyCountByIdCard(idCard,uuid);
}
......
......@@ -2,8 +2,11 @@ package com.xyst.dinas.biz.warn;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.xyst.dinas.biz.constant.RetailInfoConstant;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.transaction.annotation.Transactional;
......@@ -25,6 +28,8 @@ public class WarningServiceImpl implements WarningService {
@Autowired
private WarnSettingDao warnSettingDao;
@Autowired
private WarehouseUserService warehouseUserService;
/**
* 新增预警设置<br/>
......@@ -281,7 +286,8 @@ public class WarningServiceImpl implements WarningService {
}
@Override
public void updateRetailInfoWarnSettingAllByTypeAndMemo(String target, String toString, Double max) {
public void updateRetailInfoWarnSettingAllByTypeAndMemo(String target, String toString, Double max, List<KObject> allWarehouseUserByStationId) {
String stationUserIds = allWarehouseUserByStationId.stream().map(a -> a.getString("id")).collect(Collectors.joining(","));
List<?> objects = warnSettingDao.queryWarnSettingsListByMemoAndType(target, toString);
if (objects.size() < 1) {
String warnCalculator;
......@@ -298,14 +304,34 @@ public class WarningServiceImpl implements WarningService {
Assert.notNull(uuid, "The warSettingId must not be null");
KObject warSettingIdObj = warnSettingDao.queryWarnSettingById(uuid);
warSettingIdObj.set(WarnSettingConstant.max, max);
warSettingIdObj.set(WarnSettingConstant.personnel,stationUserIds);
warnSettingDao.update(warSettingIdObj);
//修改后触发预警
BaseBusinessWarn baseBusinessWarn = new BaseBusinessWarn(uuid);
baseBusinessWarn.warn(false);
baseBusinessWarn.warn(true);
}
}
@Override
public void updateRetailInfoWarnSettingPersonnelByStationId(UUID stationId){
List<KObject> allWarehouseUserByStationId = warehouseUserService.getAllByStationId(stationId);
String[] stationUserIds = allWarehouseUserByStationId.stream().map(a -> a.getString("id")).toArray(String[]::new);
List<KObject> objects = (List<KObject>) warnSettingDao.queryWarnSettingsListByMemoAndType(RetailInfoConstant.RETAIL_INFO_WARN_BUY_AMOUNT, stationId.toString());
if(!CollectionUtils.isEmpty(objects)){
List<KObject> objects1 = (List<KObject>) warnSettingDao.queryWarnSettingsListByMemoAndType(RetailInfoConstant.RETAIL_INFO_WARN_BUY_COUNT, stationId.toString());
objects.addAll(objects1);
}
for (KObject o : objects) {
o.set(WarnSettingConstant.personnel,stationUserIds);
warnSettingDao.update(o);
}
}
private void setRetailInfoWarningSettingTemplateEntity(String stationId, UUID billId, String target, String warnCalculator, Double max) {
WarnSettingEntity warnSettingEntity = new WarnSettingEntity();
warnSettingEntity.setBillType(RetailInfoConstant.RETAIL_INFO_WARN_BILL_TYPE);
......@@ -316,14 +342,14 @@ public class WarningServiceImpl implements WarningService {
}else if(target.equals(RetailInfoConstant.RETAIL_INFO_WARN_BUY_COUNT)){
warnSettingEntity.setTargetType(WarnTargetTypeEnum.INT_TYPE.name());
}
warnSettingEntity.setOpen(false);
warnSettingEntity.setOpen(true);
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("stationId", stationId);
stringStringHashMap.put("template","template");
warnSettingEntity.setMax(max+"");
warnSettingEntity.setMemo(JSONObjectUtils.toJson(stringStringHashMap).toString());
warnSettingEntity.setWarnCalculator(warnCalculator);
insertWarnSettingToIsNotice(warnSettingEntity, false);
insertWarnSettingToIsNotice(warnSettingEntity, true);
}
}
......@@ -103,5 +103,7 @@ public interface WarningService {
WarnSetting queryOneWarnSettingsByMemoAndType(String target, String ... memo);
void updateRetailInfoWarnSettingAllByTypeAndMemo(String target, String toString, Double max);
void updateRetailInfoWarnSettingPersonnelByStationId(UUID stationId);
void updateRetailInfoWarnSettingAllByTypeAndMemo(String target, String toString, Double max,List<KObject> stationUsers);
}
......@@ -5,6 +5,7 @@ import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.nlib.utils.StringUtils;
import com.xyst.dinas.biz.constant.RetailInfoConstant;
......@@ -16,6 +17,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;
/**
......@@ -32,6 +34,8 @@ public class RetailInfoController {
private RetailInfoService retailInfoService;
@Autowired
private WarningService warningService;
@Autowired
private WarehouseUserService warehouseUserService;
@RequestMapping(value = "list/page", method = RequestMethod.GET)
public ResponseObj getListPage(
......@@ -137,7 +141,8 @@ public class RetailInfoController {
if(StringUtils.isEmpty(target)){
return ResponseObj.error(400,"指标错误");
}
warningService.updateRetailInfoWarnSettingAllByTypeAndMemo(target,stationId.toString(),Double.parseDouble(max));
List<KObject> allWarehouseUserByStationId = warehouseUserService.getAllByStationId(stationId);
warningService.updateRetailInfoWarnSettingAllByTypeAndMemo(target,stationId.toString(),Double.parseDouble(max),allWarehouseUserByStationId);
return ResponseObj.success();
}
......
......@@ -7,7 +7,6 @@ import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.common.service.ContractService;
import com.beecode.nlib.utils.StringUtils;
import com.xyst.dinas.biz.constant.StationConstant;
import com.xyst.dinas.biz.service.StationService;
......@@ -35,9 +34,6 @@ public class StationController {
@Autowired
private WarehouseUserService warehouseUserService;
@Autowired
private ContractService contractService;
@RequestMapping(value = "list/page", method = RequestMethod.GET)
public ResponseObj getListPage(
......
......@@ -92,4 +92,21 @@ public class WarnSettingController {
return ResponseObj.success("查询成功",personnel);
}
/**
* 修改散户预警设置的人员
* @param stationId 场站id
* @return
*/
@PostMapping("/warnsetting/updateRetailInfoWarnSettingPersonnelByStationId/{stationId}")
public ResponseObj updateWaringSettingPersonnel(@PathVariable("stationId") UUID stationId){
if(stationId == null){
return ResponseObj.error(400,"'id' must be not null!");
}
warningService.updateRetailInfoWarnSettingPersonnelByStationId(stationId);
return ResponseObj.success("修改成功");
}
}
......@@ -61,7 +61,7 @@
<description></description>
</field>
<field title='违规类型名称'>
<name>violationType.typeName</name>
<name>violationType.name</name>
<type>string</type>
<ref>
<type></type>
......
......@@ -48,13 +48,13 @@
<name>violationType.id</name>
<type>uuid</type>
<ref>
<type>一般引用</type>
<type></type>
<name>com.xyst.dinas.safe.datamodel.ViolationType</name>
</ref>
<description></description>
</field>
<field title='违规类型名称'>
<name>violationType.typeName</name>
<name>violationType.name</name>
<type>string</type>
<ref>
<type></type>
......
......@@ -42,7 +42,7 @@
<description></description>
</field>
<field title='违规类型名称'>
<name>violationType.typeName</name>
<name>violationType.name</name>
<type>string</type>
<ref>
<type></type>
......
......@@ -71,7 +71,7 @@
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>violationType.typeName</m:name>
<m:name>violationType.name</m:name>
<m:title>违规类型名称</m:title>
<m:type>string</m:type>
<m:ref>
......
......@@ -56,12 +56,12 @@
<m:type>uuid</m:type>
<m:ref>
<m:name>com.xyst.dinas.safe.datamodel.ViolationType</m:name>
<m:type>一般引用</m:type>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>violationType.typeName</m:name>
<m:name>violationType.name</m:name>
<m:title>违规类型名称</m:title>
<m:type>string</m:type>
<m:ref>
......
......@@ -51,7 +51,7 @@
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>violationType.typeName</m:name>
<m:name>violationType.name</m:name>
<m:title>违规类型名称</m:title>
<m:type>string</m:type>
<m:ref>
......
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