廖井涛
2024-11-11 91275956f2ba7616e8923cf4b450483f0df5e254
修改物料库存
7个文件已修改
158 ■■■■ 已修改文件
north-glass-erp/northglass-erp/src/views/mm/ingredientStock/MaterialOutbound.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/mm/ingredientStock/ReturnToStorage.vue 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/mm/ingredientStock/SelectIngredientsStock.vue 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/controller/mm/MaterialInventoryController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/mapper/mm/MaterialInventoryMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialInventoryService.java 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/mm/ingredientStock/MaterialOutbound.vue
@@ -332,7 +332,11 @@
        <el-button @click="getTableRow(row,'edit')"
                   v-if="userStore.user.permissions.indexOf('materialOutbound.edit') > -1"
                   link type="primary" size="small">{{$t('basicData.edit')}}</el-button>
<!--        <el-button @click="getTableRow(row,'delete')" link type="primary" size="small">删除</el-button>-->
        <el-popconfirm @confirm="getTableRow(row,'delete')"  :title="$t('searchOrder.deleteConfirm')">
          <template #reference>
            <el-button :disabled="row.reviewedState===1" link type="primary" size="small">{{ $t('basicData.delete') }}</el-button>
          </template>
        </el-popconfirm>
      </template>
      <template #num1_filter="{ column, $panel }">
north-glass-erp/northglass-erp/src/views/mm/ingredientStock/ReturnToStorage.vue
@@ -24,6 +24,26 @@
      router.push({path: '/main/ingredientsStock/ReturnToStorageCreate', query: { returningId: row.returningId }})
      break
    }
    case 'delete':{
      let flowData = ref({
        returningId:row.returningId,
        userName:userStore.user.userName,
        userId:userStore.user.userId
      })
      request.post("/materialInventory/deleteReturnToStorage",flowData.value).then((res) => {
        if(res.code==200 && res.data===true){
          ElMessage.success(t('searchOrder.msgDeleteSuccess'))
          router.push({path:'/main/ingredientsStock/ReturnToStorage', query:{random:Math.random()}})
        }else{
          ElMessage.warning(t('basicData.msg.deleteSuccess'))
        }
      }).catch((err)=>{
        ElMessage.error(t('basicData.msg.ServerConnectionError'))
        router.push("/login")
      })
      return
    }
  }
}
@@ -283,7 +303,11 @@
        <el-button @click="getTableRow(row,'edit')"
                   v-if="userStore.user.permissions.indexOf('returnToStorage.edit') > -1"
                   link type="primary" size="small">{{$t('basicData.edit')}}</el-button>
<!--        <el-button @click="getTableRow(row,'delete')" link type="primary" size="small">删除</el-button>-->
        <el-popconfirm @confirm="getTableRow(row,'delete')"  :title="$t('searchOrder.deleteConfirm')">
          <template #reference>
            <el-button :disabled="row.reviewedState===1" link type="primary" size="small">{{ $t('basicData.delete') }}</el-button>
          </template>
        </el-popconfirm>
      </template>
      <template #num1_filter="{ column, $panel }">
north-glass-erp/northglass-erp/src/views/mm/ingredientStock/SelectIngredientsStock.vue
@@ -10,6 +10,7 @@
import { useI18n } from 'vue-i18n'
import {toolbarButtonClickEvent} from "@/hook/mouseMove";
import {changeFilterEvent,filterChanged} from "@/hook"
import {divideAuto, multiply} from "@/utils/decimal";
//语言获取
const { t } = useI18n()
@@ -585,22 +586,25 @@
          let  flowData = ref({
            totalArea: selectRecords.height*selectRecords.width/1000000*titleUploadData.value.inventoryQuantity,
            singlePieceArea: selectRecords.height*selectRecords.width/1000000,
            totalArea: parseFloat(divideAuto(multiply(selectRecords.height,selectRecords.width),1000000,2))*titleUploadData.value.inventoryQuantity,
            singlePieceArea: parseFloat(divideAuto(multiply(selectRecords.height,selectRecords.width),1000000,2)),
            title: titleUploadData.value,
            materialCode: selectRecords.id,
            userName:userStore.user.userName,
            userId:userStore.user.userId
          })
          console.log(flowData.value)
          request.post("/materialInventory/saveMaterialInventory", flowData.value).then((res) => {
            if(res.code==200){
            console.log(res)
            if(res.code==200 && res.data==="true"){
              ElMessage.success(t('basicData.msg.saveSuccess'))
              router.push({path: '/main/ingredientsStock/SelectIngredientsStock', query:{random:Math.random()}})
            }else{
              ElMessage.warning(res.msg)
              router.push("/login")
            }else if(res.data==="false1") {
              ElMessage.warning("库存存在多条")
            }else {
              ElMessage.warning(t('basicData.msg.ServerConnectionError'))
            }
          })
          break
north-glass-erp/src/main/java/com/example/erp/controller/mm/MaterialInventoryController.java
@@ -42,12 +42,7 @@
    @SaCheckPermission("selectIngredientsStock.add")
    @PostMapping("/saveMaterialInventory")
    public Result saveMaterialInventory( @RequestBody Map<String,Object>  object){
        if(materialInventoryService.saveMaterialInventory(object)){
            return Result.seccess();
        }else {
            throw new ServiceException(Constants.Code_500,"保存失败");
        }
        return Result.seccess(materialInventoryService.saveMaterialInventory(object));
    }
    @ApiOperation("物料库存加时间查询接口")
@@ -121,6 +116,13 @@
        return Result.seccess(materialInventoryService.getSelectReturningWarehouse(pageNum,pageSize,returningWarehouseDetail));
    }
    @ApiOperation("物料返库删除接口")
    @SaCheckPermission("returnToStorageCreate.delete")
    @PostMapping("/deleteReturnToStorage")
    public Result deleteReturnToStorage( @RequestBody Map<String,Object>  object){
        return Result.seccess(materialInventoryService.deleteReturnToStorage(object));
    }
    @ApiOperation("物料返库审核接口")
    @SaCheckPermission("returnToStorageCreate.review")
    @PostMapping("/updateReturningWarehouseToExamine")
north-glass-erp/src/main/java/com/example/erp/mapper/mm/MaterialInventoryMapper.java
@@ -56,6 +56,8 @@
    Boolean deleteMaterialOutbound(@Param("materialOutboundId") String materialOutboundId);
    Boolean deleteMaterialLog(@Param("materialOutboundId") String materialOutboundId);
    Integer getMaximum(@Param("type") String type);
    Integer getMaximums(@Param("type") String type);
@@ -119,6 +121,8 @@
    Boolean deleteReturningWarehouseDetail(@Param("returningId") String returningId);
    Boolean deleteReturningWarehouse(@Param("returningId") String returningId);
    List<MaterialOutbound> getSelectMaterialOutboundDate(@Param("offset") Integer offset,
                                                           @Param("pageSize") Integer pageSize,String startDate, String endDate,
                                                           @Param("materialOutbound") MaterialOutbound materialOutbound);
@@ -172,6 +176,10 @@
                                    @Param("totalArea") Double totalArea,
                                    @Param("materialInventory") MaterialInventory materialInventory);
    Boolean updateMaterialInventoryNull(@Param("materialCode") Long materialCode,@Param("singlePieceArea") Double singlePieceArea,
                                    @Param("totalArea") Double totalArea,
                                    @Param("materialInventory") MaterialInventory materialInventory);
    Boolean insertMaterialInventory(@Param("materialCode") Long materialCode,@Param("singlePieceArea") Double singlePieceArea,
                                    @Param("totalArea") Double totalArea,
                                    @Param("materialInventory") MaterialInventory materialInventory);
north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialInventoryService.java
@@ -164,8 +164,8 @@
    }
    public Boolean saveMaterialInventory(Map<String,Object> object) {
        boolean saveState = true;
    public String saveMaterialInventory(Map<String,Object> object) {
        String saveState = "true";
        //设置回滚点
        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
        try {
@@ -188,15 +188,27 @@
            MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class);
            //查询物料是否存在
            Integer MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture());
            if(MaterialInventoryCount>0){
                materialInventoryMapper.updateMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory);
            //查询物料是否存在
            Integer MaterialInventoryCount=0;
            if (materialInventory.getDateOfManufacture()!=null){
                MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture());
            }else{
                MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(materialCode);
            }
            if(MaterialInventoryCount==1){
                if (materialInventory.getDateOfManufacture()!=null){
                    materialInventoryMapper.updateMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory);
                }else{
                    materialInventoryMapper.updateMaterialInventoryNull(materialCode,singlePieceArea,totalArea,materialInventory);
                }
                log.setFunction("saveMaterialInventory修改");
            }else {
            }else if(MaterialInventoryCount==0) {
                materialInventoryMapper.insertMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory);
                log.setFunction("saveMaterialInventory新增");
            }else {
                return "false1";
            }
            String json="";
@@ -227,7 +239,7 @@
            sysError.setError(e+Arrays.toString(e.getStackTrace()));
            sysError.setFunc("saveMaterialInventory");
            sysErrorService.insert(sysError);
            saveState = false;
            saveState = "false";
        }
        return saveState;
@@ -317,6 +329,7 @@
            if(materialOutboundId!=null){
                materialInventoryMapper.deleteMaterialOutboundDetail(materialOutboundId);
                materialInventoryMapper.deleteMaterialOutbound(materialOutboundId);
                materialInventoryMapper.deleteMaterialLog(materialOutboundId);
            }
            Log log = new Log();
            log.setContent(object.toString());
@@ -340,6 +353,42 @@
    }
    public Boolean deleteReturnToStorage(Map<String,Object> object) {
        boolean saveState = true;
        //设置回滚点
        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
        try {
            String returningId = "";
            if (object.get("returningId") != null) {
                returningId = object.get("returningId").toString();
            }
            if(returningId!=null){
                materialInventoryMapper.deleteReturningWarehouseDetail(returningId);
                materialInventoryMapper.deleteReturningWarehouse(returningId);
                materialInventoryMapper.deleteMaterialLog(returningId);
            }
            Log log = new Log();
            log.setContent(object.toString());
            log.setOperatorId(object.get("userId").toString());
            log.setOperator(object.get("userName").toString());
            log.setFunction("deleteReturnToStorage:"+returningId);
            logService.saveLog(log);
        } catch (Exception e) {
            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
            //将异常传入数据库
            SysError sysError = new SysError();
            sysError.setError(e+Arrays.toString(e.getStackTrace()));
            sysError.setFunc("deleteMaterialOutbound");
            sysErrorService.insert(sysError);
            saveState = false;
        }
        return saveState;
    }
    public Map<String, Object> getSelectMaterialOutboundDate(Integer pageNum, Integer pageSize, List<String> selectDate, MaterialOutbound materialOutbound) {
        Integer offset = (pageNum - 1) * pageSize;
        String endDate = LocalDate.now().toString();
north-glass-erp/src/main/resources/mapper/mm/MaterialInventory.xml
@@ -549,8 +549,16 @@
        delete from mm.material_outbound_detail where material_outbound_id=#{materialOutboundId}
    </delete>
    <delete id="deleteMaterialLog" >
        delete from mm.material_log where operation_order_number=#{materialOutboundId}
    </delete>
    <delete id="deleteReturningWarehouseDetail" >
        delete from mm.returning_warehouse_detail where returning_id=#{returningId}
    </delete>
    <delete id="deleteReturningWarehouse" >
        delete from mm.returning_warehouse where returning_id=#{returningId}
    </delete>
    <select id="getMaximum" >
@@ -747,13 +755,19 @@
    <update id="updateMaterialInventory" >
        update mm.material_inventory set inventory_quantity=inventory_quantity+#{materialInventory.inventoryQuantity},
                                         available_quantity=available_quantity+#{materialInventory.inventoryQuantity},
                                         total_area=total_area+#{totalArea}
                                         total_area=single_piece_area*inventory_quantity
                                     where  material_code=#{materialCode} and date_of_manufacture=#{materialInventory.dateOfManufacture}
    </update>
    <update id="updateMaterialInventoryNull" >
        update mm.material_inventory set inventory_quantity=inventory_quantity+#{materialInventory.inventoryQuantity},
                                         available_quantity=available_quantity+#{materialInventory.inventoryQuantity},
                                         total_area=single_piece_area*inventory_quantity
        where  material_code=#{materialCode}
    </update>
    <update id="updateMaterialInventoryReturning" >
        update mm.material_inventory set available_quantity=available_quantity+#{returningWarehouseDetail.returnQuantity},
                                         total_area=total_area+#{totalArea}
        update mm.material_inventory set available_quantity=available_quantity+#{returningWarehouseDetail.returnQuantity}
       where  material_code=#{materialCode} and
                date_of_manufacture=#{returningWarehouseDetail.dateOfManufacture}
@@ -761,8 +775,7 @@
    </update>
    <update id="updateMaterialInventoryReturningNull" >
        update mm.material_inventory set available_quantity=available_quantity+#{returningWarehouseDetail.returnQuantity},
                                         total_area=total_area+#{totalArea}
        update mm.material_inventory set available_quantity=available_quantity+#{returningWarehouseDetail.returnQuantity}
        where  material_code=#{materialCode} and
            date_of_manufacture is null