diff --git a/cf-framework/cf-spring-boot-starter-biz-sms/src/main/java/com/cf/imes/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java b/cf-framework/cf-spring-boot-starter-biz-sms/src/main/java/com/cf/imes/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java index f5194faa0..37c1e8a9b 100644 --- a/cf-framework/cf-spring-boot-starter-biz-sms/src/main/java/com/cf/imes/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java +++ b/cf-framework/cf-spring-boot-starter-biz-sms/src/main/java/com/cf/imes/framework/sms/core/client/impl/aliyun/AliyunSmsClient.java @@ -100,7 +100,7 @@ public class AliyunSmsClient extends AbstractSmsClient { // 执行请求 SendSmsResponse response = client.getAcsResponse(request); return new SmsSendRespDTO().setSuccess(Objects.equals(response.getCode(), API_CODE_SUCCESS)).setSerialNo(response.getBizId()) - .setApiRequestId(response.getRequestId()).setApiCode(response.getCode()).setApiMsg(response.getMessage()).setChannelCode(properties.getChannel()); + .setApiRequestId(response.getRequestId()).setApiCode(response.getCode()).setApiMsg(response.getMessage()).setMobile(mobile).setChannelCode(properties.getChannel()); } @Override diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java index 856ccc214..7f29d5344 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/order/OrderController.java @@ -2,6 +2,7 @@ package com.cf.imes.module.executor.controller.admin.order; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; +import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils; import com.cf.imes.framework.web.config.WebProperties; import com.cf.imes.module.executor.controller.admin.order.vo.order.*; @@ -304,7 +305,7 @@ public class OrderController { System.out.println("orderXmlVO = " + orderXmlVO); } -// orderService.importExcelData(orderDO, list, index); + orderService.importExcelData(orderDO, list, index); } catch (Exception e) { @@ -411,8 +412,8 @@ public class OrderController { @GetMapping("/getOrderWarn") @Operation(summary = "生产单超期/到期告警 (工作台)") @PreAuthorize("@ss.hasPermission('productManager:List')") - public CommonResult>> getOrderOverdue() { - return success(orderService.getOrderWarn()); + public CommonResult>> getOrderOverdue(@Valid PageParam pageParam) { + return success(orderService.getOrderWarn(pageParam)); } } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java index 1d077e413..4048dfcb8 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java @@ -148,10 +148,10 @@ public interface OrderMapper extends BaseMapperX { IPage selectOrderIds(@Param("page") IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); // 生产单预警统计 - List selectOrderNear(@Param("today") LocalDateTime today, @Param("orderDate") LocalDateTime orderDate, @Param("organId") Long organId); + IPage selectOrderNear(@Param("orderDate") LocalDate orderDate, @Param("organId") Long organId, @Param("page") IPage page); // 生产单逾期统计 - List selectOrderOverdue(@Param("today") LocalDateTime today, @Param("organId") Long organId); + IPage selectOrderOverdue(@Param("today") LocalDate today, @Param("organId") Long organId, @Param("page") IPage page); /** * 生产单数量统计 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java index 9ebee13a2..281e508ec 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderBody/OrderBodyMapper.java @@ -46,11 +46,12 @@ public interface OrderBodyMapper extends BaseMapperX { } // 单个修改删除状态 by id - default int updateDeletedById(Long id, Integer deleted, Long organId) { + default int updateDeletedById(Collection ids, Integer deleted, Long organId, Long orderId) { return update(new LambdaUpdateWrapper() .set(OrderBodyDO::getDeleted, deleted) - .eq(OrderBodyDO::getId, id) - .eq(OrderBodyDO::getOrganId, organId)); + .in(OrderBodyDO::getId, ids) + .eq(OrderBodyDO::getOrganId, organId) + .eq(OrderBodyDO::getOrderId, orderId)); } default int deletedByOrderId(Long orderId, Long organId) { @@ -118,6 +119,7 @@ public interface OrderBodyMapper extends BaseMapperX { .eq(OrderBodyDO::getOrganId, organId) .eqIfPresent(OrderBodyDO::getOrderId, orderId)); } + // 批量删除 default int deleteBatch(Collection orderId) { return delete(new LambdaQueryWrapperX() diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderGroup/OrderGroupMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderGroup/OrderGroupMapper.java index ab9171afd..8577bfadc 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderGroup/OrderGroupMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderGroup/OrderGroupMapper.java @@ -36,11 +36,15 @@ public interface OrderGroupMapper extends BaseMapperX { } // 单个修改删除状态 by bodyId - default int updateDeletedById(Long id, Integer deleted, Long organId) { - return update(new LambdaUpdateWrapper() - .set(OrderGroupDO::getDeleted, deleted) - .eq(OrderGroupDO::getBodyId, id) - .eq(OrderGroupDO::getOrganId, organId)); + default int updateDeletedById(Collection bodyIds, Integer deleted, Long organId, Long orderId) { + if (bodyIds != null && !bodyIds.isEmpty()) { + return update(new LambdaUpdateWrapper() + .set(OrderGroupDO::getDeleted, deleted) + .in(OrderGroupDO::getBodyId, bodyIds) + .eq(OrderGroupDO::getOrganId, organId) + .eq(OrderGroupDO::getOrderId, orderId)); + } + return 0; } default int deletedById(Long id, Long organId) { @@ -87,12 +91,21 @@ public interface OrderGroupMapper extends BaseMapperX { .eq(OrderGroupDO::getOrganId, organId) .eqIfPresent(OrderGroupDO::getOrderId, orderId)); } + // 批量删除 default int deleteBatch(Collection orderId) { return delete(new LambdaQueryWrapperX() .in(OrderGroupDO::getOrderId, orderId)); } + // 批量查询 + default List selectListByBodyId(Collection bodyIds, Long orderId, Long organId, Integer deleted) { + return selectList(new LambdaQueryWrapperX() + .eq(OrderGroupDO::getOrderId, orderId) + .eq(OrderGroupDO::getOrganId, organId) + .in(OrderGroupDO::getBodyId, bodyIds)).stream().map(OrderGroupDO::getId).collect(Collectors.toList()); + } + List selectTestSQL(@Param("filed") String filed, @Param("field2") String field2 ,@Param("groupIds") List groupIds, @Param("organId") Long organId); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderParts/OrderPartsMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderParts/OrderPartsMapper.java index d71cdd578..97d3252a6 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderParts/OrderPartsMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/orderParts/OrderPartsMapper.java @@ -70,7 +70,7 @@ public interface OrderPartsMapper extends BaseMapperX { List selectPartList( @Param("orderIds") List orderIds,@Param("organId") Long organId); - List selectPartsIdListByBodyId(@Param("bodyId") Long bodyId, @Param("organId") Long organId); + List selectPartsIdListByBodyId(@Param("bodyIds") Collection bodyIds, @Param("organId") Long organId, @Param("orderId") Long orderId); int countPartsByOrderId(@Param("orderId") Long orderId, @Param("organId") Long organId, @Param("deleted") Integer deleted); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java index a111db9e1..91fbe697b 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/plate/PlateMapper.java @@ -110,7 +110,7 @@ public interface PlateMapper extends BaseMapperX { return update(wrapper); } - void updateDeletedById(@Param("plateIds") List plateIds, @Param("deleted") Integer deleted, @Param("organId") Long organId); + void updateDeletedById(@Param("plateIds") List plateIds, @Param("deleted") Integer deleted, @Param("organId") Long organId, @Param("orderId") Long orderId); int countPlateByOrderId(@Param("orderId") Long orderId, @Param("organId") Long organId, @Param("deleted") Integer deleted); @@ -150,9 +150,8 @@ public interface PlateMapper extends BaseMapperX { } // 房间id查小板的开料状态 - List selectPlateTypeByRoomId(@Param("orderId") Long orderId, @Param("roomId") Set roomId, - @Param("bodyId") Long bodyId, @Param("organId") Long organId, - @Param("deleted") Integer deleted); + List selectPlateTypeByRoomId(@Param("orderId") Long orderId, @Param("bodyIds") Collection bodyIds, + @Param("organId") Long organId, @Param("deleted") Integer deleted); // 根据生产单id删除 default int deleteByOrderId(Long orderId, Long organId) { diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java index d80108b66..fca9fc315 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderService.java @@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.*; import com.alibaba.fastjson.JSONObject; +import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.module.executor.controller.admin.order.vo.order.*; import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO; import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO; @@ -143,7 +144,7 @@ public interface OrderService { /** * 生产单超期告警分析统计 */ - Map> getOrderWarn(); + Map> getOrderWarn(PageParam pageParam); /** diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java index 4b18fecf5..52195de5c 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/order/OrderServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; +import com.cf.imes.framework.common.pojo.PageParam; 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.context.OrganContextHolder; @@ -63,6 +64,7 @@ import com.cf.imes.module.executor.dal.mysql.order.OrderMapper; import java.io.*; import java.net.URLEncoder; import java.time.*; +import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.ExecutionException; @@ -153,6 +155,14 @@ public class OrderServiceImpl implements OrderService { validateCustomOrderNoExists(updateReqVO.getCustomOrderNo(), updateReqVO.getId()); // 发货日期校验 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate orderDate = LocalDate.from(updateReqVO.getOrderDate()); + LocalDate deliveryDate = LocalDate.from(updateReqVO.getDeliveryDate()); + if (deliveryDate.isBefore(orderDate)) { + // 将 deliveryDate 设置为 orderDate 后的第 30 天 + deliveryDate = orderDate.plusMonths(1); + } + updateReqVO.setDeliveryDate(deliveryDate.atStartOfDay()); // 更新 OrderDO updateObj = BeanUtils.toBean(updateReqVO, OrderDO.class); if (updateReqVO.getCustomOrderNo() == null || updateReqVO.getCustomOrderNo().equals("")) { @@ -233,68 +243,69 @@ public class OrderServiceImpl implements OrderService { public void updateBodyDeletedByOrderId(Long orderId, Set roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0 validateOrderStatus(orderId, getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus()); - List plateDOList; - List bodyIds = null; + List bodyIds = new ArrayList<>(); Integer index = status == 1 ? 0 : 1; if (roomIds != null && roomIds.size() != 0) { -// 查询当前房间下的所有板材 - plateDOList = plateMapper.selectPlateTypeByRoomId(orderId, roomIds, null, getUserOrganId(), index); bodyIds = orderBodyMapper.selectBodyIdByRoomId(orderId, roomIds, getUserOrganId(), index); } else if (bodyId != null && bodyId != 0) { -// 校验柜体存在 validateOrderBodyExists(orderId, bodyId, getUserOrganId(), index); -// 查询当前房间下的所有板材 - plateDOList = plateMapper.selectPlateTypeByRoomId(orderId, null, bodyId, getUserOrganId(), index); - bodyIds = new ArrayList<>(); bodyIds.add(bodyId); - } else { - plateDOList = null; } - if (CollectionUtils.isNotEmpty(bodyIds)) { - bodyIds.forEach(id -> { - // 逻辑删除 - orderBodyMapper.updateDeletedById(id, status, getUserOrganId());// 柜体 - orderGroupMapper.updateDeletedById(id, status, getUserOrganId());// 加工组 + if (bodyIds.size() != 0){ + List plateDOList = plateMapper.selectPlateTypeByRoomId(orderId, bodyIds, getUserOrganId(), index); +// List groupIds = orderGroupMapper.selectListByBodyId(bodyIds, orderId, getUserOrganId(), index); - if (CollectionUtils.isNotEmpty(plateDOList) ){ - // (删除小板) 小板变为删除状态 - plateMapper.updateDeletedById(plateDOList, status, getUserOrganId()); - // 删除大板 - List goodsIdList = plateMapper.selectPlateNum(orderId, getUserOrganId()); - Map> goodsIdMap = goodsIdList.stream() - .collect(Collectors.groupingBy(PlateDO::getGoodsId)); + orderBodyMapper.updateDeletedById(bodyIds, status, getUserOrganId(), orderId);// 柜体 + orderGroupMapper.updateDeletedById(bodyIds, status, getUserOrganId(), orderId);// 加工组 + plateMapper.updateDeletedById(plateDOList, status, getUserOrganId(), orderId);// 删小板 + // 删除大板 + List goodsIdList = plateMapper.selectPlateNum(orderId, getUserOrganId()); + Map> goodsIdMap = goodsIdList.stream() + .collect(Collectors.groupingBy(PlateDO::getGoodsId)); - List goodsIdDeleted = new ArrayList<>(); + List goodsIdDeleted = new ArrayList<>(); + goodsIdMap.forEach((goodsId, plates) -> { + if (plates.isEmpty()) { + goodsIdDeleted.add(goodsId); + return; + } + boolean allDeleted = true; + for (PlateDO plateDO : plates) { if (status == 1) { - goodsIdMap.forEach((k, v) -> { - boolean allDeleted = true; - for (PlateDO plateDO : v) { - if (!plateDO.getDeleted()) { - allDeleted = false; - break; - } - } - if (allDeleted) { - goodsIdDeleted.add(k); - } - }); - } - - if (goodsIdDeleted.size() > 0) { - goodsMapper.updateDeletedById(goodsIdDeleted, status, getUserOrganId()); + if (!plateDO.getDeleted()) { + allDeleted = false; + break; + } + } else { + if (plateDO.getDeleted()) { + break; + } } } - - List partsList = orderPartsMapper.selectPartsIdListByBodyId(id, getUserOrganId()); // 配件 - orderPartsMapper.updateDeletedById(partsList, status, getUserOrganId()); + if (allDeleted) { + goodsIdDeleted.add(goodsId); + } }); + + if (goodsIdDeleted.size() > 0) { + goodsMapper.updateDeletedById(goodsIdDeleted, status, getUserOrganId()); + } + + List partsList = orderPartsMapper.selectPartsIdListByBodyId(bodyIds, getUserOrganId(), orderId); // 配件 + if (partsList != null && partsList.size() != 0){ + orderPartsMapper.updateDeletedById(partsList, status, getUserOrganId()); + } } + + // 生产单柜体数量判断 if (orderBodyMapper.selectCountByOrderId(orderId, getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus()) == 0) { orderMapper.updateOrderStatus(orderId, OrderStatusEnum.EMPTY.getStatus(), getUserOrganId()); + }else { + orderMapper.updateOrderStatus(orderId, OrderStatusEnum.NEW_ORDER.getStatus(), getUserOrganId()); } } @@ -552,20 +563,18 @@ public class OrderServiceImpl implements OrderService { } @Override - public Map> getOrderWarn() { - Map> map = new HashMap<>(); - - LocalDateTime yesterdayDay = LocalDateTime.now().minus(1, ChronoUnit.DAYS).withHour(23).withMinute(59).withSecond(59); - - LocalDateTime today = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0); - LocalDateTime tomorrowDay = LocalDateTime.now().plus(1, ChronoUnit.DAYS).withHour(23).withMinute(59).withSecond(59); + public Map> getOrderWarn(PageParam pageParam) { + Map> map = new HashMap<>(); + LocalDate todayDate = LocalDate.now(); + LocalDate tomorrow = LocalDate.now().plus(1, ChronoUnit.DAYS); + PageDTO page = new PageDTO<>(pageParam.getPageNo(), pageParam.getPageSize()); // 查询预警单 - List orderNearVOS = orderMapper.selectOrderNear(today, tomorrowDay, OrganContextHolder.getOrganId()); - map.put("orderNearVOS", orderNearVOS); + IPage orderNearVOS = orderMapper.selectOrderNear(tomorrow, OrganContextHolder.getOrganId(), page); + map.put("orderNearVOS", new PageResult(orderNearVOS.getRecords(), orderNearVOS.getTotal())); // 查询超时单 - List orderOverdueVOS = orderMapper.selectOrderOverdue(yesterdayDay, OrganContextHolder.getOrganId()); - map.put("orderOverdueVOS", orderOverdueVOS); + IPage orderOverdueVOS = orderMapper.selectOrderOverdue(todayDate, OrganContextHolder.getOrganId(), page); + map.put("orderOverdueVOS", new PageResult(orderOverdueVOS.getRecords(), orderOverdueVOS.getTotal())); return map; } @@ -797,7 +806,7 @@ public class OrderServiceImpl implements OrderService { // 判断生产单状态是否符合(开料之前状态判断) private void validateOrderStatus(Long orderId, Long organId, Integer status) { // 校验存在 - OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId, status); + OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId); if (orderDO == null) throw exception(ORDER_NOT_EXISTS); // 状态排除 diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataProduction.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataProduction.java index 21d765b7b..d65b13b83 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataProduction.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiDataProduction.java @@ -2,11 +2,12 @@ package com.cf.imes.module.executor.util.fileConversion.admin.api.webcad; import com.alibaba.fastjson.JSONObject; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.FeignClientsConfiguration; import org.springframework.web.bind.annotation.*; -@FeignClient(url = "https://chenfeng.tech:7779", name = "apiOrderService") +@FeignClient(url = "https://chenfeng.tech:7779", name = "apiOrderService", configuration = FeignClientsConfiguration.class ) public interface ApiDataProduction { // 登陆token diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java index abe36ab26..d6e3df4dd 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/util/fileConversion/admin/api/webcad/ApiTypeRealize.java @@ -741,8 +741,8 @@ public class ApiTypeRealize { Map plateDetails = new HashMap<>(); if (dataPlates.getJSONObject("value") != null){ // 获取 Orders 字段对应的数组 - JSONArray ordersArray = dataPlates.getJSONArray("Orders"); -// System.err.println(dataPlates); + JSONArray ordersArray = dataPlates.getJSONObject("value").getJSONArray("Orders"); + System.err.println(dataPlates); if (ordersArray != null && !ordersArray.isEmpty()) { for (int i = 0; i < ordersArray.size(); i++) { JSONObject order = ordersArray.getJSONObject(i); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml index 8ab97e0c8..e420c6714 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml @@ -189,18 +189,12 @@ o.dealer_phone_number, o.salesman, o.splitter, - o.remark, - CONCAT( - LPAD(FLOOR(TIMESTAMPDIFF(SECOND, #{today}, o.delivery_date ) / (24 * 60 * 60)), 2, '0'), '天 ', - LPAD(FLOOR(MOD(TIMESTAMPDIFF(SECOND, #{today}, o.delivery_date), (24 * 60 * 60)) / (60 * 60)), 2, '0'), ':', - LPAD(FLOOR(MOD(MOD(TIMESTAMPDIFF(SECOND, #{today}, o.delivery_date), (24 * 60 * 60)), (60 * 60)) / 60), 2, '0'), ':', - LPAD(MOD(MOD(TIMESTAMPDIFF(SECOND, #{today}, o.delivery_date), (24 * 60 * 60)), (60 * 60)) % 60, 2, '0') - ) AS becomeDue + o.remark from orders o where o.organ_id = #{organId} and o.deleted = 0 and o.status != 4 - and o.delivery_date between #{today} and #{orderDate} + and o.delivery_date = #{orderDate} SELECT parts_id FROM order_item - WHERE body_id = #{bodyId} AND organ_id = #{organId} + WHERE body_id IN + + #{bodyId} + + AND organ_id = #{organId} and order_id = #{orderId} diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml index da33fd1f1..35437ea15 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/plate/PlateMapper.xml @@ -401,10 +401,12 @@ UPDATE order_plate SET deleted = #{deleted} WHERE id IN - - #{plateId} - - AND organ_id = #{organId} + + + #{plateId} + + + AND organ_id = #{organId} and order_id = #{orderId} @@ -685,23 +687,14 @@ diff --git a/cf-module-report/cf-module-report-api/src/main/java/com/cf/imes/module/report/enums/ErrorCodeConstants.java b/cf-module-report/cf-module-report-api/src/main/java/com/cf/imes/module/report/enums/ErrorCodeConstants.java index deef36ac7..8e9d6de5f 100644 --- a/cf-module-report/cf-module-report-api/src/main/java/com/cf/imes/module/report/enums/ErrorCodeConstants.java +++ b/cf-module-report/cf-module-report-api/src/main/java/com/cf/imes/module/report/enums/ErrorCodeConstants.java @@ -17,6 +17,8 @@ public final class ErrorCodeConstants { // ========== UREPORT datasource模块 1-003-002-000 ========== public static final ErrorCode DATASOURCE_NOT_EXISTS = new ErrorCode(1_003_002_001, "报表数据源不存在"); public static final ErrorCode DATASOURCE_CONNECT_FAIL = new ErrorCode(1_003_002_002, "报表数据源连接失败"); + public static final ErrorCode DATASOURCE_SPRINGBEAN_GET_FAIL = new ErrorCode(1_003_002_003, "无法获取springbean【{}】"); + public static final ErrorCode DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL = new ErrorCode(1_003_002_004, "获取springbean方法列表失败,请检查】"); // ========== UREPORT dataset模块 1-003-003-000 ========== diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/dataset/ReportDatasetController.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/dataset/ReportDatasetController.java index d0e31458e..6b882d43a 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/dataset/ReportDatasetController.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/dataset/ReportDatasetController.java @@ -52,7 +52,7 @@ public class ReportDatasetController { @DeleteMapping("/dataset/{id}") @Operation(summary = "删除报表数据集") - @Parameter(name = "id", description = "编号", required = true) + @Parameter(name = "id", description = "数据集id", required = true) // @PreAuthorize("@ss.hasPermission('report:dataset:delete')") public CommonResult deleteDataset(@PathVariable("id") Long id) { datasetService.deleteDataset(id); @@ -61,7 +61,7 @@ public class ReportDatasetController { @GetMapping("/dataset/{id}") @Operation(summary = "获得报表数据集") - @Parameter(name = "id", description = "编号", required = true, example = "1") + @Parameter(name = "id", description = "数据集id", required = true, example = "1") // @PreAuthorize("@ss.hasPermission('report:dataset:query')") public CommonResult getDataset(@PathVariable("id") Long id) { ReportDatasetDO dataset = datasetService.getDataset(id); diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/datasource/ReportDatasourceController.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/datasource/ReportDatasourceController.java index c9f73d2da..a2124531d 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/datasource/ReportDatasourceController.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/datasource/ReportDatasourceController.java @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import java.util.List; import java.util.Map; @@ -69,7 +70,7 @@ public class ReportDatasourceController { @DeleteMapping("/datasource/{id}") @Operation(summary = "删除报表数据源") - @Parameter(name = "id", description = "编号", required = true, example = "1") + @Parameter(name = "id", description = "数据源id", required = true, example = "1") // @PreAuthorize("@ss.hasPermission('report:datasource:delete')") public CommonResult deleteDatasource(@PathVariable("id") Long id) { datasourceService.deleteDatasource(id); @@ -78,7 +79,7 @@ public class ReportDatasourceController { @GetMapping("/datasource/{id}") @Operation(summary = "获取报表数据源") - @Parameter(name = "id", description = "编号", required = true, example = "1") + @Parameter(name = "id", description = "数据源id", required = true, example = "1") // @PreAuthorize("@ss.hasPermission('report:datasource:query')") public CommonResult getDatasource(@PathVariable("id") Long id) { ReportDatasourceDO datasource = datasourceService.getDatasource(id); @@ -88,6 +89,7 @@ public class ReportDatasourceController { @GetMapping("/{templateId}/datasources") @Operation(summary = "获取报表模板下的报表数据源") // @PreAuthorize("@ss.hasPermission('report:datasource:query')") + @Parameter(name = "templateId", description = "模版id", required = true) public CommonResult> getDatasourcePage(@PathVariable(value = "templateId") Long templateId) { return success(BeanUtils.toBean(datasourceService.getTemplateDatasourceList(ReportDatasourceReqVO.builder().templateId(templateId).build()), ReportDatasourceRespVO.class)); } @@ -99,10 +101,18 @@ public class ReportDatasourceController { return success(datasourceService.getBeanDatasourceList()); } + @GetMapping("/springbean/result/clazz") + @Operation(summary = "获取springbean数据源返回对象") + @Parameter(name = "clazz", description = "返回对象类路径全名不能为空", required = true) + public List springbeanFieldList(@RequestParam(value = "clazz") @NotEmpty(message = "类路径全名不能为空") String clazz) { + return datasourceService.getSpringBeanResultFieldList(clazz); + } + @GetMapping("/datasource/bean/methods") @Operation(summary = "获取springbean数据源方法类表") // @PreAuthorize("@ss.hasPermission('report:datasource:query')") - public CommonResult> getBeanDatasourceList(@RequestParam(value = "beanId") String beanId) { + @Parameter(name = "beanId", description = "springbeanId", required = true) + public CommonResult> getBeanDatasourceList(@RequestParam(value = "beanId") @NotEmpty(message = "beanId不能为空") String beanId) { return success(datasourceService.loadBeanMethods(beanId)); } diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/template/ReportTemplateController.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/template/ReportTemplateController.java index 0d9bee876..2311a4ef7 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/template/ReportTemplateController.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/controller/admin/template/ReportTemplateController.java @@ -39,6 +39,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import java.io.OutputStream; import java.util.HashMap; @@ -79,7 +80,7 @@ public class ReportTemplateController { @DeleteMapping("/template/{id}") @Operation(summary = "删除报表模板信息") - @Parameter(name = "id", description = "编号", required = true) + @Parameter(name = "id", description = "模板id", required = true) // @PreAuthorize("@ss.hasPermission('report:template:delete')") public CommonResult deleteReportTemplate(@PathVariable("id") Long id) { templateService.deleteReportTemplate(id); @@ -88,7 +89,7 @@ public class ReportTemplateController { @GetMapping("/template/{id}") @Operation(summary = "获取报表模板信息") - @Parameter(name = "id", description = "编号", required = true, example = "1") + @Parameter(name = "id", description = "模板id", required = true, example = "1") // @PreAuthorize("@ss.hasPermission('report:template:query')") public CommonResult getReportTemplate(@PathVariable("id") Long id) { return success(templateService.getReportTemplateDefinition(id)); @@ -141,7 +142,7 @@ public class ReportTemplateController { @GetMapping("/scriptValidation") @Operation(summary = "校验表达式") @Parameter(name = "content", description = "表达式", required = true) - public List scriptValidation(@Param("content") String content) { + public List scriptValidation(@Param("content") @NotEmpty(message = "表达式不能为空") String content) { content = StringUtils.decode(content); ANTLRInputStream antlrInputStream = new ANTLRInputStream(content); ReportParserLexer lexer = new ReportParserLexer(antlrInputStream); @@ -163,7 +164,7 @@ public class ReportTemplateController { @GetMapping("/parseDataSet") @Operation(summary = "解析表达式中的数据集") @Parameter(name = "expr", description = "表达式", required = true) - public Map parseDatasetName(@Param("expr") String expr) { + public Map parseDatasetName(@Param("expr") @NotEmpty(message = "表达式不能为空") String expr) { ANTLRInputStream antlrInputStream = new ANTLRInputStream(expr); ReportParserLexer lexer = new ReportParserLexer(antlrInputStream); CommonTokenStream tokenStream = new CommonTokenStream(lexer); diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/framework/ureport/bean/MockSpringBeanDatasourceResult.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/framework/ureport/bean/MockSpringBeanDatasourceResult.java new file mode 100644 index 000000000..ab7334c59 --- /dev/null +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/framework/ureport/bean/MockSpringBeanDatasourceResult.java @@ -0,0 +1,16 @@ +package com.cf.imes.module.report.framework.ureport.bean; + +import lombok.Data; +import org.springframework.stereotype.Component; + +/** + * @author Gqr + * @since 2024/8/30 11:21 + */ +@Component +@Data +public class MockSpringBeanDatasourceResult { + private String key; + + private String value; +} diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceService.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceService.java index a87036e9b..e459a74a3 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceService.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceService.java @@ -78,5 +78,11 @@ public interface ReportDatasourceService { */ List getTableFields(PreviewParams previewParams); - + /** + * 获取数据源 + * + * @param clazz + * @return + */ + List getSpringBeanResultFieldList(String clazz); } diff --git a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java index 41c87841c..4f3dbeb49 100644 --- a/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java +++ b/cf-module-report/cf-module-report-biz/src/main/java/com/cf/imes/module/report/service/datasource/ReportDatasourceServiceImpl.java @@ -1,9 +1,11 @@ package com.cf.imes.module.report.service.datasource; import cn.hutool.core.annotation.AnnotationUtil; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.toolkit.sql.SqlInjectionUtils; +import com.bstek.common.exception.ReportDesignException; import com.bstek.common.utils.MultipleJdbcTemplate; import com.bstek.datasource.bean.DataSourceInfo; import com.bstek.datasource.bean.PreviewParams; @@ -12,6 +14,7 @@ import com.bstek.ureport.definition.dataset.Parameter; import com.bstek.ureport.definition.dataset.SqlDatasetDefinition; import com.bstek.ureport.utils.ProcedureUtils; import com.cf.imes.framework.common.exception.ServiceException; +import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil; import com.cf.imes.framework.common.util.object.BeanUtils; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetReqVO; @@ -27,6 +30,7 @@ import com.cf.imes.module.report.service.dataset.ReportDatasetService; import com.cf.imes.module.report.util.SqlInjectionUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; @@ -37,6 +41,7 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import javax.sql.DataSource; +import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.sql.Connection; import java.sql.ResultSetMetaData; @@ -51,6 +56,8 @@ import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_ILL import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_INJECTION_RISK; import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_REQUIRED; import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_NOT_EXISTS; +import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_SPRINGBEAN_GET_FAIL; +import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL; /** * 报表数据源 Service 实现类 @@ -156,29 +163,39 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService { @Override public List loadBeanMethods(String beanId) { - Object obj = applicationContext.getBean(beanId); - Class clazz = obj.getClass(); - Method[] methods = clazz.getMethods(); + Object obj; List result = new ArrayList(); - // ureport的springbean方法必须满足(String dsName, String datasetName, Map parameters) - for (Method method : methods) { - Class[] types = method.getParameterTypes(); - if (types.length != 3) { - continue; + try { + obj = applicationContext.getBean(beanId); + Class clazz = obj.getClass(); + Method[] methods = clazz.getMethods(); + + // ureport的springbean方法必须满足(String dsName, String datasetName, Map parameters) + for (Method method : methods) { + Class[] types = method.getParameterTypes(); + if (types.length != 3) { + continue; + } + Class typeClass1 = types[0]; + Class typeClass2 = types[1]; + Class typeClass3 = types[2]; + if (!String.class.isAssignableFrom(typeClass1)) { + continue; + } + if (!String.class.isAssignableFrom(typeClass2)) { + continue; + } + if (!Map.class.isAssignableFrom(typeClass3)) { + continue; + } + result.add(method.getName()); } - Class typeClass1 = types[0]; - Class typeClass2 = types[1]; - Class typeClass3 = types[2]; - if (!String.class.isAssignableFrom(typeClass1)) { - continue; - } - if (!String.class.isAssignableFrom(typeClass2)) { - continue; - } - if (!Map.class.isAssignableFrom(typeClass3)) { - continue; - } - result.add(method.getName()); + } catch (BeansException e) { + log.error("[ReportDatasourceService][loadBeanMethods]获取bean失败", e); + throw ServiceExceptionUtil.exception(DATASOURCE_SPRINGBEAN_GET_FAIL, beanId); + } catch (Exception e) { + log.error("[ReportDatasourceService][loadBeanMethods]方法列表获取异常", e); + throw ServiceExceptionUtil.exception(DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL); } return result; } @@ -241,6 +258,26 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService { } } + @Override + public List getSpringBeanResultFieldList(String clazz) { + List result = new ArrayList(); + try { + Class targetClass = Class.forName(clazz); + PropertyDescriptor[] propertyDescriptors = BeanUtil.getPropertyDescriptors(targetClass); + for (PropertyDescriptor pd : propertyDescriptors) { + String name = pd.getName(); + if ("class".equals(name)) { + continue; + } + result.add(new Field(name)); + } + return result; + + } catch (Exception ex) { + throw new ReportDesignException(ex); + } + } + /** * 查询数据源下的数据集 * diff --git a/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar b/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar index ce94db844..dd9c515b3 100644 Binary files a/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar and b/cf-module-report/cf-module-report-biz/src/main/resources/lib/ureport-core-2.3.0-SNAPSHOT.jar differ diff --git a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java index 910f015b4..1d174cbc3 100644 --- a/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java +++ b/cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java @@ -46,18 +46,15 @@ public interface ErrorCodeConstants { ErrorCode USER_IS_DISABLE = new ErrorCode(1_002_003_006, "名字为【{}】的用户已被禁用"); ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过组织最大组织配额({})!"); ErrorCode USER_ME_ERROR = new ErrorCode(1_002_003_009, "不允许操作用户自身"); - - ErrorCode THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_6_CHARACTERS = new ErrorCode(1_002_003_010, "密码长度必须至少为6个字符"); - - ErrorCode THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LETTER = new ErrorCode(1_002_003_011, "密码必须包含至少一个字母"); - + ErrorCode THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS = new ErrorCode(1_002_003_010, "密码长度必须至少为8个字符"); + ErrorCode THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LOWER_LETTER = new ErrorCode(1_002_003_011, "密码必须包含至少一个小写字母"); ErrorCode THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_NUMBER = new ErrorCode(1_002_003_012, "密码必须包含至少一个数字"); ErrorCode PASSWORDS_CAN_ONLY_CONTAIN_LETTERS_AND_NUMBERS = new ErrorCode(1_002_003_013, "密码只能包含字母和数字"); ErrorCode INSUFFICIENT_PERMISSIONS = new ErrorCode(1_002_003_014, "当前用户权限不足,无法修改开料状态"); ErrorCode USERNAME_MULTIPLE_ERROR = new ErrorCode(1_002_003_015,"存在【{}】重复用户,请联系系统管理员"); ErrorCode USER_OPERATE_SELF_STATUS_ERROR = new ErrorCode(1_002_003_016, "不允许操作用户自身状态"); - + ErrorCode THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_UPPER_LETTER = new ErrorCode(1_002_003_017, "密码必须包含至少一个大写字母"); // ========== 部门模块 1-002-004-000 ========== ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门"); diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/SystemServerApplication.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/SystemServerApplication.java index 189dad7fd..be0d9596a 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/SystemServerApplication.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/SystemServerApplication.java @@ -2,14 +2,12 @@ package com.cf.imes.module.system; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.context.config.annotation.RefreshScope; /** * 项目的启动类 * @author 晨丰科技 */ @SpringBootApplication -@RefreshScope public class SystemServerApplication { public static void main(String[] args) { diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java index cc79ad4c7..754c573d7 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/dal/mysql/user/AdminUserMapper.java @@ -13,6 +13,7 @@ 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.user.AdminUserDO; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -172,4 +173,13 @@ public interface AdminUserMapper extends BaseMapperX { */ @Select("SELECT username FROM system_users WHERE id = #{id} FOR UPDATE") AdminUserDO selectByIdForUpdate(@Param("id") Long id); + + /** + * 根据id物理删除user + * + * @param id + * @return 改动数量 + */ + @Delete("DELETE FROM system_users WHERE id = #{id}") + int physicalDeleteById(@Param("id") Long id); } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java index 218a60a1a..56d7c430e 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/auth/AdminAuthServiceImpl.java @@ -41,6 +41,7 @@ import com.xingyuv.captcha.service.CaptchaService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -58,6 +59,7 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORGAN_DATA_CODE */ @Service @Slf4j +@RefreshScope public class AdminAuthServiceImpl implements AdminAuthService { @Resource diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java index 4c218da84..b9114ab9c 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/user/AdminUserServiceImpl.java @@ -114,8 +114,9 @@ public class AdminUserServiceImpl implements AdminUserService { // 定义密码校验的正则表达式 - private static final String LENGTH_PATTERN = ".{6,}"; - private static final String LETTER_PATTERN = ".*[A-Za-z].*"; + private static final String LENGTH_PATTERN = ".{8,}"; + private static final String UPPER_LETTER_PATTERN = ".*[A-Z].*"; + private static final String LOWER_LETTER_PATTERN = ".*[a-z].*"; private static final String DIGIT_PATTERN = ".*\\d.*"; private static final String VALID_CHAR_PATTERN = "^[A-Za-z\\d]+$"; @@ -320,12 +321,14 @@ public class AdminUserServiceImpl implements AdminUserService { checkCurrentWhenOperate(id); // 校验用户存在 validateUserExists(id); - // 删除用户 - userMapper.deleteById(id); - // 删除用户关联数据 - permissionService.processUserDeleted(id); - // 删除用户岗位 - userPostMapper.deleteByUserId(id); + // 物理删除用户 + int deleteNum = userMapper.physicalDeleteById(id); + if (deleteNum > 0) { + // 删除用户关联数据 + permissionService.processUserDeleted(id); + // 删除用户岗位 + userPostMapper.deleteByUserId(id); + } } @Override @@ -463,11 +466,15 @@ public class AdminUserServiceImpl implements AdminUserService { // 检查密码长度 if (!Pattern.matches(LENGTH_PATTERN, password)) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_6_CHARACTERS); + throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS); } - // 检查是否包含字母 - if (!Pattern.matches(LETTER_PATTERN, password)) { - throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LETTER); + // 检查是否包含大写字母 + if (!Pattern.matches(UPPER_LETTER_PATTERN, password)) { + throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_UPPER_LETTER); + } + // 检查是否包含小写字母 + if (!Pattern.matches(LOWER_LETTER_PATTERN, password)) { + throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LOWER_LETTER); } // 检查是否包含数字 if (!Pattern.matches(DIGIT_PATTERN, password)) {