mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
超管统计接口50%
This commit is contained in:
+34
@@ -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;
|
||||
}
|
||||
}
|
||||
+149
@@ -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<String> 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<String> generateDateRange(LocalDate[] createTime, Integer unit) {
|
||||
// 计算时间跨度
|
||||
getTimeSpan(createTime, unit);
|
||||
// 计算后的开始和结束时间
|
||||
LocalDate startDate = ObjectUtil.clone(createTime[0]);
|
||||
LocalDate endDate = ObjectUtil.clone(createTime[1]);
|
||||
|
||||
List<String> 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();
|
||||
}
|
||||
}
|
||||
+37
-79
@@ -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<List<OrderBodyRespVO>> 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<Map<String, List<?>>> 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<PageResult<OrderPlatesDetailReqVO>> 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<PageResult<OrderPlatesDetailReqVO>> 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<PageResult<OrderPartsRespVO>> 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<PageResult<OrderPartsRespVO>> 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<Boolean> deleteBody(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam(value = "roomId", required = false, defaultValue = "0") Long roomId,
|
||||
@RequestParam(value = "roomIds", required = false, defaultValue = "0") Set<Long> 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<Boolean> restoreBody(@RequestParam("orderId") Long orderId,
|
||||
@RequestParam(value = "roomId", required = false, defaultValue = "0") Long roomId,
|
||||
@RequestParam(value = "roomIds", required = false, defaultValue = "0") Set<Long> 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<Map<String, Integer>> getOrderCountProducePeriod(@RequestParam(value = "startTime") String startTime,
|
||||
@RequestParam(value = "endTime") String endTime) {
|
||||
return success(orderService.orderCountProducePeriod(startTime, endTime));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+84
@@ -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<Map<String, Integer>> getOrgTotal() {
|
||||
return success(organApi.getOrgTotal().getData());
|
||||
}
|
||||
|
||||
@GetMapping("/total/user")
|
||||
@Operation(summary = "用户总数")
|
||||
public CommonResult<Map<String, Integer>> getUserTotal() {
|
||||
return success(adminUserApi.getUserTotal().getData());
|
||||
}
|
||||
|
||||
@GetMapping("/total/userAct")
|
||||
@Operation(summary = "用户活跃数")
|
||||
public CommonResult<Map<String, Integer>> getUserActTotal() {
|
||||
return success(adminUserApi.getUserActTotal().getData());
|
||||
}
|
||||
|
||||
@GetMapping("/total/order")
|
||||
@Operation(summary = "生产单总数")
|
||||
public CommonResult<Map<String, Integer>> getOrderTotal() {
|
||||
return success(orderSupStatisticsService.orderTotal());
|
||||
}
|
||||
|
||||
@GetMapping("/total/plateArea")
|
||||
@Operation(summary = "拆单板件平方数")
|
||||
public CommonResult<Map<String, Integer>> getPlateAreaTotal() {
|
||||
return success(orderSupStatisticsService.plateAreaTotal());
|
||||
}
|
||||
|
||||
@GetMapping("/separate/order")
|
||||
@Operation(summary = "有效、无效生产单数量统计")
|
||||
public CommonResult<Map<String, Object>> getOrderSeparate(OrderStatisticsReqVO reqVO) {
|
||||
return success(orderSupStatisticsService.orderSeparate(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/separate/org")
|
||||
@Operation(summary = "新增、注销组织数量统计")
|
||||
public CommonResult<Map<String, Object>> getOrgSeparate(OrderStatisticsReqVO reqVO) {
|
||||
return success(orderSupStatisticsService.orgSeparate(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/separate/plateArea")
|
||||
@Operation(summary = "有效、无效拆单板件数量统计")
|
||||
public CommonResult<Map<String, Object>> getPlateAreaSeparate(OrderStatisticsReqVO reqVO) {
|
||||
return success(orderSupStatisticsService.plateAreaSeparate(reqVO));
|
||||
}
|
||||
}
|
||||
+37
@@ -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<Long> roomIds;
|
||||
|
||||
@Schema(description = "柜体编号", example = "1024")
|
||||
private Set<Long> bodyIds;
|
||||
|
||||
@Schema(description = "加工组编号", example = "1024")
|
||||
private Set<Long> groupIds;
|
||||
|
||||
@Schema(description = "加工组名称", example = "1024")
|
||||
private String groupName;
|
||||
|
||||
@Schema(description = "配件名称", example = "1024")
|
||||
private String partsName;
|
||||
|
||||
@Schema(description = "是否删除", example = "false")
|
||||
private Boolean deleted;
|
||||
}
|
||||
+58
@@ -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<OrderStatisticsIsLapseRespVO>{
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
+31
@@ -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<OrderDO> {
|
||||
|
||||
/**
|
||||
* 当日生产单板件平方数
|
||||
*/
|
||||
Integer selectOrderSquareProduceToday(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 生产单按时间统计失效数量
|
||||
*/
|
||||
List<OrderStatisticsIsLapseRespVO> selectOrderCountLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 生产单按时间分组统计未失效数量
|
||||
*/
|
||||
List<OrderStatisticsIsLapseRespVO> selectOrderCountNotLapseByOrderDate(@Param("req") OrderStatisticsReqVO reqVO);
|
||||
|
||||
}
|
||||
+3
-2
@@ -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<OrderBodyDO> {
|
||||
}
|
||||
|
||||
// 根据房间id查找OrderBodyDO的id
|
||||
default List<Long> selectBodyIdByRoomId(Long orderId, Long roomId, Long organId, Integer deleted) {
|
||||
default List<Long> selectBodyIdByRoomId(Long orderId, Set<Long> roomIds, Long organId, Integer deleted) {
|
||||
return selectList(new LambdaQueryWrapper<OrderBodyDO>()
|
||||
.eq(OrderBodyDO::getOrderId, orderId)
|
||||
.eq(OrderBodyDO::getRoomId, roomId)
|
||||
.in(OrderBodyDO::getRoomId, roomIds)
|
||||
.eq(OrderBodyDO::getOrganId, organId)
|
||||
.eq(OrderBodyDO::getDeleted, deleted)
|
||||
.select(OrderBodyDO::getId)).stream()
|
||||
|
||||
+5
-4
@@ -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<OrderItemDO> {
|
||||
@Param("groupName") String groupName, @Param("organId") Long organId,
|
||||
@Param("deleted") Integer deleted);
|
||||
|
||||
IPage<PlateRespVO> selectPlatesDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Long roomId,
|
||||
@Param("bodyId") Long bodyId, @Param("groupId") Long groupId,
|
||||
IPage<PlateRespVO> selectPlatesDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Set<Long> roomId,
|
||||
@Param("bodyId") Set<Long> bodyId, @Param("groupId") Set<Long> groupId,
|
||||
@Param("groupName") String groupName, @Param("organId") Long organId,
|
||||
@Param("deleted") Integer deleted);
|
||||
|
||||
@@ -46,8 +47,8 @@ public interface OrderItemMapper extends BaseMapperX<OrderItemDO> {
|
||||
@Param("bodyId") Long bodyId, @Param("name") String name,
|
||||
@Param("organId") Long organId, @Param("deleted") Integer deleted);
|
||||
|
||||
IPage<OrderPartsRespVO> selectPartsDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Long roomId,
|
||||
@Param("bodyId") Long bodyId, @Param("name") String name,
|
||||
IPage<OrderPartsRespVO> selectPartsDetailByOrderId(@Param("page") IPage page, @Param("orderId") Long orderId, @Param("roomId") Set<Long> roomId,
|
||||
@Param("bodyId") Set<Long> bodyId, @Param("groupId") Set<Long> groupId, @Param("name") String name,
|
||||
@Param("organId") Long organId, @Param("deleted") Integer deleted);
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -142,8 +142,9 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
}
|
||||
|
||||
// 房间id查小板的开料状态
|
||||
List<Long> selectPlateTypeByRoomId(@Param("orderId") Long orderId, @Param("roomId") Long roomId, @Param("bodyId") Long bodyId,
|
||||
@Param("organId") Long organId, @Param("deleted") Integer deleted);
|
||||
List<Long> selectPlateTypeByRoomId(@Param("orderId") Long orderId, @Param("roomId") Set<Long> roomId,
|
||||
@Param("bodyId") Long bodyId, @Param("organId") Long organId,
|
||||
@Param("deleted") Integer deleted);
|
||||
|
||||
// 根据生产单id删除
|
||||
default int deleteByOrderId(Long orderId, Long organId) {
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
}
|
||||
|
||||
+5
-9
@@ -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<OrderPlatesDetailReqVO>
|
||||
* 需要修改返回值
|
||||
*/
|
||||
PageResult<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Long roomId, Long bodyId, Long groupId, String groupName, Integer pageNo, Integer pageSize, Integer deleted);
|
||||
PageResult<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Set<Long> roomId, Set<Long> bodyId, Set<Long> groupId, String groupName, Integer pageNo, Integer pageSize, Integer deleted);
|
||||
|
||||
/**
|
||||
* @param orderId: 生产单id
|
||||
@@ -83,7 +85,7 @@ public interface OrderService {
|
||||
* @return List<OrderPartsRespVO>
|
||||
* 需要修改返回值
|
||||
*/
|
||||
PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Long roomId , Long bodyId , String name, Integer pageNo, Integer pageSize, Integer deleted);
|
||||
PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Set<Long> roomId , Set<Long> bodyId, Set<Long> 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<Long> roomId, Long bodyId, Integer status);
|
||||
|
||||
/**
|
||||
* @param listMap:生产单号
|
||||
@@ -141,11 +143,6 @@ public interface OrderService {
|
||||
Map<String,List<OrderOverdueRespVO>> getOrderWarn();
|
||||
|
||||
|
||||
/**
|
||||
* 生产单单量
|
||||
*/
|
||||
Map<String, Integer> orderCountProducePeriod(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 修改生产单是否删除
|
||||
*/
|
||||
@@ -157,5 +154,4 @@ public interface OrderService {
|
||||
*/
|
||||
void realDeletedOrder(Long orderId);
|
||||
|
||||
|
||||
}
|
||||
+18
-21
@@ -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<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Long roomId, Long bodyId, Long groupId, String groupName, Integer pageNo, Integer pageSize, Integer deleted) {
|
||||
public PageResult<OrderPlatesDetailReqVO> getPlatesDetail(Long orderId, Set<Long> roomIds, Set<Long> bodyIds, Set<Long> groupIds, String groupName, Integer pageNo, Integer pageSize, Integer deleted) {
|
||||
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageNo, pageSize);
|
||||
|
||||
IPage<PlateRespVO> plateRespVOPage = orderItemMapper.selectPlatesDetailByOrderId(page, orderId, roomId, bodyId, groupId,
|
||||
IPage<PlateRespVO> plateRespVOPage = orderItemMapper.selectPlatesDetailByOrderId(page, orderId, roomIds, bodyIds, groupIds,
|
||||
groupName, getUserOrganId(), deleted);
|
||||
List<PlateRespVO> orderDetail = plateRespVOPage.getRecords();
|
||||
List<OrderPlatesDetailReqVO> platesDetailReqVOS = BeanUtils.toBean(orderDetail, OrderPlatesDetailReqVO.class);
|
||||
@@ -199,26 +206,27 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Long roomId, Long bodyId, String name, Integer pageNo, Integer pageSize, Integer deleted) {
|
||||
public PageResult<OrderPartsRespVO> getPartsDetail(Long orderId, Set<Long> roomId, Set<Long> bodyId, Set<Long> groupId, String name, Integer pageNo, Integer pageSize, Integer deleted) {
|
||||
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageNo, pageSize);
|
||||
|
||||
IPage<OrderPartsRespVO> orderDetail = orderItemMapper.selectPartsDetailByOrderId(page, orderId, roomId, bodyId, name, getUserOrganId(), deleted);
|
||||
IPage<OrderPartsRespVO> 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<Long> roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0
|
||||
validateOrderStatus(orderId, getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus());
|
||||
|
||||
List<Long> plateDOList;
|
||||
List<Long> 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<String, Integer> orderCountProducePeriod(String startTime, String endTime) {
|
||||
// 角色判断
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (loginUser.getIsSupAdmin()) { // 超级管理员
|
||||
List<OrderCountProducePeriodRespVO> orderCountProducePeriodRespVOS = orderMapper.selectOrderCountProducePeriod(null, startTime, endTime);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateOrderDel(Long orderId, Integer deleted) {
|
||||
Integer index = deleted == 1 ? 0 : 1;
|
||||
|
||||
+36
@@ -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<String, Integer> orderTotal();
|
||||
|
||||
/**
|
||||
* 拆单板件平方数统计
|
||||
*/
|
||||
Map<String, Integer> plateAreaTotal();
|
||||
|
||||
/**
|
||||
* 有效、无效生产单数量统计
|
||||
*/
|
||||
Map<String, Object> orderSeparate(OrderStatisticsReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 新增、注销组织数量统计
|
||||
*/
|
||||
Map<String, Object> orgSeparate(OrderStatisticsReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 有效、无效拆单板件数量统计
|
||||
*/
|
||||
Map<String, Object> plateAreaSeparate(OrderStatisticsReqVO reqVO);
|
||||
}
|
||||
+166
@@ -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<String, Integer> orderTotal() {
|
||||
Map<String, Integer> resultMap = new LinkedHashMap<>();
|
||||
// 生产单总数
|
||||
Integer total = orderStatisticsMapper.selectOrderCount();
|
||||
resultMap.put("total", total);
|
||||
|
||||
// 日增长量
|
||||
Integer today = orderStatisticsMapper.selectOrderCountToday();
|
||||
resultMap.put("today", today);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> plateAreaTotal() {
|
||||
Map<String, Integer> 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<String, Object> orderSeparate(OrderStatisticsReqVO reqVO) {
|
||||
setOrderStatisticsReqVO(reqVO);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
|
||||
// 所有的日期集合
|
||||
List<String> dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit());
|
||||
|
||||
// 生产单有效数量
|
||||
Map<String, List<OrderStatisticsIsLapseRespVO>> orderLapseRespMap = orderSupStatisticsMapper.selectOrderCountLapseByOrderDate(reqVO).stream()
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
// 生产单无效数量
|
||||
Map<String, List<OrderStatisticsIsLapseRespVO>> 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<String, Object> orgSeparate(OrderStatisticsReqVO reqVO) {
|
||||
setOrderStatisticsReqVO(reqVO);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
|
||||
// 所有的日期集合
|
||||
List<String> dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit());
|
||||
|
||||
// 生产单有效数量
|
||||
Map<String, List<OrderStatisticsIsLapseRespVO>> orderLapseRespMap = orderSupStatisticsMapper.selectOrderCountLapseByOrderDate(reqVO).stream()
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
// 生产单无效数量
|
||||
Map<String, List<OrderStatisticsIsLapseRespVO>> 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<String, Object> 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]});
|
||||
}
|
||||
}
|
||||
+20
-29
@@ -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<Long> orderDOList = orderMapper.selectOrderListByUpdateTime();
|
||||
List<Long> 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(" 定时任务结束 ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+23
-17
@@ -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<JSONObject> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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");
|
||||
}
|
||||
|
||||
// 计算商和余数
|
||||
|
||||
+25
-13
@@ -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<OrderDO> orderList = new ArrayList<>();
|
||||
orderList.add(orderDO);
|
||||
|
||||
// 商品信息数据 信息以全
|
||||
Map<String, Map<Long, ?>> goodsInfoChange = rawGoodsInfoChange(dataGoods, orderId, dataBlocks);
|
||||
Map<String, Map<Long, ?>> goodsInfoChange = rawGoodsInfoChange(dataGoods, orderId, dataBlocks, orgId);
|
||||
List<GoodsDO> goodsDO = (List<GoodsDO>) goodsInfoChange.get("goodsDOS").values().stream().collect(Collectors.toList());
|
||||
map.put("goodsDO", goodsDO);
|
||||
List<RawGoodsDO> rawGoodsDO = (List<RawGoodsDO>) goodsInfoChange.get("rawGoodsDOS").values().stream().collect(Collectors.toList());
|
||||
map.put("rawGoodsDO", rawGoodsDO);
|
||||
|
||||
// 柜体信息 少异形数量、板材数量
|
||||
Map<Long, OrderBodyDO> bodyInfoChange = bodyInfoChange(dataBody, orderId);
|
||||
Map<Long, OrderBodyDO> bodyInfoChange = bodyInfoChange(dataBody, orderId, orgId);
|
||||
|
||||
// 加工组 少异形数量、板材数量
|
||||
Map<String, Map<Long, ?>> group =
|
||||
groupInfoChange(dataModule, orderId, bodyInfoChange);
|
||||
groupInfoChange(dataModule, orderId, bodyInfoChange, orgId);
|
||||
Map<Long, OrderGroupDO> orderGroupDO = (Map<Long, OrderGroupDO>) group.get("orderGroup");
|
||||
Map<Long, List<Long>> groupLists = (Map<Long, List<Long>>) group.get("lists"); // 加工组中包含的板件、配件id
|
||||
// 配件
|
||||
Map<String, Map<Long, ?>> partsDO = partsInfoChange(dataParts, orderId,
|
||||
(Map<Long, GoodsDO>) goodsInfoChange.get("goodsDOS"), bodyInfoChange);
|
||||
(Map<Long, GoodsDO>) goodsInfoChange.get("goodsDOS"), bodyInfoChange, orgId);
|
||||
|
||||
Map<Long, OrderPartsRemark> partsRemark = (Map<Long, OrderPartsRemark>) partsDO.get("remarks"); // 配件备注
|
||||
map.put("partsRemark", partsRemark.values().stream().collect(Collectors.toList()));
|
||||
@@ -114,7 +117,7 @@ public class ApiTypeRealize {
|
||||
itemsList.addAll(partsItems.values());
|
||||
// 板材 写库
|
||||
Map<String, Map<Long, ?>> platesDO = platesInfoChange(dataPlates, plates, orderId,
|
||||
(Map<Long, GoodsDO>) goodsInfoChange.get("goodsDOS"), bodyInfoChange, dataBlocks);
|
||||
(Map<Long, GoodsDO>) goodsInfoChange.get("goodsDOS"), bodyInfoChange, dataBlocks, orgId);
|
||||
Map<Long, PlateDO> orderPlatesDO = (Map<Long, PlateDO>) 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<String, Map<Long, ?>> groupInfoChange(JSONObject dataModule, Long orderId, Map<Long, OrderBodyDO> bodyInfoChange) {
|
||||
private Map<String, Map<Long, ?>> groupInfoChange(JSONObject dataModule, Long orderId, Map<Long, OrderBodyDO> bodyInfoChange, Long organId) {
|
||||
Map<String, Map<Long, ?>> map = new HashMap<>();
|
||||
Map<Long, OrderGroupDO> orderGroupDOs = new HashMap<>();// 加工组id 和 加工组信息
|
||||
Map<Long, List<Long>> 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<String, Map<Long, ?>> rawGoodsInfoChange(JSONObject dataRawGoods, Long orderId, JSONObject dataBlocks) {
|
||||
public Map<String, Map<Long, ?>> rawGoodsInfoChange(JSONObject dataRawGoods, Long orderId, JSONObject dataBlocks, Long organId) {
|
||||
Map<String, Map<Long, ?>> map = new HashMap<>();
|
||||
Map<Long, RawGoodsDO> rawGoodsDOS = new HashMap<>();
|
||||
Map<Long, GoodsDO> 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<Long, OrderBodyDO> bodyInfoChange(JSONObject dataBody, Long orderId) {
|
||||
private Map<Long, OrderBodyDO> bodyInfoChange(JSONObject dataBody, Long orderId, Long organId) {
|
||||
Map<Long, OrderBodyDO> 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<String, Map<Long, ?>> partsInfoChange(JSONObject value, Long orderId, Map<Long, GoodsDO> goodsDOMap, Map<Long, OrderBodyDO> bodyInfos) {
|
||||
public Map<String, Map<Long, ?>> partsInfoChange(JSONObject value, Long orderId, Map<Long, GoodsDO> goodsDOMap, Map<Long, OrderBodyDO> bodyInfos, Long organId) {
|
||||
Map<String, Map<Long, ?>> map = new HashMap<>();
|
||||
Map<Long, OrderPartsDO> partsInfos = new HashMap<>();
|
||||
Map<Long, OrderItemDO> 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<String, Map<Long, ?>> platesInfoChange(JSONObject value, JSONObject dataPlates, Long orderId,
|
||||
Map<Long, GoodsDO> goodsDOMap, Map<Long, OrderBodyDO> bodyInfos,
|
||||
JSONObject dataBlocks) {
|
||||
JSONObject dataBlocks, Long organId) {
|
||||
// 板材 写ES
|
||||
Map<Long, PlateDetail> 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();
|
||||
|
||||
|
||||
+17
-5
@@ -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<OrderPlateImportExcelVO> 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 + "-出货日期格式错误;";
|
||||
|
||||
+17
-24
@@ -48,9 +48,12 @@ public class ExcelTypeRealize {
|
||||
@Resource
|
||||
private DictDataApi dictDataApi;
|
||||
|
||||
final String NOT_ASSIGNED_ROOM = "未分房间";
|
||||
final String NOT_ASSIGNED_BODY = "未分柜体";
|
||||
|
||||
// 数据转换 + 错误验证
|
||||
public Map<String, List<?>> 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<String, List<OrderPlateImportExcelVO>> 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<String, List<OrderPlateImportExcelVO>> 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<Object> nonNullValues = new ArrayList<>();
|
||||
|
||||
+9
@@ -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:
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.executor.dal.mysql.order.OrderSupStatisticsMapper">
|
||||
|
||||
<sql id="dateFormat">
|
||||
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@QUARTER.getValue()">
|
||||
,CONCAT(YEAR(o.order_date), '-', QUARTER(o.order_date)) as date
|
||||
</if>
|
||||
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@MONTH.getValue()">
|
||||
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date)) as date
|
||||
</if>
|
||||
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@WEEK.getValue()">
|
||||
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', FLOOR((DayOfMonth(o.order_date)-1)/7)+1) AS date
|
||||
</if>
|
||||
<if test="req.unit != null and req.unit == @com.cf.imes.module.executor.enums.OrderStatisticsUnit@DAY.getValue()">
|
||||
,CONCAT(YEAR(o.order_date), '-', MONTH(o.order_date), '-', DAY(o.order_date)) as date
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectOrderSquareProduceToday" resultType="java.lang.Integer">
|
||||
SELECT SUM(op.area) as area
|
||||
FROM orders o
|
||||
LEFT JOIN order_plate op on op.order_id = o.id
|
||||
WHERE o.deleted = 0 AND o.create_time BETWEEN #{startTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="selectOrderCountLapseByOrderDate"
|
||||
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO">
|
||||
select count(o.id) as orderCount
|
||||
<include refid="dateFormat"/>
|
||||
from orders o
|
||||
where o.order_date between #{req.createTime[0]} and #{req.createTime[1]}
|
||||
and (o.deleted = 1 or o.status = 0)
|
||||
group by date;
|
||||
</select>
|
||||
|
||||
<select id="selectOrderCountNotLapseByOrderDate"
|
||||
resultType="com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO">
|
||||
select count(o.id) as orderCount
|
||||
<include refid="dateFormat"/>
|
||||
from orders o
|
||||
where o.order_date between #{req.createTime[0]} and #{req.createTime[1]}
|
||||
and o.deleted = 0 and o.status != 0
|
||||
group by date;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+31
-10
@@ -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}
|
||||
<if test="roomId != null">
|
||||
AND i.room_id = #{roomId}
|
||||
<if test="roomId != null and roomId.size() > 0">
|
||||
AND i.room_id IN
|
||||
<foreach item="roomIdItem" collection="roomId" open="(" separator="," close=")">
|
||||
#{roomIdItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="bodyId != null">
|
||||
AND i.body_id = #{bodyId}
|
||||
<if test="bodyId != null and bodyId.size() > 0">
|
||||
AND i.body_id IN
|
||||
<foreach item="bodyIdItem" collection="bodyId" open="(" separator="," close=")">
|
||||
#{bodyIdItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="groupId != null">
|
||||
AND i.group_id = #{groupId}
|
||||
<if test="groupId != null and groupId.size() > 0">
|
||||
AND i.group_id IN
|
||||
<foreach item="groupIdItem" collection="groupId" open="(" separator="," close=")">
|
||||
#{groupIdItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="groupName != null">
|
||||
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}
|
||||
<if test="roomId != null">
|
||||
AND i.room_id = #{roomId}
|
||||
<if test="roomId != null and roomId.size() > 0">
|
||||
AND i.room_id IN
|
||||
<foreach item="roomIdItem" collection="roomId" open="(" separator="," close=")">
|
||||
#{roomIdItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="bodyId != null">
|
||||
AND i.body_id = #{bodyId}
|
||||
<if test="bodyId != null and bodyId.size() > 0">
|
||||
AND i.body_id IN
|
||||
<foreach item="bodyIdItem" collection="bodyId" open="(" separator="," close=")">
|
||||
#{bodyIdItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="groupId != null and groupId.size() > 0">
|
||||
AND i.group_id IN
|
||||
<foreach item="groupIdItem" collection="groupId" open="(" separator="," close=")">
|
||||
#{groupIdItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="name != null">
|
||||
AND p.name = #{name}
|
||||
|
||||
+6
-3
@@ -393,7 +393,7 @@
|
||||
UPDATE order_plate
|
||||
SET deleted = #{deleted}
|
||||
WHERE id IN
|
||||
<foreach collection="plateIds" item="plateId" open="(" separator="," close=")">
|
||||
<foreach item="plateId" collection="plateIds" open="(" separator="," close=")">
|
||||
#{plateId}
|
||||
</foreach>
|
||||
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}
|
||||
<if test="roomId != null">
|
||||
AND i.room_id = #{roomId}
|
||||
<if test="roomId != null and roomId.size() > 0">
|
||||
AND i.room_id IN
|
||||
<foreach item="roomIdItem" collection="roomId" open="(" separator="," close=")">
|
||||
#{roomIdItem}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="bodyId != null">
|
||||
AND i.body_id = #{bodyId}
|
||||
|
||||
+1
-3
@@ -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";// 板件纹路
|
||||
}
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ public class RemainPlateController {
|
||||
@Operation(summary = "余料板批量核销")
|
||||
@PreAuthorize("@ss.hasPermission('placeorder:remain')")
|
||||
public CommonResult<Boolean> 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<Boolean> revertRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
|
||||
remainPlateService.revertRemainPlateStatus(updateReqVO.getIds(),updateReqVO.getStatus());
|
||||
remainPlateService.revertRemainPlateStatus(updateReqVO.getId(),updateReqVO.getStatus());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import java.util.Set;
|
||||
public class RemainPlateUptReqVO {
|
||||
|
||||
@Schema(description = "余料板集", example = "16470")
|
||||
private Set<Long> ids;
|
||||
private Set<Long> id;
|
||||
|
||||
@Schema(description = "余料板状态,0未使用,1使用中", example = "1")
|
||||
private Integer status;
|
||||
|
||||
+46
-62
@@ -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<PlateDO> 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<PlateImportExcelVO> 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<PlateImportExcelVO> 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<Boolean> index = organApi.validOrgan(organId);
|
||||
CommonResult<Boolean> 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;
|
||||
}
|
||||
}
|
||||
+1
@@ -12,6 +12,7 @@
|
||||
color,
|
||||
width,
|
||||
height,
|
||||
texture,
|
||||
thickness,
|
||||
brand,
|
||||
spec,
|
||||
|
||||
@@ -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:
|
||||
|
||||
+10
@@ -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<Boolean> validOrgan(@RequestParam("id") Long id);
|
||||
|
||||
@GetMapping(PREFIX + "/total/org")
|
||||
@Operation(summary = "组织总数查询")
|
||||
CommonResult<Map<String, Integer>> getOrgTotal();
|
||||
|
||||
@GetMapping(PREFIX + "/separate/org")
|
||||
@Operation(summary = "新增、注销组织数量统计")
|
||||
CommonResult<Map<String, Object>> getOrgSeparate(@RequestParam("time") LocalDate[] createTime, @RequestParam("unit")Integer unit);
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -74,4 +74,11 @@ public interface AdminUserApi {
|
||||
@Parameter(name = "organIds", description = "组织id列表", example = "1,3", required = true)
|
||||
CommonResult<List<OrganAdminUserRespDTO>> getOrganAdminByOrganIds(@RequestParam("id") Collection<Long> organIds);
|
||||
|
||||
@GetMapping(PREFIX + "/total/user")
|
||||
@Operation(summary = "用户总数")
|
||||
CommonResult<Map<String, Integer>> getUserTotal();
|
||||
|
||||
@GetMapping(PREFIX + "/total/userAct")
|
||||
@Operation(summary = "用户活跃数")
|
||||
CommonResult<Map<String, Integer>> getUserActTotal();
|
||||
}
|
||||
|
||||
+6
@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@@ -28,4 +29,9 @@ public class OrganApiImpl implements OrganApi {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Map<String, Integer>> getOrgTotal() {
|
||||
return success(organService.orgTotal());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -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<Map<String, Integer>> getUserTotal() {
|
||||
return success(userService.userTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Map<String, Integer>> getUserActTotal() {
|
||||
return success(userService.userActTotal());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+25
@@ -4,10 +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;
|
||||
|
||||
/**
|
||||
@@ -53,4 +58,24 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
|
||||
return selectList(OrganizationDO::getPackageId, packageId);
|
||||
}
|
||||
|
||||
default Integer selectOrgCount() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrganizationDO>()
|
||||
.eq(OrganizationDO::getUpdateTime, OrderDeletedEnum.NOT_DELETED.getStatus())));
|
||||
}
|
||||
|
||||
default Integer selectOrgCountAdd() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<OrganizationDO>()
|
||||
.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<OrganizationDO>()
|
||||
.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);
|
||||
}
|
||||
|
||||
+32
@@ -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<AdminUserDO> {
|
||||
.in(AdminUserDO::getId, userIds));
|
||||
}
|
||||
|
||||
default Integer selectUserCount() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())));
|
||||
}
|
||||
|
||||
default Integer selectUserCountAdd() {
|
||||
return Math.toIntExact(selectCount(new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.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<AdminUserDO>()
|
||||
.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<AdminUserDO>()
|
||||
.eq(AdminUserDO::getDeleted, OrderDeletedEnum.NOT_DELETED.getStatus())
|
||||
.eq(AdminUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.between(AdminUserDO::getCreateTime, startTime, endTIme)));
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -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<OrganSimpleRespVO> getSimpleOrganList(String name);
|
||||
|
||||
/**
|
||||
* 组织总数统计
|
||||
*/
|
||||
Map<String, Integer> orgTotal();
|
||||
}
|
||||
|
||||
+23
-3
@@ -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<String, Integer> orgTotal() {
|
||||
Map<String, Integer> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -232,4 +232,14 @@ public interface AdminUserService {
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<OrganAdminUserRespDTO> getOrganAdminByOrganIds(Collection<Long> organIds);
|
||||
|
||||
/**
|
||||
* 用户总数统计
|
||||
*/
|
||||
Map<String, Integer> userTotal();
|
||||
|
||||
/**
|
||||
* 用户活跃数统计
|
||||
*/
|
||||
Map<String, Integer> userActTotal();
|
||||
}
|
||||
|
||||
+51
@@ -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<String, Integer> userTotal() {
|
||||
Map<String, Integer> 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<String, Integer> userActTotal() {
|
||||
Map<String, Integer> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.organ.OrganMapper">
|
||||
|
||||
<select id="selectOrgSilentCount" resultType="java.lang.Integer">
|
||||
WITH NoLoginOrgs AS (
|
||||
SELECT DISTINCT o.id
|
||||
FROM system_organization o
|
||||
LEFT JOIN system_users ul ON o.id = ul.organ_id
|
||||
AND Date (#{dateTime}) > ul.login_date
|
||||
AND ul.deleted = 0
|
||||
WHERE o.deleted =0
|
||||
|
||||
)
|
||||
|
||||
-- 查询这些沉寂组织的数量
|
||||
SELECT COUNT(*) AS count
|
||||
FROM NoLoginOrgs;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.cf.imes.module.system.dal.mysql.organ.OrganMapper">
|
||||
|
||||
<select id="selectUserSilentCount" resultType="java.lang.Integer">
|
||||
SELECT DISTINCT COUNT(*) AS count
|
||||
FROM system_users
|
||||
WHERE deleted =0
|
||||
AND Date (#{dateTime})> ul.login_date
|
||||
AND deleted = 0
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user