Merge branch 'dev_New_pro' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New_pro
| | |
| | | .gradle
|
| | | /build/
|
| | | !gradle/wrapper/gradle-wrapper.jar
|
| | |
|
| | | claude.md
|
| | | target/
|
| | | !.mvn/wrapper/maven-wrapper.jar
|
| | |
|
| | |
| | |
|
| | | !*/build/*.java
|
| | | !*/build/*.html
|
| | | !*/build/*.xml |
| | | !*/build/*.xml
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | ALTER TABLE `inspection_task` |
| | | ADD COLUMN `inspection_project` VARCHAR(100) NULL COMMENT 'å·¡æ£é¡¹ç®' AFTER `task_name`; |
| | | |
| | | ALTER TABLE `inspection_task` |
| | | ADD COLUMN `inspection_result` VARCHAR(1) NULL COMMENT 'å·¡æ£ç»æ 0å¼å¸¸ 1æ£å¸¸' AFTER `remarks`, |
| | | ADD COLUMN `abnormal_description` VARCHAR(500) NULL COMMENT 'å¼å¸¸æè¿°' AFTER `inspection_result`, |
| | | ADD COLUMN `device_repair_id` BIGINT NULL COMMENT 'å
³èç»´ä¿®åID' AFTER `abnormal_description`, |
| | | ADD COLUMN `acceptance_user_id` BIGINT NULL COMMENT 'éªæ¶äººID' AFTER `device_repair_id`, |
| | | ADD COLUMN `acceptance_name` VARCHAR(100) NULL COMMENT 'éªæ¶äºº' AFTER `acceptance_user_id`; |
| | | |
| | | ALTER TABLE `timing_task` |
| | | ADD COLUMN `inspection_project` VARCHAR(100) NULL COMMENT 'å·¡æ£é¡¹ç®' AFTER `task_name`, |
| | | ADD COLUMN `is_enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'æ¯å¦å¯ç¨ 0å¦ 1æ¯' AFTER `is_active`; |
| | | |
| | | CREATE INDEX `idx_inspection_task_device_repair_id` |
| | | ON `inspection_task` (`device_repair_id`); |
| | | |
| | | CREATE INDEX `idx_inspection_task_inspection_result` |
| | | ON `inspection_task` (`inspection_result`); |
| | | |
| | | CREATE INDEX `idx_timing_task_is_enabled` |
| | | ON `timing_task` (`is_enabled`); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # 设å¤å·¡æ£ä¸å®æ¶å·¡æ£å端èè°ææ¡£ï¼inspectiontaskï¼ |
| | | |
| | | > æ´æ°æ¥æï¼2026-05-15 |
| | | > éç¨æ¨¡åï¼è®¾å¤å·¡æ£ä»»å¡ `inspectiontask`ï¼`/inspectionTask`ï¼ä¸å®æ¶å·¡æ£ä»»å¡ï¼`/timingTask`ï¼ |
| | | |
| | | ## 1. æ¬æ¬¡æ¹å¨ |
| | | |
| | | 1. å·¡æ£ä»»å¡æ°å¢åæ®µï¼ |
| | | - `inspectionProject`ï¼å·¡æ£é¡¹ç®ï¼ |
| | | - `inspectionResult`ï¼å·¡æ£ç»æï¼`0`å¼å¸¸ / `1`æ£å¸¸ï¼å¿
å¡«ï¼ |
| | | - `abnormalDescription`ï¼å¼å¸¸æè¿°ï¼ |
| | | - `deviceRepairId`ï¼å
³èç»´ä¿®åIDï¼å¼å¸¸æ¶å端èªå¨åå¡«ï¼ |
| | | - `acceptanceUserId`ï¼éªæ¶äººIDï¼ |
| | | - `acceptanceName`ï¼éªæ¶äººï¼ |
| | | 2. å¼å¸¸æ ¡éªè§åï¼ |
| | | - `inspectionResult=1`ï¼æ£å¸¸ï¼ï¼ç
§çéå¿
å¡«ã |
| | | - `inspectionResult=0`ï¼å¼å¸¸ï¼ï¼å¿
é¡»æç
§çï¼ä¸å¿
须填å `abnormalDescription`ã |
| | | 3. å¼å¸¸èå¨è§åï¼ |
| | | - å¼å¸¸ä¿ååèªå¨çæ `device_repair` å¹¶åå¡« `deviceRepairId`ã |
| | | 4. 宿¶ä»»å¡æ°å¢åæ®µï¼ |
| | | - `inspectionProject`ï¼å·¡æ£é¡¹ç®ï¼ |
| | | - `isEnabled`ï¼æ¯å¦å¯ç¨ï¼`0`å¦ / `1`æ¯ï¼ |
| | | 5. 夿³¨å¸¦å
¥è§åï¼ |
| | | - 宿¶ä»»å¡èªå¨çæå·¡æ£è®°å½æ¶ï¼è¥å®æ¶ä»»å¡ `remarks` æå¼ï¼ä¼æ¼æ¥å°å·¡æ£è®°å½å¤æ³¨ä¸ã |
| | | |
| | | ## 2. æ°æ®åºåæ´ |
| | | |
| | | èè°åæ§è¡ SQLï¼ |
| | | |
| | | - [doc/20260515_device_maintenance_inspection_abnormal_acceptance.sql](/D:/ç马/åé/å端/product-inventory-management-after-jdk25/doc/20260515_device_maintenance_inspection_abnormal_acceptance.sql) |
| | | |
| | | > 说æï¼è¯¥èæ¬å½åä½ç¨äº `inspection_task` ä¸ `timing_task` ä¸¤å¼ è¡¨ï¼æä»¶ååå²ä¿çæªæ¹ã |
| | | |
| | | ## 3. å·¡æ£ä»»å¡æ¥å£ |
| | | |
| | | ### 3.1 ä¿åæ¥å£ |
| | | |
| | | `POST /inspectionTask/addOrEditInspectionTask` |
| | | |
| | | | åæ®µ | ç±»å | å¿
å¡« | 说æ | |
| | | |---|---|---|---| |
| | | | id | long | å¦ | æå¼=ä¿®æ¹ï¼æ å¼=æ°å¢ | |
| | | | taskId | int | 建议å¿
å¡« | 设å¤IDï¼ç¨äºå¼å¸¸èªå¨å»ºç»´ä¿®åï¼ | |
| | | | taskName | string | 建议å¿
å¡« | 设å¤åç§° | |
| | | | inspectionProject | string | å¦ | å·¡æ£é¡¹ç® | |
| | | | inspectorId | string | å¦ | å·¡æ£äººIDï¼æ¯æéå·åé | |
| | | | inspectionResult | string | æ¯ | `0`=å¼å¸¸ï¼`1`=æ£å¸¸ | |
| | | | abnormalDescription | string | æ¡ä»¶å¿
å¡« | å¼å¸¸æ¶å¿
å¡« | |
| | | | acceptanceUserId | long | å¦ | éªæ¶äººID | |
| | | | acceptanceName | string | å¦ | éªæ¶äººå§å | |
| | | | commonFileListDTO | array | æ¡ä»¶å¿
å¡« | éä»¶ç»1ï¼å¼å¸¸æ¶ä¸ç»è³å°ä¸ç»æå¾ï¼ | |
| | | | commonFileListAfterDTO | array | æ¡ä»¶å¿
å¡« | éä»¶ç»2ï¼å¼å¸¸æ¶ä¸ç»è³å°ä¸ç»æå¾ï¼ | |
| | | | commonFileListBeforeDTO | array | æ¡ä»¶å¿
å¡« | éä»¶ç»3ï¼å¼å¸¸æ¶ä¸ç»è³å°ä¸ç»æå¾ï¼ | |
| | | |
| | | å¼å¸¸ç¤ºä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "taskId": 1001, |
| | | "taskName": "ç©ºåæºA-01", |
| | | "inspectionProject": "润æ»ç³»ç»", |
| | | "inspectorId": "12", |
| | | "inspectionResult": "0", |
| | | "abnormalDescription": "çµæºå¼åï¼æ¸©ååé«", |
| | | "acceptanceUserId": 20, |
| | | "commonFileListDTO": [ |
| | | { |
| | | "id": 90001, |
| | | "application": "file" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | æ£å¸¸ç¤ºä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "taskId": 1001, |
| | | "taskName": "ç©ºåæºA-01", |
| | | "inspectionProject": "ç¹æ£", |
| | | "inspectorId": "12", |
| | | "inspectionResult": "1", |
| | | "acceptanceUserId": 20 |
| | | } |
| | | ``` |
| | | |
| | | ### 3.2 å表æ¥å£ |
| | | |
| | | `GET /inspectionTask/list` |
| | | |
| | | è¿åå
嫿°å¢åæ®µï¼ |
| | | |
| | | - `inspectionProject` |
| | | - `inspectionResult` |
| | | - `abnormalDescription` |
| | | - `deviceRepairId` |
| | | - `acceptanceUserId` |
| | | - `acceptanceName` |
| | | |
| | | ## 4. 宿¶ä»»å¡æ¥å£ |
| | | |
| | | ### 4.1 ä¿åæ¥å£ |
| | | |
| | | `POST /timingTask/addOrEditTimingTask` |
| | | |
| | | æ°å¢/æ´æ°åæ®µï¼ |
| | | |
| | | | åæ®µ | ç±»å | å¿
å¡« | 说æ | |
| | | |---|---|---|---| |
| | | | inspectionProject | string | å¦ | å·¡æ£é¡¹ç® | |
| | | | remarks | string | å¦ | 夿³¨ | |
| | | | isEnabled | int | å¦ | `0`=ç¦ç¨ï¼`1`=å¯ç¨ï¼ä¸ä¼ é»è®¤å¯ç¨ | |
| | | |
| | | 示ä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "taskName": "ç©ºåæºA-01宿¶å·¡æ£", |
| | | "inspectionProject": "æåº¦å·¡æ£", |
| | | "taskId": 1001, |
| | | "inspectorIds": "12,13", |
| | | "frequencyType": "DAILY", |
| | | "frequencyDetail": "09:00", |
| | | "remarks": "éç¹æ£æ¥è½´æ¿æ¸©åº¦", |
| | | "isEnabled": 1 |
| | | } |
| | | ``` |
| | | |
| | | ### 4.2 å¯ç¨ç¶æè¡ä¸º |
| | | |
| | | 1. `isEnabled=1`ï¼ä»»å¡è¿å
¥è°åº¦ï¼æé¢æ¬¡èªå¨çæå·¡æ£è®°å½ã |
| | | 2. `isEnabled=0`ï¼ä»»å¡ä¸è°åº¦ï¼å·²åå¨è°åº¦ä¼è¢«ç§»é¤ã |
| | | |
| | | ### 4.3 夿³¨å¸¦å
¥è§å |
| | | |
| | | 宿¶ä»»å¡èªå¨çæå·¡æ£è®°å½æ¶ï¼ |
| | | |
| | | 1. å·¡æ£è®°å½å¤æ³¨åºå®åç¼ï¼`èªå¨çæèªå®æ¶ä»»å¡ID: {id}` |
| | | 2. å½å®æ¶ä»»å¡ `remarks` é空æ¶ï¼æ¼æ¥ä¸ºï¼ |
| | | `èªå¨çæèªå®æ¶ä»»å¡ID: {id}ï¼{remarks}` |
| | | |
| | | ## 5. å¼å¸¸èªå¨å»ºç»´ä¿®åè§å |
| | | |
| | | å½å·¡æ£è®°å½ `inspectionResult=0` æ¶ï¼ |
| | | |
| | | 1. è¥ `deviceRepairId` 为空ï¼å端èªå¨å建 `device_repair`ï¼ |
| | | - `deviceLedgerId`ï¼æ¥èª `taskId` |
| | | - `deviceName`ï¼ä¼å
`taskName`ï¼å¦åå设å¤å°è´¦åç§° |
| | | - `remark`ï¼å¼å¸¸æè¿° |
| | | - `status`ï¼`0`ï¼å¾
ç»´ä¿®ï¼ |
| | | 2. è¥å·²æå
³èç»´ä¿®åï¼ä»
åæ¥æ´æ°ç»´ä¿®å `remark`ã |
| | | |
| | | ## 6. å端æ¹é 建议 |
| | | |
| | | 1. å·¡æ£è¡¨åæ°å¢ `inspectionProject` è¾å
¥æ¡ã |
| | | 2. å·¡æ£è¡¨åä¿çâæ£å¸¸/å¼å¸¸âè卿 ¡éªï¼ |
| | | - å¼å¸¸æ¶å¼ºå¶å¼å¸¸æè¿° + è³å°ä¸ç»å¾çã |
| | | 3. 宿¶ä»»å¡è¡¨åæ°å¢âæ¯å¦å¯ç¨âå¼å
³å¹¶æ å° `isEnabled`ã |
| | | 4. 宿¶ä»»å¡è¡¨åæ°å¢ `inspectionProject` ä¸ `remarks` è¾å
¥é¡¹ã |
| | | 5. å·¡æ£å表å±ç¤º `inspectionProject` å `deviceRepairId`ï¼æ¯æè·³è½¬ç»´ä¿®å详æ
ï¼ã |
| | | |
| | | ## 7. èè°éªæ¶æ¸
å |
| | | |
| | | 1. å·¡æ£æ°å¢/ä¿®æ¹å¯æ£ç¡®æäº¤ `inspectionProject` å¹¶å¨åè¡¨åæ¾ã |
| | | 2. å¼å¸¸å·¡æ£ï¼ææè¿°+æå¾ï¼ä¿åæåå¹¶åå¡« `deviceRepairId`ã |
| | | 3. å¼å¸¸å·¡æ£ç¼ºæè¿°æç¼ºå¾çæ¶è¢«æ¦æªã |
| | | 4. 宿¶ä»»å¡ `isEnabled=0` æ¶ä¸å触åèªå¨å·¡æ£è®°å½ã |
| | | 5. 宿¶ä»»å¡ `isEnabled=1` æ¶æé¢æ¬¡çæå·¡æ£è®°å½ã |
| | | 6. 宿¶ä»»å¡æ `remarks` æ¶ï¼èªå¨å·¡æ£è®°å½å¤æ³¨å¸¦ä¸è¯¥å
容ã |
| | |
| | | @Excel(name = "å·¡æ£ä»»å¡åç§°") |
| | | private String taskName; |
| | | |
| | | @Schema(description = "å·¡æ£é¡¹ç®") |
| | | @Excel(name = "å·¡æ£é¡¹ç®") |
| | | private String inspectionProject; |
| | | |
| | | @Schema(description = "设å¤id") |
| | | private Integer taskId; |
| | | |
| | |
| | | @Excel(name = "夿³¨") |
| | | private String remarks; |
| | | |
| | | @Schema(description = "å·¡æ£ç»æ 0 å¼å¸¸ 1 æ£å¸¸") |
| | | private String inspectionResult; |
| | | |
| | | @Schema(description = "å¼å¸¸æè¿°") |
| | | private String abnormalDescription; |
| | | |
| | | @Schema(description = "å
³èç»´ä¿®åID") |
| | | private Long deviceRepairId; |
| | | |
| | | @Schema(description = "éªæ¶äººID") |
| | | private Long acceptanceUserId; |
| | | |
| | | @Schema(description = "éªæ¶äºº") |
| | | @Excel(name = "éªæ¶äºº") |
| | | private String acceptanceName; |
| | | |
| | | @Schema(description = "ä»»å¡ç»è®°äººID") |
| | | private Long registrantId; |
| | | |
| | |
| | | @Excel(name = "å·¡æ£ä»»å¡åç§°") |
| | | private String taskName; |
| | | |
| | | @Schema(description = "å·¡æ£é¡¹ç®") |
| | | @Excel(name = "å·¡æ£é¡¹ç®") |
| | | private String inspectionProject; |
| | | |
| | | @Schema(description = "设å¤id") |
| | | private Integer taskId; |
| | | |
| | |
| | | @Schema(description = "æ¯å¦æ¿æ´»") |
| | | private boolean isActive; |
| | | |
| | | @Schema(description = "æ¯å¦å¯ç¨ 0å¦ 1æ¯") |
| | | @Excel(name = "æ¯å¦å¯ç¨", readConverterExp = "0=å¦,1=æ¯") |
| | | private Integer isEnabled; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remarks; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.inspectiontask.dto.InspectionTaskDto; |
| | | import com.ruoyi.inspectiontask.mapper.InspectionTaskMapper; |
| | | import com.ruoyi.inspectiontask.pojo.InspectionTask; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | private final FileUtil fileUtil; |
| | | |
| | | private final DeviceRepairMapper deviceRepairMapper; |
| | | |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | |
| | | private static final String INSPECTION_RESULT_ABNORMAL = "0"; |
| | | private static final String INSPECTION_RESULT_NORMAL = "1"; |
| | | private static final int REPAIR_STATUS_PENDING = 0; |
| | | |
| | | @Override |
| | | public IPage<InspectionTaskDto> selectInspectionTaskList(Page<InspectionTask> page, InspectionTaskDto inspectionTaskDto) { |
| | | LambdaQueryWrapper<InspectionTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | if (StringUtils.isNotBlank(inspectionTaskDto.getTaskName())) { |
| | | queryWrapper.like(InspectionTask::getTaskName, inspectionTaskDto.getTaskName()); |
| | | } |
| | | if (StringUtils.isNotBlank(inspectionTaskDto.getInspectionProject())) { |
| | | queryWrapper.like(InspectionTask::getInspectionProject, inspectionTaskDto.getInspectionProject()); |
| | | } |
| | | IPage<InspectionTask> entityPage = inspectionTaskMapper.selectPage(page, queryWrapper); |
| | | |
| | | // æ æ°æ®æåè¿å |
| | | if (CollectionUtils.isEmpty(entityPage.getRecords())) { |
| | | return new Page<>(entityPage.getCurrent(), entityPage.getSize(), entityPage.getTotal()); |
| | | } |
| | | // è·åidéå |
| | | List<Long> ids = entityPage.getRecords().stream().map(InspectionTask::getId).collect(Collectors.toList()); |
| | | //ç»è®°äººids |
| | | List<Long> registrantIds = entityPage.getRecords().stream().map(InspectionTask::getRegistrantId).collect(Collectors.toList()); |
| | | // æ¹éæ¥è¯¢ç»è®°äºº |
| | |
| | | } else { |
| | | sysUserMap = new HashMap<>(); |
| | | } |
| | | //å·¡æ£äººids |
| | | List<String> inspectorIds = entityPage.getRecords().stream().map(InspectionTask::getInspectorId).collect(Collectors.toList()); |
| | | |
| | | //è·åææä¸éå¤çç¨æ·ID |
| | | Set<Long> allUserIds = entityPage.getRecords().stream() |
| | | .map(InspectionTask::getInspectorId) // è·å"2,3"è¿æ ·çå符串 |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int addOrEditInspectionTask(InspectionTaskDto inspectionTaskDto) { |
| | | InspectionTask oldInspectionTask = null; |
| | | if (Objects.nonNull(inspectionTaskDto.getId())) { |
| | | oldInspectionTask = inspectionTaskMapper.selectById(inspectionTaskDto.getId()); |
| | | if (oldInspectionTask == null) { |
| | | throw new IllegalArgumentException("å·¡æ£ä»»å¡ä¸åå¨"); |
| | | } |
| | | } |
| | | validateInspectionInput(inspectionTaskDto, oldInspectionTask); |
| | | |
| | | InspectionTask inspectionTask = new InspectionTask(); |
| | | BeanUtils.copyProperties(inspectionTaskDto, inspectionTask); |
| | | inspectionTask.setRegistrantId(SecurityUtils.getLoginUser().getUserId()); |
| | | inspectionTask.setRegistrant(SecurityUtils.getLoginUser().getUsername()); |
| | | fillAcceptanceInfo(inspectionTask, oldInspectionTask); |
| | | int i; |
| | | if (Objects.isNull(inspectionTaskDto.getId())) { |
| | | i = inspectionTaskMapper.insert(inspectionTask); |
| | | } else { |
| | | i = inspectionTaskMapper.updateById(inspectionTask); |
| | | } |
| | | // ä¿åæä»¶ |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.INSPECTION_TASK, inspectionTask.getId(), inspectionTaskDto.getCommonFileListDTO()); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.AFTER_FILE, RecordTypeEnum.INSPECTION_TASK, inspectionTask.getId(), inspectionTaskDto.getCommonFileListAfterDTO()); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.BEFORE_FILE, RecordTypeEnum.INSPECTION_TASK, inspectionTask.getId(), inspectionTaskDto.getCommonFileListBeforeDTO()); |
| | | if (i <= 0) { |
| | | return i; |
| | | } |
| | | Long linkedRepairId = syncRepairOrderIfAbnormal(inspectionTask, oldInspectionTask); |
| | | if (linkedRepairId != null && !Objects.equals(linkedRepairId, inspectionTask.getDeviceRepairId())) { |
| | | InspectionTask relationUpdate = new InspectionTask(); |
| | | relationUpdate.setId(inspectionTask.getId()); |
| | | relationUpdate.setDeviceRepairId(linkedRepairId); |
| | | inspectionTaskMapper.updateById(relationUpdate); |
| | | inspectionTask.setDeviceRepairId(linkedRepairId); |
| | | } |
| | | // ä¿åæä»¶ï¼å段ä¸ä¼ åä¿çåå²ï¼ |
| | | saveInspectionAttachments(inspectionTask.getId(), inspectionTaskDto); |
| | | |
| | | return i; |
| | | } |
| | | |
| | | private void validateInspectionInput(InspectionTaskDto inspectionTaskDto, InspectionTask oldInspectionTask) { |
| | | String inspectionResult = inspectionTaskDto.getInspectionResult(); |
| | | if (StringUtils.isBlank(inspectionResult) && oldInspectionTask != null) { |
| | | inspectionResult = oldInspectionTask.getInspectionResult(); |
| | | } |
| | | if (StringUtils.isBlank(inspectionResult)) { |
| | | throw new IllegalArgumentException("è¯·éæ©å·¡æ£ç»æ"); |
| | | } |
| | | if (!INSPECTION_RESULT_ABNORMAL.equals(inspectionResult) && !INSPECTION_RESULT_NORMAL.equals(inspectionResult)) { |
| | | throw new IllegalArgumentException("å·¡æ£ç»æä»
æ¯æï¼0-å¼å¸¸ï¼1-æ£å¸¸"); |
| | | } |
| | | inspectionTaskDto.setInspectionResult(inspectionResult); |
| | | |
| | | if (!INSPECTION_RESULT_ABNORMAL.equals(inspectionResult)) { |
| | | return; |
| | | } |
| | | |
| | | String abnormalDescription = inspectionTaskDto.getAbnormalDescription(); |
| | | if (StringUtils.isBlank(abnormalDescription) && oldInspectionTask != null) { |
| | | abnormalDescription = oldInspectionTask.getAbnormalDescription(); |
| | | } |
| | | if (StringUtils.isBlank(abnormalDescription)) { |
| | | throw new IllegalArgumentException("å·¡æ£ç»æä¸ºå¼å¸¸æ¶ï¼å¼å¸¸æè¿°ä¸è½ä¸ºç©º"); |
| | | } |
| | | inspectionTaskDto.setAbnormalDescription(abnormalDescription); |
| | | |
| | | if (!hasAnyInspectionPhotoAfterSave(inspectionTaskDto, oldInspectionTask)) { |
| | | throw new IllegalArgumentException("å·¡æ£ç»æä¸ºå¼å¸¸æ¶ï¼å¿
é¡»ä¸ä¼ è³å°ä¸å¼ ç
§ç"); |
| | | } |
| | | } |
| | | |
| | | private boolean hasAnyInspectionPhotoAfterSave(InspectionTaskDto inspectionTaskDto, InspectionTask oldInspectionTask) { |
| | | Long recordId = oldInspectionTask == null ? null : oldInspectionTask.getId(); |
| | | return hasApplicationPhotoAfterSave(inspectionTaskDto.getCommonFileListDTO(), ApplicationTypeEnum.FILE, recordId) |
| | | || hasApplicationPhotoAfterSave(inspectionTaskDto.getCommonFileListAfterDTO(), ApplicationTypeEnum.AFTER_FILE, recordId) |
| | | || hasApplicationPhotoAfterSave(inspectionTaskDto.getCommonFileListBeforeDTO(), ApplicationTypeEnum.BEFORE_FILE, recordId); |
| | | } |
| | | |
| | | private boolean hasApplicationPhotoAfterSave(List<StorageBlobDTO> requestPhotos, ApplicationTypeEnum applicationType, Long recordId) { |
| | | if (requestPhotos != null) { |
| | | return !requestPhotos.isEmpty(); |
| | | } |
| | | if (recordId == null) { |
| | | return false; |
| | | } |
| | | return CollectionUtils.isNotEmpty(fileUtil.getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(applicationType, RecordTypeEnum.INSPECTION_TASK, recordId)); |
| | | } |
| | | |
| | | private void fillAcceptanceInfo(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | Long acceptanceUserId = inspectionTask.getAcceptanceUserId(); |
| | | if (acceptanceUserId == null && oldInspectionTask != null) { |
| | | acceptanceUserId = oldInspectionTask.getAcceptanceUserId(); |
| | | } |
| | | if (acceptanceUserId != null) { |
| | | inspectionTask.setAcceptanceUserId(acceptanceUserId); |
| | | } |
| | | |
| | | String acceptanceName = inspectionTask.getAcceptanceName(); |
| | | if (StringUtils.isBlank(acceptanceName) && acceptanceUserId != null) { |
| | | SysUser acceptanceUser = sysUserMapper.selectUserById(acceptanceUserId); |
| | | if (acceptanceUser != null) { |
| | | acceptanceName = acceptanceUser.getNickName(); |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(acceptanceName) && oldInspectionTask != null) { |
| | | acceptanceName = oldInspectionTask.getAcceptanceName(); |
| | | } |
| | | inspectionTask.setAcceptanceName(acceptanceName); |
| | | } |
| | | |
| | | private Long syncRepairOrderIfAbnormal(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | if (!INSPECTION_RESULT_ABNORMAL.equals(inspectionTask.getInspectionResult())) { |
| | | return inspectionTask.getDeviceRepairId(); |
| | | } |
| | | Long linkedRepairId = inspectionTask.getDeviceRepairId(); |
| | | if (linkedRepairId == null && oldInspectionTask != null) { |
| | | linkedRepairId = oldInspectionTask.getDeviceRepairId(); |
| | | } |
| | | |
| | | if (linkedRepairId != null) { |
| | | DeviceRepair updateRepair = new DeviceRepair(); |
| | | updateRepair.setId(linkedRepairId); |
| | | updateRepair.setRemark(inspectionTask.getAbnormalDescription()); |
| | | deviceRepairMapper.updateById(updateRepair); |
| | | return linkedRepairId; |
| | | } |
| | | |
| | | DeviceRepair deviceRepair = buildDeviceRepair(inspectionTask, oldInspectionTask); |
| | | deviceRepairMapper.insert(deviceRepair); |
| | | return deviceRepair.getId(); |
| | | } |
| | | |
| | | private DeviceRepair buildDeviceRepair(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | DeviceRepair deviceRepair = new DeviceRepair(); |
| | | Long deviceLedgerId = resolveDeviceLedgerId(inspectionTask, oldInspectionTask); |
| | | DeviceLedger deviceLedger = resolveDeviceLedger(deviceLedgerId); |
| | | deviceRepair.setDeviceLedgerId(deviceLedgerId); |
| | | deviceRepair.setDeviceName(resolveDeviceName(inspectionTask, oldInspectionTask, deviceLedger)); |
| | | deviceRepair.setDeviceModel(deviceLedger == null ? null : deviceLedger.getDeviceModel()); |
| | | deviceRepair.setRepairName(resolveRepairReporter(inspectionTask, oldInspectionTask)); |
| | | deviceRepair.setRepairTime(new Date()); |
| | | deviceRepair.setRemark(inspectionTask.getAbnormalDescription()); |
| | | deviceRepair.setMachineryCategory(deviceLedger == null ? null : deviceLedger.getType()); |
| | | deviceRepair.setStatus(REPAIR_STATUS_PENDING); |
| | | return deviceRepair; |
| | | } |
| | | |
| | | private Long resolveDeviceLedgerId(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | Integer taskId = inspectionTask.getTaskId(); |
| | | if (taskId == null && oldInspectionTask != null) { |
| | | taskId = oldInspectionTask.getTaskId(); |
| | | } |
| | | if (taskId == null || taskId <= 0) { |
| | | return null; |
| | | } |
| | | return taskId.longValue(); |
| | | } |
| | | |
| | | private DeviceLedger resolveDeviceLedger(Long deviceLedgerId) { |
| | | if (deviceLedgerId == null) { |
| | | return null; |
| | | } |
| | | return deviceLedgerMapper.selectById(deviceLedgerId); |
| | | } |
| | | |
| | | private String resolveDeviceName(InspectionTask inspectionTask, InspectionTask oldInspectionTask, DeviceLedger deviceLedger) { |
| | | String taskName = inspectionTask.getTaskName(); |
| | | if (StringUtils.isBlank(taskName) && oldInspectionTask != null) { |
| | | taskName = oldInspectionTask.getTaskName(); |
| | | } |
| | | if (StringUtils.isNotBlank(taskName)) { |
| | | return taskName; |
| | | } |
| | | return deviceLedger == null ? null : deviceLedger.getDeviceName(); |
| | | } |
| | | |
| | | private String resolveRepairReporter(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | String reporter = inspectionTask.getInspector(); |
| | | if (StringUtils.isBlank(reporter) && oldInspectionTask != null) { |
| | | reporter = oldInspectionTask.getInspector(); |
| | | } |
| | | if (StringUtils.isNotBlank(reporter)) { |
| | | return reporter; |
| | | } |
| | | String inspectorNameByUserId = resolveInspectorNameByUserId(inspectionTask.getInspectorId()); |
| | | if (StringUtils.isBlank(inspectorNameByUserId) && oldInspectionTask != null) { |
| | | inspectorNameByUserId = resolveInspectorNameByUserId(oldInspectionTask.getInspectorId()); |
| | | } |
| | | if (StringUtils.isNotBlank(inspectorNameByUserId)) { |
| | | return inspectorNameByUserId; |
| | | } |
| | | try { |
| | | return SecurityUtils.getUsername(); |
| | | } catch (Exception ignored) { |
| | | return "system"; |
| | | } |
| | | } |
| | | |
| | | private String resolveInspectorNameByUserId(String inspectorIds) { |
| | | if (StringUtils.isBlank(inspectorIds)) { |
| | | return null; |
| | | } |
| | | String firstInspectorId = Arrays.stream(inspectorIds.split(",")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::isNotBlank) |
| | | .findFirst() |
| | | .orElse(null); |
| | | if (!StringUtils.isNumeric(firstInspectorId)) { |
| | | return null; |
| | | } |
| | | SysUser sysUser = sysUserMapper.selectUserById(Long.parseLong(firstInspectorId)); |
| | | return sysUser == null ? null : sysUser.getNickName(); |
| | | } |
| | | |
| | | private void saveInspectionAttachments(Long inspectionTaskId, InspectionTaskDto inspectionTaskDto) { |
| | | saveAttachmentIfPresent(inspectionTaskId, ApplicationTypeEnum.FILE, inspectionTaskDto.getCommonFileListDTO()); |
| | | saveAttachmentIfPresent(inspectionTaskId, ApplicationTypeEnum.AFTER_FILE, inspectionTaskDto.getCommonFileListAfterDTO()); |
| | | saveAttachmentIfPresent(inspectionTaskId, ApplicationTypeEnum.BEFORE_FILE, inspectionTaskDto.getCommonFileListBeforeDTO()); |
| | | } |
| | | |
| | | private void saveAttachmentIfPresent(Long inspectionTaskId, ApplicationTypeEnum applicationTypeEnum, List<StorageBlobDTO> storageBlobDTOS) { |
| | | if (storageBlobDTOS == null) { |
| | | return; |
| | | } |
| | | fileUtil.saveStorageAttachment(applicationTypeEnum, RecordTypeEnum.INSPECTION_TASK, inspectionTaskId, storageBlobDTOS); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int delByIds(Long[] ids) { |
| | |
| | | import com.ruoyi.inspectiontask.mapper.InspectionTaskMapper; |
| | | import com.ruoyi.inspectiontask.pojo.InspectionTask; |
| | | import com.ruoyi.inspectiontask.pojo.TimingTask; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.quartz.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| | |
| | | TimingTask timingTask = tasks.isEmpty() ? null : tasks.get(0); |
| | | if (timingTask == null) { |
| | | throw new JobExecutionException("æ¾ä¸å°å®æ¶ä»»å¡: " + taskId); |
| | | } |
| | | if (timingTask.getIsEnabled() != null && timingTask.getIsEnabled() == 0) { |
| | | return; |
| | | } |
| | | |
| | | // if (!timingTask.isActive()) { |
| | |
| | | |
| | | // å¤å¶åºæ¬å±æ§ |
| | | inspectionTask.setTaskName(timingTask.getTaskName()); |
| | | inspectionTask.setInspectionProject(timingTask.getInspectionProject()); |
| | | inspectionTask.setTaskId(timingTask.getTaskId()); |
| | | inspectionTask.setInspectorId(timingTask.getInspectorIds()); |
| | | inspectionTask.setInspectionLocation(timingTask.getInspectionLocation()); |
| | | inspectionTask.setRemarks("èªå¨çæèªå®æ¶ä»»å¡ID: " + timingTask.getId()); |
| | | String remarks = "èªå¨çæèªå®æ¶ä»»å¡ID: " + timingTask.getId(); |
| | | if (StringUtils.isNotBlank(timingTask.getRemarks())) { |
| | | remarks = remarks + "ï¼" + timingTask.getRemarks(); |
| | | } |
| | | inspectionTask.setRemarks(remarks); |
| | | inspectionTask.setRegistrantId(timingTask.getRegistrantId()); |
| | | inspectionTask.setFrequencyType(timingTask.getFrequencyType()); |
| | | inspectionTask.setFrequencyDetail(timingTask.getFrequencyDetail()); |
| | |
| | | private final TimingTaskMapper timingTaskMapper; |
| | | private final TimingTaskScheduler timingTaskScheduler; |
| | | private final SysUserMapper sysUserMapper; |
| | | private static final int ENABLED = 1; |
| | | private static final int DISABLED = 0; |
| | | |
| | | |
| | | @Override |
| | |
| | | LambdaQueryWrapper<TimingTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.isNotBlank(timingTask.getTaskName())) { |
| | | queryWrapper.like(TimingTask::getTaskName, timingTask.getTaskName()); |
| | | } |
| | | if (StringUtils.isNotBlank(timingTask.getInspectionProject())) { |
| | | queryWrapper.like(TimingTask::getInspectionProject, timingTask.getInspectionProject()); |
| | | } |
| | | if (timingTask.getIsEnabled() != null) { |
| | | queryWrapper.eq(TimingTask::getIsEnabled, timingTask.getIsEnabled()); |
| | | } |
| | | IPage<TimingTask> taskPage = timingTaskMapper.selectPage(page, queryWrapper); |
| | | |
| | |
| | | @Override |
| | | @Transactional |
| | | public int addOrEditTimingTask(TimingTaskDto timingTaskDto) throws SchedulerException { |
| | | TimingTask oldTimingTask = null; |
| | | if (Objects.nonNull(timingTaskDto.getId())) { |
| | | oldTimingTask = timingTaskMapper.selectById(timingTaskDto.getId()); |
| | | if (oldTimingTask == null) { |
| | | throw new IllegalArgumentException("宿¶ä»»å¡ä¸åå¨"); |
| | | } |
| | | } |
| | | TimingTask timingTask = new TimingTask(); |
| | | BeanUtils.copyProperties(timingTaskDto, timingTask); |
| | | timingTask.setIsEnabled(resolveEnabledValue(timingTask.getIsEnabled(), oldTimingTask)); |
| | | timingTask.setActive(ENABLED == timingTask.getIsEnabled()); |
| | | // 1. è§£æå符串为 LocalDateï¼åªå
å«å¹´ææ¥ï¼ |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDate localDate = LocalDate.now(); |
| | |
| | | // 设置å建人信æ¯åé»è®¤å¼ |
| | | if (Objects.isNull(timingTaskDto.getId())) { |
| | | timingTask.setRegistrationDate(LocalDate.now()); |
| | | timingTask.setActive(true); |
| | | |
| | | // 计ç®é¦æ¬¡æ§è¡æ¶é´ |
| | | LocalDateTime firstExecutionTime = calculateFirstExecutionTime(timingTask); |
| | | timingTask.setNextExecutionTime(firstExecutionTime); |
| | | int result = timingTaskMapper.insert(timingTask); |
| | | if (result > 0) { |
| | | if (result > 0 && isEnabled(timingTask.getIsEnabled(), timingTask.isActive())) { |
| | | // æ°å¢æååæ·»å å°è°åº¦å¨ |
| | | timingTaskScheduler.scheduleTimingTask(timingTask); |
| | | } |
| | |
| | | |
| | | int result = timingTaskMapper.updateById(timingTask); |
| | | if (result > 0) { |
| | | // æ´æ°æååéæ°è°åº¦ä»»å¡ |
| | | timingTaskScheduler.rescheduleTimingTask(timingTask); |
| | | boolean oldEnabled = isEnabled(oldTimingTask == null ? null : oldTimingTask.getIsEnabled(), oldTimingTask != null && oldTimingTask.isActive()); |
| | | boolean newEnabled = isEnabled(timingTask.getIsEnabled(), timingTask.isActive()); |
| | | if (!newEnabled) { |
| | | timingTaskScheduler.unscheduleTimingTask(timingTask.getId()); |
| | | } else if (oldEnabled) { |
| | | // æ´æ°æååéæ°è°åº¦ä»»å¡ |
| | | timingTaskScheduler.rescheduleTimingTask(timingTask); |
| | | } else { |
| | | // ä»ç¦ç¨æ¹ä¸ºå¯ç¨æ¶éæ°å建è°åº¦ä»»å¡ |
| | | timingTaskScheduler.scheduleTimingTask(timingTask); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | |
| | | return days; |
| | | } |
| | | |
| | | private Integer resolveEnabledValue(Integer requestEnabled, TimingTask oldTimingTask) { |
| | | if (requestEnabled != null) { |
| | | return requestEnabled; |
| | | } |
| | | if (oldTimingTask != null) { |
| | | if (oldTimingTask.getIsEnabled() != null) { |
| | | return oldTimingTask.getIsEnabled(); |
| | | } |
| | | return oldTimingTask.isActive() ? ENABLED : DISABLED; |
| | | } |
| | | return ENABLED; |
| | | } |
| | | |
| | | private boolean isEnabled(Integer enabledValue, boolean activeFallback) { |
| | | if (enabledValue != null) { |
| | | return ENABLED == enabledValue; |
| | | } |
| | | return activeFallback; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | |
| | | */ |
| | | @Data |
| | | @TableName("product_record") |
| | | public class ProductRecord { |
| | | public class ProductRecord implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | |
| | | return R.ok(stockInventoryDtoIPage); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å¯¹åºæ¹å·åæ°é |
| | | * @param page |
| | | * @param stockInventoryDto |
| | | * @return |
| | | */ |
| | | @GetMapping("/getBatchNoQty") |
| | | @Operation(summary = "æ¥è¯¢å¯¹åºæ¹å·åæ°é") |
| | | public R getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) { |
| | | IPage<StockInventoryDto> stockInventoryDtoIPage = stockInventoryService.getBatchNoQty(page, stockInventoryDto); |
| | | return R.ok(stockInventoryDtoIPage); |
| | | } |
| | | |
| | | @PostMapping("/addstockInventory") |
| | | @Operation(summary = "æ°å¢åºå") |
| | | public R addstockInventory(@RequestBody StockInventoryDto stockInventoryDto) { |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("importStockInventory") |
| | | @PostMapping("/importStockInventory") |
| | | @Operation(summary = "导å
¥åºå") |
| | | public R importStockInventory(MultipartFile file) { |
| | | return stockInventoryService.importStockInventory(file); |
| | |
| | | stockInventoryService.exportStockInventory(response, stockInventoryDto); |
| | | } |
| | | |
| | | @GetMapping("stockInventoryPage") |
| | | @GetMapping("/stockInventoryPage") |
| | | @Operation(summary = "åºåæ¥è¡¨æ¥è¯¢") |
| | | public R stockInventoryPage(Page page, StockInventoryDto stockInventoryDto) { |
| | | return R.ok(stockInventoryService.stockInventoryPage(stockInventoryDto,page)); |
| | | } |
| | | |
| | | @GetMapping("stockInAndOutRecord") |
| | | @GetMapping("/stockInAndOutRecord") |
| | | @Operation(summary = "ç»è®¡å个产åçå
¥åºååºåºè®°å½") |
| | | public R stockInAndOutRecord(StockInventoryDto stockInventoryDto,Page page) { |
| | | return R.ok(stockInventoryService.stockInAndOutRecord(stockInventoryDto,page)); |
| | |
| | | public R thawStock(@RequestBody StockInventoryDto stockInventoryDto) { |
| | | return R.ok(stockInventoryService.thawStock(stockInventoryDto)); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getByModelId") |
| | | @Operation(summary = "æ ¹æ®äº§åè§æ ¼IDè·åå
¥åºè®°å½") |
| | |
| | | |
| | | @Schema(description = "ä¸åæ ¼åºåID") |
| | | private Long unQualifiedId; |
| | | |
| | | @Schema(description = "产åid") |
| | | private Long productId; |
| | | } |
| | |
| | | List<StockInventory> listSelectableBatchNoByProductModelIds(@Param("productModelIds") List<Long> productModelIds); |
| | | |
| | | List<StockInventory> getByModelId(@Param("productModelId") Long productModelId); |
| | | |
| | | IPage<StockInventoryDto> getBatchNoQty(Page page, @Param("ew") StockInventoryDto stockInventoryDto); |
| | | } |
| | |
| | | Boolean thawStock(StockInventoryDto stockInventoryDto); |
| | | |
| | | List<StockInventory> getByModelId(Long modelId); |
| | | |
| | | IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto); |
| | | } |
| | |
| | | import com.ruoyi.stock.service.StockOutRecordService; |
| | | import com.ruoyi.stock.service.StockUninventoryService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | * @since 2026-01-21 04:16:36 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | @RequiredArgsConstructor |
| | | public class StockInventoryServiceImpl extends ServiceImpl<StockInventoryMapper, StockInventory> implements StockInventoryService { |
| | | |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | private StockInRecordService stockInRecordService; |
| | | private StockOutRecordService stockOutRecordService; |
| | | private StockUninventoryService stockUninventoryService; |
| | | private SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private ProductModelMapper productModelMapper; |
| | | private final StockInventoryMapper stockInventoryMapper; |
| | | private final StockInRecordService stockInRecordService; |
| | | private final StockOutRecordService stockOutRecordService; |
| | | private final StockUninventoryService stockUninventoryService; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final ProductModelMapper productModelMapper; |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> pagestockInventory(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.pagestockInventory(page, stockInventoryDto); |
| | |
| | | newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity()); |
| | | newStockInventory.setWarnNum(stockInventoryDto.getWarnNum()); |
| | | stockInventoryMapper.insert(newStockInventory); |
| | | }else { |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | | } else { |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean subtractStockInventory(StockInventoryDto stockInventoryDto) { |
| | | LambdaQueryWrapper<StockInventory> eq = new QueryWrapper<StockInventory>().lambda() |
| | | .eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId()); |
| | | .eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId()); |
| | | if (StringUtils.isEmpty(stockInventoryDto.getBatchNo())) { |
| | | eq.isNull(StockInventory::getBatchNo); |
| | | stockInventoryDto.setBatchNo(null); |
| | |
| | | } |
| | | |
| | | stockInventoryDto.setProductModelId(matchedProduct.getProductModelId()); |
| | | this.addstockInventory(stockInventoryDto); |
| | | this.addStockInRecordOnly(stockInventoryDto); |
| | | successCount++; |
| | | } |
| | | |
| | |
| | | |
| | | List<StockInventoryExportData> list = stockInventoryMapper.listStockInventoryExportData(stockInventoryDto); |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class); |
| | | util.exportExcel(response,list, "åºåä¿¡æ¯"); |
| | | util.exportExcel(response, list, "åºåä¿¡æ¯"); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<StockInRecordDto> stockInventoryPage(StockInventoryDto stockInventoryDto, Page page) { |
| | | return stockInventoryMapper.stockInventoryPage(stockInventoryDto,page); |
| | | return stockInventoryMapper.stockInventoryPage(stockInventoryDto, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> stockInAndOutRecord(StockInventoryDto stockInventoryDto, Page page) { |
| | | return stockInventoryMapper.stockInAndOutRecord(stockInventoryDto,page); |
| | | return stockInventoryMapper.stockInAndOutRecord(stockInventoryDto, page); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean frozenStock(StockInventoryDto stockInventoryDto) { |
| | | StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId()); |
| | | if (stockInventory.getQualitity().compareTo(stockInventoryDto.getLockedQuantity())<0) { |
| | | if (stockInventory.getQualitity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) { |
| | | throw new RuntimeException("å»ç»æ°éä¸è½è¶
è¿åºåæ°é"); |
| | | } |
| | | if (ObjectUtils.isEmpty(stockInventory.getLockedQuantity())) { |
| | | stockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity()); |
| | | }else { |
| | | } else { |
| | | stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().add(stockInventoryDto.getLockedQuantity())); |
| | | } |
| | | return this.updateById(stockInventory); |
| | |
| | | @Override |
| | | public Boolean thawStock(StockInventoryDto stockInventoryDto) { |
| | | StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId()); |
| | | if (stockInventory.getLockedQuantity().compareTo(stockInventoryDto.getLockedQuantity())<0) { |
| | | if (stockInventory.getLockedQuantity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) { |
| | | throw new RuntimeException("è§£å»æ°éä¸è½è¶
è¿å»ç»æ°é"); |
| | | } |
| | | stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().subtract(stockInventoryDto.getLockedQuantity())); |
| | |
| | | public List<StockInventory> getByModelId(Long modelId) { |
| | | return stockInventoryMapper.getByModelId(modelId); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.getBatchNoQty(page, stockInventoryDto); |
| | | } |
| | | } |
| | |
| | | from customer c |
| | | left join sys_user u on c.usage_user = u.user_id |
| | | <where> |
| | | and c.usage_status = 1 |
| | | <if test="c.customerName != null and c.customerName != ''"> |
| | | and customer_name like concat('%', #{c.customerName}, '%') |
| | | </if> |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |
| | | </mapper> |
| | |
| | | INNER JOIN product_tree pt ON p.parent_id = pt.id |
| | | ) |
| | | select |
| | | batch_no, |
| | | MAX(qualifiedId) as qualifiedId, |
| | | MAX(unQualifiedId) as unQualifiedId, |
| | | SUM(qualifiedQuantity) as qualifiedQuantity, |
| | | SUM(unQualifiedQuantity) as unQualifiedQuantity, |
| | | SUM(qualifiedLockedQuantity) as qualifiedLockedQuantity, |
| | | SUM(unQualifiedLockedQuantity) as unQualifiedLockedQuantity, |
| | | SUM(qualifiedQuantity - qualifiedLockedQuantity - IFNULL(qualifiedPendingOut, 0)) as qualifiedUnLockedQuantity, |
| | | SUM(unQualifiedQuantity - unQualifiedLockedQuantity - IFNULL(unQualifiedPendingOut, 0)) as unQualifiedUnLockedQuantity, |
| | | SUM(IFNULL(qualifiedPendingOut, 0)) as qualifiedPendingOutQuantity, |
| | | SUM(IFNULL(unQualifiedPendingOut, 0)) as unQualifiedPendingOutQuantity, |
| | | product_model_id, |
| | | MAX(create_time) as create_time, |
| | | MAX(update_time) as update_time, |
| | | MAX(warn_num) as warn_num, |
| | | MAX(version) as version, |
| | | model, |
| | | MAX(remark) as remark, |
| | | unit, |
| | | product_name, |
| | | product_id, |
| | | 'combined' as stockType |
| | | GROUP_CONCAT(DISTINCT batch_no ORDER BY batch_no SEPARATOR ',') as batch_no, |
| | | MAX(qualifiedId) as qualifiedId, |
| | | MAX(unQualifiedId) as unQualifiedId, |
| | | SUM(qualifiedQuantity) as qualifiedQuantity, |
| | | SUM(unQualifiedQuantity) as unQualifiedQuantity, |
| | | SUM(qualifiedLockedQuantity) as qualifiedLockedQuantity, |
| | | SUM(unQualifiedLockedQuantity) as unQualifiedLockedQuantity, |
| | | SUM(qualifiedQuantity - qualifiedLockedQuantity - IFNULL(qualifiedPendingOut, 0)) as qualifiedUnLockedQuantity, |
| | | SUM(unQualifiedQuantity - unQualifiedLockedQuantity - IFNULL(unQualifiedPendingOut, 0)) as unQualifiedUnLockedQuantity, |
| | | SUM(IFNULL(qualifiedPendingOut, 0)) as qualifiedPendingOutQuantity, |
| | | SUM(IFNULL(unQualifiedPendingOut, 0)) as unQualifiedPendingOutQuantity, |
| | | product_model_id, |
| | | MAX(create_time) as create_time, |
| | | MAX(update_time) as update_time, |
| | | MAX(warn_num) as warn_num, |
| | | MAX(version) as version, |
| | | model, |
| | | MAX(remark) as remark, |
| | | unit, |
| | | product_name, |
| | | product_id, |
| | | 'combined' as stockType |
| | | from ( |
| | | select |
| | | si.batch_no, |
| | | si.id as qualifiedId, |
| | | null as unQualifiedId, |
| | | si.qualitity as qualifiedQuantity, |
| | | 0 as unQualifiedQuantity, |
| | | COALESCE(si.locked_quantity, 0) as locked_quantity, |
| | | COALESCE(si.locked_quantity, 0) as qualifiedLockedQuantity, |
| | | 0 as unQualifiedLockedQuantity, |
| | | si.product_model_id, |
| | | si.create_time, |
| | | si.update_time, |
| | | COALESCE(si.warn_num, 0) as warn_num, |
| | | si.version, |
| | | (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity, |
| | | pm.model, |
| | | si.remark, |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | ( |
| | | select IFNULL(SUM(sor.stock_out_num), 0) |
| | | from stock_out_record sor |
| | | where sor.product_model_id = si.product_model_id |
| | | and (si.batch_no is null and sor.batch_no is null or si.batch_no = sor.batch_no) |
| | | and sor.type = '0' |
| | | and sor.approval_status = 0 |
| | | ) as qualifiedPendingOut, |
| | | 0 as unqualifiedPendingOut |
| | | from stock_inventory si |
| | | left join product_model pm on si.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | select |
| | | si.batch_no, |
| | | si.id as qualifiedId, |
| | | null as unQualifiedId, |
| | | si.qualitity as qualifiedQuantity, |
| | | 0 as unQualifiedQuantity, |
| | | COALESCE(si.locked_quantity, 0) as locked_quantity, |
| | | COALESCE(si.locked_quantity, 0) as qualifiedLockedQuantity, |
| | | 0 as unQualifiedLockedQuantity, |
| | | si.product_model_id, |
| | | si.create_time, |
| | | si.update_time, |
| | | COALESCE(si.warn_num, 0) as warn_num, |
| | | si.version, |
| | | (si.qualitity - COALESCE(si.locked_quantity, 0)) as un_locked_quantity, |
| | | pm.model, |
| | | si.remark, |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | ( |
| | | select IFNULL(SUM(sor.stock_out_num), 0) |
| | | from stock_out_record sor |
| | | where sor.product_model_id = si.product_model_id |
| | | and ( |
| | | (si.batch_no is null and sor.batch_no is null) |
| | | or si.batch_no = sor.batch_no |
| | | ) |
| | | and sor.type = '0' |
| | | and sor.approval_status = 0 |
| | | ) as qualifiedPendingOut, |
| | | 0 as unQualifiedPendingOut |
| | | from stock_inventory si |
| | | left join product_model pm on si.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | |
| | | union all |
| | | union all |
| | | |
| | | select |
| | | su.batch_no, |
| | | null as qualifiedId, |
| | | su.id as unQualifiedId, |
| | | 0 as qualifiedQuantity, |
| | | su.qualitity as unQualifiedQuantity, |
| | | COALESCE(su.locked_quantity, 0) as locked_quantity, |
| | | 0 as qualifiedLockedQuantity, |
| | | COALESCE(su.locked_quantity, 0) as unQualifiedLockedQuantity, |
| | | su.product_model_id, |
| | | su.create_time, |
| | | su.update_time, |
| | | 0 as warn_num, |
| | | su.version, |
| | | (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity, |
| | | pm.model, |
| | | su.remark, |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | 0 as qualifiedPendingOut, |
| | | ( |
| | | select IFNULL(SUM(sor.stock_out_num), 0) |
| | | from stock_out_record sor |
| | | where sor.product_model_id = su.product_model_id |
| | | and (su.batch_no is null and sor.batch_no is null or su.batch_no = sor.batch_no) |
| | | and sor.type = '1' |
| | | and sor.approval_status = 0 |
| | | ) as unqualifiedPendingOut |
| | | from stock_uninventory su |
| | | left join product_model pm on su.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | select |
| | | su.batch_no, |
| | | null as qualifiedId, |
| | | su.id as unQualifiedId, |
| | | 0 as qualifiedQuantity, |
| | | su.qualitity as unQualifiedQuantity, |
| | | COALESCE(su.locked_quantity, 0) as locked_quantity, |
| | | 0 as qualifiedLockedQuantity, |
| | | COALESCE(su.locked_quantity, 0) as unQualifiedLockedQuantity, |
| | | su.product_model_id, |
| | | su.create_time, |
| | | su.update_time, |
| | | 0 as warn_num, |
| | | su.version, |
| | | (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity, |
| | | pm.model, |
| | | su.remark, |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | 0 as qualifiedPendingOut, |
| | | ( |
| | | select IFNULL(SUM(sor.stock_out_num), 0) |
| | | from stock_out_record sor |
| | | where sor.product_model_id = su.product_model_id |
| | | and ( |
| | | (su.batch_no is null and sor.batch_no is null) |
| | | or su.batch_no = sor.batch_no |
| | | ) |
| | | and sor.type = '1' |
| | | and sor.approval_status = 0 |
| | | ) as unQualifiedPendingOut |
| | | from stock_uninventory su |
| | | left join product_model pm on su.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | ) as combined |
| | | <where> |
| | | <if test="ew.productName != null and ew.productName !=''"> |
| | |
| | | select distinct p.product_name |
| | | from product p |
| | | left join product_model pm on p.id = pm.product_id |
| | | where p.product_name like concat('%',#{ew.productName},'%') or pm.model like concat('%',#{ew.productName},'%') |
| | | where p.product_name like concat('%',#{ew.productName},'%') |
| | | or pm.model like concat('%',#{ew.productName},'%') |
| | | ) |
| | | </if> |
| | | <if test="ew.topParentProductId != null and ew.topParentProductId > 0"> |
| | | and combined.product_id in (select id from product_tree) |
| | | </if> |
| | | </where> |
| | | group by batch_no, product_model_id, model, unit, product_name, product_id |
| | | group by |
| | | product_model_id, |
| | | model, |
| | | unit, |
| | | product_name, |
| | | product_id |
| | | </select> |
| | | |
| | | <select id="listStockInventoryExportData" resultType="com.ruoyi.stock.execl.StockInventoryExportData"> |
| | |
| | | where si.product_model_id = #{productModelId} |
| | | </select> |
| | | |
| | | <select id="getBatchNoQty" resultType="com.ruoyi.stock.dto.StockInventoryDto"> |
| | | select |
| | | batch_no, |
| | | MAX(qualifiedId) as qualifiedId, |
| | | MAX(unQualifiedId) as unQualifiedId, |
| | | |
| | | SUM(qualifiedQuantity) as qualifiedQuantity, |
| | | SUM(unQualifiedQuantity) as unQualifiedQuantity, |
| | | |
| | | SUM(qualifiedLockedQuantity) as qualifiedLockedQuantity, |
| | | SUM(unQualifiedLockedQuantity) as unQualifiedLockedQuantity, |
| | | |
| | | SUM(IFNULL(qualifiedPendingOut, 0)) as qualifiedPendingOutQuantity, |
| | | SUM(IFNULL(unQualifiedPendingOut, 0)) as unQualifiedPendingOutQuantity, |
| | | |
| | | SUM(qualifiedQuantity - qualifiedLockedQuantity - IFNULL(qualifiedPendingOut, 0)) as qualifiedUnLockedQuantity, |
| | | SUM(unQualifiedQuantity - unQualifiedLockedQuantity - IFNULL(unQualifiedPendingOut, 0)) as unQualifiedUnLockedQuantity, |
| | | |
| | | product_model_id, |
| | | model, |
| | | unit, |
| | | product_name, |
| | | product_id, |
| | | |
| | | MAX(create_time) as create_time, |
| | | MAX(update_time) as update_time, |
| | | MAX(warn_num) as warn_num, |
| | | MAX(version) as version, |
| | | MAX(remark) as remark, |
| | | |
| | | 'combined' as stockType |
| | | from ( |
| | | select |
| | | si.batch_no, |
| | | si.id as qualifiedId, |
| | | null as unQualifiedId, |
| | | |
| | | si.qualitity as qualifiedQuantity, |
| | | 0 as unQualifiedQuantity, |
| | | |
| | | COALESCE(si.locked_quantity, 0) as qualifiedLockedQuantity, |
| | | 0 as unQualifiedLockedQuantity, |
| | | |
| | | si.product_model_id, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | |
| | | si.create_time, |
| | | si.update_time, |
| | | COALESCE(si.warn_num, 0) as warn_num, |
| | | si.version, |
| | | si.remark, |
| | | |
| | | ( |
| | | select IFNULL(SUM(sor.stock_out_num), 0) |
| | | from stock_out_record sor |
| | | where sor.product_model_id = si.product_model_id |
| | | and ( |
| | | (si.batch_no is null and sor.batch_no is null) |
| | | or si.batch_no = sor.batch_no |
| | | ) |
| | | and sor.type = '0' |
| | | and sor.approval_status = 0 |
| | | ) as qualifiedPendingOut, |
| | | |
| | | 0 as unQualifiedPendingOut |
| | | from stock_inventory si |
| | | left join product_model pm on si.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | |
| | | union all |
| | | |
| | | select |
| | | su.batch_no, |
| | | null as qualifiedId, |
| | | su.id as unQualifiedId, |
| | | |
| | | 0 as qualifiedQuantity, |
| | | su.qualitity as unQualifiedQuantity, |
| | | |
| | | 0 as qualifiedLockedQuantity, |
| | | COALESCE(su.locked_quantity, 0) as unQualifiedLockedQuantity, |
| | | |
| | | su.product_model_id, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name, |
| | | p.id as product_id, |
| | | |
| | | su.create_time, |
| | | su.update_time, |
| | | 0 as warn_num, |
| | | su.version, |
| | | su.remark, |
| | | |
| | | 0 as qualifiedPendingOut, |
| | | |
| | | ( |
| | | select IFNULL(SUM(sor.stock_out_num), 0) |
| | | from stock_out_record sor |
| | | where sor.product_model_id = su.product_model_id |
| | | and ( |
| | | (su.batch_no is null and sor.batch_no is null) |
| | | or su.batch_no = sor.batch_no |
| | | ) |
| | | and sor.type = '1' |
| | | and sor.approval_status = 0 |
| | | ) as unQualifiedPendingOut |
| | | from stock_uninventory su |
| | | left join product_model pm on su.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | ) as combined |
| | | <where> |
| | | <if test="ew.productModelId != null and ew.productModelId > 0"> |
| | | and combined.product_model_id = #{ew.productModelId} |
| | | </if> |
| | | |
| | | <if test="ew.productId != null and ew.productId > 0"> |
| | | and combined.product_id = #{ew.productId} |
| | | </if> |
| | | </where> |
| | | group by |
| | | batch_no, |
| | | product_model_id, |
| | | model, |
| | | unit, |
| | | product_name, |
| | | product_id |
| | | order by |
| | | batch_no |
| | | </select> |
| | | |
| | | </mapper> |