hfxc226 3 vuotta sitten
vanhempi
commit
4a09479fe6

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/dto/sqarepartmanage/SparePartInfoDTO.java

@@ -31,6 +31,10 @@ public class SparePartInfoDTO extends BaseDTO implements Serializable {
      * 指标参数
      */
     private String params;
+    /**
+     * 预警状态:1:待处理,2询价中,3采购中,4已结束
+     */
+    private Integer warnStatus;
     /**
    * 主键
    */

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/dto/store/OutStoreDetailDTO.java

@@ -57,7 +57,7 @@ public class OutStoreDetailDTO extends BaseDTO implements Serializable {
      */
     private String outNo;
     /**
-     * 库仓库id
+     * 库仓库id
      */
     private String storeId;
     /**

+ 14 - 0
platform-dao/src/main/java/com/platform/dao/dto/store/SpareStoreDTO.java

@@ -82,6 +82,10 @@ public class SpareStoreDTO extends BaseDTO implements Serializable {
      * 备件id
      */
     private String spareId;
+    /**
+     * 备件名称
+     */
+    private String spareName;
     /**
      * 仓库id
      */
@@ -109,6 +113,16 @@ public class SpareStoreDTO extends BaseDTO implements Serializable {
      * 数量
      */
     private BigDecimal num;
+    /**
+     * 查找小雨最低库存
+     */
+    @Transient
+    private Boolean minStock;
+    /**
+     * 查找大于最高库存
+     */
+    @Transient
+    private Boolean maxStock;
     /**
      * 排序
      */

+ 10 - 6
platform-dao/src/main/java/com/platform/dao/entity/sqarepartmanage/SparePartInfo.java

@@ -25,13 +25,17 @@ import javax.persistence.Transient;
 @Table(name = "t_spare_part_info")
 @Data
 @Accessors(chain = true)
-public class SparePartInfo implements Serializable{
+public class SparePartInfo implements Serializable {
 
     /**
      * 主键
      */
-        @Id
+    @Id
     private String id;
+    /**
+     * 预警状态:1:待处理,2询价中,3采购中,4已结束
+     */
+    private Integer warnStatus;
     /**
      * 备件编码
      */
@@ -206,7 +210,7 @@ public class SparePartInfo implements Serializable{
      * 当前库存
      */
     @Transient
-    private BigDecimal  currentStock;
+    private BigDecimal currentStock;
     /**
      * 生产商
      */
@@ -253,9 +257,9 @@ public class SparePartInfo implements Serializable{
      */
     private Integer yt;
 
-   /**
-    * 数据权限
-    */
+    /**
+     * 数据权限
+     */
     @Transient
     private DataScope dataScope;
 

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/entity/store/Store.java

@@ -65,7 +65,7 @@ public class Store implements Serializable{
      */
     private String name;
     /**
-     * 类型: 1-厂区 2-生产线
+     * 类型: 1- 2-生产线
      */
     private Integer type;
     /**

+ 5 - 0
platform-dao/src/main/java/com/platform/dao/mapper/store/SpareStoreMapper.java

@@ -39,6 +39,11 @@ public interface SpareStoreMapper extends MyMapper<SpareStore> {
      */
     Integer selectCurrentStock(@Param("id") Object id);
 
+    /**
+     * 备件仓库库存汇总
+     * @param record
+     * @return
+     */
     List<SpareStoreVO> selectTotalStock(SpareStoreDTO record);
 
     /**

+ 15 - 10
platform-dao/src/main/java/com/platform/dao/vo/export/sb/ExportSbInfoVO.java

@@ -12,8 +12,8 @@ import java.time.LocalDateTime;
 /**
  * @Description 设备基础信息导出VO
  * @Author liuyu
- * @Date 2020-04-21 21:05:46
- * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
+ * @Date 2021-04-21 21:05:46
+ * @Version Copyright (c) 2021,北京乾元坤和科技有限公司 All rights reserved.
  */
 @Data
 @Accessors(chain = true)
@@ -88,7 +88,7 @@ public class ExportSbInfoVO implements Serializable {
     /**
      * 使用施工组名称
      */
-    @Excel(name = "使用机台", orderNum = "14")
+    @Excel(name = "使用机台/使用人", orderNum = "14")
     private String saveUserName;
     /**
      * 维修人
@@ -134,32 +134,37 @@ public class ExportSbInfoVO implements Serializable {
     /**
      * 存放位置
      */
-    @Excel(name = "财务编码1", orderNum = "23")
+    @Excel(name = "存放位置", orderNum = "23")
     private String positionName;
     /**
      * 财务编码/固定资产编号
      */
-    @Excel(name = "财务编码2", orderNum = "24")
+    @Excel(name = "财务编码1", orderNum = "24")
+    private String financingNo;
+    /**
+     * 财务编码/固定资产编号
+     */
+    @Excel(name = "财务编码2", orderNum = "25")
     private String financingNoTwo;
     /**
      * 财务编码/固定资产编号
      */
-    @Excel(name = "财务编码3", orderNum = "25")
+    @Excel(name = "财务编码3", orderNum = "26")
     private String financingNoThird;
     /**
      * 财务编码/固定资产编号
      */
-    @Excel(name = "财务编码4", orderNum = "26")
+    @Excel(name = "财务编码4", orderNum = "27")
     private String financingNoFour;
     /**
-     * 财务编码/固定资产编号
+     * 财务编码5
      */
-    @Excel(name = "财务编码5", orderNum = "27")
+    @Excel(name = "财务编码5", orderNum = "28")
     private String financingNoFive;
     /**
      * 自定义参数
      */
-    @Excel(name = "财务编码5", orderNum = "28")
+    @Excel(name = "自定义参数", orderNum = "29")
     private String paramList;
 
 }

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/sparepartmanage/SparePartInfoVO.java

@@ -31,6 +31,10 @@ public class SparePartInfoVO extends BaseVO implements Serializable {
      * 指标参数
      */
     private String params;
+    /**
+     * 预警状态:1:待处理,2询价中,3采购中,4已结束
+     */
+    private Integer warnStatus;
     /**
      * 使用周期:月
      */

+ 8 - 1
platform-dao/src/main/java/com/platform/dao/vo/query/store/SpareStoreVO.java

@@ -82,7 +82,14 @@ public class SpareStoreVO extends BaseVO implements Serializable {
      * 数量
      */
     private BigDecimal num;
-
+    /**
+     * 最低库存
+     */
+    private BigDecimal minStock;
+    /**
+     * 最高库存
+     */
+    private BigDecimal maxStock;
     /**
      * 库存数量
      */

+ 10 - 2
platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartInfoMapper.xml

@@ -23,6 +23,7 @@
         <result column="producer_id" jdbcType="VARCHAR" property="producerId"/>
         <result column="supplier_id" jdbcType="VARCHAR" property="supplierId"/>
         <result column="unit" jdbcType="SMALLINT" property="unit"/>
+        <result column="warn_status" jdbcType="SMALLINT" property="warnStatus"/>
         <result column="unit_bz" jdbcType="SMALLINT" property="unitBz"/>
         <result column="unit_rate" jdbcType="DOUBLE" property="unitRate"/>
         <result column="max_stock" jdbcType="DOUBLE" property="maxStock"/>
@@ -56,6 +57,7 @@
     purchase_period,
     use_period,
     unit_bz,
+warn_status,
     unit_rate,
     image,
     qr_code,
@@ -99,6 +101,9 @@
             <if test="name != null and name != ''">
                 AND info.name = #{name}
             </if>
+            <if test="warnStatus != null and warnStatus != ''">
+                AND info.warn_status = #{warnStatus}
+            </if>
             <if test="ggxh != null and ggxh != ''">
                 AND info.ggxh like concat('%',#{ggxh},'%')
             </if>
@@ -159,7 +164,7 @@
         select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
         spare.initial_value, spare.producer_id,
         spare.unit,
-        spare.unit_bz,
+        spare.unit_bz,spare.warn_status,
         spare.unit_rate,
         spare.image,
         spare.qr_code,
@@ -185,7 +190,7 @@
         select spare.id as spareId, spare.no, spare.unite_no, spare.name, spare.type_id, spare.level,
                spare.initial_value, spare.producer_id,
                spare.unit,
-               spare.unit_bz,
+               spare.unit_bz,spare.warn_status
                spare.unit_rate,
                spare.image,
                spare.qr_code,
@@ -236,6 +241,9 @@
                 <if test="item.middleNo != null">
                     middle_no = #{item.middleNo},
                 </if>
+                <if test="item.warnStatus != null">
+                    warn_status = #{item.warnStatus},
+                </if>
                 <if test="item.unit != null">
                     child_no = #{item.childNo},
                 </if>

+ 14 - 2
platform-dao/src/main/resources/mapper/store/SpareStoreMapper.xml

@@ -107,6 +107,8 @@
         info.NO,
         info.NAME,
         info.unit,
+        info.min_stock,
+        info.max_stock,
         info.init_no AS initNo,
         info.ggxh,
         info.initial_value as price,
@@ -135,6 +137,12 @@
         sparestore.spare_id
         )
         FIRST ON info.id = FIRST.spare_id
+        <if test="minStock != null">
+            and info.min_stock  > FIRST.totalStock
+        </if>
+        <if test="maxStock != null">
+            and FIRST.totalStock > info.max_stock
+        </if>
     </select>
 
     <select id="selectList" parameterType="com.platform.dao.dto.store.SpareStoreDTO"
@@ -153,6 +161,7 @@
                 and (
                        spareinfo.name like concat('%',#{keyword},'%')
                     or spareinfo.no like concat('%',#{keyword},'%')
+                    or spareinfo.ggxh like concat('%',#{keyword},'%')
                 )
             </if>
             <if test="typeId != null and typeId != ''">
@@ -167,11 +176,14 @@
             <if test="childTypeId != null and childTypeId != ''">
                 and spareinfo.child_type_id = #{childTypeId}
             </if>
+            <if test="spareName != null and spareName != ''">
+                and spareinfo.name like concat('%',#{spareName},'%')
+            </if>
             <if test="ggxh != null and ggxh != ''">
-                and spareinfo.ggxh = #{ggxh}
+                and spareinfo.ggxh like concat('%',#{ggxh},'%')
             </if>
             <if test="initNo != null and initNo != ''">
-                and spareinfo.init_no = #{initNo}
+                and spareinfo.init_no like concat('%',#{initNo},'%')
             </if>
             <if test="typeNameLike != null and typeNameLike != ''">
                 and spareType.name like concat('%',#{typeNameLike},'%')

+ 2 - 2
platform-service/src/main/java/com/platform/service/store/OutStoreFormService.java

@@ -52,11 +52,11 @@ public interface OutStoreFormService extends IBaseService<OutStoreForm, OutStore
      */
     OutStoreFormVO getDetail(Object id);
 
-    public void updateModelByDTO(OutStoreFormDTO model) ;
+    void updateModelByDTO(OutStoreFormDTO model) ;
 
     OutStoreForm saveModelByPickForm(SparePickFormDTO sparePickFormDTO, List<SparePickDetailVO> pickDetailList);
 
-    public void updateStore(String outStoreFormId);
+    void updateStore(String outStoreFormId);
 
     void saveModelByDTOImp(OutStoreFormDTO form);
 

+ 76 - 56
platform-service/src/main/java/com/platform/service/store/impl/InStoreFormServiceImpl.java

@@ -37,6 +37,7 @@ import com.platform.service.event.WorkplaceBacklogEvent;
 import com.platform.service.store.InStoreFormService;
 import com.platform.service.store.StoreService;
 import lombok.AllArgsConstructor;
+import org.springframework.boot.autoconfigure.session.StoreType;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -62,6 +63,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
     private SpareStoreMapper spareStoreMapper;
     private StoreService storeService;
     private SpareBackFormMapper spareBackFormMapper;
+
     @Override
     public int batchDelete(List<String> ids) {
         //Weekend<OutStoreForm> weekend = new Weekend<>(OutStoreForm.class);
@@ -92,7 +94,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         BeanConverterUtil.copyObjectProperties(inStoreForm, inStoreFormVO);
         // 查询入库详情列表
         Store store = storeService.getModelById(inStoreFormVO.getStoreId());
-        if(store == null){
+        if (store == null) {
             throw new BusinessException("仓库已经删除,无法查询;");
         }
         inStoreFormVO.setStoreName(store.getName());
@@ -102,6 +104,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
     /**
      * 只有未入库状态才可以删除,不需要回滚
+     *
      * @param id :
      * @return
      */
@@ -109,14 +112,14 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
     @Transactional(rollbackFor = Exception.class)
     public boolean cascadingDeleteByKey(String id) {
         InStoreForm form = mapper.selectByPrimaryKey(id);
-        if( form.getStatus()!=null && (form.getStatus().intValue() == InStoreStatusEnum.EXECUTING.getValue())){
+        if (form.getStatus() != null && (form.getStatus().intValue() == InStoreStatusEnum.EXECUTING.getValue())) {
             throw new BusinessException("已入库的不可以删除,入库单id:" + form.getId());
         }
         // 刪除入库单
         int result = mapper.deleteByPrimaryKey(id);
         UserInfo userInfo = SecurityUtils.getUserInfo();
         // 刪除详情,更新详情涉及的库存
-        if(result == 1){
+        if (result == 1) {
             Weekend<InStoreDetail> detailWeekend = new Weekend<>(InStoreDetail.class);
             detailWeekend.weekendCriteria().andEqualTo(InStoreDetail::getInId, id);
             List<InStoreDetail> detailList = detailMapper.selectByExample(detailWeekend);
@@ -124,25 +127,25 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
             // 批量更新仓库库存
             /**detailList.forEach(detail -> {
-                Weekend<SpareStore> spareStoreWeekend = new Weekend<>(SpareStore.class);
-                spareStoreWeekend.weekendCriteria().andEqualTo(SpareStore::getSpareId, detail.getSpareId())
-                        .andEqualTo(SpareStore::getStoreId, detail.getStoreId());
-                SpareStore spareStore = spareStoreMapper.selectOneByExample(spareStoreWeekend);
-                if (ObjectUtil.isNull(spareStore)) {
-                    throw new BusinessException("找不到对应仓库,请检查仓库是否存在!,仓库id:" + detail.getStoreId());
-                } else {
-                    if (spareStore.getNum() ==null) {
-                        spareStore.setNum(detail.getNum());
-                    }else{
-                        spareStore.setNum(BigDecimalUtil.add(spareStore.getNum(),detail.getNum()));
-                    }
-                    spareStore.setUpdateTime(LocalDateTime.now());
-                    spareStore.setUpdateUserId(userInfo.getUserId());
-                    spareStore.setUpdateUserName(userInfo.getRealName());
-                    //storeList.add(spareStore);
-                    spareStoreMapper.updateByPrimaryKeySelective(spareStore);
-                }
-            });**/
+             Weekend<SpareStore> spareStoreWeekend = new Weekend<>(SpareStore.class);
+             spareStoreWeekend.weekendCriteria().andEqualTo(SpareStore::getSpareId, detail.getSpareId())
+             .andEqualTo(SpareStore::getStoreId, detail.getStoreId());
+             SpareStore spareStore = spareStoreMapper.selectOneByExample(spareStoreWeekend);
+             if (ObjectUtil.isNull(spareStore)) {
+             throw new BusinessException("找不到对应仓库,请检查仓库是否存在!,仓库id:" + detail.getStoreId());
+             } else {
+             if (spareStore.getNum() ==null) {
+             spareStore.setNum(detail.getNum());
+             }else{
+             spareStore.setNum(BigDecimalUtil.add(spareStore.getNum(),detail.getNum()));
+             }
+             spareStore.setUpdateTime(LocalDateTime.now());
+             spareStore.setUpdateUserId(userInfo.getUserId());
+             spareStore.setUpdateUserName(userInfo.getRealName());
+             //storeList.add(spareStore);
+             spareStoreMapper.updateByPrimaryKeySelective(spareStore);
+             }
+             });**/
 
             // 批量删除入库详情
             List<String> ids = detailList.stream().map(InStoreDetail::getId).collect(Collectors.toList());
@@ -172,6 +175,13 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
     @Override
     public InStoreForm saveModelByDTO(InStoreFormDTO model) {
+        Store store = storeService.getModelById(model.getStoreId());
+        if (store == null) {
+            throw new BusinessException("仓库不存在, storeId:" + model.getStoreId() );
+        }
+        if (store.getLevel().equals(StoreLevelEnum.ZONGCANG)){
+            throw new BusinessException("请选择库位");
+        }
         UserInfo userInfo = SecurityUtils.getUserInfo();
         model.setUserInfo(userInfo);
         Weekend<InStoreForm> weekend = new Weekend<>(InStoreForm.class);
@@ -184,7 +194,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         List<InStoreDetailDTO> detailList = model.getDetailList();
         BigDecimal totalPrice = new BigDecimal(0);
         // 插入
-        for(InStoreDetailDTO detail:detailList) {
+        for (InStoreDetailDTO detail : detailList) {
             detail.setUserInfo(userInfo);
             detail.setType(inStoreForm.getType());
             detail.setInId(inStoreForm.getId());
@@ -202,7 +212,8 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
                 storeDetail.setUpdateUserId(userInfo.getUserId());
                 detailMapper.updateByPrimaryKeySelective(storeDetail);
             }
-        };
+        }
+        ;
         inStoreForm.setTotalPrice(totalPrice);
         mapper.updateByPrimaryKey(inStoreForm);
         return inStoreForm;
@@ -219,7 +230,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         List<InStoreDetailDTO> detailList = model.getDetailList();
         BigDecimal totalPrice = new BigDecimal(0);
         // 插入
-        for(InStoreDetailDTO detail:detailList) {
+        for (InStoreDetailDTO detail : detailList) {
             model.setCreatedUserId("1");
             detail.setType(inStoreForm.getType());
             detail.setInId(inStoreForm.getId());
@@ -237,7 +248,8 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
                 storeDetail.setUpdateUserId(userInfo.getUserId());
                 detailMapper.updateByPrimaryKeySelective(storeDetail);
             }
-        };
+        }
+        ;
         // 更新库存
         updateStore(inStoreForm.getId());
         return inStoreForm;
@@ -245,6 +257,13 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
     @Override
     public void updateModelByDTO(InStoreFormDTO model) {
+        Store store = storeService.getModelById(model.getStoreId());
+        if (store == null) {
+            throw new BusinessException("仓库不存在, storeId:" + model.getStoreId() );
+        }
+        if (store.getLevel().equals(StoreLevelEnum.ZONGCANG)) {
+            throw new BusinessException("请选择库位");
+        }
         // 更新
         super.modModelByDTO(model);
         // 入库单详情
@@ -253,7 +272,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         // 先删后插,前端删除的不存在与ids里面,说明被删掉了,需要删除
         Weekend<InStoreDetail> detailWeekend = new Weekend<>(InStoreDetail.class);
         List<String> ids = detailList.stream().map(InStoreDetailDTO::getId).collect(Collectors.toList());
-        detailWeekend.weekendCriteria().andNotIn(InStoreDetail::getId, ids).andEqualTo(InStoreDetail::getInId,model.getId());
+        detailWeekend.weekendCriteria().andNotIn(InStoreDetail::getId, ids).andEqualTo(InStoreDetail::getInId, model.getId());
         // List<InStoreDetail> delDetailList = detailMapper.selectByExample(detailWeekend);
         detailMapper.deleteByExample(detailWeekend);
         BigDecimal totalPrice = new BigDecimal(0);
@@ -261,9 +280,9 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         List<InStoreDetail> updateDetailList = new ArrayList<InStoreDetail>();
         List<InStoreDetail> addDetailList = new ArrayList<InStoreDetail>();
 
-        for(InStoreDetailDTO detail:detailList) {
+        for (InStoreDetailDTO detail : detailList) {
             InStoreDetail realDetail = detailMapper.selectByPrimaryKey(detail.getId());
-            if(ObjectUtil.isNull(realDetail)){
+            if (ObjectUtil.isNull(realDetail)) {
                 detail.setUserInfo(userInfo);
                 detail.setInId(model.getId());
                 detail.setStoreId(model.getStoreId());
@@ -273,18 +292,19 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
                 BeanConverterUtil.copyObjectProperties(detail, storeDetail);
                 storeDetail.setId(IdGeneratorUtils.getObjectId());
                 addDetailList.add(storeDetail);
-            }else{
+            } else {
                 totalPrice = totalPrice.add(detail.getTotalPrice());
                 InStoreDetail storeDetail = new InStoreDetail();
                 BeanConverterUtil.copyObjectProperties(detail, storeDetail);
                 updateDetailList.add(storeDetail);
             }
-        };
+        }
+        ;
 
-        if(!CollectionUtils.isEmpty(addDetailList)){
+        if (!CollectionUtils.isEmpty(addDetailList)) {
             detailMapper.insertListforComplex(addDetailList);
         }
-        if(!CollectionUtils.isEmpty(updateDetailList)){
+        if (!CollectionUtils.isEmpty(updateDetailList)) {
             detailMapper.updateBatch(updateDetailList);
         }
 
@@ -295,7 +315,6 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
     }
 
     /**
-     *
      * @param dto
      * @param dispatchOrderList
      * @return
@@ -322,10 +341,10 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         model.setPurchaseId(dto.getPurchaseId());
         model.setStoreId(dto.getStoreId());
         Store store = storeService.getModelById(model.getStoreId());
-        if(store == null){
+        if (store == null) {
             throw new BusinessException("找不到仓库,请给项目部设置总仓以及对应的负责人, storeId:" + model.getStoreId());
         }
-        if(store.getUserId() == null){
+        if (store.getUserId() == null) {
             throw new BusinessException("找不到仓库的负责人,请设置负责人, storeId:" + store.getId());
         }
         model.setStatus(InStoreStatusEnum.NOT_EXECUTE.getValue());
@@ -353,13 +372,13 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
             detail.setPurchaseTotalPrice(dispatchOrder.getTotalPrice());
             detailList.add(detail);
         });
-        if(!CollectionUtils.isEmpty(detailList)){
+        if (!CollectionUtils.isEmpty(detailList)) {
             detailMapper.insertListforComplex(detailList);
         }
 
         // 采购验收后,直接入库,并通知仓库负责人
         this.updateStore(inStoreForm.getId());
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent( WorkplaceBacklogTypeEnum.PURCHASE_WUZI_MESSAGE.getValue(), WorkplaceBacklogDetailTypeEnum.PURCHASE_WUZI_MESSAGE.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.PURCHASE_WUZI_MESSAGE.getValue(), WorkplaceBacklogDetailTypeEnum.PURCHASE_WUZI_MESSAGE.getValue(),
                 inStoreForm.getId(), MessageTemplateUtil.getPurchaseWuZiInStore(inStoreForm.getId()),
                 inStoreForm.getId(), ListUtils.newArrayList(store.getUserId())));
         return inStoreForm;
@@ -386,23 +405,23 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
 
         // 找到明细
         Weekend<InStoreDetail> detailWeekend = new Weekend<>(InStoreDetail.class);
-        detailWeekend.weekendCriteria().andEqualTo(InStoreDetail::getInId,model.getId());
+        detailWeekend.weekendCriteria().andEqualTo(InStoreDetail::getInId, model.getId());
         List<InStoreDetail> detailList = detailMapper.selectByExample(detailWeekend);
 
         // 更新退库状态
-        if( model.getBackId() != null ){
+        if (model.getBackId() != null) {
             SpareBackForm spareBackForm = spareBackFormMapper.selectByPrimaryKey(model.getBackId());
             spareBackForm.setStatus(SpareBackFormStatusEnum.FINISHED.getValue());
             spareBackFormMapper.updateByPrimaryKeySelective(spareBackForm);
 
-            SpringContextHolder.publishEvent(new WorkplaceBacklogEvent( WorkplaceBacklogTypeEnum.BACK_STORE.getValue(), WorkplaceBacklogDetailTypeEnum.BACK_STORE.getValue(),
+            SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.BACK_STORE.getValue(), WorkplaceBacklogDetailTypeEnum.BACK_STORE.getValue(),
                     spareBackForm.getId(), MessageTemplateUtil.getBackStoreFinish(spareBackForm.getId()),
                     spareBackForm.getId(), ListUtils.newArrayList(spareBackForm.getPickUserId())));
         }
 
         //BigDecimal totalNum = new BigDecimal(0);
         // 更新库存
-        for(InStoreDetail detail:detailList) {
+        for (InStoreDetail detail : detailList) {
             // 更新库存信息
             Weekend<SpareStore> spareStoreWeekend = new Weekend<>(SpareStore.class);
             spareStoreWeekend.weekendCriteria().andEqualTo(SpareStore::getSpareId, detail.getSpareId())
@@ -427,11 +446,12 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
                 spareStore.setUpdateTime(LocalDateTime.now());
                 spareStore.setUpdateUserId(userInfo.getUserId());
                 spareStore.setUpdateUserName(userInfo.getRealName());
-                spareStore.setPrice(getNewPrice(spareStore,detail));
+                spareStore.setPrice(getNewPrice(spareStore, detail));
                 spareStore.setNum(BigDecimalUtil.add(spareStore.getNum(), detail.getNum()));
                 spareStoreMapper.updateByPrimaryKeySelective(spareStore);
             }
-        };
+        }
+        ;
     }
 
     /**
@@ -445,10 +465,10 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
      * @return
      */
     private BigDecimal getNewPrice(SpareStore spareStore, InStoreDetail detail) {
-        BigDecimal totalStorePrice = BigDecimalUtil.mul(spareStore.getPrice(),spareStore.getNum());
-        BigDecimal totalInPrice = BigDecimalUtil.mul(detail.getPrice(),detail.getNum());
-        BigDecimal totalPrice = BigDecimalUtil.add(totalStorePrice,totalInPrice);
-        BigDecimal totalNum = BigDecimalUtil.add(spareStore.getNum(),detail.getNum());
+        BigDecimal totalStorePrice = BigDecimalUtil.mul(spareStore.getPrice(), spareStore.getNum());
+        BigDecimal totalInPrice = BigDecimalUtil.mul(detail.getPrice(), detail.getNum());
+        BigDecimal totalPrice = BigDecimalUtil.add(totalStorePrice, totalInPrice);
+        BigDecimal totalNum = BigDecimalUtil.add(spareStore.getNum(), detail.getNum());
         BigDecimal price = BigDecimalUtil.div(totalPrice, totalNum);
         return price;
     }
@@ -469,14 +489,14 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         model.setDelFlag(false);
         model.setUserInfo(userInfo);
 
-        Store store =  storeService.getModelById(sparePickFormDTO.getStoreId());
+        Store store = storeService.getModelById(sparePickFormDTO.getStoreId());
         model.setCreatedUserId(store.getUserId());
         model.setType(InStoreTypeEnum.XIANZHI_RUKU.getValue());
         model.setStatus(OutStoreStatusEnum.NOT_EXECUTE.getValue());
         model.setRemark(sparePickFormDTO.getRemark());
         InStoreForm form = super.saveModelByDTO(model);
         List<InStoreDetail> detailList = new ArrayList<InStoreDetail>();
-        selectDetailList.forEach(pickDetail->{
+        selectDetailList.forEach(pickDetail -> {
             InStoreDetail detail = new InStoreDetail();
             detail.setId(IdGeneratorUtils.getObjectId());
             detail.setCreatedTime(pickDetail.getCreatedTime());
@@ -492,7 +512,7 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
         });
         detailMapper.insertListforComplex(detailList);
 
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent( WorkplaceBacklogTypeEnum.BACK_STORE.getValue(), WorkplaceBacklogDetailTypeEnum.BACK_STORE.getValue(),
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.BACK_STORE.getValue(), WorkplaceBacklogDetailTypeEnum.BACK_STORE.getValue(),
                 form.getId(), MessageTemplateUtil.getBackStore(form.getId()),
                 form.getId(), ListUtils.newArrayList(store.getUserId())));
         return form;
@@ -518,10 +538,10 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
             model.setTotalPrice(job.getProfitPrice());
             model.setStoreId(job.getStoreId());
             Store store = storeService.getModelById(model.getStoreId());
-            if(store == null){
+            if (store == null) {
                 throw new BusinessException("找不到仓库,请给项目部设置总仓以及对应的负责人, storeId:" + model.getStoreId());
             }
-            if(store.getUserId() == null){
+            if (store.getUserId() == null) {
                 throw new BusinessException("找不到仓库的负责人,请设置负责人, storeId:" + store.getId());
             }
             model.setCreatedUserId(job.getCheckUserId());
@@ -544,11 +564,11 @@ public class InStoreFormServiceImpl extends BaseServiceImpl<InStoreFormMapper, I
             formList.add(inStoreForm);
 
         });
-        if(!CollectionUtils.isEmpty(detailList)){
+        if (!CollectionUtils.isEmpty(detailList)) {
             detailMapper.insertListforComplex(detailList);
         }
-        if(!CollectionUtils.isEmpty(formList)){
-            for(InStoreForm form: formList){
+        if (!CollectionUtils.isEmpty(formList)) {
+            for (InStoreForm form : formList) {
                 updateStore(form.getId());
             }
         }

+ 9 - 7
platform-service/src/main/java/com/platform/service/store/impl/OutStoreFormServiceImpl.java

@@ -82,8 +82,10 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
         OutStoreFormVO outStoreFormVO = new OutStoreFormVO();
         BeanConverterUtil.copyObjectProperties(outStoreForm,outStoreFormVO);
         // 详情列表
-        Store store = storeService.getModelById(outStoreForm.getStoreId());
-        outStoreFormVO.setStoreName(store.getName());
+        if(StringUtils.isNotBlank(outStoreForm.getStoreId())){
+            Store store = storeService.getModelById(outStoreForm.getStoreId());
+            outStoreFormVO.setStoreName(store.getName());
+        }
         outStoreFormVO.setDetailList(mapper.selectDetailList(id));
         return outStoreFormVO;
     }
@@ -159,7 +161,7 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
         for(OutStoreDetailDTO detail:detailList) {
             detail.setUserInfo(userInfo);
             detail.setOutId(outStoreForm.getId());
-            detail.setStoreId(outStoreForm.getStoreId());
+            // detail.setStoreId(outStoreForm.getStoreId());
             detail.setId(IdGeneratorUtils.getObjectId());
             totalPrice = totalPrice.add(detail.getTotalPrice());
             detail.setOutNo(outStoreForm.getOutNo());
@@ -212,10 +214,10 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
             // 更新库存信息
             Weekend<SpareStore> spareStoreWeekend = new Weekend<>(SpareStore.class);
             spareStoreWeekend.weekendCriteria().andEqualTo(SpareStore::getSpareId, storeDetail.getSpareId())
-                    .andEqualTo(SpareStore::getStoreId, outStoreForm.getStoreId());
+                    .andEqualTo(SpareStore::getStoreId, storeDetail.getStoreId());
             SpareStore spareStore = spareStoreMapper.selectOneByExample(spareStoreWeekend);
             if (ObjectUtil.isNull(spareStore)) {
-                throw new BusinessException("找不到该备件仓库!,备件ID:"+storeDetail.getSpareId()+",仓库ID:"+outStoreForm.getStoreId());
+                throw new BusinessException("找不到该备件仓库!,备件ID:"+storeDetail.getSpareId()+",仓库ID:"+storeDetail.getStoreId());
             } else {
                 BigDecimal rest = spareStore.getNum().subtract(storeDetail.getNum());
                 if (rest.compareTo(new BigDecimal(0)) < 0) {
@@ -301,7 +303,7 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
             if(ObjectUtil.isNull(realDetail)){
                 detail.setUserInfo(userInfo);
                 detail.setOutId(model.getId());
-                detail.setStoreId(model.getStoreId());
+                //detail.setStoreId(model.getStoreId());
                 detail.setOutNo(model.getOutNo());
                 totalPrice = totalPrice.add(detail.getTotalPrice());
                 OutStoreDetail storeDetail = new OutStoreDetail();
@@ -329,7 +331,7 @@ public class OutStoreFormServiceImpl extends BaseServiceImpl<OutStoreFormMapper,
     }
 
     /**
-     * 领用直接生成出库单,但是出库单提交,不修改实际库存
+     * 领用直接生成出库单,但是出库单提交,不修改实际库存
      *
      * @param sparePickFormDTO
      * @param pickDetailList