接口对接修改,超管分时间统计生产单

This commit is contained in:
lym
2024-08-19 17:52:04 +08:00
parent 939a8e003f
commit 889aa87456
23 changed files with 553 additions and 94 deletions
@@ -340,31 +340,19 @@ public class OrderController {
@DeleteMapping("/delete-body") @DeleteMapping("/delete-body")
@Operation(summary = "删除柜体") @Operation(summary = "删除柜体")
@Parameters({
@Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024"),
@Parameter(name = "roomIds", description = "房间编号", example = "1"),
@Parameter(name = "bodyId", description = "柜体编号", example = "1")
})
@PreAuthorize("@ss.hasPermission('production:manager-list:deleteCabinet')") @PreAuthorize("@ss.hasPermission('production:manager-list:deleteCabinet')")
public CommonResult<Boolean> deleteBody(@RequestParam("orderId") Long orderId, public CommonResult<Boolean> deleteBody(@Valid @RequestBody OrderModuleParameterRespVO orderModuleParameterRespVO) {
@RequestParam(value = "roomIds", required = false, defaultValue = "0") Set<Long> roomIds, orderService.updateBodyDeletedByOrderId(orderModuleParameterRespVO.getOrderId(), orderModuleParameterRespVO.getRoomIds(),
@RequestParam(value = "bodyId", required = false, defaultValue = "0") Long bodyId) { orderModuleParameterRespVO.getBodyId(), OrderDeletedEnum.DELETED.getStatus());
orderService.updateBodyDeletedByOrderId(orderId, roomIds, bodyId, OrderDeletedEnum.DELETED.getStatus());
return success(true); return success(true);
} }
@PutMapping("/restore-body") @PutMapping("/restore-body")
@Operation(summary = "还原柜体") @Operation(summary = "还原柜体")
@Parameters({
@Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024"),
@Parameter(name = "roomIds", description = "房间编号", example = "1"),
@Parameter(name = "bodyId", description = "柜体编号", example = "1")
})
@PreAuthorize("@ss.hasPermission('production:manager-list:restoreCabinet')") @PreAuthorize("@ss.hasPermission('production:manager-list:restoreCabinet')")
public CommonResult<Boolean> restoreBody(@RequestParam("orderId") Long orderId, public CommonResult<Boolean> restoreBody(@Valid @RequestBody OrderModuleParameterRespVO orderModuleParameterRespVO) {
@RequestParam(value = "roomIds", required = false, defaultValue = "0") Set<Long> roomIds, orderService.updateBodyDeletedByOrderId(orderModuleParameterRespVO.getOrderId(), orderModuleParameterRespVO.getRoomIds(),
@RequestParam(value = "bodyId", required = false, defaultValue = "0") Long bodyId) { orderModuleParameterRespVO.getBodyId(), OrderDeletedEnum.NOT_DELETED.getStatus());
orderService.updateBodyDeletedByOrderId(orderId, roomIds, bodyId, OrderDeletedEnum.NOT_DELETED.getStatus());
return success(true); return success(true);
} }
@@ -4,6 +4,7 @@ import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
import com.cf.imes.module.executor.service.order.OrderSupStatisticsService; import com.cf.imes.module.executor.service.order.OrderSupStatisticsService;
import com.cf.imes.module.system.api.organ.OrganApi; import com.cf.imes.module.system.api.organ.OrganApi;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
import com.cf.imes.module.system.api.user.AdminUserApi; import com.cf.imes.module.system.api.user.AdminUserApi;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -14,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map; import java.util.Map;
import static com.cf.imes.framework.common.pojo.CommonResult.success; import static com.cf.imes.framework.common.pojo.CommonResult.success;
@@ -66,19 +69,25 @@ public class OrderSupStatisticsController {
@GetMapping("/separate/order") @GetMapping("/separate/order")
@Operation(summary = "有效、无效生产单数量统计") @Operation(summary = "有效、无效生产单数量统计")
public CommonResult<Map<String, Object>> getOrderSeparate(OrderStatisticsReqVO reqVO) { public CommonResult<Map<String, Object>> getOrderSeparate(@Valid OrderStatisticsReqVO reqVO) {
return success(orderSupStatisticsService.orderSeparate(reqVO)); return success(orderSupStatisticsService.orderSeparate(reqVO));
} }
@GetMapping("/separate/org") @GetMapping("/separate/org")
@Operation(summary = "新增、注销组织数量统计") @Operation(summary = "新增、注销组织数量统计")
public CommonResult<Map<String, Object>> getOrgSeparate(OrderStatisticsReqVO reqVO) { public CommonResult<Map<String, Object>> getOrgSeparate(@Valid OrgStatisticsReqDTO reqVO) {
return success(orderSupStatisticsService.orgSeparate(reqVO)); return organApi.getOrgSeparate(reqVO);
} }
@GetMapping("/separate/plateArea") @GetMapping("/separate/plateArea")
@Operation(summary = "有效、无效拆单板件数量统计") @Operation(summary = "有效、无效拆单板件平方统计")
public CommonResult<Map<String, Object>> getPlateAreaSeparate(OrderStatisticsReqVO reqVO) { public CommonResult<Map<String, Object>> getPlateAreaSeparate(@Valid OrderStatisticsReqVO reqVO) {
return success(orderSupStatisticsService.plateAreaSeparate(reqVO)); return success(orderSupStatisticsService.plateAreaSeparate(reqVO));
} }
@GetMapping("/warn/org")
@Operation(summary = "组织过期日期统计")
public CommonResult<Map<String, List<Object>>> getWarnToOrg() {
return organApi.getWarnToOrg();
}
} }
@@ -0,0 +1,24 @@
package com.cf.imes.module.executor.controller.admin.order.vo.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.Set;
@Schema(description = "管理后台 - 柜体删除传参")
@Data
@ToString(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OrderModuleParameterRespVO {
@Schema(description = "生产单号", example = "1024")
private Long orderId;
@Schema(description = "房间编号", example = "1024")
private Set<Long> roomIds;
@Schema(description = "柜体编号", example = "1024")
private Long bodyId;
}
@@ -1,6 +1,7 @@
package com.cf.imes.module.executor.dal.mysql.order; package com.cf.imes.module.executor.dal.mysql.order;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsAreaRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
@@ -16,7 +17,7 @@ public interface OrderSupStatisticsMapper extends BaseMapperX<OrderDO> {
/** /**
* 当日生产单板件平方数 * 当日生产单板件平方数
*/ */
Integer selectOrderSquareProduceToday(LocalDateTime startTime, LocalDateTime endTime); Integer selectOrderSquareProduceToday(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
/** /**
* 生产单按时间统计失效数量 * 生产单按时间统计失效数量
@@ -28,4 +29,13 @@ public interface OrderSupStatisticsMapper extends BaseMapperX<OrderDO> {
*/ */
List<OrderStatisticsIsLapseRespVO> selectOrderCountNotLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO); List<OrderStatisticsIsLapseRespVO> selectOrderCountNotLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO);
/**
* 生产单按时间统计无效板件平方数
*/
List<OrderStatisticsAreaRespVO> selectPlateAreaLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO);
/**
* 生产单按时间分组统计有效板件平方数
*/
List<OrderStatisticsAreaRespVO> selectPlateAreaNotLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO);
} }
@@ -150,7 +150,7 @@ public class OrderServiceImpl implements OrderService {
validateCustomOrderNoExists(updateReqVO.getCustomOrderNo(), updateReqVO.getId()); validateCustomOrderNoExists(updateReqVO.getCustomOrderNo(), updateReqVO.getId());
// 更新 // 更新
OrderDO updateObj = BeanUtils.toBean(updateReqVO, OrderDO.class); OrderDO updateObj = BeanUtils.toBean(updateReqVO, OrderDO.class);
if (updateReqVO.getCustomOrderNo() == null || updateReqVO.getCustomOrderNo().equals("")){ if (updateReqVO.getCustomOrderNo() == null || updateReqVO.getCustomOrderNo().equals("")) {
updateObj.setCustomOrderNo(""); updateObj.setCustomOrderNo("");
} }
orderMapper.updateById(updateObj); orderMapper.updateById(updateObj);
@@ -209,7 +209,7 @@ public class OrderServiceImpl implements OrderService {
public PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Set<Long> roomId, Set<Long> bodyId, Set<Long> groupId, String name, Integer pageNo, Integer pageSize, Integer deleted) { public PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Set<Long> roomId, Set<Long> bodyId, Set<Long> groupId, String name, Integer pageNo, Integer pageSize, Integer deleted) {
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageNo, pageSize); PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageNo, pageSize);
IPage<OrderPartsRespVO> orderDetail = orderItemMapper.selectPartsDetailByOrderId(page, orderId, roomId, bodyId,groupId, name, getUserOrganId(), deleted); IPage<OrderPartsRespVO> orderDetail = orderItemMapper.selectPartsDetailByOrderId(page, orderId, roomId, bodyId, groupId, name, getUserOrganId(), deleted);
return new PageResult(orderDetail.getRecords(), orderDetail.getTotal()); return new PageResult(orderDetail.getRecords(), orderDetail.getTotal());
} }
@@ -244,33 +244,36 @@ public class OrderServiceImpl implements OrderService {
orderBodyMapper.updateDeletedById(id, status, getUserOrganId());// 柜体 orderBodyMapper.updateDeletedById(id, status, getUserOrganId());// 柜体
orderGroupMapper.updateDeletedById(id, status, getUserOrganId());// 加工组 orderGroupMapper.updateDeletedById(id, status, getUserOrganId());// 加工组
// (删除小板) 小板变为删除状态 if (CollectionUtils.isNotEmpty(plateDOList) ){
plateMapper.updateDeletedById(plateDOList, status, getUserOrganId()); // (删除小板) 小板变为删除状态
// 删除大板 plateMapper.updateDeletedById(plateDOList, status, getUserOrganId());
List<PlateDO> goodsIdList = plateMapper.selectPlateNum(orderId, getUserOrganId()); // 删除大板
Map<Long, List<PlateDO>> goodsIdMap = goodsIdList.stream() List<PlateDO> goodsIdList = plateMapper.selectPlateNum(orderId, getUserOrganId());
.collect(Collectors.groupingBy(PlateDO::getGoodsId)); Map<Long, List<PlateDO>> goodsIdMap = goodsIdList.stream()
.collect(Collectors.groupingBy(PlateDO::getGoodsId));
List<Long> goodsIdDeleted = new ArrayList<>(); List<Long> goodsIdDeleted = new ArrayList<>();
if (status == 1) { if (status == 1) {
goodsIdMap.forEach((k, v) -> { goodsIdMap.forEach((k, v) -> {
boolean allDeleted = true; boolean allDeleted = true;
for (PlateDO plateDO : v) { for (PlateDO plateDO : v) {
if (!plateDO.getDeleted()) { if (!plateDO.getDeleted()) {
allDeleted = false; allDeleted = false;
break; break;
}
} }
} if (allDeleted) {
if (allDeleted) { goodsIdDeleted.add(k);
goodsIdDeleted.add(k); }
} });
}); }
if (goodsIdDeleted.size() > 0) {
goodsMapper.updateDeletedById(goodsIdDeleted, status, getUserOrganId());
}
} }
if (goodsIdDeleted.size() > 0) {
goodsMapper.updateDeletedById(goodsIdDeleted, status, getUserOrganId());
}
List<Long> partsList = orderPartsMapper.selectPartsIdListByBodyId(id, getUserOrganId()); // 配件 List<Long> partsList = orderPartsMapper.selectPartsIdListByBodyId(id, getUserOrganId()); // 配件
orderPartsMapper.updateDeletedById(partsList, status, getUserOrganId()); orderPartsMapper.updateDeletedById(partsList, status, getUserOrganId());
}); });
@@ -707,11 +710,9 @@ public class OrderServiceImpl implements OrderService {
if (orderDO == null) if (orderDO == null)
throw exception(ORDER_NOT_EXISTS); throw exception(ORDER_NOT_EXISTS);
// 状态排除 // 状态排除
if (Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus())) {
throw exception(ORDER_IS_EMPTY);
}
if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus()) && if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus()) &&
!Objects.equals(orderDO.getStatus(), OrderStatusEnum.SORTED.getStatus())) !Objects.equals(orderDO.getStatus(), OrderStatusEnum.SORTED.getStatus()) &&
!Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus()))
throw exception(ORDER_NOT_CANCEL); throw exception(ORDER_NOT_CANCEL);
} }
@@ -25,12 +25,7 @@ public interface OrderSupStatisticsService {
Map<String, Object> orderSeparate(OrderStatisticsReqVO reqVO); Map<String, Object> orderSeparate(OrderStatisticsReqVO reqVO);
/** /**
* 新增、注销组织数量统计 * 有效、无效拆单板件平方统计
*/
Map<String, Object> orgSeparate(OrderStatisticsReqVO reqVO);
/**
* 有效、无效拆单板件数量统计
*/ */
Map<String, Object> plateAreaSeparate(OrderStatisticsReqVO reqVO); Map<String, Object> plateAreaSeparate(OrderStatisticsReqVO reqVO);
} }
@@ -3,16 +3,17 @@ package com.cf.imes.module.executor.service.order;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.OrderStatisticsUnit; import com.cf.imes.framework.common.enums.OrderStatisticsUnit;
import com.cf.imes.framework.organ.core.aop.OrganIgnore; import com.cf.imes.framework.organ.core.aop.OrganIgnore;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsAreaRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsStatusRespVO;
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanStatisticsCountRespVO;
import com.cf.imes.module.executor.dal.mysql.order.OrderStatisticsMapper; import com.cf.imes.module.executor.dal.mysql.order.OrderStatisticsMapper;
import com.cf.imes.module.executor.dal.mysql.order.OrderSupStatisticsMapper; import com.cf.imes.module.executor.dal.mysql.order.OrderSupStatisticsMapper;
import com.cf.imes.module.system.api.organ.OrganApi;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
@@ -29,6 +30,10 @@ public class OrderSupStatisticsServiceImpl implements OrderSupStatisticsService{
@Resource @Resource
private OrderSupStatisticsMapper orderSupStatisticsMapper; private OrderSupStatisticsMapper orderSupStatisticsMapper;
@Resource
private OrganApi organApi;
@Override @Override
@OrganIgnore @OrganIgnore
public Map<String, Integer> orderTotal() { public Map<String, Integer> orderTotal() {
@@ -62,6 +67,7 @@ public class OrderSupStatisticsServiceImpl implements OrderSupStatisticsService{
} }
@Override @Override
@OrganIgnore
public Map<String, Object> orderSeparate(OrderStatisticsReqVO reqVO) { public Map<String, Object> orderSeparate(OrderStatisticsReqVO reqVO) {
setOrderStatisticsReqVO(reqVO); setOrderStatisticsReqVO(reqVO);
@@ -105,7 +111,8 @@ public class OrderSupStatisticsServiceImpl implements OrderSupStatisticsService{
} }
@Override @Override
public Map<String, Object> orgSeparate(OrderStatisticsReqVO reqVO) { @OrganIgnore
public Map<String, Object> plateAreaSeparate(OrderStatisticsReqVO reqVO) {
setOrderStatisticsReqVO(reqVO); setOrderStatisticsReqVO(reqVO);
Map<String, Object> resultMap = new LinkedHashMap<>(); Map<String, Object> resultMap = new LinkedHashMap<>();
@@ -113,44 +120,38 @@ public class OrderSupStatisticsServiceImpl implements OrderSupStatisticsService{
// 所有的日期集合 // 所有的日期集合
List<String> dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit()); List<String> dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit());
// 生产单有效数量 // 生产单有效板件平方数量
Map<String, List<OrderStatisticsIsLapseRespVO>> orderLapseRespMap = orderSupStatisticsMapper.selectOrderCountLapseByOrderDate(reqVO).stream() Map<String, List<OrderStatisticsAreaRespVO>> orderLapseRespMap = orderSupStatisticsMapper.selectPlateAreaNotLapseByOrderDate(reqVO).stream()
.sorted(Comparator.naturalOrder()) .sorted(Comparator.naturalOrder())
.collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList())); .collect(Collectors.groupingBy(OrderStatisticsAreaRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
// 生产单无效数量 // 生产单无效板件平方数量
Map<String, List<OrderStatisticsIsLapseRespVO>> orderNotLapseRespMap = orderSupStatisticsMapper.selectOrderCountNotLapseByOrderDate(reqVO).stream() Map<String, List<OrderStatisticsAreaRespVO>> orderNotLapseRespMap = orderSupStatisticsMapper.selectPlateAreaLapseByOrderDate(reqVO).stream()
.sorted(Comparator.naturalOrder()) .sorted(Comparator.naturalOrder())
.collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList())); .collect(Collectors.groupingBy(OrderStatisticsAreaRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
// 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组 // 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组
for (String dateStr : dateList) { for (String dateStr : dateList) {
int[] countArr = new int[2]; BigDecimal[] countArr = new BigDecimal[2];
// 生产单有效数量 // 生产单有效数量
Integer orderNotLapseCount = Optional.ofNullable(orderNotLapseRespMap.get(dateStr)) BigDecimal orderNotLapseCount = Optional.ofNullable(orderNotLapseRespMap.get(dateStr))
.map(list -> list.stream().findFirst().orElse(new OrderStatisticsIsLapseRespVO())) .map(list -> list.stream().findFirst().orElse(new OrderStatisticsAreaRespVO()))
.map(OrderStatisticsIsLapseRespVO::getOrderCount) .map(OrderStatisticsAreaRespVO::getAreaSum)
.orElse(0); .orElse(BigDecimal.valueOf(0));
countArr[0] = orderNotLapseCount; countArr[0] = orderNotLapseCount;
// 生产单无效数量 // 生产单无效数量
Integer orderLapseCount = Optional.ofNullable(orderLapseRespMap.get(dateStr)) BigDecimal orderLapseCount = Optional.ofNullable(orderLapseRespMap.get(dateStr))
.map(list -> list.stream().findFirst().orElse(new OrderStatisticsIsLapseRespVO())) .map(list -> list.stream().findFirst().orElse(new OrderStatisticsAreaRespVO()))
.map(OrderStatisticsIsLapseRespVO::getOrderCount) .map(OrderStatisticsAreaRespVO::getAreaSum)
.orElse(0); .orElse(BigDecimal.valueOf(0));
countArr[1] = orderLapseCount; countArr[1] = orderLapseCount;
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr); resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr);
} }
return resultMap; return resultMap;
}
@Override
public Map<String, Object> plateAreaSeparate(OrderStatisticsReqVO reqVO) {
return null;
} }
private void setOrderStatisticsReqVO(OrderStatisticsReqVO reqVO){ private void setOrderStatisticsReqVO(OrderStatisticsReqVO reqVO){
@@ -44,4 +44,26 @@
group by date; group by date;
</select> </select>
<select id="selectPlateAreaLapseByOrderDate"
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsAreaRespVO">
select sum(op.area) as areaSum
<include refid="dateFormat"/>
from orders o
left join order_plate op on op.order_id = o.id and op.deleted = 0
where o.order_date between #{req.createTime[0]} and #{req.createTime[1]}
and (o.deleted = 1 or o.status = 0)
group by date;
</select>
<select id="selectPlateAreaNotLapseByOrderDate"
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsAreaRespVO">
select sum(op.area) as areaSum
<include refid="dateFormat"/>
from orders o
left join order_plate op on op.order_id = o.id and op.deleted = 0
where o.order_date between #{req.createTime[0]} and #{req.createTime[1]}
and o.deleted = 0 and o.status != 0
group by date;
</select>
</mapper> </mapper>
@@ -1,6 +1,7 @@
package com.cf.imes.module.system.api.organ; package com.cf.imes.module.system.api.organ;
import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
import com.cf.imes.module.system.enums.ApiConstants; import com.cf.imes.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@@ -9,6 +10,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -34,6 +36,9 @@ public interface OrganApi {
@GetMapping(PREFIX + "/separate/org") @GetMapping(PREFIX + "/separate/org")
@Operation(summary = "新增、注销组织数量统计") @Operation(summary = "新增、注销组织数量统计")
CommonResult<Map<String, Object>> getOrgSeparate(@RequestParam("time") LocalDate[] createTime, @RequestParam("unit")Integer unit); CommonResult<Map<String, Object>> getOrgSeparate(@Valid OrgStatisticsReqDTO reqVO);
@GetMapping(PREFIX + "/warn/org")
@Operation(summary = "组织过期日期统计")
CommonResult<Map<String, List<Object>>> getWarnToOrg();
} }
@@ -0,0 +1,60 @@
package com.cf.imes.module.system.api.organ.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 组织是否新增统计")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
public class OrgStatisticsIsLapseRespDTO implements Comparable<OrgStatisticsIsLapseRespDTO>{
@Schema(description = "组织状态")
private Integer orgStatus;
@Schema(description = "组织数量")
private Integer orgCount;
@Schema(description = "组织时间")
private String date;
@Schema(description = "是否删除")
private Boolean deleted;
@Override
public int compareTo(@NotNull OrgStatisticsIsLapseRespDTO o) {
// 解析 orderDate 字符串为年、月、周
String[] partsThis = date.split("-");
String[] partsOther = o.date.split("-");
// 比较年份
int yearComparison = Integer.compare(Integer.parseInt(partsThis[0]), Integer.parseInt(partsOther[0]));
if (yearComparison != 0) {
return yearComparison;
}
// 比较月份
if (partsThis.length > 1 && partsOther.length > 1) {
int monthComparison = Integer.compare(Integer.parseInt(partsThis[1]), Integer.parseInt(partsOther[1]));
if (monthComparison != 0) {
return monthComparison;
}
}
// 比较周数
if (partsThis.length > 2 && partsOther.length > 2) {
int weekComparison = Integer.compare(Integer.parseInt(partsThis[2]), Integer.parseInt(partsOther[2]));
if (weekComparison != 0) {
return weekComparison;
}
}
// 如果所有部分都相同,则按状态排序
return this.orgStatus.compareTo(o.orgStatus);
}
}
@@ -0,0 +1,29 @@
package com.cf.imes.module.system.api.organ.dto;
import com.cf.imes.module.system.validation.org.OrgStatisticsUnitInEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
/**
* 统计集合 --- 组织统计
*/
@Schema(description = "管理后台 - 生产单统计 Request VO")
@Data
public class OrgStatisticsReqDTO {
@Schema(description = "组织id")
private Long organId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate[] createTime;
/**
* 统计维度单位
*/
@Schema(description = "统计维度单位", example = "0", allowableValues = {"0", "1", "2", "3"}, type = "integer")
@OrgStatisticsUnitInEnum
private Integer unit;
}
@@ -0,0 +1,35 @@
package com.cf.imes.module.system.validation.org;
/**
* @projectName: cf_imes_server
* @author: 晨丰科技
* @date: 2024/8/19 9:56
*/
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 生产单统计维度单位入参校验注解
*/
@Target({
ElementType.METHOD,
ElementType.FIELD,
ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR,
ElementType.PARAMETER,
ElementType.TYPE_USE
})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(
validatedBy = {OrgStatisticsUnitInEnumValidator.class}
)
public @interface OrgStatisticsUnitInEnum {
String message() default "生产单统计维度单位[unit]错误,请检查";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,32 @@
package com.cf.imes.module.system.validation.org;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.OrderStatisticsUnit;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 生产单统计维度单位入参校验器
*/
public class OrgStatisticsUnitInEnumValidator implements ConstraintValidator<OrgStatisticsUnitInEnum, Integer> {
@Override
public void initialize(OrgStatisticsUnitInEnum constraintAnnotation) {
ConstraintValidator.super.initialize(constraintAnnotation);
}
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
if (ObjectUtil.isNull(value)) {
return true;
}
OrderStatisticsUnit unit = OrderStatisticsUnit.fromValue(value);
if (ObjectUtil.isNotNull(unit)) {
return true;
} else {
return false;
}
}
}
@@ -1,16 +1,24 @@
package com.cf.imes.module.system.api.organ; package com.cf.imes.module.system.api.organ;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.OrderStatisticsUnit;
import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganRespVO;
import com.cf.imes.module.system.service.organ.OrganService; import com.cf.imes.module.system.service.organ.OrganService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.time.LocalDateTime;
import java.util.Map; import java.util.*;
import java.util.stream.Collectors;
import static com.cf.imes.framework.common.pojo.CommonResult.success; import static com.cf.imes.framework.common.pojo.CommonResult.success;
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.getDateList;
@RestController // 提供 RESTful API 接口,给 Feign 调用 @RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated @Validated
@@ -36,8 +44,77 @@ public class OrganApiImpl implements OrganApi {
} }
@Override @Override
public CommonResult<Map<String, Object>> getOrgSeparate(LocalDate[] createTime, Integer unit) { public CommonResult<Map<String, Object>> getOrgSeparate(OrgStatisticsReqDTO reqVO) {
return null; setOrgStatisticsReqVO(reqVO);
Map<String, Object> resultMap = new LinkedHashMap<>();
// 所有的日期集合
List<String> dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit());
// 生产单有效数量
Map<String, List<OrgStatisticsIsLapseRespDTO>> orderLapseRespMap = organService.orgCountAddByOrderDateAdd(reqVO).stream()
.sorted(Comparator.naturalOrder())
.collect(Collectors.groupingBy(OrgStatisticsIsLapseRespDTO::getDate, LinkedHashMap::new, Collectors.toList()));
// 组织无效数量
Map<String, List<OrgStatisticsIsLapseRespDTO>> orderNotLapseRespMap = organService.orgCountLapseByOrderDate(reqVO).stream()
.sorted(Comparator.naturalOrder())
.collect(Collectors.groupingBy(OrgStatisticsIsLapseRespDTO::getDate, LinkedHashMap::new, Collectors.toList()));
// 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组
for (String dateStr : dateList) {
int[] countArr = new int[2];
// 组织有效数量
Integer orderNotLapseCount = Optional.ofNullable(orderNotLapseRespMap.get(dateStr))
.map(list -> list.stream().findFirst().orElse(new OrgStatisticsIsLapseRespDTO()))
.map(OrgStatisticsIsLapseRespDTO::getOrgCount)
.orElse(0);
countArr[0] = orderNotLapseCount;
// 组织无效数量
Integer orderLapseCount = Optional.ofNullable(orderLapseRespMap.get(dateStr))
.map(list -> list.stream().findFirst().orElse(new OrgStatisticsIsLapseRespDTO()))
.map(OrgStatisticsIsLapseRespDTO::getOrgCount)
.orElse(0);
countArr[1] = orderLapseCount;
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr);
}
return success(resultMap);
} }
@Override
public CommonResult<Map<String, List<Object>>> getWarnToOrg() {
Map<String, List<Object>> map = new HashMap<>();
LocalDateTime today = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
LocalDateTime afterDay = today.plusDays(15).withHour(23).withMinute(59).withSecond(59);
LocalDateTime alertDay = LocalDateTime.now().withHour(23).withMinute(59).withSecond(59);
// 即将过期组织
List<OrganRespVO> expireOrg = organService.orgCountExpire(today, afterDay);
map.put("expireOrg", Collections.singletonList(expireOrg));
// 已过期组织
List<OrganRespVO> lapseOrg = organService.orgCountExpired(alertDay);
map.put("expiredOrg", Collections.singletonList(lapseOrg));
return success(map);
}
private void setOrgStatisticsReqVO(OrgStatisticsReqDTO reqVO){
if (ObjectUtil.isNull(reqVO.getUnit())){
reqVO.setUnit(OrderStatisticsUnit.DAY.getValue());
}
if (ObjectUtil.isNull(reqVO.getCreateTime())){
reqVO.setCreateTime(new LocalDate[2]);
}
LocalDate[] time = reqVO.getCreateTime();
reqVO.setCreateTime(new LocalDate[]{time[0], time[1]});
}
} }
@@ -5,6 +5,8 @@ import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.executor.enums.OrderDeletedEnum; import com.cf.imes.module.executor.enums.OrderDeletedEnum;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO;
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO; import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@@ -61,7 +63,7 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
default Integer selectOrgCount() { default Integer selectOrgCount() {
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrganizationDO>() return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrganizationDO>()
.eq(OrganizationDO::getUpdateTime, OrderDeletedEnum.NOT_DELETED.getStatus()))); .eq(OrganizationDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())));
} }
default Integer selectOrgCountAdd() { default Integer selectOrgCountAdd() {
@@ -91,6 +93,25 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
List<OrganizationDO> selectTestSQL(@Param("sql") String sql); List<OrganizationDO> selectTestSQL(@Param("sql") String sql);
/**
* 组织按时间统计新增数量
*/
List<OrgStatisticsIsLapseRespDTO> selectOrgCountAddByOrderDate(@Param("req") OrgStatisticsReqDTO reqVO);
/**
* 组织按时间分组统计注销数量
*/
List<OrgStatisticsIsLapseRespDTO> selectOrgCountLapseByOrderDate(@Param("req") OrgStatisticsReqDTO reqVO);
default List<OrganizationDO> selectOrgCountExpire(LocalDateTime today, LocalDateTime afterDay){
return selectList(new LambdaQueryWrapperX<OrganizationDO>()
.eq(OrganizationDO::getDeleted,false)
.between(OrganizationDO::getExpireTime,today,afterDay));
}
default List<OrganizationDO> selectOrgCountExpired(LocalDateTime alertDay){
return selectList(new LambdaQueryWrapperX<OrganizationDO>()
.eq(OrganizationDO::getDeleted,false)
.lt(OrganizationDO::getExpireTime,alertDay));
}
} }
@@ -129,12 +129,16 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59))))); LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59)))));
} }
Integer selectUserSilentCount(@Param("dateTime")LocalDateTime dateTime); default Integer selectUserCountSilent(LocalDateTime dateTime) {
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())
.lt(AdminUserDO::getLoginDate, dateTime)));
}
default Integer selectUserActCountTime(LocalDateTime startTime, LocalDateTime endTIme) { default Integer selectUserActCountTime(LocalDateTime startTime, LocalDateTime endTIme) {
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>() return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus()) .eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())
.eq(AdminUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) .eq(AdminUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.between(AdminUserDO::getCreateTime, startTime, endTIme))); .between(AdminUserDO::getLoginDate, startTime, endTIme)));
} }
} }
@@ -0,0 +1,32 @@
package com.cf.imes.module.system.order;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* 生产单统计维度单位入参校验注解
*
* @author Gqr
* @since 2024/7/17 9:33
*/
@Target({
ElementType.METHOD,
ElementType.FIELD,
ElementType.ANNOTATION_TYPE,
ElementType.CONSTRUCTOR,
ElementType.PARAMETER,
ElementType.TYPE_USE
})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(
validatedBy = {OrderStatisticsUnitInEnumValidator.class}
)
public @interface OrderStatisticsUnitInEnum {
String message() default "生产单统计维度单位[unit]错误,请检查";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
@@ -0,0 +1,36 @@
package com.cf.imes.module.system.order;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.module.executor.enums.OrderStatisticsUnit;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 生产单统计维度单位入参校验器
*
* @author Gqr
* @since 2024/7/17 9:33
*/
public class OrderStatisticsUnitInEnumValidator implements ConstraintValidator<OrderStatisticsUnitInEnum, Integer> {
@Override
public void initialize(OrderStatisticsUnitInEnum constraintAnnotation) {
ConstraintValidator.super.initialize(constraintAnnotation);
}
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
if (ObjectUtil.isNull(value)) {
return true;
}
OrderStatisticsUnit unit = OrderStatisticsUnit.fromValue(value);
if (ObjectUtil.isNotNull(unit)) {
return true;
} else {
return false;
}
}
}
@@ -2,15 +2,18 @@ package com.cf.imes.module.system.service.organ;
import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganRespVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSaveReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSaveReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO;
import com.cf.imes.module.system.controller.admin.user.vo.user.UserSimpleRespVO;
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO; import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
import com.cf.imes.module.system.service.organ.handler.OrganInfoHandler; import com.cf.imes.module.system.service.organ.handler.OrganInfoHandler;
import com.cf.imes.module.system.service.organ.handler.OrganMenuHandler; import com.cf.imes.module.system.service.organ.handler.OrganMenuHandler;
import javax.validation.Valid; import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -136,4 +139,24 @@ public interface OrganService {
* 组织总数统计 * 组织总数统计
*/ */
Map<String, Integer> orgTotal(); Map<String, Integer> orgTotal();
/**
* 组织新增统计
*/
List<OrgStatisticsIsLapseRespDTO> orgCountAddByOrderDateAdd(OrgStatisticsReqDTO reqVO);
/**
* 组织注销统计
*/
List<OrgStatisticsIsLapseRespDTO> orgCountLapseByOrderDate(OrgStatisticsReqDTO reqVO);
/**
* 即将过期组织统计
*/
List<OrganRespVO> orgCountExpire(LocalDateTime today, LocalDateTime afterDay);
/**
* 已过期组织统计
*/
List<OrganRespVO> orgCountExpired(LocalDateTime alertDay);
} }
@@ -15,7 +15,10 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.config.OrganProperties; import com.cf.imes.framework.organ.config.OrganProperties;
import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.framework.organ.core.util.OrganUtils; import com.cf.imes.framework.organ.core.util.OrganUtils;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
import com.cf.imes.module.system.constants.permission.InternalRoleConstants; import com.cf.imes.module.system.constants.permission.InternalRoleConstants;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganRespVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO;
import com.cf.imes.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import com.cf.imes.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO;
@@ -44,6 +47,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -372,4 +376,24 @@ public class OrganServiceImpl implements OrganService {
return map; return map;
} }
@Override
public List<OrgStatisticsIsLapseRespDTO> orgCountAddByOrderDateAdd(OrgStatisticsReqDTO reqVO) {
return organMapper.selectOrgCountAddByOrderDate(reqVO);
}
@Override
public List<OrgStatisticsIsLapseRespDTO> orgCountLapseByOrderDate(OrgStatisticsReqDTO reqVO) {
return organMapper.selectOrgCountLapseByOrderDate(reqVO);
}
@Override
public List<OrganRespVO> orgCountExpire(LocalDateTime today, LocalDateTime afterDay) {
return BeanUtils.toBean(organMapper.selectOrgCountExpire(today, afterDay), OrganRespVO.class);
}
@Override
public List<OrganRespVO> orgCountExpired(LocalDateTime alertDay) {
return BeanUtils.toBean(organMapper.selectOrgCountExpired(alertDay), OrganRespVO.class);
}
} }
@@ -597,7 +597,7 @@ public class AdminUserServiceImpl implements AdminUserService {
map.put("userTodayDel", userTodayDel); map.put("userTodayDel", userTodayDel);
// 当日沉寂数 (30天未登录) // 当日沉寂数 (30天未登录)
Date date = DateUtil.offsetDay(new Date(), -30); Date date = DateUtil.offsetDay(new Date(), -30);
Integer userTodaySilent = userMapper.selectUserSilentCount(DateUtil.beginOfDay(date).toLocalDateTime()); Integer userTodaySilent = userMapper.selectUserCountSilent(DateUtil.beginOfDay(date).toLocalDateTime());
map.put("userTodaySilent", userTodaySilent); map.put("userTodaySilent", userTodaySilent);
return map; return map;
@@ -28,8 +28,39 @@
</select> </select>
<sql id="dateFormat">
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.OrderStatisticsUnit@QUARTER.getValue()">
,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.OrderStatisticsUnit@MONTH.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.OrderStatisticsUnit@WEEK.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', FLOOR((DayOfMonth(o.order_date)-1)/7)+1) AS date
</if>
<if test="req.unit != null and req.unit == @com.cf.imes.framework.common.enums.OrderStatisticsUnit@DAY.getValue()">
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as date
</if>
</sql>
<select id="selectOrgCountLapseByOrderDate"
resultType="com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO">
select count(o.id) as orgCount
<include refid="dateFormat"/>
from system_organization o
where o.update_time between #{req.createTime[0]} and #{req.createTime[1]}
and o.deleted = 1
group by date;
</select>
<select id="selectOrgCountAddByOrderDate"
resultType="com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO">
select count(o.id) as orgCount
<include refid="dateFormat"/>
from system_organization o
where o.create_time between #{req.createTime[0]} and #{req.createTime[1]}
and o.deleted = 0
group by date;
</select>
</mapper> </mapper>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cf.imes.module.system.dal.mysql.organ.OrganMapper"> <mapper namespace="com.cf.imes.module.system.dal.mysql.user.AdminUserMapper">
<select id="selectUserSilentCount" resultType="java.lang.Integer"> <select id="selectUserSilentCount" resultType="java.lang.Integer">
SELECT DISTINCT COUNT(*) AS count SELECT DISTINCT COUNT(*) AS count