Parcourir la source

库存的入库出库代码优化
图稿库的新增功能完成

xiaomi il y a 1 an
Parent
commit
e5ab9bed05

+ 549 - 0
sd-business/src/main/java/com/sd/business/a-json/ArtworkLibraryApi.json

@@ -0,0 +1,549 @@
+{
+  "openapi": "3.0.1",
+  "tags": [
+    {
+      "name": "图稿库"
+    }
+  ],
+  "paths": {
+    "/artworkLibrary/list": {
+      "post": {
+        "summary": "列表",
+        "tags": [
+          "图稿库"
+        ],
+        "requestBody": {
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": null,
+                "required": null,
+                "title": null,
+                "properties": null,
+                "items": null
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "成功",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "required": [
+                    "code",
+                    "success",
+                    "msg",
+                    "data"
+                  ],
+                  "title": null,
+                  "properties": {
+                    "code": {
+                      "type": "Integer",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "success": {
+                      "type": "boolean",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "msg": {
+                      "type": "string",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "data": {
+                      "type": "array",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": {
+                        "type": "object",
+                        "required": null,
+                        "title": null,
+                        "properties": {
+                          "id": {
+                            "type": "integer",
+                            "required": null,
+                            "title": "id",
+                            "properties": null,
+                            "items": null
+                          },
+                          "artworkName": {
+                            "type": "string",
+                            "required": null,
+                            "title": "图稿名称",
+                            "properties": null,
+                            "items": null
+                          },
+                          "artworkUploadUrl": {
+                            "type": "string",
+                            "required": null,
+                            "title": "图稿上传地址",
+                            "properties": null,
+                            "items": null
+                          },
+                          "artworkTepy": {
+                            "type": "integer",
+                            "required": null,
+                            "title": "地址类型(0图片  1文件)",
+                            "properties": null,
+                            "items": null
+                          }
+                        },
+                        "items": null
+                      }
+                    }
+                  },
+                  "items": null
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/artworkLibrary/page": {
+      "post": {
+        "summary": "分页",
+        "tags": [
+          "图稿库"
+        ],
+        "requestBody": {
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "required": [
+                  "pageNum",
+                  "pageSize"
+                ],
+                "title": null,
+                "properties": {
+                  "pageNum": {
+                    "type": "integer",
+                    "required": null,
+                    "title": "页数",
+                    "properties": null,
+                    "items": null
+                  },
+                  "pageSize": {
+                    "type": "integer",
+                    "required": null,
+                    "title": "每页大小",
+                    "properties": null,
+                    "items": null
+                  }
+                },
+                "items": null
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "成功",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "required": [
+                    "code",
+                    "success",
+                    "msg",
+                    "data"
+                  ],
+                  "title": null,
+                  "properties": {
+                    "code": {
+                      "type": "Integer",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "success": {
+                      "type": "boolean",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "msg": {
+                      "type": "string",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "data": {
+                      "type": "object",
+                      "required": [
+                        "rows",
+                        "total"
+                      ],
+                      "title": null,
+                      "properties": {
+                        "rows": {
+                          "type": "array",
+                          "required": null,
+                          "title": "分页数据",
+                          "properties": null,
+                          "items": {
+                            "type": "object",
+                            "required": null,
+                            "title": null,
+                            "properties": {
+                              "id": {
+                                "type": "integer",
+                                "required": null,
+                                "title": "id",
+                                "properties": null,
+                                "items": null
+                              },
+                              "artworkName": {
+                                "type": "string",
+                                "required": null,
+                                "title": "图稿名称",
+                                "properties": null,
+                                "items": null
+                              },
+                              "artworkUploadUrl": {
+                                "type": "string",
+                                "required": null,
+                                "title": "图稿上传地址",
+                                "properties": null,
+                                "items": null
+                              },
+                              "artworkTepy": {
+                                "type": "integer",
+                                "required": null,
+                                "title": "地址类型(0图片  1文件)",
+                                "properties": null,
+                                "items": null
+                              }
+                            },
+                            "items": null
+                          }
+                        },
+                        "total": {
+                          "type": "integer",
+                          "required": null,
+                          "title": "总条数",
+                          "properties": null,
+                          "items": null
+                        }
+                      },
+                      "items": null
+                    }
+                  },
+                  "items": null
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/artworkLibrary/detail": {
+      "post": {
+        "summary": "明细",
+        "tags": [
+          "图稿库"
+        ],
+        "requestBody": {
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "required": [
+                  "id"
+                ],
+                "title": null,
+                "properties": {
+                  "id": {
+                    "type": "integer",
+                    "required": null,
+                    "title": "图稿库id",
+                    "properties": null,
+                    "items": null
+                  }
+                },
+                "items": null
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "成功",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "required": [
+                    "code",
+                    "success",
+                    "msg",
+                    "data"
+                  ],
+                  "title": null,
+                  "properties": {
+                    "code": {
+                      "type": "Integer",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "success": {
+                      "type": "boolean",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "msg": {
+                      "type": "string",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "data": {
+                      "type": "object",
+                      "required": null,
+                      "title": null,
+                      "properties": {
+                        "id": {
+                          "type": "integer",
+                          "required": null,
+                          "title": "id",
+                          "properties": null,
+                          "items": null
+                        },
+                        "artworkName": {
+                          "type": "string",
+                          "required": null,
+                          "title": "图稿名称",
+                          "properties": null,
+                          "items": null
+                        },
+                        "artworkUploadUrl": {
+                          "type": "string",
+                          "required": null,
+                          "title": "图稿上传地址",
+                          "properties": null,
+                          "items": null
+                        },
+                        "artworkTepy": {
+                          "type": "integer",
+                          "required": null,
+                          "title": "地址类型(0图片  1文件)",
+                          "properties": null,
+                          "items": null
+                        }
+                      },
+                      "items": null
+                    }
+                  },
+                  "items": null
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/artworkLibrary/edit": {
+      "post": {
+        "summary": "编辑",
+        "tags": [
+          "图稿库"
+        ],
+        "requestBody": {
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "required": null,
+                "title": null,
+                "properties": {
+                  "id": {
+                    "type": "integer",
+                    "required": null,
+                    "title": "id",
+                    "properties": null,
+                    "items": null
+                  },
+                  "artworkName": {
+                    "type": "string",
+                    "required": null,
+                    "title": "图稿名称",
+                    "properties": null,
+                    "items": null
+                  },
+                  "artworkUploadUrl": {
+                    "type": "string",
+                    "required": null,
+                    "title": "图稿上传地址",
+                    "properties": null,
+                    "items": null
+                  },
+                  "artworkTepy": {
+                    "type": "integer",
+                    "required": null,
+                    "title": "地址类型(0图片  1文件)",
+                    "properties": null,
+                    "items": null
+                  }
+                },
+                "items": null
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "成功",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "required": [
+                    "code",
+                    "success",
+                    "msg",
+                    "data"
+                  ],
+                  "title": null,
+                  "properties": {
+                    "code": {
+                      "type": "Integer",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "success": {
+                      "type": "boolean",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "msg": {
+                      "type": "string",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "data": {
+                      "type": null,
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    }
+                  },
+                  "items": null
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/artworkLibrary/delete": {
+      "post": {
+        "summary": "删除",
+        "tags": [
+          "图稿库"
+        ],
+        "requestBody": {
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "required": [
+                  "id"
+                ],
+                "title": null,
+                "properties": {
+                  "id": {
+                    "type": "integer",
+                    "required": null,
+                    "title": "图稿库id",
+                    "properties": null,
+                    "items": null
+                  }
+                },
+                "items": null
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "成功",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "required": [
+                    "code",
+                    "success",
+                    "msg",
+                    "data"
+                  ],
+                  "title": null,
+                  "properties": {
+                    "code": {
+                      "type": "Integer",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "success": {
+                      "type": "boolean",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "msg": {
+                      "type": "string",
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    },
+                    "data": {
+                      "type": null,
+                      "required": null,
+                      "title": null,
+                      "properties": null,
+                      "items": null
+                    }
+                  },
+                  "items": null
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}

+ 77 - 0
sd-business/src/main/java/com/sd/business/controller/artwork/ArtworkLibraryController.java

@@ -0,0 +1,77 @@
+package com.sd.business.controller.artwork;
+
+import org.springframework.web.bind.annotation.*;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sd.business.entity.artwork.vo.ArtworkLibraryVo;
+import com.sd.business.entity.artwork.dto.ArtworkLibrarySelectDto;
+import com.sd.business.entity.artwork.dto.ArtworkLibraryDto;
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.sd.business.service.artwork.ArtworkLibraryService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 图稿库 前端控制器
+ * </p>
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+@RestController
+@RequestMapping("/artworkLibrary")
+public class ArtworkLibraryController {
+
+    @Autowired
+    private ArtworkLibraryService artworkLibraryService;
+
+    /**
+     * 图稿库列表
+     */
+    @PostMapping("/list")
+    public List<ArtworkLibraryVo> list(@RequestBody ArtworkLibrarySelectDto dto) {
+        return artworkLibraryService.getList(dto);
+    }
+
+    /**
+     * 图稿库分页
+     */
+    @PostMapping("/page")
+    public Page<ArtworkLibraryVo> page(@RequestBody ArtworkLibrarySelectDto dto) {
+        return artworkLibraryService.getPage(dto);
+    }
+
+    /**
+     * 图稿库明细
+     */
+    @PostMapping("/detail")
+    public ArtworkLibraryVo detail(@RequestBody BaseSelectDto dto) {
+        return artworkLibraryService.detail(dto.getId());
+    }
+
+    /**
+     * 图稿库新增
+     */
+    @PostMapping("/add")
+    public void add(@RequestBody List<ArtworkLibraryDto> artworkLibraryDto) {
+        artworkLibraryService.add(artworkLibraryDto);
+    }
+
+    /**
+     * 图稿库编辑
+     */
+    @PostMapping("/edit")
+    public void edit(@RequestBody List<ArtworkLibraryDto> artworkLibraryDto) {
+        artworkLibraryService.edit(artworkLibraryDto);
+    }
+
+    /**
+     * 图稿库删除
+     */
+    @PostMapping("/delete")
+    public void delete(@RequestBody BaseSelectDto dto) {
+        artworkLibraryService.delete(dto.getId());
+    }
+
+}

+ 21 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/dto/ArtworkLibraryDto.java

@@ -0,0 +1,21 @@
+package com.sd.business.entity.artwork.dto;
+
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 图稿库新增编辑入参实体
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+@Getter
+@Setter
+public class ArtworkLibraryDto extends ArtworkLibrary {
+
+    /**
+     * 图库id
+     */
+    private Long artworkId;
+}

+ 17 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/dto/ArtworkLibrarySelectDto.java

@@ -0,0 +1,17 @@
+package com.sd.business.entity.artwork.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 图稿库列表查询入参实体
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+@Getter
+@Setter
+public class ArtworkLibrarySelectDto extends BaseSelectDto {
+
+}

+ 36 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/po/ArtworkLibrary.java

@@ -0,0 +1,36 @@
+package com.sd.business.entity.artwork.po;
+
+import com.ruoyi.common.core.domain.BaseIdPo;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 图稿库
+ * </p>
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+@Getter
+@Setter
+@TableName("artwork_library")
+public class ArtworkLibrary extends BaseIdPo {
+
+    /**
+     * 图稿名称
+     */
+    private String artworkName;
+
+    /**
+     * 图稿上传地址
+     */
+    private String artworkUploadUrl;
+
+    /**
+     * 地址类型(0图片  1文件)
+     */
+    private Long artworkTepy;
+
+}

+ 17 - 0
sd-business/src/main/java/com/sd/business/entity/artwork/vo/ArtworkLibraryVo.java

@@ -0,0 +1,17 @@
+package com.sd.business.entity.artwork.vo;
+
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 图稿库列表查询返回值实体
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+@Getter
+@Setter
+public class ArtworkLibraryVo extends ArtworkLibrary {
+
+}

+ 0 - 5
sd-business/src/main/java/com/sd/business/entity/in/po/InOutStorageDetails.java

@@ -21,11 +21,6 @@ import java.math.BigDecimal;
 public class InOutStorageDetails extends BasePo {
 
     /**
-     * 出入库id
-     */
-    private Long inOutStorageId;
-
-    /**
      * 事业部id
      */
     private Long departmentId;

+ 32 - 0
sd-business/src/main/java/com/sd/business/mapper/artwork/ArtworkLibraryMapper.java

@@ -0,0 +1,32 @@
+package com.sd.business.mapper.artwork;
+
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sd.business.entity.artwork.vo.ArtworkLibraryVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 图稿库 Mapper 接口
+ * </p>
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+public interface ArtworkLibraryMapper extends BaseMapper<ArtworkLibrary> {
+
+    /**
+     * 图稿库列表
+     */
+    List<ArtworkLibraryVo> getList(@Param("ew") IWrapper<ArtworkLibrary> wrapper);
+
+    /**
+     * 图稿库分页
+     */
+    Page<ArtworkLibraryVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<ArtworkLibrary> wrapper);
+
+}

+ 52 - 0
sd-business/src/main/java/com/sd/business/service/artwork/ArtworkLibraryService.java

@@ -0,0 +1,52 @@
+package com.sd.business.service.artwork;
+
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import com.ruoyi.common.core.service.BaseService;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sd.business.entity.artwork.vo.ArtworkLibraryVo;
+import com.sd.business.entity.artwork.dto.ArtworkLibrarySelectDto;
+import com.sd.business.entity.artwork.dto.ArtworkLibraryDto;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 图稿库 服务类
+ * </p>
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+public interface ArtworkLibraryService extends BaseService<ArtworkLibrary> {
+
+    /**
+     * 图稿库列表
+     */
+    List<ArtworkLibraryVo> getList(ArtworkLibrarySelectDto dto);
+
+    /**
+     * 图稿库分页
+     */
+    Page<ArtworkLibraryVo> getPage(ArtworkLibrarySelectDto dto);
+
+    /**
+     * 图稿库明细
+     */
+    ArtworkLibraryVo detail(Long id);
+
+    /**
+     * 图稿库新增
+     */
+    void add(List<ArtworkLibraryDto> artworkLibraryDto);
+
+    /**
+     * 图稿库编辑
+     */
+    void edit(List<ArtworkLibraryDto> artworkLibraryDto);
+
+    /**
+     * 图稿库删除
+     */
+    void delete(Long id);
+
+}

+ 109 - 0
sd-business/src/main/java/com/sd/business/service/artwork/impl/ArtworkLibraryServiceImpl.java

@@ -0,0 +1,109 @@
+package com.sd.business.service.artwork.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.ruoyi.common.utils.StringUtils;
+import com.sd.business.entity.artwork.po.ArtworkLibrary;
+import com.sd.business.mapper.artwork.ArtworkLibraryMapper;
+import com.sd.business.service.artwork.ArtworkLibraryService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sd.business.entity.artwork.vo.ArtworkLibraryVo;
+import com.sd.business.entity.artwork.dto.ArtworkLibrarySelectDto;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.sd.business.entity.artwork.dto.ArtworkLibraryDto;
+import cn.hutool.core.bean.BeanUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 图稿库 服务实现类
+ * </p>
+ *
+ * @author dk
+ * @since 2023-08-01
+ */
+@Service
+public class ArtworkLibraryServiceImpl extends ServiceImpl<ArtworkLibraryMapper, ArtworkLibrary> implements ArtworkLibraryService {
+
+    @Override
+    public List<ArtworkLibraryVo> getList(ArtworkLibrarySelectDto dto) {
+        IWrapper<ArtworkLibrary> wrapper = getWrapper();
+        wrapper.orderByDesc("al", ArtworkLibrary::getId);
+        List<ArtworkLibraryVo> list = this.baseMapper.getList(wrapper);
+        return list;
+    }
+
+    @Override
+    public Page<ArtworkLibraryVo> getPage(ArtworkLibrarySelectDto dto) {
+        IWrapper<ArtworkLibrary> wrapper = getWrapper();
+        wrapper.orderByDesc("al", ArtworkLibrary::getId);
+        Page<ArtworkLibraryVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        return page;
+    }
+
+    /**
+     * 删除图稿
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public ArtworkLibraryVo detail(Long id) {
+        ArtworkLibrary ArtworkLibrary = this.getById(id);
+        ArtworkLibraryVo result = BeanUtil.toBean(ArtworkLibrary, ArtworkLibraryVo.class);
+        return result;
+    }
+
+    /**
+     * 新增图稿
+     *
+     * @param artworkLibraryDto
+     */
+    @Override
+    public void add(List<ArtworkLibraryDto> artworkLibraryDto) {
+        ArrayList<ArtworkLibrary> artworkList = new ArrayList<>();
+        for (ArtworkLibraryDto dto : artworkLibraryDto) {
+            ArtworkLibrary artworkLibrary = new ArtworkLibrary();
+            if (StringUtils.containsAny(dto.getArtworkUploadUrl(), ".ez3")) {
+                artworkLibrary.setArtworkName(dto.getArtworkName());
+                artworkLibrary.setArtworkUploadUrl(dto.getArtworkUploadUrl());
+                artworkLibrary.setId(dto.getArtworkId());
+                artworkLibrary.setArtworkTepy(1L);
+            } else {
+                artworkLibrary.setArtworkName(dto.getArtworkName());
+                artworkLibrary.setArtworkUploadUrl(dto.getArtworkUploadUrl());
+                artworkLibrary.setId(dto.getArtworkId());
+                artworkLibrary.setArtworkTepy(0L);
+            }
+            artworkList.add(artworkLibrary);
+        }
+        this.saveBatch(artworkList);
+    }
+
+    /**
+     * 修改图稿
+     *
+     * @param artworkLibraryDto
+     */
+    @Override
+    public void edit(List<ArtworkLibraryDto> artworkLibraryDto) {
+        ArrayList<ArtworkLibrary> artworkList = new ArrayList<>();
+        for (ArtworkLibraryDto dto : artworkLibraryDto) {
+            ArtworkLibrary artworkLibrary = new ArtworkLibrary();
+            artworkLibrary.setArtworkName(dto.getArtworkName());
+            artworkLibrary.setArtworkUploadUrl(dto.getArtworkUploadUrl());
+            artworkLibrary.setId(dto.getArtworkId());
+            artworkList.add(artworkLibrary);
+        }
+        this.updateBatchById(artworkList);
+    }
+
+    @Override
+    public void delete(Long id) {
+        this.removeById(id);
+    }
+
+}

+ 0 - 4
sd-business/src/main/java/com/sd/business/service/in/impl/InOutStorageServiceImpl.java

@@ -103,16 +103,12 @@ public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InO
                 //创建InOutStorageDetails对象
                 InOutStorageDetails details = new InOutStorageDetails();
                 //将数据进行填充
-                details.setInOutStorageId(bom.getInOutStorageId());
                 details.setInUnitPrice(UNITPRICE);
                 details.setQuantity(bom.getQuantity());
                 details.setWarehouseId(inOutStorageDto.getWarehouseId());
                 details.setBomSpecId(bom.getBomSpecId());
                 details.setDepartmentId(inOutStorageDto.getDepartmentId());
 
-                //计算入库金额
-                BigDecimal sumPrice = UNITPRICE.multiply(bom.getQuantity());
-                details.setInSumPrice(sumPrice);
                 detailsList.add(details);
             }
         }

+ 29 - 51
sd-business/src/main/java/com/sd/business/service/inventory/impl/InventoryServiceImpl.java

@@ -11,6 +11,7 @@ import com.sd.business.entity.in.po.InOutStorageDetails;
 import com.sd.business.entity.inventory.bo.InOutFun;
 import com.sd.business.entity.inventory.dto.InventorySelectDto;
 import com.sd.business.entity.inventory.dto.QuantityByWarehouseDto;
+import com.sd.business.entity.inventory.po.BalancePriceNum;
 import com.sd.business.entity.inventory.po.Inventory;
 import com.sd.business.entity.inventory.po.InventoryBackup;
 import com.sd.business.entity.inventory.vo.InventoryVo;
@@ -28,6 +29,7 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
@@ -75,8 +77,6 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
         Page<InventoryVo> page = this.baseMapper.getPage(dto.getPage(), wrapper, tableName);
         return page;
     }
-
-
     @Override
     public List<QuantityByWarehouseVo> getQuantityByWarehouse(QuantityByWarehouseDto dto) {
         return baseMapper.getQuantityByWarehouse(dto);
@@ -112,25 +112,26 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
                     inventoryList.add(inventory);
                     map.put(bomSpecId, inventory);
                 }
-                List<InOutStorageDetails> detailsList = getInOutStorageDetailsMap(warehouseId, bomSpecIdList);
-                if (CollUtil.isEmpty(detailsList)){
-                    for (InOutStorageDetails details : detailsList) {
-                        details.setInSumPrice(BigDecimal.ZERO);
-                        details.setQuantity(BigDecimal.ZERO);
-                    }
-                }
-                BigDecimal sumPrice = detailsList.stream().map(InOutStorageDetails::getInSumPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-                BigDecimal sumQuantity = detailsList.stream().map(InOutStorageDetails::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
+                Map<Long, List<InOutStorageDetails>> inOutStorageDetailsMap = getInOutStorageDetailsMap(warehouseId, bomSpecIdList);
+
+                //获取结存数量
+                BigDecimal sumQuantity = inOutStorageDetailsMap.getOrDefault(inOutFun.getBomSpecId(), Collections.emptyList())
+                        .stream().map(InOutStorageDetails::getQuantity)
+                        .filter(item -> item.compareTo(BigDecimal.ZERO) > 0)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+                BigDecimal sumPrice = inOutStorageDetailsMap.getOrDefault(inOutFun.getBomSpecId(), Collections.emptyList()).stream()
+                        .filter(item -> item.getQuantity().compareTo(BigDecimal.ZERO) > 0)
+                        .map(item -> item.getQuantity().multiply(item.getInUnitPrice()))
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
 
                 // 计算最新的结存数量和结存金额
                 sumQuantity = sumQuantity.add(quantity);
-
                 BigDecimal balancep = quantity.multiply(unitPrice);
                 sumPrice = sumPrice.add(balancep);
                 BigDecimal balanceUnitPrice = sumPrice.divide(sumQuantity, 2, BigDecimal.ROUND_HALF_UP);
                 inventory.setBalanceUnitPrice(balanceUnitPrice);
             }
-
             saveOrUpdateBatch(inventoryList);
         }
     }
@@ -138,7 +139,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
     @Override
     public void out(Long departmentId, Long warehouseId, List<? extends InOutFun> list) {
 
-        //存储一条数据出库的数量,可以改变
+        //存储一条数据出库的数量,可以改变
         Map<Long, BigDecimal> map = list.stream()
                 .collect(Collectors.toMap(InOutFun::getBomSpecId, InOutFun::getQuantity));
 
@@ -167,8 +168,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
                     throw new ServiceException("出库失败,品名为:" + bomSpec.getName() + "的bom库存不足");
                 }
 
-                List<InOutStorageDetails> outStorageDetails = inOutStorageDetailsMap.get(bomSpecId);
-
+                List<InOutStorageDetails> outStorageDetails = inOutStorageDetailsMap.getOrDefault(bomSpecId, Collections.emptyList());
                 // 循环次数
                 int j = 0;
 
@@ -176,27 +176,26 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
                 BigDecimal quantity = map.get(bomSpecId);
 
                 do {
-
                     if (outStorageDetails.size() == j) {
-                        throw new ServiceException("数据异常,无法计算库存单价");
+                        throw new ServiceException("数据异常,无法计算库存单价!!");
                     }
-
                     // 获取这条记录剩余的数量
                     InOutStorageDetails inOutStorageDetails = outStorageDetails.get(j);
 
                     // 单条可出库数量
                     BigDecimal tempQuantity = inOutStorageDetails.getQuantity();
 
-                    if (tempQuantity.compareTo(quantity) >= 0) {
+                    if (tempQuantity.compareTo(quantity) > 0) {
                         inOutStorageDetails.setQuantity(tempQuantity.subtract(quantity));
                         quantity = BigDecimal.ZERO;
+                    } else if (tempQuantity.compareTo(quantity) < 0) {
+                        inOutStorageDetails.setQuantity(BigDecimal.ZERO);
+                        quantity = tempQuantity.subtract(quantity).abs();
                     } else {
                         inOutStorageDetails.setQuantity(BigDecimal.ZERO);
-                        quantity = tempQuantity.subtract(quantity);
+                        quantity = BigDecimal.ZERO;
                     }
-
                     updateList.add(inOutStorageDetails);
-
                     j++;
 
                 } while (quantity.compareTo(BigDecimal.ZERO) > 0);
@@ -213,11 +212,16 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
                         .map(item -> item.getQuantity().multiply(item.getInUnitPrice()))
                         .reduce(BigDecimal.ZERO, BigDecimal::add);
 
+                BigDecimal balanceUnitPrice;
                 // 结存单价
-                BigDecimal balanceUnitPrice = totalInventoryAmount.divide(totalInventory, 2, RoundingMode.HALF_UP);
-
+                if (totalInventory.compareTo(BigDecimal.ZERO) == 0) {
+                    balanceUnitPrice = BigDecimal.ZERO;
+                } else {
+                    balanceUnitPrice = totalInventoryAmount.divide(totalInventory, 2, RoundingMode.HALF_UP);
+                }
                 // 赋值结存单价
                 inventory.setBalanceUnitPrice(balanceUnitPrice);
+                inventory.setQuantity(totalInventory);
             }
 
             // 修改计算结存单价的出入库明细表
@@ -225,32 +229,8 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
 
             // 修改库存数量以及结存单价
             updateBatchById(inventoryList);
-
         }
-
     }
-
-    //将出库金额添加到map
-    private void addOutPriceMap(Map<Long, BigDecimal> outPriceMap, Map<Long, BigDecimal> map, InOutStorageDetails details) {
-
-        BigDecimal mapQuantity = map.get(details.getBomSpecId());
-        BigDecimal multiply;
-
-        //如果出库数量大于库存记录数量
-        if (mapQuantity.compareTo(details.getQuantity()) > 0) {
-            multiply = details.getQuantity().multiply(details.getInUnitPrice());
-        } else {
-            multiply = mapQuantity.multiply(details.getInUnitPrice());
-        }
-        if (outPriceMap.containsKey(details.getBomSpecId())) {
-            BigDecimal naxtPrice = outPriceMap.get(details.getBomSpecId());
-            BigDecimal addPrice = naxtPrice.add(multiply);
-            outPriceMap.put(details.getBomSpecId(), addPrice);
-        } else {
-            outPriceMap.put(details.getBomSpecId(), multiply);
-        }
-    }
-
     private List<Inventory> getInventoryList(Long departmentId, Long warehouseId, List<Long> bomSpecIdList) {
         return list(q -> q
                 .eq(Inventory::getDepartmentId, departmentId)
@@ -258,14 +238,12 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
                 .in(Inventory::getBomSpecId, bomSpecIdList)
         );
     }
-
     private Map<Long, List<InOutStorageDetails>> getInOutStorageDetailsMap(Long warehouseId, List<Long> bomSpecIdList) {
         List<InOutStorageDetails> list = inOutStorageDetailsService.list(q -> q
                 .eq(InOutStorageDetails::getWarehouseId, warehouseId)
                 .in(InOutStorageDetails::getBomSpecId, bomSpecIdList)
                 .gt(InOutStorageDetails::getQuantity, BigDecimal.ZERO)
         );
-
         return list.stream().collect(Collectors.groupingBy(InOutStorageDetails::getBomSpecId));
     }
 

+ 24 - 0
sd-business/src/main/resources/mapper/artwork/ArtworkLibraryMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sd.business.mapper.artwork.ArtworkLibraryMapper">
+    <select id="getList" resultType="com.sd.business.entity.artwork.vo.ArtworkLibraryVo">
+        select
+            al.id,
+            al.artwork_name,
+            al.artwork_upload_url,
+            al.artwork_tepy
+        from artwork_library al
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="getPage" resultType="com.sd.business.entity.artwork.vo.ArtworkLibraryVo">
+        select
+            al.id,
+            al.artwork_name,
+            al.artwork_upload_url,
+            al.artwork_tepy
+        from artwork_library al
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>