入库 reload

入库 reload
pull/1/head
siontion 9 months ago
parent d5f99a48e0
commit 74a08096aa

@ -1,95 +1,116 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.storage; package com.chanko.yunxi.mes.module.heli.controller.admin.storage;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import javax.validation.*; import javax.validation.*;
import javax.servlet.http.*; import javax.servlet.http.*;
import java.util.*; import java.time.LocalDateTime;
import java.io.IOException; import java.util.*;
import java.io.IOException;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult; import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success; import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*; import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.*;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO; import com.chanko.yunxi.mes.module.heli.controller.admin.storage.vo.*;
import com.chanko.yunxi.mes.module.heli.service.storage.StorageService; import com.chanko.yunxi.mes.module.heli.dal.dataobject.storage.StorageDO;
import com.chanko.yunxi.mes.module.heli.service.storage.StorageService;
@Tag(name = "管理后台 - 入/出库")
@RestController @Tag(name = "管理后台 - 入/出库")
@RequestMapping("/heli/storage") @RestController
@Validated @RequestMapping("/heli/storage")
public class StorageController { @Validated
public class StorageController {
@Resource
private StorageService storageService; @Resource
private StorageService storageService;
@PostMapping("/create")
@Operation(summary = "创建入/出库") @PostMapping("/create")
@PreAuthorize("@ss.hasPermission('heli:storage:create')") @Operation(summary = "创建入/出库")
public CommonResult<Long> createStorage(@Valid @RequestBody StorageSaveReqVO createReqVO) { @PreAuthorize("@ss.hasPermission('heli:storage:create')")
return success(storageService.createStorage(createReqVO)); public CommonResult<Long> createStorage(@Valid @RequestBody StorageSaveReqVO createReqVO) {
} return success(storageService.createStorage(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新入/出库") @PutMapping("/update")
@PreAuthorize("@ss.hasPermission('heli:storage:update')") @Operation(summary = "更新入/出库")
public CommonResult<Boolean> updateStorage(@Valid @RequestBody StorageSaveReqVO updateReqVO) { @PreAuthorize("@ss.hasPermission('heli:storage:update')")
storageService.updateStorage(updateReqVO); public CommonResult<Boolean> updateStorage(@Valid @RequestBody StorageSaveReqVO updateReqVO) {
return success(true); storageService.updateStorage(updateReqVO);
} return success(true);
}
@DeleteMapping("/delete") @PutMapping("/update-status")
@Operation(summary = "删除入/出库") @Operation(summary = "更新入/出库")
@Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('heli:storage:update')")
@PreAuthorize("@ss.hasPermission('heli:storage:delete')") public CommonResult<Boolean> updateStorageStatus(@Valid @RequestBody StorageSaveReqVO updateReqVO) {
public CommonResult<Boolean> deleteStorage(@RequestParam("id") Long id) { StorageDO targetDo = storageService.getStorage(updateReqVO.getId());
storageService.deleteStorage(id); targetDo.setStatus(updateReqVO.getStatus());
return success(true);
} LocalDateTime currTime = LocalDateTime.now();
if(updateReqVO.getStatus().equals(2)){
@GetMapping("/get") targetDo.setKeeper(updateReqVO.getKeeper());
@Operation(summary = "获得入/出库") targetDo.setKeeperTime(currTime);
@Parameter(name = "id", description = "编号", required = true, example = "1024") }else{
@PreAuthorize("@ss.hasPermission('heli:storage:query')") targetDo.setCancel(updateReqVO.getCancel());
public CommonResult<StorageRespVO> getStorage(@RequestParam("id") Long id) { targetDo.setCancelTime(currTime);
StorageDO storage = storageService.getStorage(id); }
return success(BeanUtils.toBean(storage, StorageRespVO.class)); updateReqVO = BeanUtils.toBean(targetDo, StorageSaveReqVO.class);
}
storageService.updateStorage(updateReqVO);
@GetMapping("/page") return success(true);
@Operation(summary = "获得入/出库分页") }
@PreAuthorize("@ss.hasPermission('heli:storage:query')")
public CommonResult<PageResult<StorageRespVO>> getStoragePage(@Valid StoragePageReqVO pageReqVO) { @DeleteMapping("/delete")
PageResult<StorageDO> pageResult = storageService.getStoragePage(pageReqVO); @Operation(summary = "删除入/出库")
return success(BeanUtils.toBean(pageResult, StorageRespVO.class)); @Parameter(name = "id", description = "编号", required = true)
} @PreAuthorize("@ss.hasPermission('heli:storage:delete')")
public CommonResult<Boolean> deleteStorage(@RequestParam("id") Long id) {
@GetMapping("/export-excel") storageService.deleteStorage(id);
@Operation(summary = "导出入/出库 Excel") return success(true);
@PreAuthorize("@ss.hasPermission('heli:storage:export')") }
@OperateLog(type = EXPORT)
public void exportStorageExcel(@Valid StoragePageReqVO pageReqVO, @GetMapping("/get")
HttpServletResponse response) throws IOException { @Operation(summary = "获得入/出库")
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); @Parameter(name = "id", description = "编号", required = true, example = "1024")
List<StorageDO> list = storageService.getStoragePage(pageReqVO).getList(); @PreAuthorize("@ss.hasPermission('heli:storage:query')")
// 导出 Excel public CommonResult<StorageRespVO> getStorage(@RequestParam("id") Long id) {
ExcelUtils.write(response, "入/出库.xls", "数据", StorageRespVO.class, StorageDO storage = storageService.getStorage(id);
BeanUtils.toBean(list, StorageRespVO.class)); return success(BeanUtils.toBean(storage, StorageRespVO.class));
} }
} @GetMapping("/page")
@Operation(summary = "获得入/出库分页")
@PreAuthorize("@ss.hasPermission('heli:storage:query')")
public CommonResult<PageResult<StorageRespVO>> getStoragePage(@Valid StoragePageReqVO pageReqVO) {
PageResult<StorageDO> pageResult = storageService.getStoragePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, StorageRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出入/出库 Excel")
@PreAuthorize("@ss.hasPermission('heli:storage:export')")
@OperateLog(type = EXPORT)
public void exportStorageExcel(@Valid StoragePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<StorageDO> list = storageService.getStoragePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "入/出库.xls", "数据", StorageRespVO.class,
BeanUtils.toBean(list, StorageRespVO.class));
}
}

@ -37,6 +37,10 @@ export const createStorage = async (data: StorageVO) => {
export const updateStorage = async (data: StorageVO) => { export const updateStorage = async (data: StorageVO) => {
return await request.put({ url: `/heli/storage/update`, data }) return await request.put({ url: `/heli/storage/update`, data })
} }
// 修改入/出库
export const updateStorageStatus = async (data: StorageVO) => {
return await request.put({ url: `/heli/storage/update-status`, data })
}
// 删除入/出库 // 删除入/出库
export const deleteStorage = async (id: number) => { export const deleteStorage = async (id: number) => {

@ -272,13 +272,13 @@
</el-row> </el-row>
<el-row justify="center"> <el-row justify="center">
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="outbound" label="作废人"> <el-form-item prop="cancel" label="作废人">
{{ userList.find((user) => user.id == formData.outbound)?.nickname }} {{ userList.find((user) => user.id == formData.cancel)?.nickname }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="outboundTime" label="作废时间"> <el-form-item prop="cancelTime" label="作废时间">
{{ formatDate(formData.outboundTime, 'YYYY-MM-DD HH:mm') }} {{ formatDate(formData.cancelTime, 'YYYY-MM-DD HH:mm') }}
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -304,6 +304,7 @@ import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import * as StorageApi from '@/api/heli/storage' import * as StorageApi from '@/api/heli/storage'
import * as StorageMatApi from '@/api/heli/storagemat' import * as StorageMatApi from '@/api/heli/storagemat'
import { getAccessToken, getTenantId } from "@/utils/auth" import { getAccessToken, getTenantId } from "@/utils/auth"
import { useUserStore } from '@/store/modules/user'
import * as MaterialApi from '@/api/heli/material' import * as MaterialApi from '@/api/heli/material'
import * as WarehouseApi from '@/api/heli/warehouse' import * as WarehouseApi from '@/api/heli/warehouse'
@ -367,7 +368,14 @@ const handleStatus = (async (num) => {
formData.value.status = num formData.value.status = num
const dataUpdate = formData.value as unknown as StorageApi.StorageVO const dataUpdate = formData.value as unknown as StorageApi.StorageVO
await StorageApi.updateStorage(dataUpdate)
if(num==2){
dataUpdate.keeper = useUserStore().getUser.id
}else{
dataUpdate.cancel = useUserStore().getUser.id
}
await StorageApi.updateStorageStatus(dataUpdate)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
@ -387,6 +395,7 @@ const handleStatus = (async (num) => {
default: default:
break break
} }
reload();
}) })
const userList = ref<UserApi.UserVO[]>([]) // const userList = ref<UserApi.UserVO[]>([]) //
@ -479,6 +488,7 @@ const submitForm = async () => {
// //
reload(); reload();
} finally { } finally {
formLoading.value = false formLoading.value = false
} }

@ -242,25 +242,25 @@
</el-row> </el-row>
<el-row justify="center"> <el-row justify="center">
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="keeper" label="出库人"> <el-form-item prop="outbound" label="出库人">
{{ userList.find((user) => user.id == formData.keeper)?.nickname }} {{ userList.find((user) => user.id == formData.outbound)?.nickname }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="keeperTime" label="出库时间"> <el-form-item prop="outboundTime" label="出库时间">
{{ formatDate(formData.keeperTime, 'YYYY-MM-DD HH:mm') }} {{ formatDate(formData.outboundTime, 'YYYY-MM-DD HH:mm') }}
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row justify="center"> <el-row justify="center">
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="outbound" label="作废人"> <el-form-item prop="cancel" label="作废人">
{{ userList.find((user) => user.id == formData.outbound)?.nickname }} {{ userList.find((user) => user.id == formData.cancel)?.nickname }}
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item prop="outboundTime" label="作废时间"> <el-form-item prop="cancelTime" label="作废时间">
{{ formatDate(formData.outboundTime, 'YYYY-MM-DD HH:mm') }} {{ formatDate(formData.cancelTime, 'YYYY-MM-DD HH:mm') }}
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -286,6 +286,7 @@ import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import * as StorageApi from '@/api/heli/storage' import * as StorageApi from '@/api/heli/storage'
import * as StorageMatApi from '@/api/heli/storagemat' import * as StorageMatApi from '@/api/heli/storagemat'
import { getAccessToken, getTenantId } from "@/utils/auth" import { getAccessToken, getTenantId } from "@/utils/auth"
import { useUserStore } from '@/store/modules/user'
import * as MaterialApi from '@/api/heli/material' import * as MaterialApi from '@/api/heli/material'
import * as WarehouseApi from '@/api/heli/warehouse' import * as WarehouseApi from '@/api/heli/warehouse'
@ -349,6 +350,13 @@ const handleStatus = (async (num) => {
formData.value.status = num formData.value.status = num
const dataUpdate = formData.value as unknown as StorageApi.StorageVO const dataUpdate = formData.value as unknown as StorageApi.StorageVO
if(num==2){
dataUpdate.outbound = useUserStore().getUser.id
dataUpdate.outboundTime = new Date().toLocaleString()
}else{
dataUpdate.cancel = useUserStore().getUser.id
dataUpdate.cancelTime = new Date().toLocaleString()
}
await StorageApi.updateStorage(dataUpdate) await StorageApi.updateStorage(dataUpdate)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
@ -369,6 +377,7 @@ const handleStatus = (async (num) => {
default: default:
break break
} }
reload()
}) })
const userList = ref<UserApi.UserVO[]>([]) // const userList = ref<UserApi.UserVO[]>([]) //
@ -429,6 +438,23 @@ const submitForm = async () => {
} catch (e) { } catch (e) {
return return
} }
//
const matCurrentData = await StorageMatApi.getStorageMatList()
var hasRestNum = true
formData.value.matItemDOList.forEach( (rest) =>{
if(matCurrentData.find((mat)=>{ mat.matId == rest.matId && mat.pnId == rest.pnId && mat.matRest<rest.matRest}))
{
hasRestNum = fasle
}
})
if(!hasRestNum){
message.alertWarning('物料库存不足')
return
}
// //
formLoading.value = true formLoading.value = true
try { try {
@ -709,6 +735,7 @@ onMounted(async () => {
item.matUnit = matVos.list.find((record) => record.id == item.matId)?.unit item.matUnit = matVos.list.find((record) => record.id == item.matId)?.unit
item.pnlist = pnList.value.filter((pn) => pn.rgId == item.rgId) item.pnlist = pnList.value.filter((pn) => pn.rgId == item.rgId)
item.matRest = matLastData.value.find((rest) => rest.rgId == item.rgId && rest.pnId == item.pnId)?.matRest item.matRest = matLastData.value.find((rest) => rest.rgId == item.rgId && rest.pnId == item.pnId)?.matRest
item.matRest = item.matRest == undefined?0:item.matRest
matCount = matCount + 1 matCount = matCount + 1

Loading…
Cancel
Save