|
@@ -88,6 +88,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
@Override
|
|
|
public int addPlan(PlanAddBo bo) {
|
|
|
+ // app是否可用
|
|
|
QueryWrapper<App> appQueryWrapper = new QueryWrapper<>();
|
|
|
appQueryWrapper.eq("appkey",bo.getAppkey());
|
|
|
appQueryWrapper.eq("state",1);
|
|
@@ -95,6 +96,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
App app = appMapper.selectOne(appQueryWrapper);
|
|
|
if (app == null)
|
|
|
return -1;
|
|
|
+ // 校验
|
|
|
Map<String,Object> params = Dict.create()
|
|
|
.set("appkey",bo.getAppkey())
|
|
|
.set("goodsId",bo.getGoodsId())
|
|
@@ -156,6 +158,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
@Override
|
|
|
public int checkPlan(PlanBo bo,Long userId,String userName) {
|
|
|
+ // 是否有该计划
|
|
|
QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
planQueryWrapper.eq("plan_id",bo.getPlanId());
|
|
|
planQueryWrapper.eq("deleted","0");
|
|
@@ -170,21 +173,23 @@ public class PlanServiceImpl implements PlanService {
|
|
|
App app = appMapper.selectOne(appQueryWrapper);
|
|
|
if (app == null)
|
|
|
return -1;
|
|
|
-
|
|
|
+ // 确定审核状态并更新广告计划
|
|
|
plan.setState(bo.getState());
|
|
|
+ LocalDateTime now = LocalDateTime.now(ZoneId.of("Asia/Shanghai")); // 启动回调地址时也用该时间
|
|
|
+ plan.setAuditTime(now);
|
|
|
int i = planMapper.updateById(plan);
|
|
|
- if (i == 0)
|
|
|
- return 0;
|
|
|
-// SysUser sysUser = sysUserMapper.selectById(userId);
|
|
|
+ if (i == 0) return 0;
|
|
|
+ // 插入审核记录
|
|
|
PlanAudit audit = new PlanAudit(bo,userId.toString(),userName);
|
|
|
int insert = planAuditMapper.insert(audit);
|
|
|
- if (insert == 1){
|
|
|
+ if (insert == 1){ // 审核计划插入成功
|
|
|
+ // 启动回调地址
|
|
|
CallBackBean callBackBean = new CallBackBean();
|
|
|
callBackBean.setAuditPerson(userName);
|
|
|
if (bo.getState() == 1)
|
|
|
callBackBean.setAuditComment("审核通过");
|
|
|
else callBackBean.setAuditComment("审核不通过");
|
|
|
- callBackBean.setAuditTime(LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
|
|
|
+ callBackBean.setAuditTime(now);
|
|
|
SendCallBackUtil.sendCallBack(app.getCallBack(),callBackBean);
|
|
|
}
|
|
|
return insert;
|
|
@@ -196,8 +201,8 @@ public class PlanServiceImpl implements PlanService {
|
|
|
QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
if (bo.getText() != null)
|
|
|
planQueryWrapper.and(planQueryWrapper1 -> {
|
|
|
- planQueryWrapper1.like("plan_id",bo.getText())
|
|
|
- .or()
|
|
|
+ planQueryWrapper1/*.like("plan_id",bo.getText())
|
|
|
+ .or()*/
|
|
|
.like("plan_name",bo.getText())
|
|
|
.or()
|
|
|
.like("principal_name",bo.getText())
|
|
@@ -264,12 +269,14 @@ public class PlanServiceImpl implements PlanService {
|
|
|
@Override
|
|
|
public List<PlanPushVo> getPlanPushByCode(String equipmentCode) {
|
|
|
List<PlanPushVo> pushVos = new ArrayList<>();
|
|
|
+ // 根据设备编号查询设备下的广告计划子项
|
|
|
QueryWrapper<PlanItem> itemQueryWrapper = new QueryWrapper<>();
|
|
|
itemQueryWrapper.eq("equipment_code",equipmentCode);
|
|
|
itemQueryWrapper.eq("deleted","0");
|
|
|
List<PlanItem> items = planItemMapper.selectList(itemQueryWrapper);
|
|
|
+ // 排序
|
|
|
items.sort(Comparator.comparing(PlanItem::getSort).reversed());
|
|
|
- for (PlanItem item : items){
|
|
|
+ for (PlanItem item : items){ // 根据计划子项查询计划,并补齐返回信息
|
|
|
QueryWrapper<Plan> planQueryWrapper = new QueryWrapper<>();
|
|
|
planQueryWrapper.eq("plan_id",item.getPlanId());
|
|
|
planQueryWrapper.apply("plan_start_time <= STR_TO_DATE({0},'%Y-%m-%d %H:%i:%s')",LocalDateTime.now(ZoneId.of("Asia/Shanghai")));
|
|
@@ -286,12 +293,14 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
@Override
|
|
|
public int planUpDown(String planId) {
|
|
|
+ // 是否存在该广告计划
|
|
|
QueryWrapper<Plan> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("plan_id",planId);
|
|
|
queryWrapper.eq("deleted","0");
|
|
|
Plan plan = planMapper.selectOne(queryWrapper);
|
|
|
if (plan == null)
|
|
|
return -1;
|
|
|
+ // 改变状态,1:上架;0:下架
|
|
|
plan.setOnState(plan.getOnState()+1);
|
|
|
if (plan.getOnState() >= 2)
|
|
|
plan.setOnState(0);
|
|
@@ -305,8 +314,8 @@ public class PlanServiceImpl implements PlanService {
|
|
|
planQueryWrapper.eq("state",bo.getState());
|
|
|
if (bo.getText() != null)
|
|
|
planQueryWrapper.and(planQueryWrapper1 -> {
|
|
|
- planQueryWrapper1.like("plan_id",bo.getText())
|
|
|
- .or()
|
|
|
+ planQueryWrapper1/*.like("plan_id",bo.getText())
|
|
|
+ .or()*/
|
|
|
.like("app_name",bo.getText())
|
|
|
.or()
|
|
|
.like("commercial_name",bo.getText());
|
|
@@ -320,6 +329,7 @@ public class PlanServiceImpl implements PlanService {
|
|
|
List<PlanManageListVo> vos = new ArrayList<>();
|
|
|
for (Plan plan : plans){
|
|
|
PlanManageListVo vo = new PlanManageListVo(plan);
|
|
|
+ // 查询计划的设备数量
|
|
|
Integer count = planItemMapper.selectEquipmentCountByPlanId(plan.getPlanId());
|
|
|
vo.setEquipmentCount(count);
|
|
|
vos.add(vo);
|
|
@@ -391,10 +401,10 @@ public class PlanServiceImpl implements PlanService {
|
|
|
QueryWrapper<PlanPushStatistics> statisticsQueryWrapper = new QueryWrapper<>();
|
|
|
if (bo.getText() != null)
|
|
|
statisticsQueryWrapper.and(planPushStatisticsQueryWrapper -> {
|
|
|
- planPushStatisticsQueryWrapper.like("equipment_id",bo.getText())
|
|
|
+ planPushStatisticsQueryWrapper/*.like("equipment_id",bo.getText())
|
|
|
.or()
|
|
|
.like("equipment_code",bo.getText())
|
|
|
- .or()
|
|
|
+ .or()*/
|
|
|
.like("equipment_name",bo.getText());
|
|
|
});
|
|
|
if (bo.getStartTime() != null)
|