更新
This commit is contained in:
parent
914f1d107d
commit
5d48ccc1bd
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.inspection.mapper;
|
||||
|
||||
import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject;
|
||||
import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
|
||||
import cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -39,7 +40,7 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
|
||||
*/
|
||||
void recheck(@Param("list") List<InspectionWorkNode> workNodes, @Param("status") String status);
|
||||
|
||||
List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject);
|
||||
List<StaffProjectCountVO> getStaffCount(DlInspectionProject dlInspectionProject);
|
||||
|
||||
/**
|
||||
* 根据检测id获取异常节点
|
||||
|
@ -1,14 +1,20 @@
|
||||
package cn.iocoder.yudao.module.inspection.service.impl;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.appBase.controller.admin.InspectionSocket;
|
||||
import cn.iocoder.yudao.module.shop.entity.ShopConfig;
|
||||
import cn.iocoder.yudao.module.shop.service.IShopConfigService;
|
||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import cn.iocoder.yudao.util.SendSmsUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -29,6 +35,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.util.DistanceUtil.getDistanceMeter;
|
||||
|
||||
/**
|
||||
@ -44,6 +52,12 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
|
||||
@Autowired
|
||||
private AppInspectionPartnerService partnerService;
|
||||
@Autowired
|
||||
private InspectionSocket inspectionSocket;
|
||||
@Resource
|
||||
private DictDataApi dictDataApi;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private AppInspectionGoodsService goodsService;
|
||||
@Autowired
|
||||
private InspectionGoodsSkuService skuService;
|
||||
@ -189,6 +203,16 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
|
||||
log.error(ignored.getMessage());
|
||||
}
|
||||
baseMapper.insert(appointment);
|
||||
// 发送提示音
|
||||
//根据dictType查询角色
|
||||
List<DictDataRespDTO> roleList = dictDataApi.getDictDataList("inspection_appointmentInspection_accept");
|
||||
List<String> codes = roleList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
|
||||
|
||||
//根据角色查询用户
|
||||
List<UserDTO> userListByCodes = roleService.getUserListByCodes(codes);
|
||||
for (UserDTO userListByCode : userListByCodes) {
|
||||
inspectionSocket.sendMessage("接工单", userListByCode.getId().toString());
|
||||
}
|
||||
return appointment.getId();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.inspection.service.DlInspectionProjectService;
|
||||
import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService;
|
||||
import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService;
|
||||
import cn.iocoder.yudao.module.inspection.service.InspectionStepInfoService;
|
||||
import cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
@ -426,7 +427,40 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject) {
|
||||
return baseMapper.getStaffCount(dlInspectionProject);
|
||||
Map<Long, Map<String, Object>> tempMap = new LinkedHashMap<>();
|
||||
List<StaffProjectCountVO> staffCount = baseMapper.getStaffCount(dlInspectionProject);
|
||||
for (StaffProjectCountVO vo : staffCount) {
|
||||
Map<String, Object> userEntry = tempMap.computeIfAbsent(vo.getUserId(), k -> {
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put("userId", vo.getUserId());
|
||||
m.put("nickname", vo.getNickname());
|
||||
m.put("totalCount", 0L); // 初始总数
|
||||
m.put("children", new ArrayList<Map<String, Object>>());
|
||||
return m;
|
||||
});
|
||||
|
||||
// 添加项目
|
||||
List<Map<String, Object>> children = (List<Map<String, Object>>) userEntry.get("children");
|
||||
Map<String, Object> project = new HashMap<>();
|
||||
project.put("projectName", vo.getProjectName());
|
||||
project.put("count", vo.getCount());
|
||||
children.add(project);
|
||||
|
||||
// 累加总数
|
||||
Long currentTotal = (Long) userEntry.get("totalCount");
|
||||
userEntry.put("totalCount", currentTotal + vo.getCount());
|
||||
}
|
||||
|
||||
// 转成 List 并按 totalCount 降序排序
|
||||
return tempMap.values().stream()
|
||||
.peek(userEntry -> {
|
||||
// 排序每个用户下的项目 children
|
||||
List<Map<String, Object>> children = (List<Map<String, Object>>) userEntry.get("children");
|
||||
children.sort((a, b) -> Long.compare((Long) b.get("count"), (Long) a.get("count")));
|
||||
})
|
||||
.sorted((a, b) -> Long.compare((Long) b.get("totalCount"), (Long) a.get("totalCount")))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.shop.entity.ShopConfig;
|
||||
@ -15,6 +16,7 @@ import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.iocoder.yudao.util.StringUtils;
|
||||
@ -52,6 +54,8 @@ public class ShopInspectionGoodsServiceImpl extends ServiceImpl<ShopInspectionGo
|
||||
private AppInspectionPartnerService appInspectionPartnerService;
|
||||
@Autowired
|
||||
private InspectionGoodsSkuService skuService;
|
||||
@Autowired
|
||||
private ShopInspectionCategoryService shopInspectionCategoryService;
|
||||
|
||||
|
||||
|
||||
@ -161,7 +165,27 @@ public class ShopInspectionGoodsServiceImpl extends ServiceImpl<ShopInspectionGo
|
||||
public int insertShopInspectionGoods(ShopInspectionGoods shopInspectionGoods)
|
||||
{
|
||||
shopInspectionGoods.setListingStatus("0");
|
||||
return baseMapper.insert(shopInspectionGoods);
|
||||
baseMapper.insert(shopInspectionGoods);
|
||||
// 根据商品分类id查询商品分类
|
||||
ShopInspectionCategory category = shopInspectionCategoryService.getById(shopInspectionGoods.getGoodsCategoryId());
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
// 获取模板列表
|
||||
List<InspectionCategoryTemplate> templates = categoryTemplateService.list(Wrappers.<InspectionCategoryTemplate>lambdaQuery()
|
||||
.eq(InspectionCategoryTemplate::getCategoryId, category.getId()));
|
||||
List<InspectionGoodsSku> skuList = new ArrayList<>();
|
||||
for (InspectionCategoryTemplate template : templates) {
|
||||
InspectionGoodsSku sku = new InspectionGoodsSku();
|
||||
sku.setGoodsId(shopInspectionGoods.getId());
|
||||
sku.setSkuName(template.getSkuName());
|
||||
sku.setPrice(template.getSkuPrice());
|
||||
sku.setDbPrice(template.getSkuPrice());
|
||||
sku.setDwPrice(template.getSkuPrice());
|
||||
sku.setYgPrice(template.getSkuPrice());
|
||||
skuList.add(sku);
|
||||
}
|
||||
skuService.saveBatch(skuList);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,11 @@
|
||||
package cn.iocoder.yudao.module.inspection.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StaffProjectCountVO {
|
||||
private Long userId;
|
||||
private Long count;
|
||||
private String nickname;
|
||||
private String projectName;
|
||||
}
|
@ -182,62 +182,81 @@
|
||||
<!-- ORDER BY orderCount DESC; -- 根据接单数量进行降序排序-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="getStaffCount" resultType="java.util.Map"
|
||||
<!-- <select id="getStaffCount" resultType="java.util.Map"-->
|
||||
<!-- parameterType="cn.iocoder.yudao.module.inspection.entity.DlInspectionProject">-->
|
||||
<!-- SELECT-->
|
||||
<!-- iwn.deal_user_id, -- 处理人员ID-->
|
||||
<!-- su.nickname, -- 处理人员名称-->
|
||||
<!-- su.avatar, -- 处理人员头像-->
|
||||
<!-- COUNT(DISTINCT iwn.id) AS orderCount, -- 统计每个员工的唯一订单数量-->
|
||||
<!-- SUM(IFNULL(royalty.royalty_amount, 0) / 100) AS royaltyAmount, -- 计算每个员工的总佣金-->
|
||||
<!-- su.mobile, -- 处理人员手机号-->
|
||||
<!-- COALESCE(waijianCount, 0) AS waijianCount, -- 包含“外检”的订单数量-->
|
||||
<!-- COALESCE(anjianCount, 0) AS anjianCount, -- 包含“安检”的订单数量-->
|
||||
<!-- COALESCE(proj_stats.otherCount, 0) AS otherCount -- 其他订单数量(排除“外检”和“安检”)-->
|
||||
<!-- FROM-->
|
||||
<!-- inspection_work_node iwn-->
|
||||
<!-- LEFT JOIN system_users su ON su.id = iwn.deal_user_id -- 处理人员信息-->
|
||||
<!-- LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id-->
|
||||
<!-- LEFT JOIN order_info orders ON info.inspection_order_id = orders.id-->
|
||||
<!-- LEFT JOIN inspection_project_royalty AS royalty-->
|
||||
<!-- ON iwn.project_id = royalty.project_id-->
|
||||
<!-- AND orders.goods_id = royalty.goods_id-->
|
||||
<!-- LEFT JOIN (-->
|
||||
<!-- SELECT-->
|
||||
<!-- iwn.deal_user_id,-->
|
||||
<!-- SUM(CASE WHEN proj.project_name LIKE '环检外检%' THEN 1 ELSE 0 END) AS waijianCount,-->
|
||||
<!-- SUM(CASE WHEN proj.project_name LIKE '安检%' THEN 1 ELSE 0 END) AS anjianCount,-->
|
||||
<!-- SUM(-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN proj.project_name NOT LIKE '环检外检%'-->
|
||||
<!-- AND proj.project_name NOT LIKE '安检%'-->
|
||||
<!-- THEN 1 ELSE 0-->
|
||||
<!-- END-->
|
||||
<!-- ) AS otherCount -- 统计不包含“外检”和“安检”的订单-->
|
||||
<!-- FROM-->
|
||||
<!-- inspection_work_node iwn-->
|
||||
<!-- LEFT JOIN inspection_project AS proj ON iwn.project_id = proj.id-->
|
||||
<!-- LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id-->
|
||||
<!-- WHERE iwn.deleted = 0 -- 排除已删除的数据-->
|
||||
<!-- AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录-->
|
||||
<!-- AND iwn.status = 2-->
|
||||
<!-- AND info.status = 1-->
|
||||
<!-- GROUP BY-->
|
||||
<!-- iwn.deal_user_id-->
|
||||
<!-- ) proj_stats ON iwn.deal_user_id = proj_stats.deal_user_id -- 获取“外检”和“安检”的统计-->
|
||||
<!-- <where>-->
|
||||
<!-- iwn.deleted = 0 -- 排除已删除的数据-->
|
||||
<!-- AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录-->
|
||||
<!-- AND iwn.status = 2-->
|
||||
<!-- AND info.status = 1-->
|
||||
<!-- <if test="id != null and id != ''">-->
|
||||
<!-- AND iwn.project_id = #{id} -- 只在这里加上id过滤-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- GROUP BY-->
|
||||
<!-- iwn.deal_user_id -- 根据处理人员ID进行分组-->
|
||||
<!-- ORDER BY-->
|
||||
<!-- orderCount DESC; -- 根据接单数量进行降序排序-->
|
||||
<!-- </select>-->
|
||||
<select id="getStaffCount" resultType="cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO"
|
||||
parameterType="cn.iocoder.yudao.module.inspection.entity.DlInspectionProject">
|
||||
SELECT
|
||||
iwn.deal_user_id, -- 处理人员ID
|
||||
su.nickname, -- 处理人员名称
|
||||
su.avatar, -- 处理人员头像
|
||||
COUNT(DISTINCT iwn.id) AS orderCount, -- 统计每个员工的唯一订单数量
|
||||
SUM(IFNULL(royalty.royalty_amount, 0) / 100) AS royaltyAmount, -- 计算每个员工的总佣金
|
||||
su.mobile, -- 处理人员手机号
|
||||
COALESCE(waijianCount, 0) AS waijianCount, -- 包含“外检”的订单数量
|
||||
COALESCE(anjianCount, 0) AS anjianCount, -- 包含“安检”的订单数量
|
||||
COALESCE(proj_stats.otherCount, 0) AS otherCount -- 其他订单数量(排除“外检”和“安检”)
|
||||
FROM
|
||||
inspection_work_node iwn
|
||||
LEFT JOIN system_users su ON su.id = iwn.deal_user_id -- 处理人员信息
|
||||
LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id
|
||||
LEFT JOIN order_info orders ON info.inspection_order_id = orders.id
|
||||
LEFT JOIN inspection_project_royalty AS royalty
|
||||
ON iwn.project_id = royalty.project_id
|
||||
AND orders.goods_id = royalty.goods_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
iwn.deal_user_id,
|
||||
SUM(CASE WHEN proj.project_name LIKE '环检外检%' THEN 1 ELSE 0 END) AS waijianCount,
|
||||
SUM(CASE WHEN proj.project_name LIKE '安检%' THEN 1 ELSE 0 END) AS anjianCount,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN proj.project_name NOT LIKE '环检外检%'
|
||||
AND proj.project_name NOT LIKE '安检%'
|
||||
THEN 1 ELSE 0
|
||||
END
|
||||
) AS otherCount -- 统计不包含“外检”和“安检”的订单
|
||||
FROM
|
||||
inspection_work_node iwn
|
||||
LEFT JOIN inspection_project AS proj ON iwn.project_id = proj.id
|
||||
LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id
|
||||
WHERE iwn.deleted = 0 -- 排除已删除的数据
|
||||
AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录
|
||||
AND iwn.status = 2
|
||||
AND info.status = 1
|
||||
GROUP BY
|
||||
iwn.deal_user_id
|
||||
) proj_stats ON iwn.deal_user_id = proj_stats.deal_user_id -- 获取“外检”和“安检”的统计
|
||||
<where>
|
||||
iwn.deleted = 0 -- 排除已删除的数据
|
||||
AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录
|
||||
AND iwn.status = 2
|
||||
AND info.status = 1
|
||||
<if test="id != null and id != ''">
|
||||
AND iwn.project_id = #{id} -- 只在这里加上id过滤
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
iwn.deal_user_id -- 根据处理人员ID进行分组
|
||||
ORDER BY
|
||||
orderCount DESC; -- 根据接单数量进行降序排序
|
||||
SELECT
|
||||
ip.project_name, count(iwn.id) as count,is2.user_id,su.nickname
|
||||
FROM inspection_staff is2
|
||||
LEFT JOIN inspection_work_node iwn ON is2.user_id = iwn.deal_user_id
|
||||
LEFT JOIN inspection_project ip ON iwn.project_id = ip.id
|
||||
LEFT JOIN system_users su on su.id = is2.user_id
|
||||
WHERE
|
||||
ip.id in (
|
||||
SELECT
|
||||
ip2.id
|
||||
FROM
|
||||
inspection_project ip2
|
||||
WHERE
|
||||
ip2.deleted = 0
|
||||
)
|
||||
group by is2.user_id,ip.project_name
|
||||
</select>
|
||||
<select id="selectExceptionNodesByInspectionIds" resultType="java.util.Map">
|
||||
SELECT
|
||||
|
@ -144,8 +144,17 @@ FROM
|
||||
<select id="hotGoodsList" resultType="cn.iocoder.yudao.module.inspection.vo.HotGoodsVo">
|
||||
SELECT
|
||||
goods.title AS goodsName,
|
||||
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then oi.goods_price else 0 end ) AS salesAmount,
|
||||
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then 1 else 0 end ) AS salesNum
|
||||
ROUND(
|
||||
SUM(
|
||||
CASE
|
||||
WHEN (ii.`status` = '1' AND ii.is_pass = '1') OR ii.`status` = '0'
|
||||
THEN oi.goods_price
|
||||
ELSE 0
|
||||
END
|
||||
) / 100.0,
|
||||
2
|
||||
) AS salesAmount,
|
||||
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then 1 else 0 end ) AS salesNum
|
||||
FROM
|
||||
shop_inspection_goods goods
|
||||
left join order_info oi on oi.goods_id = goods.id and validation_time is not null and validation_time like concat(#{dateStr},'%')
|
||||
|
Loading…
Reference in New Issue
Block a user