完成奇怪的需求若干

This commit is contained in:
donqi 2023-01-02 16:32:52 +08:00
parent 07350aa6d5
commit 6dd21f31e7
9 changed files with 48 additions and 15 deletions

View File

@ -11,6 +11,7 @@ import com.ghy.common.utils.StringUtils;
import com.ghy.common.utils.poi.ExcelUtil; import com.ghy.common.utils.poi.ExcelUtil;
import com.ghy.goods.domain.*; import com.ghy.goods.domain.*;
import com.ghy.goods.service.*; import com.ghy.goods.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
@ -67,11 +68,11 @@ public class GoodsController extends BaseController {
@PostMapping("/app/list") @PostMapping("/app/list")
@ResponseBody @ResponseBody
public TableDataInfo appList(@RequestBody Goods goods) { public TableDataInfo appList(@RequestBody Goods goods) {
startPage();
// 判断类目id是否为第三级不是的话需要找到所有符合条件的第三级类目id作为新的条件 // 判断类目id是否为第三级不是的话需要找到所有符合条件的第三级类目id作为新的条件
if (goods.getDeptGoodsCategoryId() != null) { if (goods.getDeptGoodsCategoryId() != null) {
logger.info("入参:" + goods.getDeptGoodsCategoryId());
GoodsCategory goodsCategory = goodsCategoryService.selectById(goods.getDeptGoodsCategoryId()); GoodsCategory goodsCategory = goodsCategoryService.selectById(goods.getDeptGoodsCategoryId());
logger.info("查询到的类目:" + goodsCategory);
if (goodsCategory.getLevel() == 0) { if (goodsCategory.getLevel() == 0) {
goods.setDeptGoodsCategoryId(null); goods.setDeptGoodsCategoryId(null);
} else if (goodsCategory.getLevel() == 1) { } else if (goodsCategory.getLevel() == 1) {
@ -85,17 +86,28 @@ public class GoodsController extends BaseController {
List<GoodsCategory> thirdCategories = goodsCategoryService.selectGoodsCategoryList(params); List<GoodsCategory> thirdCategories = goodsCategoryService.selectGoodsCategoryList(params);
thirdCategoryIds.addAll(thirdCategories.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList())); thirdCategoryIds.addAll(thirdCategories.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList()));
}); });
if (CollectionUtils.isNotEmpty(thirdCategoryIds)) {
goods.setDeptGoodsCategoryId(null); goods.setDeptGoodsCategoryId(null);
goods.setDeptGoodsCategoryIds(thirdCategoryIds); goods.setDeptGoodsCategoryIds(thirdCategoryIds);
} else {
goods.setDeptGoodsCategoryId(-1l);
}
} else if (goodsCategory.getLevel() == 2) { } else if (goodsCategory.getLevel() == 2) {
GoodsCategory params = new GoodsCategory(); GoodsCategory params = new GoodsCategory();
params.setParentCategoryId(goodsCategory.getGoodsCategoryId()); params.setParentCategoryId(goodsCategory.getGoodsCategoryId());
List<GoodsCategory> filteredCategory = goodsCategoryService.selectGoodsCategoryList(params); List<GoodsCategory> filteredCategory = goodsCategoryService.selectGoodsCategoryList(params);
List<Long> filteredCategoryIds = filteredCategory.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList()); List<Long> filteredCategoryIds = filteredCategory.stream().map(GoodsCategory::getGoodsCategoryId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(filteredCategoryIds)) {
goods.setDeptGoodsCategoryId(null); goods.setDeptGoodsCategoryId(null);
goods.setDeptGoodsCategoryIds(filteredCategoryIds); goods.setDeptGoodsCategoryIds(filteredCategoryIds);
} else {
goods.setDeptGoodsCategoryId(-1l);
} }
} }
}
startPage();
List<Goods> list = goodsService.selectGoodsList(goods); List<Goods> list = goodsService.selectGoodsList(goods);
list.forEach(one -> { list.forEach(one -> {
// 补全商品服务区域 // 补全商品服务区域

View File

@ -175,7 +175,7 @@ public class GoodsDeptCategoryController extends BaseController {
@PostMapping("/app/list") @PostMapping("/app/list")
@ResponseBody @ResponseBody
public AjaxResult appList(@RequestBody DeptGoodsCategory deptGoodsCategory) { public AjaxResult appList(@RequestBody DeptGoodsCategory deptGoodsCategory) {
return AjaxResult.success(deptGoodsCategoryService.appList(deptGoodsCategory.getDeptId())); return AjaxResult.success(deptGoodsCategoryService.appList(deptGoodsCategory));
} }
@PostMapping("/app/category") @PostMapping("/app/category")

View File

@ -245,7 +245,15 @@ public class WorkerController extends BaseController {
goods.setStatus(Integer.valueOf(GoodsStatus.OK.getCode())); goods.setStatus(Integer.valueOf(GoodsStatus.OK.getCode()));
WorkerListResponse workerListResponse = JSONObject.parseObject(JSON.toJSONString(w), WorkerListResponse.class); WorkerListResponse workerListResponse = JSONObject.parseObject(JSON.toJSONString(w), WorkerListResponse.class);
workerListResponse.setGoodsList(goodsService.selectGoodsList(goods)); workerListResponse.setGoodsList(goodsService.selectGoodsList(goods));
if (workerListRequest.isJustShowCurWorkerArea()) {
workerListResponse.setWorkerAreas(workerAreaService.getWorkerAreaList(new WorkerArea(){{
setWorkerId(w.getWorkerId());
setDistrictId(worker.getDistrictId());
setDistrictIds(worker.getDistrictIds());
}}));
} else {
workerListResponse.setWorkerAreas(workerAreaService.getByWorker(w.getWorkerId())); workerListResponse.setWorkerAreas(workerAreaService.getByWorker(w.getWorkerId()));
}
workerListResponse.setGoodsCategories(workerGoodsCategoryService.getByWorker(w.getWorkerId())); workerListResponse.setGoodsCategories(workerGoodsCategoryService.getByWorker(w.getWorkerId()));
workerListResponse.setSpecialSkills(specialSkillService.getByWorker(w.getWorkerId())); workerListResponse.setSpecialSkills(specialSkillService.getByWorker(w.getWorkerId()));
resList.add(workerListResponse); resList.add(workerListResponse);

View File

@ -22,4 +22,6 @@ public class WorkerListRequest {
private Long workerId; private Long workerId;
private Long exceptParentAreaId; private Long exceptParentAreaId;
private boolean justShowCurWorkerArea;
} }

View File

@ -53,10 +53,10 @@ public interface DeptGoodsCategoryService {
List<Ztree> tree(Long parentId); List<Ztree> tree(Long parentId);
/** /**
* @param deptId 筛选条件 * @param deptGoodsCategory 筛选条件
* @return 父子层级的list * @return 父子层级的list
*/ */
List<DeptGoodsCategory> appList(Long deptId); List<DeptGoodsCategory> appList(DeptGoodsCategory deptGoodsCategory);
/** /**
* @param deptGoodsCategory 查询条件 * @param deptGoodsCategory 查询条件

View File

@ -66,9 +66,7 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
} }
@Override @Override
public List<DeptGoodsCategory> appList(Long deptId) { public List<DeptGoodsCategory> appList(DeptGoodsCategory deptGoodsCategory) {
DeptGoodsCategory deptGoodsCategory = new DeptGoodsCategory();
deptGoodsCategory.setDeptId(deptId);
// 第一层 // 第一层
List<DeptGoodsCategory> goodsCategoryList = deptGoodsCategoryMapper.appList(deptGoodsCategory); List<DeptGoodsCategory> goodsCategoryList = deptGoodsCategoryMapper.appList(deptGoodsCategory);
// 第二层 // 第二层

View File

@ -101,7 +101,7 @@
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''"> <if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">
AND dept_goods_category_id = #{deptGoodsCategoryId} AND dept_goods_category_id = #{deptGoodsCategoryId}
</if> </if>
<if test="deptGoodsCategoryIds != null"> <if test="deptGoodsCategoryIds != null and deptGoodsCategoryIds.size > 0">
AND dept_goods_category_id in AND dept_goods_category_id in
<foreach collection="deptGoodsCategoryIds" item="deptGoodsCategoryId" open="(" separator="," close=")"> <foreach collection="deptGoodsCategoryIds" item="deptGoodsCategoryId" open="(" separator="," close=")">
#{deptGoodsCategoryId} #{deptGoodsCategoryId}

View File

@ -4,6 +4,8 @@ import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity; import com.ghy.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author clunt * @author clunt
* 师傅服务区域 * 师傅服务区域
@ -26,6 +28,8 @@ public class WorkerArea extends BaseEntity {
@Excel(name = "区/县区域id", cellType = Excel.ColumnType.NUMERIC) @Excel(name = "区/县区域id", cellType = Excel.ColumnType.NUMERIC)
private Long districtId; private Long districtId;
private List<Long> districtIds;
@Excel(name = "街道区域id", cellType = Excel.ColumnType.NUMERIC) @Excel(name = "街道区域id", cellType = Excel.ColumnType.NUMERIC)
private Long streetId; private Long streetId;

View File

@ -64,7 +64,16 @@
<include refid="selectWorkerArea"></include> <include refid="selectWorkerArea"></include>
<where> <where>
<if test="districtId != null"> <if test="districtId != null">
AND district_id = #{districtId} AND wa.district_id = #{districtId}
</if>
<if test="districtIds != null and districtIds.size > 0">
AND wa.district_id in
<foreach collection="districtIds" item="districtId" open="(" separator="," close=")">
#{districtId}
</foreach>
</if>
<if test="workerId != null">
AND wa.worker_id = #{workerId}
</if> </if>
</where> </where>
</select> </select>