西海岸新增:购物车添加与一键申请

This commit is contained in:
lizhicheng 2022-10-08 19:03:01 +08:00
parent a409420df3
commit 00eace9698
4 changed files with 92 additions and 8 deletions

View File

@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
/**
@ -79,6 +80,14 @@ public class ResourceCarController {
}
}
@PostMapping("/batchInsert")
@ApiOperation("批量添加申购车")
@LogOperation(value = "批量添加申购车", operationTable = "tb_resource_car;")
public Result save(@RequestBody List<ResourceCarDTO> dtoList) {
dtoList.stream().forEach(dto->resourceCarService.insertOrUpdate(dto));
return new Result();
}
@DeleteMapping("/delete")
@ApiOperation("删除申购记录")
@LogOperation(value = "删除申购记录", operationTable = "tb_resource_car;")

View File

@ -38,4 +38,15 @@ public interface ResourceCarDao extends BaseDao<ResourceCarEntity> {
@Param("pageSize") Integer pageSize);
Integer selectProvideDeptCount(@Param("userId") Long userId, @Param("name") String name);
List<Map> selectInfrastructureCarGroupByDept(@Param("userId") Long userId,
@Param("pageNum") Integer pageNum,
@Param("pageSize") Integer pageSize,
@Param("name") String name);
List<Map> selectInfrastructureListByDept(@Param("name") String name,
@Param("userId") Long userId,
@Param("deptId") Long deptId,
@Param("pageNum") Integer pageNum,
@Param("pageSize") Integer pageSize);
}

View File

@ -15,12 +15,11 @@ import io.renren.modules.security.user.UserDetail;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
* 申购记录表
@ -37,6 +36,9 @@ public class ResourceCarServiceImpl extends CrudServiceImpl<ResourceCarDao, Reso
@Autowired
private ResourceCarDao resourceCarDao;
@Value("${project.place}")
private Integer projectPlace;
@Override
public QueryWrapper<ResourceCarEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<ResourceCarEntity> wrapper = new QueryWrapper<>();
@ -107,15 +109,37 @@ public class ResourceCarServiceImpl extends CrudServiceImpl<ResourceCarDao, Reso
public Object selectResourceCarGroupByDept(String name, Integer pageNum, Integer pageSize) {
Long userId = SecurityUser.getUserId();
HashMap<Object, Object> resultMap = new HashMap<>();
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: {
List<Map> maps = resourceCarDao.selectResourceCarGroupByDept(userId, (pageNum - 1) * pageSize, pageSize, name);
resultMap.put("list", maps);
resultMap.put("deptCount", resourceCarDao.selectProvideDeptCount(userId, name));
}
break;
case TSINGTAO_XHA: {
List<Map> maps = resourceCarDao.selectInfrastructureCarGroupByDept(userId, (pageNum - 1) * pageSize, pageSize, name);
resultMap.put("list", maps);
resultMap.put("deptCount", maps.stream().collect(Collectors.groupingBy(it->it.get("deptId"))).size());
}
break;
}
return resultMap;
}
@Override
public Object selectResourceListByDept(String name, Long deptId, Integer pageNum, Integer pageSize) {
Long userId = SecurityUser.getUserId();
return resourceCarDao.selectResourceListByDept(name, userId, deptId, (pageNum - 1) * pageSize, pageSize);
List<Map> result=new ArrayList<>();
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: {
result.addAll(resourceCarDao.selectResourceListByDept(name, userId, deptId, (pageNum - 1) * pageSize, pageSize));
}
break;
case TSINGTAO_XHA: {
result.addAll(resourceCarDao.selectInfrastructureListByDept(name, userId, deptId, (pageNum - 1) * pageSize, pageSize));
}
break;
}
return result;
}
}

View File

@ -82,6 +82,25 @@
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectInfrastructureCarGroupByDept" resultType="java.util.Map">
SELECT
dept.id AS "deptId",
dept.name AS "deptName",
COUNT(car.id) AS "count"
FROM
(select del_flag, user_id, json_extract(note1, '$[0].idtCameraChannel') as id, TRIM(BOTH '"' FROM json_extract(note1, '$[0].managementUnitName')) as dept_name, json_extract(note1, '$[0].channelName') as name
from tb_resource_car where note1 IS NOT NULL) car,
sys_dept dept
WHERE car.user_id = #{userId}
AND car.dept_name=dept.name
AND car.del_flag = 0
<if test="name != null and name != ''">
AND car.name LIKE CONCAT('%',#{name},'%')
</if>
GROUP BY car.dept_name
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectResourceListByDept" resultType="java.util.Map">
SELECT
car.id AS "id",
@ -135,6 +154,27 @@
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectInfrastructureListByDept" resultType="java.util.Map">
SELECT
car.id AS "id",
car.resource_id AS "resourceId",
car.name AS "resourceName",
car.note1,
car.create_date AS "time"
FROM
(select del_flag, user_id, note1, create_date, resource_id, json_extract(note1, '$[0].idtCameraChannel') as id, TRIM(BOTH '"' FROM json_extract(note1, '$[0].managementUnitName')) as dept_name, json_extract(note1, '$[0].channelName') as name
from tb_resource_car where note1 IS NOT NULL) car
left join sys_dept dept on car.dept_name=dept.name
WHERE 1 = 1
AND car.user_id = #{userId}
AND dept.id = #{deptId}
AND car.del_flag = 0
<if test="name != null and name != ''">
AND car.name LIKE CONCAT('%',#{name},'%')
</if>
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectProvideDeptCount" resultType="java.lang.Integer">
SELECT
COUNT(*)