Commit de052b58 authored by 赵啸非's avatar 赵啸非

添加批量新增窗口业务接口

parent 484dd4f0
......@@ -158,14 +158,14 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
if ("0".equals(parentId)) {
return collect;
}
AreaEntity areaEntity = this.selectOne(new AreaQuery().iid(parentId));
if (!ObjectUtils.isEmpty(areaEntity)) {
//查询当前区域是否有站点。
List<AreaTreeSelect> collect1 = siteService.find(new SiteQuery().areaCode(areaEntity.getAreaCode()))
.stream().map(site -> new AreaTreeSelect(site)).collect(Collectors.toList());
collect.addAll(collect1);
}
// AreaEntity areaEntity = this.selectOne(new AreaQuery().iid(parentId));
// if (!ObjectUtils.isEmpty(areaEntity)) {
// //查询当前区域是否有站点。
// List<AreaTreeSelect> collect1 = siteService.find(new SiteQuery().areaCode(areaEntity.getAreaCode()))
// .stream().map(site -> new AreaTreeSelect(site)).collect(Collectors.toList());
// collect.addAll(collect1);
//
// }
return collect;
}
......
......@@ -14,4 +14,10 @@ import java.util.List;
@Data
public class WindowBusinessVo extends BaseEntityLong {
/**
* 站点业务IDs
*/
private String siteBusinessIds;
}
\ No newline at end of file
package com.mortals.xhx.module.window.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.window.model.WindowBusinessEntity;
/**
......@@ -11,4 +12,5 @@ import com.mortals.xhx.module.window.model.WindowBusinessEntity;
*/
public interface WindowBusinessService extends ICRUDService<WindowBusinessEntity,Long>{
}
\ No newline at end of file
package com.mortals.xhx.module.window.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.window.model.WindowEntity;
/**
......@@ -11,4 +12,15 @@ import com.mortals.xhx.module.window.model.WindowEntity;
*/
public interface WindowService extends ICRUDService<WindowEntity,Long>{
/**
* 添加业务到窗口
* @param businessIds
* @param windowId
* @param context
*/
void addBusinessToWindow(String businessIds, Long windowId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.window.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.business.model.BusinessEntity;
import com.mortals.xhx.module.business.model.BusinessQuery;
import com.mortals.xhx.module.site.model.SiteBusinessEntity;
import com.mortals.xhx.module.site.model.SiteBusinessQuery;
import com.mortals.xhx.module.site.model.SiteEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.window.dao.WindowBusinessDao;
import com.mortals.xhx.module.window.model.WindowBusinessEntity;
import com.mortals.xhx.module.window.service.WindowBusinessService;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* WindowBusinessService
* 窗口业务 service实现
......@@ -13,5 +29,5 @@ import com.mortals.xhx.module.window.service.WindowBusinessService;
*/
@Service("windowBusinessService")
public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBusinessDao, WindowBusinessEntity, Long> implements WindowBusinessService {
}
\ No newline at end of file
......@@ -3,9 +3,21 @@ package com.mortals.xhx.module.window.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.business.model.BusinessEntity;
import com.mortals.xhx.module.business.model.BusinessQuery;
import com.mortals.xhx.module.business.service.BusinessService;
import com.mortals.xhx.module.site.model.SiteBusinessEntity;
import com.mortals.xhx.module.site.model.SiteBusinessQuery;
import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.service.SiteBusinessService;
import com.mortals.xhx.module.window.model.WindowBusinessEntity;
import com.mortals.xhx.module.window.model.WindowBusinessQuery;
import com.mortals.xhx.module.window.service.WindowBusinessService;
import com.mortals.xhx.module.workman.model.WorkmanEntity;
import com.mortals.xhx.module.workman.model.WorkmanQuery;
import com.mortals.xhx.module.workman.service.WorkmanService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
......@@ -14,6 +26,8 @@ import com.mortals.xhx.module.window.model.WindowEntity;
import com.mortals.xhx.module.window.service.WindowService;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -31,6 +45,11 @@ public class WindowServiceImpl extends AbstractCRUDServiceImpl<WindowDao, Window
@Autowired
private WorkmanService workmanService;
@Autowired
private WindowBusinessService windowBusinessService;
@Autowired
private BusinessService businessService;
@Override
protected void findAfter(WindowEntity params, PageInfo pageInfo, Context context, List<WindowEntity> list) throws AppException {
......@@ -42,4 +61,46 @@ public class WindowServiceImpl extends AbstractCRUDServiceImpl<WindowDao, Window
}).count();
super.findAfter(params, pageInfo, context, list);
}
@Override
public void addBusinessToWindow(String businessIds, Long windowId, Context context) {
if (ObjectUtils.isEmpty(windowId)) {
throw new AppException("请选择对应窗口");
}
List<Long> businessIdList = Arrays.asList(businessIds.split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
WindowBusinessQuery windowBusinessQuery = new WindowBusinessQuery();
//windowBusinessQuery.setSiteBusinessIdList(businessIdList);
//先删除后再新增
windowBusinessQuery.setWindowId(windowId);
Long[] ids = windowBusinessService.find(windowBusinessQuery).stream()
.map(WindowBusinessEntity::getId).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(ids)) {
windowBusinessService.remove(ids, context);
}
WindowEntity windowEntity = this.get(windowId, context);
List<WindowBusinessEntity> windowBusinessEntities = businessIdList.stream().map(id -> {
WindowBusinessEntity windowBusinessEntity = new WindowBusinessEntity();
windowBusinessEntity.initAttrValue();
if (!ObjectUtils.isEmpty(windowEntity)) {
windowBusinessEntity.setWindowId(windowId);
windowBusinessEntity.setWindowName(windowEntity.getName());
} else {
return null;
}
BusinessEntity businessEntity = businessService.get(id, context);
if (!ObjectUtils.isEmpty(businessEntity)) {
windowBusinessEntity.setSiteBusinessId(id);
windowBusinessEntity.setBusinessName(businessEntity.getName());
} else {
return null;
}
return windowBusinessEntity;
}).collect(Collectors.toList());
windowBusinessService.save(windowBusinessEntities, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.window.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BasePhpCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.window.model.WindowBusinessEntity;
import com.mortals.xhx.module.window.service.WindowBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* 窗口业务
*
......@@ -26,4 +33,6 @@ public class WindowBusinessController extends BasePhpCRUDJsonMappingController<W
super.setModuleDesc("窗口业务");
}
}
\ No newline at end of file
package com.mortals.xhx.module.window.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BasePhpCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.window.model.WindowEntity;
import com.mortals.xhx.module.window.service.WindowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -37,4 +42,27 @@ public class WindowController extends BasePhpCRUDJsonMappingController<WindowSer
super.init(model, context);
}
/**
* 添加业务到窗口
*/
@PostMapping(value = "addBusinessToWindow")
public String addBusinessToSite(@RequestBody Map<String, Object> map) {
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<String, Object>();
String businessIds=(String)map.get("businessIds");
Long windowId= DataUtil.converObj2Long(map.get("windowId"));
try {
this.service.addBusinessToWindow(businessIds,windowId,getContext());
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "添加业务到窗口成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
}
\ No newline at end of file
package com.mortals.xhx.module.window.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BasePhpCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.window.model.WindowMatterEntity;
......@@ -7,6 +10,10 @@ import com.mortals.xhx.module.window.service.WindowMatterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Map;
/**
*
* 窗口事项
......@@ -26,4 +33,14 @@ public class WindowMatterController extends BasePhpCRUDJsonMappingController<Win
super.setModuleDesc( "窗口事项");
}
@Override
protected void doListBefore(WindowMatterEntity query, Map<String, Object> model, Context context) throws AppException {
query.setOrderColList(new ArrayList<OrderCol>() {
{
add(new OrderCol("a.sort", OrderCol.DESCENDING));
}
});
super.doListBefore(query, model, context);
}
}
\ No newline at end of file
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