Commit 64bba6ca by 高晓磊

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

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