diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/OrderStatisticsUnit.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/OrderStatisticsUnit.java new file mode 100644 index 000000000..efeec02b4 --- /dev/null +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/enums/OrderStatisticsUnit.java @@ -0,0 +1,34 @@ +package com.cf.imes.framework.common.enums; + +/** + * 生产单统计维度单位 + * @author Gqr + * @since 2024/8/6 10:04 + */ +public enum OrderStatisticsUnit { + //季度、月、周、日 + QUARTER(0), + MONTH(1), + WEEK(2), + DAY(3); + + OrderStatisticsUnit(Integer value) { + this.value = value; + } + + private Integer value; + + public Integer getValue() { + return value; + } + + // from value + public static OrderStatisticsUnit fromValue(Integer value) { + for (OrderStatisticsUnit unit : OrderStatisticsUnit.values()) { + if (unit.getValue().equals(value)) { + return unit; + } + } + return null; + } +} diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/util/time/StatisticsChangeUtils.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/util/time/StatisticsChangeUtils.java new file mode 100644 index 000000000..044ffe248 --- /dev/null +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/util/time/StatisticsChangeUtils.java @@ -0,0 +1,149 @@ +package com.cf.imes.framework.common.util.time; + +import cn.hutool.core.util.ObjectUtil; +import com.cf.imes.framework.common.enums.OrderStatisticsUnit; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; +import java.util.List; + +/** + * 统计时间转换工具类 + */ +public class StatisticsChangeUtils { + + /** + * 获取日期区间格式下的所有日期字符串 + * 1、reqVO设置机构id + * 2、计算时间跨度设置到reqVO + * 3、返回所有日期的集合 + * @return + */ + public static List getDateList(LocalDate[] createTime, Integer unit) { + // 计算时间跨度 + getTimeSpan(createTime, unit); + + // 所有的日期集合 + return generateDateRange(createTime, unit); + } + + /** + * 获取统计的时间跨度 + * 计算起止时间:前端不传入时间就根据维度单位从当前日期计算 + * + */ + public static LocalDate[] getTimeSpan(LocalDate[] createTime, Integer unit) { + LocalDate startTime = null; + LocalDate endTime; + LocalDate now = LocalDate.now(); + if (ObjectUtil.isNull(createTime) || ObjectUtil.isNull(createTime[0]) || ObjectUtil.isNull(createTime[1])) { + endTime = now; + switch (OrderStatisticsUnit.fromValue(unit)) { + case QUARTER: + // 从now往前的2年 + startTime = now.minusYears(2); + break; + case MONTH: + // 包含now往前的12个月 + startTime = now.minusMonths(11); + break; + case WEEK: + // 包含now往前的12周 + startTime = now.minusWeeks(11); + break; + case DAY: + // 包含now往前的15天 + startTime = now.minusDays(14); + break; + default: + break; + } + // 声明一个LocalDateTime的数组,把startTime和endTime放进去 + createTime[0] = startTime; + createTime[1] = endTime; + } + return createTime; + } + + /** + * 获取日期范围内的所有格式字符串 + * + * @return + */ + public static List generateDateRange(LocalDate[] createTime, Integer unit) { + // 计算时间跨度 + getTimeSpan(createTime, unit); + // 计算后的开始和结束时间 + LocalDate startDate = ObjectUtil.clone(createTime[0]); + LocalDate endDate = ObjectUtil.clone(createTime[1]); + + List dates = new ArrayList<>(); + while (!startDate.isAfter(endDate)) { + String dateStr; + switch (OrderStatisticsUnit.fromValue(unit)) { + case QUARTER: + dateStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-Q")); + // 加一季度(3个月) + startDate = startDate.plusMonths(3); + break; + case MONTH: + dateStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-M")); + // 加一月 + startDate = startDate.plusMonths(1); + break; + case WEEK: + // 使用自定义格式表示月份 + dateStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-M")); + // 计算从月份第一天到当前日期经过了多少周 + LocalDate monthStart = startDate.with(TemporalAdjusters.firstDayOfMonth()); + long weeksInMonth = ChronoUnit.WEEKS.between(monthStart, startDate) + 1; + dateStr = dateStr + "-" + weeksInMonth; + // 加一周 + startDate = startDate.plusWeeks(1); + break; + case DAY: + dateStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-M-d")); + // 加一天 + startDate = startDate.plusDays(1); + break; + default: + throw new IllegalArgumentException("Unsupported unit: " + unit); + } + dates.add(dateStr); + } + return dates; + } + + /** + * 构建日期格式到图标横轴可用格式 + * 2024-1 -> 2024年第1季度 + * 2024-1-1 -> 2024年1月 + * ... + * @param unit + * @return + */ + public static String generateDateRangeAxis(String date, Integer unit) { + OrderStatisticsUnit orderStatisticsUnit = OrderStatisticsUnit.fromValue(unit); + StringBuilder newDateStrBuffer = new StringBuilder(); + String[] dateSplit = date.split("-"); + switch (orderStatisticsUnit) { + case QUARTER: + newDateStrBuffer.append("第").append(dateSplit[1]).append("季度"); + break; + case MONTH: + newDateStrBuffer.append(dateSplit[1]).append("月"); + break; + case WEEK: + newDateStrBuffer.append("第").append(dateSplit[2]).append("周"); + break; + case DAY: + newDateStrBuffer.append(dateSplit[2]); + break; + default: + } + return newDateStrBuffer.toString(); + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java index cf2b1df1a..98a707e82 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java @@ -1,7 +1,5 @@ package com.cf.imes.module.executor.controller.admin.order; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; import com.cf.imes.module.executor.controller.admin.order.vo.order.*; @@ -11,13 +9,13 @@ import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsResp import com.cf.imes.module.executor.enums.OrderDeletedEnum; import com.cf.imes.module.executor.enums.OrderStatusEnum; import com.cf.imes.module.executor.enums.OrderTypeEnum; -import com.cf.imes.module.executor.service.order.intervalometer.OrderScheduledImpl; import com.cf.imes.module.executor.util.ExcelWriterUtil; import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataAchieve; import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize; import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelReadUtil; import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.OrderPlateImportExcelVO; import io.swagger.v3.oas.annotations.Parameters; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -62,6 +60,7 @@ import java.util.concurrent.ExecutionException; @RestController @RequestMapping("/executor/order") @Validated +@Slf4j public class OrderController { @Resource @@ -76,8 +75,6 @@ public class OrderController { @Resource private ApiTypeRealize apiTypeRealize; - @Resource - private OrderScheduledImpl orderScheduledImpl; @PutMapping("/update") @Operation(summary = "更新生产单") @@ -87,7 +84,7 @@ public class OrderController { return success(true); } -// 做生产单是否作废判断 + // 做生产单是否作废判断 @GetMapping("/get") @Operation(summary = "获得(单个)生产单") @Parameter(name = "id", description = "编号", required = true, example = "1024") @@ -103,7 +100,7 @@ public class OrderController { return success(BeanUtils.toBean(orderService.getOrderPage(pageReqVO), OrderRespVO.class)); } -// 不做生产单是否作废判断 + // 不做生产单是否作废判断 @GetMapping("/printing") @Operation(summary = "打印/导出 数据文件") @Parameters({ @@ -150,7 +147,7 @@ public class OrderController { } -// 获取api订单接口 + // 获取api订单接口 @GetMapping("/getApiOrder") @Operation(summary = "获取api订单接口") @Parameters({ @@ -173,7 +170,7 @@ public class OrderController { return success(orderService.getApiOrderList(orderList)); } -// api-生产单导入 + // api-生产单导入 @GetMapping("getApiData") @Operation(summary = "生产单api数据导入新增") @PreAuthorize("@ss.hasPermission('production:manager-list:create')") @@ -184,7 +181,7 @@ public class OrderController { JSONObject oauth = apiDataAchieve.getApiToken(organId).get(); String token = oauth.getJSONObject("info").getString("access_token"); String shopId = oauth.getJSONObject("info").getString("shop_id"); - JSONObject order= apiDataAchieve.getApiOrder(token, shopId, orderNo).get(); + JSONObject order = apiDataAchieve.getApiOrder(token, shopId, orderNo).get(); if (!order.getString("err_code").equals("0")) { throw exception(PLATE_PLAN_DATA_ERROR); } @@ -255,7 +252,7 @@ public class OrderController { } if (list.size() == 0) { orderDO.setStatus(OrderStatusEnum.EMPTY.getStatus()); - }else { + } else { orderDO.setStatus(OrderStatusEnum.NEW_ORDER.getStatus()); } } else { // 板材导入 @@ -268,14 +265,15 @@ public class OrderController { } orderService.importExcelData(orderDO, list, index); + + } catch (Exception e) { ExcelWriterUtil.writeErr(response, "系统出现未知错误,请下载模板,按照模板重新上传文件", orderService.getSavePath() + File.separator + "order_err.xlsx"); } } - -// 生产单详情 + // 生产单详情 @GetMapping("/get-room") @Operation(summary = "生产单详情-房间和柜体id") @Parameters({ @@ -284,8 +282,8 @@ public class OrderController { }) @PreAuthorize("@ss.hasPermission('production:manager-list:detail')") public CommonResult> getRoom(@RequestParam("orderId") Long orderId, - @RequestParam(value ="deleted", required = false, defaultValue = "false") Boolean deleted) { - if (deleted == null){ + @RequestParam(value = "deleted", required = false, defaultValue = "false") Boolean deleted) { + if (deleted == null) { deleted = false; } return success(orderService.getOrderBody(orderId, !deleted ? 0 : 1)); @@ -307,77 +305,51 @@ public class OrderController { }) @PreAuthorize("@ss.hasPermission('production:manager-list:detail')") public CommonResult>> getModule(@RequestParam("orderId") Long orderId, - @RequestParam(value ="deleted", required = false, defaultValue = "false") Boolean deleted) { - if (deleted == null){ + @RequestParam(value = "deleted", required = false, defaultValue = "false") Boolean deleted) { + if (deleted == null) { deleted = false; } return success(orderService.getModule(orderId, !deleted ? 0 : 1)); } - @GetMapping("/get-platesDetailsPage") + @PostMapping("/get-platesDetailsPage") @Operation(summary = "生产单详情-板材详细信息(分页)") - @Parameters({ - @Parameter(name = "orderId", description = "生产单编号", example = "1024"), - @Parameter(name = "roomId", description = "房间编号", example = "1024"), - @Parameter(name = "bodyId", description = "柜体编号", example = "1024"), - @Parameter(name = "groupId", description = "加工组编号", example = "1024"), - @Parameter(name = "groupName", description = "加工组名称", example = "弧形"), - @Parameter(name = "pageNo", description = "第几页", example = "1"), - @Parameter(name = "pageSize", description = "条数", example = "10"), - @Parameter(name = "deleted", description = "是否删除", example = "false") - }) @PreAuthorize("@ss.hasPermission('production:manager-list:detail')") - public CommonResult> platesDetails(@RequestParam("orderId") Long orderId, - @RequestParam(value = "roomId", required = false) Long roomId, - @RequestParam(value = "bodyId", required = false) Long bodyId, - @RequestParam(value = "groupId", required = false) Long groupId, - @RequestParam(value = "groupName", required = false) String groupName, - @RequestParam(value = "pageNo") Integer pageNo, - @RequestParam(value = "pageSize") Integer pageSize, - @RequestParam(value ="deleted", required = false, defaultValue = "false") Boolean deleted) { - if (deleted == null){ - deleted = false; + public CommonResult> platesDetails(@Valid @RequestBody OrderBodyPageRespVO orderBodyPageRespVO) { + if (orderBodyPageRespVO.getDeleted() == null) { + orderBodyPageRespVO.setDeleted(false); } - return success(orderService.getPlatesDetail(orderId, roomId, bodyId, groupId, groupName, pageNo, pageSize, !deleted ? 0 : 1)); + return success(orderService.getPlatesDetail(orderBodyPageRespVO.getOrderId(), + orderBodyPageRespVO.getRoomIds(), orderBodyPageRespVO.getBodyIds(), + orderBodyPageRespVO.getGroupIds(), orderBodyPageRespVO.getGroupName(), + orderBodyPageRespVO.getPageNo(), orderBodyPageRespVO.getPageSize(), !orderBodyPageRespVO.getDeleted() ? 0 : 1)); } - @GetMapping("/get-partsDetailsPage") + @PostMapping("/get-partsDetailsPage") @Operation(summary = "生产单详情-配件详细信息(分页)") - @Parameters({ - @Parameter(name = "orderId", description = "生产单编号", example = "1024"), - @Parameter(name = "roomId", description = "房间编号", example = "1024"), - @Parameter(name = "bodyId", description = "柜体编号", example = "1024"), - @Parameter(name = "name", description = "配件名称", example = "1024"), - @Parameter(name = "pageNo", description = "第几页", example = "1"), - @Parameter(name = "pageSize", description = "条数", example = "10"), - @Parameter(name = "deleted", description = "是否删除", example = "false") - }) @PreAuthorize("@ss.hasPermission('production:manager-list:detail')") - public CommonResult> partsDetails(@RequestParam("orderId") Long orderId, - @RequestParam(value = "roomId", required = false) Long roomId, - @RequestParam(value = "bodyId", required = false) Long bodyId, - @RequestParam(value = "name", required = false) String name, - @RequestParam(value = "pageNo") Integer pageNo, - @RequestParam(value = "pageSize") Integer pageSize, - @RequestParam(value ="deleted", required = false, defaultValue = "false") Boolean deleted) { - if (deleted == null){ - deleted = false; + public CommonResult> partsDetails(@Valid @RequestBody OrderBodyPageRespVO orderBodyPageRespVO) { + if (orderBodyPageRespVO.getDeleted() == null) { + orderBodyPageRespVO.setDeleted(false); } - return success(orderService.getPartsDetail(orderId, roomId, bodyId, name, pageNo, pageSize, !deleted ? 0 : 1)); + return success(orderService.getPartsDetail(orderBodyPageRespVO.getOrderId(), + orderBodyPageRespVO.getRoomIds(), orderBodyPageRespVO.getBodyIds(), + orderBodyPageRespVO.getGroupIds(), orderBodyPageRespVO.getPartsName(), + orderBodyPageRespVO.getPageNo(), orderBodyPageRespVO.getPageSize(), !orderBodyPageRespVO.getDeleted() ? 0 : 1)); } @DeleteMapping("/delete-body") @Operation(summary = "删除柜体") @Parameters({ @Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024"), - @Parameter(name = "roomId", description = "房间编号", example = "1"), + @Parameter(name = "roomIds", description = "房间编号", example = "1"), @Parameter(name = "bodyId", description = "柜体编号", example = "1") }) @PreAuthorize("@ss.hasPermission('production:manager-list:deleteCabinet')") public CommonResult deleteBody(@RequestParam("orderId") Long orderId, - @RequestParam(value = "roomId", required = false, defaultValue = "0") Long roomId, + @RequestParam(value = "roomIds", required = false, defaultValue = "0") Set roomIds, @RequestParam(value = "bodyId", required = false, defaultValue = "0") Long bodyId) { - orderService.updateBodyDeletedByOrderId(orderId, roomId, bodyId, OrderDeletedEnum.DELETED.getStatus()); + orderService.updateBodyDeletedByOrderId(orderId, roomIds, bodyId, OrderDeletedEnum.DELETED.getStatus()); return success(true); } @@ -385,14 +357,14 @@ public class OrderController { @Operation(summary = "还原柜体") @Parameters({ @Parameter(name = "orderId", description = "生产单编号", required = true, example = "1024"), - @Parameter(name = "roomId", description = "房间编号", example = "1"), + @Parameter(name = "roomIds", description = "房间编号", example = "1"), @Parameter(name = "bodyId", description = "柜体编号", example = "1") }) @PreAuthorize("@ss.hasPermission('production:manager-list:restoreCabinet')") public CommonResult restoreBody(@RequestParam("orderId") Long orderId, - @RequestParam(value = "roomId", required = false, defaultValue = "0") Long roomId, + @RequestParam(value = "roomIds", required = false, defaultValue = "0") Set roomIds, @RequestParam(value = "bodyId", required = false, defaultValue = "0") Long bodyId) { - orderService.updateBodyDeletedByOrderId(orderId, roomId, bodyId, OrderDeletedEnum.NOT_DELETED.getStatus()); + orderService.updateBodyDeletedByOrderId(orderId, roomIds, bodyId, OrderDeletedEnum.NOT_DELETED.getStatus()); return success(true); } @@ -414,18 +386,4 @@ public class OrderController { return success(orderService.getOrderWarn()); } - // 生产单单量 还没有完成 - @GetMapping("/orderCountProducePeriod") - @Operation(summary = "生产单单量") - @Parameters({ - @Parameter(name = "startTime", description = "开始时间", example = "2024-07-15"), - @Parameter(name = "endTime", description = "结束时间", example = "2024-07-16") - }) - @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult> getOrderCountProducePeriod(@RequestParam(value = "startTime") String startTime, - @RequestParam(value = "endTime") String endTime) { - return success(orderService.orderCountProducePeriod(startTime, endTime)); - } - - } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderSupStatisticsController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderSupStatisticsController.java new file mode 100644 index 000000000..8bac74204 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderSupStatisticsController.java @@ -0,0 +1,84 @@ +package com.cf.imes.module.executor.controller.admin.order; + +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.service.order.OrderSupStatisticsService; +import com.cf.imes.module.system.api.organ.OrganApi; +import com.cf.imes.module.system.api.user.AdminUserApi; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Map; + +import static com.cf.imes.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 超管-生产单统计管理") +@RestController +@RequestMapping("/executor/order/supStatistics") +@Validated +@Slf4j +public class OrderSupStatisticsController { + + @Resource + private OrderSupStatisticsService orderSupStatisticsService; + + @Resource + private OrganApi organApi; + + @Resource + private AdminUserApi adminUserApi; + + @GetMapping("/total/org") + @Operation(summary = "组织总数") + public CommonResult> getOrgTotal() { + return success(organApi.getOrgTotal().getData()); + } + + @GetMapping("/total/user") + @Operation(summary = "用户总数") + public CommonResult> getUserTotal() { + return success(adminUserApi.getUserTotal().getData()); + } + + @GetMapping("/total/userAct") + @Operation(summary = "用户活跃数") + public CommonResult> getUserActTotal() { + return success(adminUserApi.getUserActTotal().getData()); + } + + @GetMapping("/total/order") + @Operation(summary = "生产单总数") + public CommonResult> getOrderTotal() { + return success(orderSupStatisticsService.orderTotal()); + } + + @GetMapping("/total/plateArea") + @Operation(summary = "拆单板件平方数") + public CommonResult> getPlateAreaTotal() { + return success(orderSupStatisticsService.plateAreaTotal()); + } + + @GetMapping("/separate/order") + @Operation(summary = "有效、无效生产单数量统计") + public CommonResult> getOrderSeparate(OrderStatisticsReqVO reqVO) { + return success(orderSupStatisticsService.orderSeparate(reqVO)); + } + + @GetMapping("/separate/org") + @Operation(summary = "新增、注销组织数量统计") + public CommonResult> getOrgSeparate(OrderStatisticsReqVO reqVO) { + return success(orderSupStatisticsService.orgSeparate(reqVO)); + } + + @GetMapping("/separate/plateArea") + @Operation(summary = "有效、无效拆单板件数量统计") + public CommonResult> getPlateAreaSeparate(OrderStatisticsReqVO reqVO) { + return success(orderSupStatisticsService.plateAreaSeparate(reqVO)); + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderBodyPageRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderBodyPageRespVO.java new file mode 100644 index 000000000..d4f51cb65 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderBodyPageRespVO.java @@ -0,0 +1,37 @@ +package com.cf.imes.module.executor.controller.admin.order.vo.order; + +import com.cf.imes.framework.common.pojo.PageParam; +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 OrderBodyPageRespVO extends PageParam { + + @Schema(description = "生产单号", example = "1024") + private Long orderId; + + @Schema(description = "房间编号", example = "1024") + private Set roomIds; + + @Schema(description = "柜体编号", example = "1024") + private Set bodyIds; + + @Schema(description = "加工组编号", example = "1024") + private Set groupIds; + + @Schema(description = "加工组名称", example = "1024") + private String groupName; + + @Schema(description = "配件名称", example = "1024") + private String partsName; + + @Schema(description = "是否删除", example = "false") + private Boolean deleted; +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatisticsIsLapseRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatisticsIsLapseRespVO.java new file mode 100644 index 000000000..ffc834b32 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/vo/order/OrderStatisticsIsLapseRespVO.java @@ -0,0 +1,58 @@ +package com.cf.imes.module.executor.controller.admin.order.vo.order; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import org.jetbrains.annotations.NotNull; + +@Schema(description = "管理后台 - 生产单是否有效统计") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString(callSuper = true) +public class OrderStatisticsIsLapseRespVO implements Comparable{ + + @Schema(description = "订单状态") + private Integer orderStatus; + + @Schema(description = "订单数量") + private Integer orderCount; + + @Schema(description = "生产单时间") + private String date; + + @Schema(description = "是否删除") + private Boolean deleted; + + @Override + public int compareTo(@NotNull OrderStatisticsIsLapseRespVO 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.orderStatus.compareTo(o.orderStatus); + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderSupStatisticsMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderSupStatisticsMapper.java new file mode 100644 index 000000000..defaf2e65 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderSupStatisticsMapper.java @@ -0,0 +1,31 @@ +package com.cf.imes.module.executor.dal.mysql.order; + +import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; +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.dal.dataobject.order.OrderDO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.time.LocalDateTime; +import java.util.List; + +@Mapper +public interface OrderSupStatisticsMapper extends BaseMapperX { + + /** + * 当日生产单板件平方数 + */ + Integer selectOrderSquareProduceToday(LocalDateTime startTime, LocalDateTime endTime); + + /** + * 生产单按时间统计失效数量 + */ + List selectOrderCountLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO); + + /** + * 生产单按时间分组统计未失效数量 + */ + List selectOrderCountNotLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO); + +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java index c51097be3..4e9242919 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java @@ -18,6 +18,7 @@ import org.apache.ibatis.annotations.Update; import java.io.Serializable; import java.util.Collection; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; /** @@ -106,10 +107,10 @@ public interface OrderBodyMapper extends BaseMapperX { } // 根据房间id查找OrderBodyDO的id - default List selectBodyIdByRoomId(Long orderId, Long roomId, Long organId, Integer deleted) { + default List selectBodyIdByRoomId(Long orderId, Set roomIds, Long organId, Integer deleted) { return selectList(new LambdaQueryWrapper() .eq(OrderBodyDO::getOrderId, orderId) - .eq(OrderBodyDO::getRoomId, roomId) + .in(OrderBodyDO::getRoomId, roomIds) .eq(OrderBodyDO::getOrganId, organId) .eq(OrderBodyDO::getDeleted, deleted) .select(OrderBodyDO::getId)).stream() diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java index 8ef380f18..5a8971ec1 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderItem/OrderItemMapper.java @@ -23,6 +23,7 @@ import org.apache.ibatis.annotations.Update; import java.util.Collection; import java.util.List; +import java.util.Set; /** * 生产单明细表 order_item Mapper @@ -37,8 +38,8 @@ public interface OrderItemMapper extends BaseMapperX { @Param("groupName") String groupName, @Param("organId") Long organId, @Param("deleted") Integer deleted); - IPage selectPlatesDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Long roomId, - @Param("bodyId") Long bodyId, @Param("groupId") Long groupId, + IPage selectPlatesDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Set roomId, + @Param("bodyId") Set bodyId, @Param("groupId") Set groupId, @Param("groupName") String groupName, @Param("organId") Long organId, @Param("deleted") Integer deleted); @@ -46,8 +47,8 @@ public interface OrderItemMapper extends BaseMapperX { @Param("bodyId") Long bodyId, @Param("name") String name, @Param("organId") Long organId, @Param("deleted") Integer deleted); - IPage selectPartsDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Long roomId, - @Param("bodyId") Long bodyId, @Param("name") String name, + IPage selectPartsDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Set roomId, + @Param("bodyId") Set bodyId, @Param("groupId") Set groupId, @Param("name") String name, @Param("organId") Long organId, @Param("deleted") Integer deleted); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java index 62e73bd80..9caf7ab59 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java @@ -142,8 +142,9 @@ public interface PlateMapper extends BaseMapperX { } // 房间id查小板的开料状态 - List selectPlateTypeByRoomId(@Param("orderId") Long orderId, @Param("roomId") Long roomId, @Param("bodyId") Long bodyId, - @Param("organId") Long organId, @Param("deleted") Integer deleted); + List selectPlateTypeByRoomId(@Param("orderId") Long orderId, @Param("roomId") Set roomId, + @Param("bodyId") Long bodyId, @Param("organId") Long organId, + @Param("deleted") Integer deleted); // 根据生产单id删除 default int deleteByOrderId(Long orderId, Long organId) { diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java index 81998298b..d7707899b 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/framework/rpc/config/RpcConfiguration.java @@ -16,7 +16,7 @@ import org.springframework.context.annotation.Configuration; * @author there */ @Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {AdminUserApi.class, MachineApi.class, DictDataApi.class, +@EnableFeignClients(clients = {AdminUserApi.class, MachineApi.class, DictDataApi.class,AdminUserApi.class, FileApi.class, ProcessGroupApi.class, FileApi.class, DataSourceApi.class, ApplicationApi.class, ProcessApi.class, ReportTemplateApi.class}) public class RpcConfiguration { } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java index 84352fe09..12fb3c9d1 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java @@ -19,6 +19,8 @@ import java.io.File; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.concurrent.CountDownLatch; /** * 生产单表 order_{N} Service 接口 @@ -74,7 +76,7 @@ public interface OrderService { * @return List * 需要修改返回值 */ - PageResult getPlatesDetail(Long orderId, Long roomId, Long bodyId, Long groupId, String groupName, Integer pageNo, Integer pageSize, Integer deleted); + PageResult getPlatesDetail(Long orderId, Set roomId, Set bodyId, Set groupId, String groupName, Integer pageNo, Integer pageSize, Integer deleted); /** * @param orderId: 生产单id @@ -83,7 +85,7 @@ public interface OrderService { * @return List * 需要修改返回值 */ - PageResult getPartsDetail(Long orderId, Long roomId , Long bodyId , String name, Integer pageNo, Integer pageSize, Integer deleted); + PageResult getPartsDetail(Long orderId, Set roomId , Set bodyId, Set groupId, String name, Integer pageNo, Integer pageSize, Integer deleted); /** * 删除柜体/柜体还原 @@ -91,7 +93,7 @@ public interface OrderService { * @param roomId: 房间id * @param bodyId: 柜体id */ - void updateBodyDeletedByOrderId(Long orderId , Long roomId, Long bodyId, Integer status); + void updateBodyDeletedByOrderId(Long orderId , Set roomId, Long bodyId, Integer status); /** * @param listMap:生产单号 @@ -141,11 +143,6 @@ public interface OrderService { Map> getOrderWarn(); - /** - * 生产单单量 - */ - Map orderCountProducePeriod(String startTime, String endTime); - /** * 修改生产单是否删除 */ @@ -157,5 +154,4 @@ public interface OrderService { */ void realDeletedOrder(Long orderId); - } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java index 8657db8d4..3c67be098 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java @@ -6,6 +6,7 @@ import cn.smallbun.screw.core.util.CollectionUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -13,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.cf.imes.framework.organ.core.aop.OrganIgnore; import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.security.core.LoginUser; import com.cf.imes.module.executor.controller.admin.order.vo.order.*; @@ -67,6 +69,7 @@ import java.net.URLEncoder; import java.time.*; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.concurrent.CountDownLatch; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -76,6 +79,7 @@ import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.ge import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*; import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; +import org.springframework.web.context.request.RequestContextHolder; /** * 生产单表 order_{N} Service 实现类 @@ -146,6 +150,9 @@ public class OrderServiceImpl implements OrderService { validateCustomOrderNoExists(updateReqVO.getCustomOrderNo(), updateReqVO.getId()); // 更新 OrderDO updateObj = BeanUtils.toBean(updateReqVO, OrderDO.class); + if (updateReqVO.getCustomOrderNo() == null || updateReqVO.getCustomOrderNo().equals("")){ + updateObj.setCustomOrderNo(""); + } orderMapper.updateById(updateObj); } @@ -188,10 +195,10 @@ public class OrderServiceImpl implements OrderService { } @Override - public PageResult getPlatesDetail(Long orderId, Long roomId, Long bodyId, Long groupId, String groupName, Integer pageNo, Integer pageSize, Integer deleted) { + public PageResult getPlatesDetail(Long orderId, Set roomIds, Set bodyIds, Set groupIds, String groupName, Integer pageNo, Integer pageSize, Integer deleted) { PageDTO page = new PageDTO<>(pageNo, pageSize); - IPage plateRespVOPage = orderItemMapper.selectPlatesDetailByOrderId(page, orderId, roomId, bodyId, groupId, + IPage plateRespVOPage = orderItemMapper.selectPlatesDetailByOrderId(page, orderId, roomIds, bodyIds, groupIds, groupName, getUserOrganId(), deleted); List orderDetail = plateRespVOPage.getRecords(); List platesDetailReqVOS = BeanUtils.toBean(orderDetail, OrderPlatesDetailReqVO.class); @@ -199,26 +206,27 @@ public class OrderServiceImpl implements OrderService { } @Override - public PageResult getPartsDetail(Long orderId, Long roomId, Long bodyId, String name, Integer pageNo, Integer pageSize, Integer deleted) { + public PageResult getPartsDetail(Long orderId, Set roomId, Set bodyId, Set groupId, String name, Integer pageNo, Integer pageSize, Integer deleted) { PageDTO page = new PageDTO<>(pageNo, pageSize); - IPage orderDetail = orderItemMapper.selectPartsDetailByOrderId(page, orderId, roomId, bodyId, name, getUserOrganId(), deleted); + IPage orderDetail = orderItemMapper.selectPartsDetailByOrderId(page, orderId, roomId, bodyId,groupId, name, getUserOrganId(), deleted); return new PageResult(orderDetail.getRecords(), orderDetail.getTotal()); } @Override @Transactional(rollbackFor = Exception.class) - public void updateBodyDeletedByOrderId(Long orderId, Long roomId, Long bodyId, Integer status) { // 要删除传1,还原传0 + public void updateBodyDeletedByOrderId(Long orderId, Set roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0 validateOrderStatus(orderId, getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus()); List plateDOList; List bodyIds = null; Integer index = status == 1 ? 0 : 1; - if (roomId != 0) { + + if (roomIds != null && roomIds.size() != 0) { // 查询当前房间下的所有板材 - plateDOList = plateMapper.selectPlateTypeByRoomId(orderId, roomId, null, getUserOrganId(), index); - bodyIds = orderBodyMapper.selectBodyIdByRoomId(orderId, roomId, getUserOrganId(), index); + plateDOList = plateMapper.selectPlateTypeByRoomId(orderId, roomIds, null, getUserOrganId(), index); + bodyIds = orderBodyMapper.selectBodyIdByRoomId(orderId, roomIds, getUserOrganId(), index); } else if (bodyId != 0) { // 校验柜体存在 validateOrderBodyExists(orderId, bodyId, getUserOrganId(), index); @@ -233,8 +241,8 @@ public class OrderServiceImpl implements OrderService { if (CollectionUtils.isNotEmpty(bodyIds)) { bodyIds.forEach(id -> { // 逻辑删除 - orderBodyMapper.updateDeletedById(bodyId, status, getUserOrganId());// 柜体 - orderGroupMapper.updateDeletedById(bodyId, status, getUserOrganId());// 加工组 + orderBodyMapper.updateDeletedById(id, status, getUserOrganId());// 柜体 + orderGroupMapper.updateDeletedById(id, status, getUserOrganId());// 加工组 // (删除小板) 小板变为删除状态 plateMapper.updateDeletedById(plateDOList, status, getUserOrganId()); @@ -467,17 +475,6 @@ public class OrderServiceImpl implements OrderService { return map; } - // 待完成 - @Override - public Map orderCountProducePeriod(String startTime, String endTime) { -// 角色判断 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - if (loginUser.getIsSupAdmin()) { // 超级管理员 - List orderCountProducePeriodRespVOS = orderMapper.selectOrderCountProducePeriod(null, startTime, endTime); - } - return null; - } - @Override public Integer updateOrderDel(Long orderId, Integer deleted) { Integer index = deleted == 1 ? 0 : 1; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderSupStatisticsService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderSupStatisticsService.java new file mode 100644 index 000000000..a9d12ffe5 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderSupStatisticsService.java @@ -0,0 +1,36 @@ +package com.cf.imes.module.executor.service.order; + +import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; + +import java.util.Map; + +/** + * 生产单统计 —— 超管 + */ +public interface OrderSupStatisticsService { + + /** + * 生产单总数统计 + */ + Map orderTotal(); + + /** + * 拆单板件平方数统计 + */ + Map plateAreaTotal(); + + /** + * 有效、无效生产单数量统计 + */ + Map orderSeparate(OrderStatisticsReqVO reqVO); + + /** + * 新增、注销组织数量统计 + */ + Map orgSeparate(OrderStatisticsReqVO reqVO); + + /** + * 有效、无效拆单板件数量统计 + */ + Map plateAreaSeparate(OrderStatisticsReqVO reqVO); +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderSupStatisticsServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderSupStatisticsServiceImpl.java new file mode 100644 index 000000000..b60511c43 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderSupStatisticsServiceImpl.java @@ -0,0 +1,166 @@ +package com.cf.imes.module.executor.service.order; + +import cn.hutool.core.util.ObjectUtil; +import com.cf.imes.framework.common.enums.OrderStatisticsUnit; +import com.cf.imes.framework.organ.core.aop.OrganIgnore; +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.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.OrderSupStatisticsMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.*; +import java.util.stream.Collectors; + +import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.*; + +@Service +@Validated +public class OrderSupStatisticsServiceImpl implements OrderSupStatisticsService{ + @Resource + private OrderStatisticsMapper orderStatisticsMapper; + + @Resource + private OrderSupStatisticsMapper orderSupStatisticsMapper; + @Override + @OrganIgnore + public Map orderTotal() { + Map resultMap = new LinkedHashMap<>(); + // 生产单总数 + Integer total = orderStatisticsMapper.selectOrderCount(); + resultMap.put("total", total); + + // 日增长量 + Integer today = orderStatisticsMapper.selectOrderCountToday(); + resultMap.put("today", today); + return resultMap; + } + + @Override + public Map plateAreaTotal() { + Map resultMap = new LinkedHashMap<>(); + + // 生产单板件平方数 + Integer total = orderStatisticsMapper.selectOrderSquareProduce(); + resultMap.put("total", total); + + // 当日生产单板件平方数 + LocalDate date = LocalDate.now(); + LocalDateTime startTime = LocalDateTime.of(date, LocalTime.MIDNIGHT); + LocalDateTime endTime = LocalDateTime.of(date, LocalTime.MAX); + Integer today = orderSupStatisticsMapper.selectOrderSquareProduceToday(startTime, endTime); + resultMap.put("today", today); + + return resultMap; + } + + @Override + public Map orderSeparate(OrderStatisticsReqVO reqVO) { + setOrderStatisticsReqVO(reqVO); + + Map resultMap = new LinkedHashMap<>(); + + // 所有的日期集合 + List dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit()); + + // 生产单有效数量 + Map> orderLapseRespMap = orderSupStatisticsMapper.selectOrderCountLapseByOrderDate(reqVO).stream() + .sorted(Comparator.naturalOrder()) + .collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList())); + + // 生产单无效数量 + Map> orderNotLapseRespMap = orderSupStatisticsMapper.selectOrderCountNotLapseByOrderDate(reqVO).stream() + .sorted(Comparator.naturalOrder()) + .collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::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 OrderStatisticsIsLapseRespVO())) + .map(OrderStatisticsIsLapseRespVO::getOrderCount) + .orElse(0); + countArr[0] = orderNotLapseCount; + + + // 生产单无效数量 + Integer orderLapseCount = Optional.ofNullable(orderLapseRespMap.get(dateStr)) + .map(list -> list.stream().findFirst().orElse(new OrderStatisticsIsLapseRespVO())) + .map(OrderStatisticsIsLapseRespVO::getOrderCount) + .orElse(0); + countArr[1] = orderLapseCount; + + resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr); + } + + return resultMap; + } + + @Override + public Map orgSeparate(OrderStatisticsReqVO reqVO) { + setOrderStatisticsReqVO(reqVO); + + Map resultMap = new LinkedHashMap<>(); + + // 所有的日期集合 + List dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit()); + + // 生产单有效数量 + Map> orderLapseRespMap = orderSupStatisticsMapper.selectOrderCountLapseByOrderDate(reqVO).stream() + .sorted(Comparator.naturalOrder()) + .collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList())); + + // 生产单无效数量 + Map> orderNotLapseRespMap = orderSupStatisticsMapper.selectOrderCountNotLapseByOrderDate(reqVO).stream() + .sorted(Comparator.naturalOrder()) + .collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::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 OrderStatisticsIsLapseRespVO())) + .map(OrderStatisticsIsLapseRespVO::getOrderCount) + .orElse(0); + countArr[0] = orderNotLapseCount; + + + // 生产单无效数量 + Integer orderLapseCount = Optional.ofNullable(orderLapseRespMap.get(dateStr)) + .map(list -> list.stream().findFirst().orElse(new OrderStatisticsIsLapseRespVO())) + .map(OrderStatisticsIsLapseRespVO::getOrderCount) + .orElse(0); + countArr[1] = orderLapseCount; + + resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr); + } + + return resultMap; + + } + + @Override + public Map plateAreaSeparate(OrderStatisticsReqVO reqVO) { + return null; + } + + private void setOrderStatisticsReqVO(OrderStatisticsReqVO 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]}); + } +} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/intervalometer/OrderScheduledImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/intervalometer/OrderScheduledImpl.java index f4affc8aa..c2efcd4de 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/intervalometer/OrderScheduledImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/intervalometer/OrderScheduledImpl.java @@ -1,5 +1,6 @@ package com.cf.imes.module.executor.service.order.intervalometer; +import com.baomidou.dynamic.datasource.annotation.DS; import com.cf.imes.framework.organ.core.aop.OrganIgnore; import com.cf.imes.module.executor.dal.mysql.goods.GoodsMapper; import com.cf.imes.module.executor.dal.mysql.order.OrderMapper; @@ -11,7 +12,6 @@ import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper; import com.cf.imes.module.executor.service.order.OrderInputProcessor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -19,18 +19,16 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; -import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; - /** * 生产单定时处理器 */ @Slf4j @Component +@DS("slave") public class OrderScheduledImpl { @Resource -// @Qualifier("imes_prod") private OrderMapper orderMapper; @Resource @@ -61,38 +59,31 @@ public class OrderScheduledImpl { public static final String ORDER_PARTS_REMARK_MODEL = "imes_order_parts_remark_model"; - public OrderScheduledImpl() { - } - // @Scheduled(cron = "0 0 2 * * ?") -// @Scheduled(cron = "0/1 * * * * *") +// @Scheduled(cron = "0 0 2 * * ?") @OrganIgnore @Transactional(rollbackFor = Exception.class) public void fixedDeletedOrder() { - System.out.println(" 定时任务开始 "); - if (getLoginUser() == null){ - } - List orderDOList = orderMapper.selectOrderListByUpdateTime(); + List orderDOList = orderMapper.selectOrderListByUpdateTime(); -// // 作废 生产单表,body,group,goods,parts,plate,raw_goods,item -// rawGoodsMapper.deleteBatch(orderDOList); -// goodsMapper.deleteBatch(orderDOList); -// orderItemMapper.deleteBatch(orderDOList); -// orderBodyMapper.deleteBatch(orderDOList); -// orderGroupMapper.deleteBatch(orderDOList); -// -// orderPartsMapper.deleteBatch(orderDOList); -// plateMapper.deleteBatch(orderDOList); -// -// orderMapper.deleteBatchIds(orderDOList); // 生产单删除 -// -//// 删除板材的造型数据 es -// orderInputProcessor.deleteByOrderId(orderDOList, ORDER_PLATE_MODEL); -//// 删除备注信息 es -// orderInputProcessor.deleteByOrderId(orderDOList, ORDER_PARTS_REMARK_MODEL); + // 作废 生产单表,body,group,goods,parts,plate,raw_goods,item + rawGoodsMapper.deleteBatch(orderDOList); + goodsMapper.deleteBatch(orderDOList); + orderItemMapper.deleteBatch(orderDOList); + orderBodyMapper.deleteBatch(orderDOList); + orderGroupMapper.deleteBatch(orderDOList); + + orderPartsMapper.deleteBatch(orderDOList); + plateMapper.deleteBatch(orderDOList); + + orderMapper.deleteBatchIds(orderDOList); // 生产单删除 + +// 删除板材的造型数据 es + orderInputProcessor.deleteByOrderId(orderDOList, ORDER_PLATE_MODEL); +// 删除备注信息 es + orderInputProcessor.deleteByOrderId(orderDOList, ORDER_PARTS_REMARK_MODEL); - System.out.println(" 定时任务结束 "); } } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java index 872f9f9bd..57815fff6 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataAchieve.java @@ -35,6 +35,7 @@ public class ApiDataAchieve { private ApplicationApi applicationApi; private static final int PARTS_PAGE_MAX = 100; + private static final int PARTS_PAGE_MAX_Test = 95; // 获得token数据 public Future getApiToken(Long organId) { @@ -44,14 +45,14 @@ public class ApiDataAchieve { JSONObject json = apiDataProduction.getApiTokenMessage(appId, appSecret); if (!json.getString("err_msg").equals("success")) { - throw exception(APP_TOKEN_ERROR); +// throw exception(APP_TOKEN_ERROR); } // String token = json.getJSONObject("info").getString("access_token"); return new AsyncResult<>(json); } // 获取板件生产数据信息 - @Async +// @Async public Future getApiPlateProData(String token, String orderNo) { JSONObject jsonPlatesData = new JSONObject(); jsonPlatesData.put("order_no", orderNo);//生产单号需要传入赋值 @@ -62,7 +63,7 @@ public class ApiDataAchieve { } // 获取配件信息 分页获取 - @Async +// @Async public Future getApiPartsMessage(String token, String orderNo) { JSONObject jsonParts = new JSONObject(); jsonParts.put("curr_page", 1); @@ -70,7 +71,8 @@ public class ApiDataAchieve { jsonParts.put("order_no", orderNo); JSONObject parts = apiDataProduction.getApiOrderPartsMessage(token, jsonParts); if (!parts.getString("err_code").equals("0")) { - throw exception(PARTS_DATA_ERROR); + log.error("配件数据获取错误" + orderNo); +// throw exception(PARTS_DATA_ERROR); } JSONObject dataParts = new JSONObject(); for (int i = 1; i <= parts.getJSONObject("value").getInteger("PageCount"); i++) { @@ -82,7 +84,7 @@ public class ApiDataAchieve { } // 柜体信息转换 - @Async +// @Async public Future getApiBodyMessage(String token, String orderNo) { JSONObject jsonBody = new JSONObject(); jsonBody.put("curr_page", 1); @@ -90,7 +92,8 @@ public class ApiDataAchieve { jsonBody.put("order_no", orderNo); JSONObject body = apiDataProduction.getApiOrderBodyMessage(token, jsonBody); if (!body.getString("err_code").equals("0")) { - throw exception(BODY_DATA_ERROR); + log.error("柜体数据获取错误" + orderNo); +// throw exception(BODY_DATA_ERROR); } JSONObject dataBody = new JSONObject(); for (int i = 1; i <= body.getJSONObject("value").getInteger("PageCount"); i++) { @@ -102,7 +105,7 @@ public class ApiDataAchieve { } // 商品信息转换 - @Async +// @Async public Future getApiGoodsMessage(String token, String orderNo) { JSONObject jsonGoods = new JSONObject(); jsonGoods.put("curr_page", 1); @@ -110,7 +113,8 @@ public class ApiDataAchieve { jsonGoods.put("order_no", orderNo); JSONObject goods = apiDataProduction.getApiOrderGoodsMessage(token, jsonGoods); if (!goods.getString("err_code").equals("0")) { - throw exception(GOODS_DATA_ERROR); + log.error("商品信息转换失败" + orderNo); +// throw exception(GOODS_DATA_ERROR); } JSONObject dataGoods = new JSONObject(); for (int i = 1; i <= goods.getJSONObject("value").getInteger("PageCount"); i++) { @@ -122,7 +126,7 @@ public class ApiDataAchieve { } // 板材明细信息转换 - @Async +// @Async public Future getApiPlateDetailMessage(String token, String orderNo) { JSONObject jsonPlates = new JSONObject(); jsonPlates.put("curr_page", 1); @@ -130,7 +134,8 @@ public class ApiDataAchieve { jsonPlates.put("order_no", orderNo); JSONObject plates = apiDataProduction.getApiBlocksDataMessage(token, jsonPlates); if (!plates.getString("err_code").equals("0")) { - throw exception(PLATE_DATA_ERROR); + log.error("板材明细获取错误" + orderNo); +// throw exception(PLATE_DATA_ERROR); } JSONObject plate = new JSONObject(); for (int i = 1; i <= plates.getJSONObject("value").getInteger("PageCount"); i++) { @@ -142,7 +147,7 @@ public class ApiDataAchieve { } // 加工组信息转换 - @Async +// @Async public Future getApiGroupMessage(String token, String orderNo) { JSONObject jsonModule = new JSONObject(); jsonModule.put("order_no", orderNo); @@ -151,7 +156,7 @@ public class ApiDataAchieve { } // 板材数据信息转换 - @Async +// @Async public Future getApiBlocksMessage(String token, String orderNo) { JSONObject jsonBlocks = new JSONObject(); jsonBlocks.put("curr_page", 1); @@ -159,7 +164,8 @@ public class ApiDataAchieve { jsonBlocks.put("order_no", orderNo); JSONObject blocks = apiDataProduction.getApiBlocksMessage(token, jsonBlocks); if (!blocks.getString("err_code").equals("0")) { - throw new IllegalArgumentException(String.valueOf(ErrorCodeConstants.PLATE_DATA_ERROR)); +// throw new IllegalArgumentException(String.valueOf(ErrorCodeConstants.PLATE_DATA_ERROR)); + log.error("板材数据获取错误" + orderNo); // throw exception(PLATE_DATA_ERROR); } JSONObject block = new JSONObject(); @@ -180,7 +186,7 @@ public class ApiDataAchieve { } public Future getApiOrder(String token) { // 批量导入专用,之后删除 JSONObject jsonOrders = new JSONObject(); - jsonOrders.put("page_count", PARTS_PAGE_MAX ); + jsonOrders.put("page_count", PARTS_PAGE_MAX_Test ); JSONObject order = apiDataProduction.getApiOrderList(token, jsonOrders); return new AsyncResult<>(order); } @@ -197,7 +203,7 @@ public class ApiDataAchieve { LocalDate endTime = LocalDate.parse(createDateMax, formatter); long daysBetweenSimple = ChronoUnit.DAYS.between(startTime, endTime); if (daysBetweenSimple > 30) { - throw exception(ORDER_DATE_ERR); +// throw exception(ORDER_DATE_ERR); } jsonOrders.put("create_date_min", createDateMin + " 00:00:00"); @@ -216,7 +222,7 @@ public class ApiDataAchieve { JSONObject orders = apiDataProduction.getApiOrderList(token, jsonOrders); if (!orders.getString("err_code").equals("0")) { - throw exception(ORDER_READ_ERR); +// throw exception(ORDER_READ_ERR); } JSONObject order = new JSONObject(); int countPage = divideWithPlusOne(orders.getInteger("count"), PARTS_PAGE_MAX); @@ -268,7 +274,7 @@ public class ApiDataAchieve { public int divideWithPlusOne(int dividend, int divisor) { // 首先检查除数是否为0,避免除以0的异常 if (divisor == 0) { - throw new IllegalArgumentException("除数不能为0"); +// throw new IllegalArgumentException("除数不能为0"); } // 计算商和余数 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java index b07e53a93..764afce64 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java @@ -77,29 +77,32 @@ public class ApiTypeRealize { // 生产单id Long orderId = (Long) identifierGenerator.nextId(null); +// 获取组织id 之后删除 + Long orgId = 325L; + // 生产单数据 - OrderDO orderDO = orderInfoChange(order, orderId, orderNo); + OrderDO orderDO = orderInfoChange(order, orderId, orderNo, orgId); List orderList = new ArrayList<>(); orderList.add(orderDO); // 商品信息数据 信息以全 - Map> goodsInfoChange = rawGoodsInfoChange(dataGoods, orderId, dataBlocks); + Map> goodsInfoChange = rawGoodsInfoChange(dataGoods, orderId, dataBlocks, orgId); List goodsDO = (List) goodsInfoChange.get("goodsDOS").values().stream().collect(Collectors.toList()); map.put("goodsDO", goodsDO); List rawGoodsDO = (List) goodsInfoChange.get("rawGoodsDOS").values().stream().collect(Collectors.toList()); map.put("rawGoodsDO", rawGoodsDO); // 柜体信息 少异形数量、板材数量 - Map bodyInfoChange = bodyInfoChange(dataBody, orderId); + Map bodyInfoChange = bodyInfoChange(dataBody, orderId, orgId); // 加工组 少异形数量、板材数量 Map> group = - groupInfoChange(dataModule, orderId, bodyInfoChange); + groupInfoChange(dataModule, orderId, bodyInfoChange, orgId); Map orderGroupDO = (Map) group.get("orderGroup"); Map> groupLists = (Map>) group.get("lists"); // 加工组中包含的板件、配件id // 配件 Map> partsDO = partsInfoChange(dataParts, orderId, - (Map) goodsInfoChange.get("goodsDOS"), bodyInfoChange); + (Map) goodsInfoChange.get("goodsDOS"), bodyInfoChange, orgId); Map partsRemark = (Map) partsDO.get("remarks"); // 配件备注 map.put("partsRemark", partsRemark.values().stream().collect(Collectors.toList())); @@ -114,7 +117,7 @@ public class ApiTypeRealize { itemsList.addAll(partsItems.values()); // 板材 写库 Map> platesDO = platesInfoChange(dataPlates, plates, orderId, - (Map) goodsInfoChange.get("goodsDOS"), bodyInfoChange, dataBlocks); + (Map) goodsInfoChange.get("goodsDOS"), bodyInfoChange, dataBlocks, orgId); Map orderPlatesDO = (Map) platesDO.get("platesInfos"); map.put("platesDO", orderPlatesDO.values().stream().collect(Collectors.toList())); map.put("plateDetail", platesDO.get("plateDetail").values().stream().collect(Collectors.toList())); @@ -218,7 +221,7 @@ public class ApiTypeRealize { /** * 加工组 信息转换 */ - private Map> groupInfoChange(JSONObject dataModule, Long orderId, Map bodyInfoChange) { + private Map> groupInfoChange(JSONObject dataModule, Long orderId, Map bodyInfoChange, Long organId) { Map> map = new HashMap<>(); Map orderGroupDOs = new HashMap<>();// 加工组id 和 加工组信息 Map> groupLists = new HashMap<>();// 加工组id 和 详细信息 @@ -245,6 +248,7 @@ public class ApiTypeRealize { .unregularNum(0) .filename("无") .remark("无") + .organId(organId) .build(); groupLists.put(group.getLong("ModuleID"), jsonArrayToList(group.getJSONArray("ItemIDList"))); orderGroupDOs.put(group.getLong("ModuleID"), bodyInfo); @@ -264,7 +268,7 @@ public class ApiTypeRealize { * @author Administrator * @date 2024/4/30 */ - public OrderDO orderInfoChange(JSONObject orderJson, Long orderId, String orderNo) { + public OrderDO orderInfoChange(JSONObject orderJson, Long orderId, String orderNo, Long organId) { // 获取 Orders 字段对应的数组 JSONObject order = orderJson.getJSONArray("data").getJSONObject(0); @@ -277,7 +281,7 @@ public class ApiTypeRealize { LocalDate deliveryDate = LocalDate.parse(order.getString("end_date"), formatter); if (deliveryDate.isBefore(orderDate)) { // 将 deliveryDate 设置为 orderDate 后的第 30 天 - deliveryDate = orderDate.plus(30, ChronoUnit.DAYS); + deliveryDate = orderDate.plusMonths(1); } String orderRemark = "[" + orderNo + "]; "; @@ -302,6 +306,7 @@ public class ApiTypeRealize { // .splitter("") .splitter(order.getString("cd_nick_name")) .remark(orderRemark + order.getString("comments")) + .organId(organId) .build(); Integer submitState = order.getInteger("submit_state"); @@ -341,7 +346,7 @@ public class ApiTypeRealize { * @author Administrator * @date 2024/4/30 */ - public Map> rawGoodsInfoChange(JSONObject dataRawGoods, Long orderId, JSONObject dataBlocks) { + public Map> rawGoodsInfoChange(JSONObject dataRawGoods, Long orderId, JSONObject dataBlocks, Long organId) { Map> map = new HashMap<>(); Map rawGoodsDOS = new HashMap<>(); Map goodsDOS = new HashMap<>(); @@ -364,6 +369,7 @@ public class ApiTypeRealize { .price(goods.getDouble("Price")) .brand(goods.getString("Brand")) .spec(goods.getString("Spec")) + .organId(organId) .build(); rawGoodsDOS.put(goods.getLong("GoodsID"), rawGoodsDO); @@ -382,6 +388,7 @@ public class ApiTypeRealize { .price(BigDecimal.valueOf(goods.getDouble("Price"))) .brand(goods.getString("Brand")) .spec(goods.getString("Spec")) + .organId(organId) .build(); goodsDOS.put(goods.getLong("GoodsID"), goodsDO); @@ -401,7 +408,7 @@ public class ApiTypeRealize { * @author Administrator * @date 2024/4/30 */ - private Map bodyInfoChange(JSONObject dataBody, Long orderId) { + private Map bodyInfoChange(JSONObject dataBody, Long orderId, Long organId) { Map bodyInfos = new HashMap<>(); if (dataBody.getJSONArray("List") != null && @@ -423,6 +430,7 @@ public class ApiTypeRealize { .unregularNum(0) .filename("无") .remark("无") + .organId(organId) .build(); bodyInfos.put(body.getLong("BoxID"), bodyInfo); @@ -453,7 +461,7 @@ public class ApiTypeRealize { * @author Administrator * @date 2024/4/30 */ - public Map> partsInfoChange(JSONObject value, Long orderId, Map goodsDOMap, Map bodyInfos) { + public Map> partsInfoChange(JSONObject value, Long orderId, Map goodsDOMap, Map bodyInfos, Long organId) { Map> map = new HashMap<>(); Map partsInfos = new HashMap<>(); Map partsItem = new HashMap<>(); @@ -481,6 +489,7 @@ public class ApiTypeRealize { .price(parts.getDouble("Price")) .isComposite(parts.getBoolean("IsComposite")) .remark(parts.getString("Remark")) + .organId(organId) .build(); remarks.put(parts.getLong("ItemID"), partsRemarkChange(parts, orderId, partsId)); partsInfos.put(parts.getLong("ItemID"), partsInfo); @@ -497,6 +506,7 @@ public class ApiTypeRealize { .groupId(0L) .partsId(partsId) .num(parts.getDouble("Num")) + .organId(organId) .build(); partsItem.put(parts.getLong("ItemID"), item); } @@ -531,7 +541,7 @@ public class ApiTypeRealize { */ private Map> platesInfoChange(JSONObject value, JSONObject dataPlates, Long orderId, Map goodsDOMap, Map bodyInfos, - JSONObject dataBlocks) { + JSONObject dataBlocks, Long organId) { // 板材 写ES Map plateDetail = platesDetailChange(value); @@ -594,6 +604,7 @@ public class ApiTypeRealize { .isCancel(false) .filterType("") .remark(remark) + .organId(organId) .build(); // item 明细 @@ -608,6 +619,7 @@ public class ApiTypeRealize { .groupId(0L) .partsId(0L) .plateId(plateId) + .organId(organId) .num(1.0) .build(); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelReadUtil.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelReadUtil.java index 0dc8566c6..3b7ad1d20 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelReadUtil.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelReadUtil.java @@ -1,7 +1,5 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.excel; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.map.MapUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; @@ -22,6 +20,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -49,18 +48,26 @@ public class ExcelReadUtil { // 文件读取 List list = new ArrayList<>();// plate AtomicBoolean index = new AtomicBoolean(true); + AtomicInteger i = new AtomicInteger(); dataLists.forEach( item -> { - if (item.get(0).equals("###")) { - index.set(false); + if (item.get(0) != null){ + if (item.get(0).equals("###")) { + index.set(false); + } } + if (index.get()) { orderMap.put(item.get(0), item.get(1)); orderMap.put(item.get(16), item.get(17)); + i.getAndIncrement(); } else { - if (!(item.get(0).equals("序号") || item.get(0).equals("###"))) { + if (i.getAndIncrement() > 6){ list.add(changeValue(item)); } +// if (item.get(1).equals("配件") || item.get(1).equals("板材")) { +// list.add(changeValue(item)); +// } } } @@ -124,6 +131,11 @@ public class ExcelReadUtil { // 文件读取 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); try { LocalDate orderDate = LocalDate.parse(s, formatter); + LocalDate now = LocalDate.now(); + if (orderDate.isBefore(LocalDate.now())) { + orderDate = now.plus(30, ChronoUnit.DAYS); + } + System.out.println(" orderDate " + orderDate); orderDO.setDeliveryDate(orderDate.atStartOfDay()); // } catch (DateTimeParseException e) { error += s + "-出货日期格式错误;"; diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java index c2fb9570e..8f02f2713 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/files/excel/ExcelTypeRealize.java @@ -48,9 +48,12 @@ public class ExcelTypeRealize { @Resource private DictDataApi dictDataApi; + final String NOT_ASSIGNED_ROOM = "未分房间"; + final String NOT_ASSIGNED_BODY = "未分柜体"; + // 数据转换 + 错误验证 public Map> changeDate(List list, Long orderId) { - if (list.isEmpty()){ + if (list.isEmpty()) { // throw exception(FILE_UPLOAD_ERR); return null; } @@ -136,7 +139,7 @@ public class ExcelTypeRealize { // 房间名称为条件进行分组 Map> roomCollect = excelVOS.stream().collect( Collectors.groupingBy( - excelVO -> excelVO.getRoomsName() != null ? excelVO.getRoomsName() : " ", + excelVO -> excelVO.getRoomsName() != null ? excelVO.getRoomsName() : "未命名", Collectors.toList() )); @@ -145,7 +148,7 @@ public class ExcelTypeRealize { // 柜体名称为条件进行分组 Map> bodyCollect = listRoom.stream() .collect(Collectors.groupingBy( - excelVO -> excelVO.getCabinetsName() != null ? excelVO.getCabinetsName() : " ", + excelVO -> excelVO.getCabinetsName() != null ? excelVO.getCabinetsName() : "未命名", Collectors.toList() )); @@ -176,15 +179,17 @@ public class ExcelTypeRealize { // 板数量 final Double[] plateCountByCombination = {0.0}; Long groupId = (Long) snowFlakeGenerator.nextId(null); - OrderGroupDO orderGroupDO = OrderGroupDO.builder().id(groupId).orderId(orderId).organId(organId).bodyId(bodyId) - .groupTypeId(groupTypeId).groupTypeName(synthesisTypeName).name(!Objects.equals(combinationName, " ") ? combinationName : synthesisTypeName).width(0.0).height(0.0) - .depth(0.0).multiNum(0).plateNum(0).unregularNum(0).filename("无").remark("无").build(); + OrderGroupDO orderGroupDO = OrderGroupDO.builder().id(groupId).orderId(orderId).organId(organId).bodyId(bodyId) + .groupTypeId(groupTypeId).groupTypeName(synthesisTypeName).name(!Objects.equals(combinationName, " ") ? combinationName : synthesisTypeName).width(0.0).height(0.0) + .depth(0.0).multiNum(0).plateNum(0).unregularNum(0).filename("无").remark("无").build(); listCombinationName.forEach(combination -> { if (combination.getGoodType().equals("板材")) { //板材 plateCountByCombination[0] = plateCountByCombination[0] + Double.parseDouble(combination.getGoodsNumber()); + System.out.println(" 房间名0 " + combination.getRoomsName() + " 柜体名0 " + combination.getCabinetsName() + " 柜体板数量0 " + plateCountByCabinetName[0] + " 加工组板数量0 " + plateCountByCombination[0]); + for (int i = 0; i < Integer.parseInt(combination.getGoodsNumber()); i++) { long plateNo = idWorker.nextId(); long obtainingTime = idWorker.obtainingTime(); @@ -233,7 +238,7 @@ public class ExcelTypeRealize { orderModelDOS.add(OrderModelDO.builder().orderId(orderId).plateId(plateId) .typographicFace(Integer.valueOf(typographyDTO.getValue())).build()); } - plateCountByCabinetName[0] = plateCountByCabinetName[0] + plateCountByCombination[0]; + } else { //配件 @@ -255,15 +260,17 @@ public class ExcelTypeRealize { }); orderGroupDO.setPlateNum(plateCountByCombination[0].intValue()); + plateCountByCabinetName[0] = plateCountByCabinetName[0] + plateCountByCombination[0]; if (orderGroupDO.getGroupTypeName() != null && !orderGroupDO.getGroupTypeName().trim().isEmpty()) { orderGroupDOS.add(orderGroupDO); } }); }); orderBodyDO.setPlateNum(Integer.valueOf(plateCountByCabinetName[0].intValue())); - if (orderBodyDO.getName() != null && !orderBodyDO.getName().trim().isEmpty()) { - orderBodyDOS.add(orderBodyDO); - } +// if (orderBodyDO.getName() != null && !orderBodyDO.getName().trim().isEmpty()) { + orderBodyDOS.add(orderBodyDO); +// } + System.out.println(" ban-num " + plateCountByCabinetName[0]); }); }); @@ -281,20 +288,6 @@ public class ExcelTypeRealize { return map; } - // 备注提取 -// private String remarkExtract(String remark) { -// JSONObject jsonObject = new JSONObject(remark); -// JSONObject nonNullJsonObject = new JSONObject(); -// -// for (String key : jsonObject.keySet()) { -// Object value = jsonObject.get(key); -// if (value != null) { -// nonNullJsonObject.put(key, value); -// } -// } -// -// return nonNullJsonObject.toString(); -// } private String remarkExtract(String remark) { JSONObject jsonObject = new JSONObject(remark); List nonNullValues = new ArrayList<>(); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml index 75796e617..f7662f6a9 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml @@ -50,6 +50,15 @@ spring: password: root # username: sa # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W + slave: # 模拟从库,可根据自己需要修改 + name: imes_prod + url: jdbc:mysql://192.168.1.205:8066/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 + # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 + # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 + username: root + password: root # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 redis: diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderSupStatisticsMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderSupStatisticsMapper.xml new file mode 100644 index 000000000..828dc1210 --- /dev/null +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderSupStatisticsMapper.xml @@ -0,0 +1,47 @@ + + + + + + + ,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as date + + + ,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as date + + + ,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', FLOOR((DayOfMonth(o.order_date)-1)/7)+1) AS date + + + ,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as date + + + + + + + + + + \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/orderItem/OrderItemMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/orderItem/OrderItemMapper.xml index 2d31502d4..54c5b4426 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/orderItem/OrderItemMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/orderItem/OrderItemMapper.xml @@ -12,14 +12,23 @@ LEFT JOIN `order_goods` g ON g.id = p.goods_id LEFT JOIN `order_group` gp ON gp.id = i.group_id WHERE i.order_id = #{orderId} AND i.organ_id = #{organId} AND p.deleted = #{deleted} - - AND i.room_id = #{roomId} + + AND i.room_id IN + + #{roomIdItem} + - - AND i.body_id = #{bodyId} + + AND i.body_id IN + + #{bodyIdItem} + - - AND i.group_id = #{groupId} + + AND i.group_id IN + + #{groupIdItem} + AND gp.name = #{groupName} @@ -32,11 +41,23 @@ FROM order_item i RIGHT JOIN `order_parts` p ON i.parts_id = p.id WHERE i.order_id = #{orderId} AND i.organ_id = #{organId} AND p.deleted = #{deleted} - - AND i.room_id = #{roomId} + + AND i.room_id IN + + #{roomIdItem} + - - AND i.body_id = #{bodyId} + + AND i.body_id IN + + #{bodyIdItem} + + + + AND i.group_id IN + + #{groupIdItem} + AND p.name = #{name} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml index fe429d6e0..11701c0a4 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml @@ -393,7 +393,7 @@ UPDATE order_plate SET deleted = #{deleted} WHERE id IN - + #{plateId} AND organ_id = #{organId} @@ -608,8 +608,11 @@ FROM order_plate p LEFT JOIN order_item i ON p.id = i.plate_id WHERE i.organ_id = #{organId} AND i.order_id = #{orderId} AND p.deleted = #{deleted} - - AND i.room_id = #{roomId} + + AND i.room_id IN + + #{roomIdItem} + AND i.body_id = #{bodyId} diff --git a/cf-module-prod-manage/cf-module-prod-manage-api/src/main/java/com/cf/imes/module/manage/enums/DictTypeConstants.java b/cf-module-prod-manage/cf-module-prod-manage-api/src/main/java/com/cf/imes/module/manage/enums/DictTypeConstants.java index 918c0375e..fa2bb15a1 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-api/src/main/java/com/cf/imes/module/manage/enums/DictTypeConstants.java +++ b/cf-module-prod-manage/cf-module-prod-manage-api/src/main/java/com/cf/imes/module/manage/enums/DictTypeConstants.java @@ -7,7 +7,5 @@ package com.cf.imes.module.manage.enums; */ public interface DictTypeConstants { - String SYNTHESIS_TYPE = "synthesisType";//加工组类型 - - String PLATE_TEXTURE = "product_manger_texture_type";// 板件纹路 + String PLATE_TEXTURE = "plate_texture_type";// 板件纹路 } diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java index 33fdc6017..5e9bdea9a 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/RemainPlateController.java @@ -66,7 +66,7 @@ public class RemainPlateController { @Operation(summary = "余料板批量核销") @PreAuthorize("@ss.hasPermission('placeorder:remain')") public CommonResult updateRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) { - remainPlateService.updateRemainPlateStatus(updateReqVO.getIds(), + remainPlateService.updateRemainPlateStatus(updateReqVO.getId(), updateReqVO.getStatus(), updateReqVO.getUseType(), updateReqVO.getPlanId()); @@ -77,7 +77,7 @@ public class RemainPlateController { @Operation(summary = "余料板批量释放") @PreAuthorize("@ss.hasPermission('placeorder:remain')") public CommonResult revertRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) { - remainPlateService.revertRemainPlateStatus(updateReqVO.getIds(),updateReqVO.getStatus()); + remainPlateService.revertRemainPlateStatus(updateReqVO.getId(),updateReqVO.getStatus()); return success(true); } diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/plate/PlateRespVO.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/plate/PlateRespVO.java index e3616fdf8..af1977faa 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/plate/PlateRespVO.java +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/plate/PlateRespVO.java @@ -1,5 +1,8 @@ package com.cf.imes.module.manage.controller.admin.plate.vo.plate; +import com.cf.imes.framework.excel.core.annotations.DictFormat; +import com.cf.imes.framework.excel.core.convert.DictConvert; +import com.cf.imes.module.system.enums.DictTypeConstants; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @@ -32,7 +35,8 @@ public class PlateRespVO { private String color; @Schema(description = "纹理", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("纹理") + @ExcelProperty(value = "纹理", converter = DictConvert.class) + @DictFormat(DictTypeConstants.USER_SEX) private Boolean texture; @Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED) diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/remain/RemainPlateUptReqVO.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/remain/RemainPlateUptReqVO.java index 5d5baa35a..800bc1cdb 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/remain/RemainPlateUptReqVO.java +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/controller/admin/plate/vo/remain/RemainPlateUptReqVO.java @@ -10,7 +10,7 @@ import java.util.Set; public class RemainPlateUptReqVO { @Schema(description = "余料板集", example = "16470") - private Set ids; + private Set id; @Schema(description = "余料板状态,0未使用,1使用中", example = "1") private Integer status; diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/plate/PlateServiceImpl.java b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/plate/PlateServiceImpl.java index cea6b42c4..b541747c9 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/plate/PlateServiceImpl.java +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/java/com/cf/imes/module/manage/service/plate/PlateServiceImpl.java @@ -1,7 +1,5 @@ package com.cf.imes.module.manage.service.plate; -import cn.hutool.core.collection.CollUtil; -import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil; import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.organ.core.aop.OrganIgnore; import com.cf.imes.framework.organ.core.context.OrganContextHolder; @@ -58,15 +56,10 @@ public class PlateServiceImpl implements PlateService { @OrganIgnore public Long createPlate(PlateSaveReqVO createReqVO) { PlateDO plate = BeanUtils.toBean(createReqVO, PlateDO.class); - if (permissionApi.hasRoles(getLoginUser().getId(), BASE_PLATE_CREATE_PERMISSION).getData()){ - if (plate.getOrganId() != null && plate.getOrganId() != 0 ){ - validateOrganExists(plate.getOrganId()); - } - } else { - plate.setOrganId(OrganContextHolder.getOrganId()); - } + // 判断板材是否存在 - validateGoodExists(plate.getGoodsId(),plate.getOrganId()); + validateGoodExists(plate.getGoodsId(), + getOrganId(BASE_PLATE_CREATE_PERMISSION, getLoginUser().getId(), plate.getOrganId())); plateMapper.insert(plate);// 组织id未传输 // 返回 @@ -77,17 +70,9 @@ public class PlateServiceImpl implements PlateService { @OrganIgnore @Transactional(rollbackFor = Exception.class) public void updatePlate(PlateSaveReqVO updateReqVO) { - // 更新 判断是否有组织id - if (permissionApi.hasRoles(getLoginUser().getId(), BASE_PLATE_UPDATE_PERMISSION).getData()){ - if (updateReqVO.getOrganId() != null && updateReqVO.getOrganId() != 0 ){ - validateOrganExists(updateReqVO.getOrganId()); - } - } else { - updateReqVO.setOrganId(OrganContextHolder.getOrganId()); - } - // 校验存在 - validatePlateExists(updateReqVO.getId(), updateReqVO.getOrganId()); + validatePlateExists(updateReqVO.getId(), + getOrganId(BASE_PLATE_UPDATE_PERMISSION, getLoginUser().getId(), updateReqVO.getOrganId())); PlateDO updateObj = BeanUtils.toBean(updateReqVO, PlateDO.class); plateMapper.updateById(updateObj); } @@ -95,25 +80,16 @@ public class PlateServiceImpl implements PlateService { @Override @OrganIgnore @Transactional(rollbackFor = Exception.class) - public void deletePlate(Long id,Long organId) { - boolean hasPermission = permissionApi.hasRoles(getLoginUser().getId(), BASE_PLATE_DELETE_PERMISSION).getData(); - - Long organIdDefault = OrganContextHolder.getOrganId(); - - if (hasPermission && organId != null && organId != 0) { - - validateOrganExists(organId); - - organIdDefault = organId; - } + public void deletePlate(Long id, Long organId) { // 校验存在 - validatePlateExists(id,organIdDefault); + validatePlateExists(id, + getOrganId(BASE_PLATE_DELETE_PERMISSION, getLoginUser().getId(), organId)); // 删除 plateMapper.deleteById(id); } - private void validatePlateExists(Long id,Long organId) { - if (plateMapper.selectOneById(id,organId) == null) { + private void validatePlateExists(Long id, Long organId) { + if (plateMapper.selectOneById(id, organId) == null) { throw exception(PLATE_NOT_EXISTS); } } @@ -126,22 +102,22 @@ public class PlateServiceImpl implements PlateService { @Override public PlateDO getPlateGoods(String id, Long organId) { - return plateMapper.selectByGoodID(id,organId); + return plateMapper.selectByGoodID(id, organId); } @Override @OrganIgnore public PageResult getPlatePage(PlatePageReqVO pageReqVO) { - if (permissionApi.hasRoles(getLoginUser().getId(), BASE_PLATE_QUERY_PERMISSION).getData()){ - if (pageReqVO.getOrganId() != null && pageReqVO.getOrganId() != 0 ){ - validateOrganExists(pageReqVO.getOrganId()); - } - } else { - pageReqVO.setOrganId(OrganContextHolder.getOrganId()); - } - if (pageReqVO.getOrganId() == null || pageReqVO.getOrganId() == 0){ - pageReqVO.setOrganId(OrganContextHolder.getOrganId()); - } +// if (permissionApi.hasRoles(getLoginUser().getId(), BASE_PLATE_QUERY_PERMISSION).getData()) { +// if (pageReqVO.getOrganId() != null && pageReqVO.getOrganId() != 0) { +// validateOrganExists(pageReqVO.getOrganId()); +// } +// } else { +// pageReqVO.setOrganId(OrganContextHolder.getOrganId()); +// } +// if (pageReqVO.getOrganId() == null || pageReqVO.getOrganId() == 0) { + pageReqVO.setOrganId(getOrganId(BASE_PLATE_QUERY_PERMISSION, getLoginUser().getId(), pageReqVO.getOrganId())); +// } return plateMapper.selectPage(pageReqVO); } @@ -149,18 +125,10 @@ public class PlateServiceImpl implements PlateService { @Override @OrganIgnore @Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入 - public PlateImportRespVO importPlateList(List importPlates, boolean isUpdateSupport , Long organId) { -// System.out.println(" importPlates " + importPlates); -// if (CollUtil.isEmpty(importPlates)) { -// throw ServiceExceptionUtil.exception(ErrorCodeConstants.PLATE_IMPORT_LIST_IS_EMPTY); -// } - if (permissionApi.hasRoles(getLoginUser().getId(), BASE_PLATE_IMPORT_PERMISSION).getData()){ - if (organId != null && organId != 0 ){ - validateOrganExists(organId); - } - } else { - organId = OrganContextHolder.getOrganId(); - } + public PlateImportRespVO importPlateList(List importPlates, boolean isUpdateSupport, Long organId) { + + organId = getOrganId(BASE_PLATE_IMPORT_PERMISSION, getLoginUser().getId(), organId); + PlateImportRespVO respVO = PlateImportRespVO.builder().createPlateNames(new ArrayList<>()) .updatePlateNames(new ArrayList<>()).failurePlateNames(new LinkedHashMap<>()).build(); // 批量插入集合 @@ -184,27 +152,43 @@ public class PlateServiceImpl implements PlateService { } }); // 批量插入,批量更新 - if (insertList.size() > 0 && insertList != null) { + if (insertList.size() > 0) { plateMapper.insertBatch(insertList); } - if (updateList.size() > 0 && updateList != null) { + if (updateList.size() > 0) { plateMapper.updateBatch(updateList); } return respVO; } private void validateOrganExists(Long organId) { - CommonResult index = organApi.validOrgan(organId); + CommonResult index = organApi.validOrgan(organId); if (!index.isSuccess()) { throw exception(ErrorCodeConstants.ORGAN_NOT_EXISTS); } } // 当前组织中板材是否存在 - private void validateGoodExists(String goodsId ,Long organId) { - if (plateMapper.selectByGoodID(goodsId ,organId) != null){ + private void validateGoodExists(String goodsId, Long organId) { + if (plateMapper.selectByGoodID(goodsId, organId) != null) { throw exception(ErrorCodeConstants.PLATE_EXISTS); } } + // 组织id返回 + private Long getOrganId(String type, Long userId, Long organId) { + + boolean hasPermission = permissionApi.hasRoles(userId, type).getData(); + + Long organIdDefault = OrganContextHolder.getOrganId(); + + if (hasPermission && organId != null && organId != 0) { + + validateOrganExists(organId); + + organIdDefault = organId; + } + + return organIdDefault; + } } \ No newline at end of file diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/mapper/plate/PlateMapper.xml b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/mapper/plate/PlateMapper.xml index 06dd7e4c7..efdada0e3 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/mapper/plate/PlateMapper.xml +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/mapper/plate/PlateMapper.xml @@ -12,6 +12,7 @@ color, width, height, + texture, thickness, brand, spec, diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application.yaml b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application.yaml index c376ca198..6a587132c 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application.yaml +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application.yaml @@ -127,6 +127,22 @@ aj: req-check-minute-limit: 60 # check 接口一分钟内请求数限制 req-verify-minute-limit: 60 # verify 接口一分钟内请求数限制 + +--- #################### 线程相关配置 #################### + +# 异步线程配置 自定义使用参数 +async: + executor: + thread: + core_pool_size: 26 # 配置核心线程数 默认8个 核数*2+2 + max_pool_size: 100 # 配置最大线程数 + queue_capacity: 99988 # 配置队列大小 + keep_alive_seconds: 20 #设置线程空闲等待时间秒s + name: + prefix: async-thread- # 配置线程池中的线程的名称前缀 + + + --- #################### 晨丰相关配置 #################### chenfeng: diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/organ/OrganApi.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/organ/OrganApi.java index 2a19e252a..3d49a52fd 100644 --- a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/organ/OrganApi.java +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/organ/OrganApi.java @@ -9,7 +9,9 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import java.time.LocalDate; import java.util.List; +import java.util.Map; @FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory = @Tag(name = "RPC 服务 - 多组织") @@ -26,4 +28,12 @@ public interface OrganApi { @Parameter(name = "id", description = "组织编号", required = true, example = "1024") CommonResult validOrgan(@RequestParam("id") Long id); + @GetMapping(PREFIX + "/total/org") + @Operation(summary = "组织总数查询") + CommonResult> getOrgTotal(); + + @GetMapping(PREFIX + "/separate/org") + @Operation(summary = "新增、注销组织数量统计") + CommonResult> getOrgSeparate(@RequestParam("time") LocalDate[] createTime, @RequestParam("unit")Integer unit); + } diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/user/AdminUserApi.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/user/AdminUserApi.java index eb8bee9f6..4c35dac20 100644 --- a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/user/AdminUserApi.java +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/api/user/AdminUserApi.java @@ -74,4 +74,11 @@ public interface AdminUserApi { @Parameter(name = "organIds", description = "组织id列表", example = "1,3", required = true) CommonResult> getOrganAdminByOrganIds(@RequestParam("id") Collection organIds); + @GetMapping(PREFIX + "/total/user") + @Operation(summary = "用户总数") + CommonResult> getUserTotal(); + + @GetMapping(PREFIX + "/total/userAct") + @Operation(summary = "用户活跃数") + CommonResult> getUserActTotal(); } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/organ/OrganApiImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/organ/OrganApiImpl.java index a88ec1faa..ec5a67fd5 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/organ/OrganApiImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/organ/OrganApiImpl.java @@ -6,7 +6,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.time.LocalDate; import java.util.List; +import java.util.Map; import static com.cf.imes.framework.common.pojo.CommonResult.success; @@ -28,4 +30,14 @@ public class OrganApiImpl implements OrganApi { return success(true); } + @Override + public CommonResult> getOrgTotal() { + return success(organService.orgTotal()); + } + + @Override + public CommonResult> getOrgSeparate(LocalDate[] createTime, Integer unit) { + return null; + } + } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/user/AdminUserApiImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/user/AdminUserApiImpl.java index 455562d11..9736adfa3 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/user/AdminUserApiImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/api/user/AdminUserApiImpl.java @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.Set; import static com.cf.imes.framework.common.pojo.CommonResult.success; @@ -64,5 +65,15 @@ public class AdminUserApiImpl implements AdminUserApi { return success(userService.getOrganAdminByOrganIds(organIds)); } + @Override + public CommonResult> getUserTotal() { + return success(userService.userTotal()); + } + + @Override + public CommonResult> getUserActTotal() { + return success(userService.userActTotal()); + } + } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/organ/OrganMapper.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/organ/OrganMapper.java index 4d5b99dd7..2391e86f2 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/organ/OrganMapper.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/organ/OrganMapper.java @@ -4,11 +4,15 @@ import cn.hutool.core.util.StrUtil; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.cf.imes.module.executor.enums.OrderDeletedEnum; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO; import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.List; /** @@ -55,6 +59,27 @@ public interface OrganMapper extends BaseMapperX { } + default Integer selectOrgCount() { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eq(OrganizationDO::getUpdateTime, OrderDeletedEnum.NOT_DELETED.getStatus()))); + } + + default Integer selectOrgCountAdd() { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eq(OrganizationDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus()) + .between(OrganizationDO::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT), + LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59))))); + } + + default Integer selectOrgCountDel() { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eq(OrganizationDO::getDeleted, OrderDeletedEnum.DELETED.getStatus()) + .between(OrganizationDO::getDeleted, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT), + LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59))))); + } + + Integer selectOrgSilentCount(@Param("dateTime")LocalDateTime dateTime); + default List selectOrganList(Integer status) { return selectList(new LambdaQueryWrapperX() @@ -67,4 +92,5 @@ public interface OrganMapper extends BaseMapperX { + } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java index a75928082..8fc5f8f5f 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java @@ -2,17 +2,23 @@ package com.cf.imes.module.system.dal.mysql.user; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.cf.imes.framework.common.enums.CommonStatusEnum; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.organ.core.aop.OrganIgnore; import com.cf.imes.framework.security.core.LoginUser; import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; +import com.cf.imes.module.executor.enums.OrderDeletedEnum; import com.cf.imes.module.system.controller.admin.user.vo.user.UserPageReqVO; +import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO; import com.cf.imes.module.system.dal.dataobject.user.AdminUserDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.Collection; import java.util.List; import java.util.Objects; @@ -104,5 +110,31 @@ public interface AdminUserMapper extends BaseMapperX { .in(AdminUserDO::getId, userIds)); } + default Integer selectUserCount() { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus()))); + } + default Integer selectUserCountAdd() { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus()) + .between(AdminUserDO::getCreateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT), + LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59))))); + } + + default Integer selectUserCountDel() { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eq(AdminUserDO::getDeleted, OrderDeletedEnum.DELETED.getStatus()) + .between(AdminUserDO::getUpdateTime, LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT), + LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59))))); + } + + Integer selectUserSilentCount(@Param("dateTime")LocalDateTime dateTime); + + default Integer selectUserActCountTime(LocalDateTime startTime, LocalDateTime endTIme) { + return Math.toIntExact(selectCount(new LambdaQueryWrapperX() + .eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus()) + .eq(AdminUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) + .between(AdminUserDO::getCreateTime, startTime, endTIme))); + } } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganService.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganService.java index 5d4190d55..d882f6ed6 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganService.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganService.java @@ -12,6 +12,7 @@ import com.cf.imes.module.system.service.organ.handler.OrganMenuHandler; import javax.validation.Valid; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -130,4 +131,9 @@ public interface OrganService { void validOrgan(Long id); List getSimpleOrganList(String name); + + /** + * 组织总数统计 + */ + Map orgTotal(); } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganServiceImpl.java index e2c08f560..12c95e6ec 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/organ/OrganServiceImpl.java @@ -1,6 +1,7 @@ package com.cf.imes.module.system.service.organ; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -43,9 +44,7 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.List; -import java.util.Objects; -import java.util.Set; +import java.util.*; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.cf.imes.module.system.enums.ErrorCodeConstants.*; @@ -352,4 +351,25 @@ public class OrganServiceImpl implements OrganService { return organProperties == null || Boolean.FALSE.equals(organProperties.getEnable()); } + @Override + public Map orgTotal() { + Map map = new HashMap<>(); + + // 组织总数 + Integer orgTotal = organMapper.selectOrgCount(); + map.put("orgTotal", orgTotal); + // 当日新增数 + Integer orgAdd = organMapper.selectOrgCountAdd(); + map.put("orgAdd", orgAdd); + // 当日状态-删除 + Integer orgDel = organMapper.selectOrgCountDel(); + map.put("orgDel", orgDel); + // 当日沉寂数 (组织中所有用户30天未登录) + // 获得30天前的时间,赋值时间为0:00:00 + Date date = DateUtil.offsetDay(new Date(), -30); + Integer orgSilent = organMapper.selectOrgSilentCount(DateUtil.beginOfDay(date).toLocalDateTime()); + map.put("orgSilent", orgSilent); + return map; + } + } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserService.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserService.java index 3d36042f5..44cfb5c61 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserService.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserService.java @@ -232,4 +232,14 @@ public interface AdminUserService { * @return 用户列表 */ List getOrganAdminByOrganIds(Collection organIds); + + /** + * 用户总数统计 + */ + Map userTotal(); + + /** + * 用户活跃数统计 + */ + Map userActTotal(); } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java index 4f18382c1..74343df01 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java @@ -1,6 +1,7 @@ package com.cf.imes.module.system.service.user; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ObjectUtil; import com.cf.imes.framework.common.enums.CommonStatusEnum; @@ -47,7 +48,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.InputStream; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.*; import java.util.regex.Pattern; @@ -578,4 +581,52 @@ public class AdminUserServiceImpl implements AdminUserService { throw exception(USER_ME_ERROR); } } + + @Override + public Map userTotal() { + Map map = new HashMap<>(); + + // 用户总数 + Integer userTotal = userMapper.selectUserCount(); + map.put("userTotal", userTotal); + // 当日新增数 + Integer userTodayAdd = userMapper.selectUserCountAdd(); + map.put("userTodayAdd", userTodayAdd); + // 当日状态-停止数 + Integer userTodayDel = userMapper.selectUserCountDel(); + map.put("userTodayDel", userTodayDel); + // 当日沉寂数 (30天未登录) + Date date = DateUtil.offsetDay(new Date(), -30); + Integer userTodaySilent = userMapper.selectUserSilentCount(DateUtil.beginOfDay(date).toLocalDateTime()); + map.put("userTodaySilent", userTodaySilent); + + return map; + } + + @Override + public Map userActTotal() { + Map map = new HashMap<>(); + + LocalDateTime startTime = getFirstDayOfMonth(); + LocalDateTime endTIme = LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59)); + // 用户月活跃数 + Integer userMonthAct = userMapper.selectUserActCountTime(startTime, endTIme); + map.put("userMonthAct", userMonthAct); + // 用户日活跃数 + Integer userDayAct = userMapper.selectUserActCountTime(LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0)), endTIme); + map.put("userDayAct", userDayAct); + return map; + } + +// 获得此月第一天日期 + public LocalDateTime getFirstDayOfMonth() { + // 获取当前日期 + LocalDate today = LocalDate.now(); + + // 获取当前月份的第一天 + LocalDate firstDayOfMonth = today.withDayOfMonth(1); + + // 将时间设置为 0 点 + return LocalDateTime.of(firstDayOfMonth, LocalTime.MIDNIGHT); + } } diff --git a/cf-module-system/cf-module-system-biz/src/main/resources/mapper/organ/OrganMapper.xml b/cf-module-system/cf-module-system-biz/src/main/resources/mapper/organ/OrganMapper.xml index 309ff8e59..b47107e52 100644 --- a/cf-module-system/cf-module-system-biz/src/main/resources/mapper/organ/OrganMapper.xml +++ b/cf-module-system/cf-module-system-biz/src/main/resources/mapper/organ/OrganMapper.xml @@ -2,6 +2,22 @@ + + diff --git a/cf-module-system/cf-module-system-biz/src/main/resources/mapper/user/AdminUserMapper.xml b/cf-module-system/cf-module-system-biz/src/main/resources/mapper/user/AdminUserMapper.xml new file mode 100644 index 000000000..ddfd9380f --- /dev/null +++ b/cf-module-system/cf-module-system-biz/src/main/resources/mapper/user/AdminUserMapper.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file