package com.consum.base.controller; import com.consum.base.BaseController; import com.consum.base.core.utils.PageUtil; import com.consum.base.pojo.query.LWhFormInventoryQry; import com.consum.base.pojo.request.FormInventoryParam; import com.consum.base.pojo.request.LWhFormInventoryParam; import com.consum.base.pojo.response.FormInventoryDetailVO; import com.consum.base.pojo.response.FormInventoryGoodsVO; import com.consum.base.pojo.response.FormInventoryVO; import com.consum.base.service.FinSysTenantUserServiceImpl; import com.consum.base.service.LWhFormInventoryGoodsServiceImpl; import com.consum.base.service.LWhFormInventoryServiceImpl; import com.consum.model.po.FinSysTenantUser; import com.consum.model.po.LWhFormInventory; import com.walker.db.page.GenericPager; import com.walker.web.ResponseValue; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import java.util.List; import java.util.Objects; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @Description 盘点 * @Author 卢庆阳 * @Date 2023/10/23 */ @Api(value = "盘点", tags = "盘点") @RestController @RequestMapping("/pc/l/wh/form/inventory") public class LWhFormInventoryController extends BaseController { @Autowired private LWhFormInventoryServiceImpl lWhFormInventoryService; @Autowired private FinSysTenantUserServiceImpl finSysTenantUserService; @Autowired private LWhFormInventoryGoodsServiceImpl inventoryGoodsService; /** * @Description 新增 * @Author 卢庆阳 * @Date 2023/10/31 */ @ApiOperation(value = "新增盘点", notes = "新增盘点") @ApiImplicitParams({ @ApiImplicitParam(name = "param", value = "盘点单信息", dataType = "FormInventoryParam") }) @PostMapping("/add") public ResponseValue add(@RequestBody FormInventoryParam param) { FinSysTenantUser sysInfo = this.getSysInfo(); if (sysInfo == null) { return ResponseValue.error("登录用户信息不存在"); } //根据盘点人id查询盘点人 FinSysTenantUser finSysTenantUser = new FinSysTenantUser(); finSysTenantUser.setId(param.getOperatorUserId()); FinSysTenantUser operatorUser = finSysTenantUserService.get(finSysTenantUser); //根据监盘人id查询监盘人 FinSysTenantUser monitorUserInfo = new FinSysTenantUser(); monitorUserInfo.setId(param.getMonitorUserId()); FinSysTenantUser monitorUser = finSysTenantUserService.get(monitorUserInfo); int result = this.lWhFormInventoryService.add(param, this.getSysInfo(), operatorUser, monitorUser); if (result > 0) { return ResponseValue.success(); } return ResponseValue.error("新增失败!"); } /** * @Description 盘点单列表查询 * @Author 卢庆阳 * @Date 2023/10/31 */ @ApiOperation(value = "盘点单列表查询", notes = "盘点单列表查询") @ApiImplicitParams({ @ApiImplicitParam(name = "param", value = "盘点条件", dataType = "LWhFormInventoryParam", required = true, paramType = "query") }) @GetMapping("/list") public ResponseValue queryList(LWhFormInventoryQry param) { FinSysTenantUser sysInfo = this.getSysInfo(); if (sysInfo == null) { return ResponseValue.error("登录用户信息不存在"); } GenericPager pager = this.lWhFormInventoryService.queryList(param, sysInfo); return ResponseValue.success(pager); } @ApiOperation(value = "盘点单物品列表查询", notes = "盘点单物品列表查询", response = FormInventoryVO.class) @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "盘点单id", dataType = "Long", required = true, paramType = "query") }) @ApiResponse(code = 200, message = "成功", response = FormInventoryVO.class) @GetMapping("/query") public ResponseValue queryInventBaseGoodTemplate(Long id) { FinSysTenantUser sysInfo = this.getSysInfo(); if (sysInfo == null) { return ResponseValue.error("登录用户信息不存在"); } if (id == null) { return ResponseValue.error("参数不能为空"); } FormInventoryVO formInventoryVO = this.lWhFormInventoryService.queryInventBaseGoodTemplate(id); this.lWhFormInventoryService.saveInventory(formInventoryVO, id); return ResponseValue.success(formInventoryVO); } /** * @Description 编辑 * @Author 卢庆阳 * @Date 2023/10/31 */ @ApiOperation(value = "编辑盘点", notes = "编辑盘点") @ApiImplicitParams({ @ApiImplicitParam(name = "param", value = "盘点单信息", dataType = "FormInventoryParam") }) @PostMapping("/edit") public ResponseValue edit(@RequestBody FormInventoryParam param) { LWhFormInventory lWhFormInventory = lWhFormInventoryService.get(new LWhFormInventory(param.getId())); if (lWhFormInventory == null) { return ResponseValue.error("编辑失败!"); } if (lWhFormInventory.getStates() != 0) { return ResponseValue.error("未开始状态才能编辑!"); } int num = lWhFormInventoryService.delete(new LWhFormInventory(param.getId())); if (num == 0) { return ResponseValue.error("编辑失败!"); } ResponseValue add = this.add(param); if (add.getCode() == ResponseValue.CODE_SUCCESS) { return ResponseValue.success(); } return ResponseValue.error("编辑失败!"); } /** * @Description 根据id删除 */ @ApiOperation(value = "根据id删除盘点", notes = "根据id删除盘点") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "盘点单id", dataType = "Long", required = true, paramType = "query") }) @DeleteMapping("/del") public ResponseValue delById(Long id) { if (id == null) { return ResponseValue.error("参数不能为空!"); } LWhFormInventory lWhFormInventory = lWhFormInventoryService.get(new LWhFormInventory(id)); if (lWhFormInventory == null) { return ResponseValue.error("删除失败!"); } if (lWhFormInventory.getStates() != 0) { return ResponseValue.error("未开始状态才能删除!"); } int num = lWhFormInventoryService.delete(new LWhFormInventory(id)); if (num == 0) { return ResponseValue.error("删除失败!"); } return ResponseValue.success(1); } /** * 暂存 * * @author 卢庆阳 * @date 2023/10/31 */ @ApiOperation(value = "盘点暂存", notes = "盘点暂存") @ApiImplicitParams({ @ApiImplicitParam(name = "param", value = "盘点单信息", dataType = "LWhFormInventoryDto") }) @PostMapping("/temporary/storage") public ResponseValue temporaryStorage(@RequestBody LWhFormInventoryParam dto) { if (dto == null) { return ResponseValue.error("参数错误"); } int num = this.lWhFormInventoryService.updateInventoryInfo(dto, 1); return num > 0 ? ResponseValue.success(1) : ResponseValue.error("暂存失败!"); } /** * 完成盘点 * * @author 卢庆阳 * @date 2023/10/31 */ @ApiOperation(value = "完成盘点", notes = "完成盘点") @ApiImplicitParams({ @ApiImplicitParam(name = "param", value = "盘点单信息", dataType = "LWhFormInventoryDto") }) @PostMapping("/finish") public ResponseValue finishPd(@RequestBody LWhFormInventoryParam dto) { if (dto == null) { return ResponseValue.error("参数错误"); } int num = this.lWhFormInventoryService.updateInventoryInfo(dto, 2); return num > 0 ? ResponseValue.success(1) : ResponseValue.error("盘点失败!"); } /** * @Description 异常明细列表查询 * @Author 卢庆阳 * @Date 2023/11/1 */ @ApiOperation(value = "异常明细列表查询", notes = "异常明细列表查询") @ApiImplicitParams({ @ApiImplicitParam(name = "param", value = "盘点条件", dataType = "LWhFormInventoryParam", paramType = "query") }) @GetMapping("/list/PdDetail") public ResponseValue queryPdDetailList(LWhFormInventoryQry param) { FinSysTenantUser sysInfo = this.getSysInfo(); if (sysInfo == null) { return ResponseValue.error("登录用户信息不存在"); } PageUtil result = this.lWhFormInventoryService.queryPdDetailList(param, sysInfo); return ResponseValue.success(result); } @ApiOperation(value = "根据id查询盘点物品详细信息", notes = "根据id查询盘点物品详细信息") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "盘点id", dataType = "Long", required = true, paramType = "query") }) @GetMapping("/detail") public ResponseValue selectDetailById(Long id) { FinSysTenantUser sysInfo = this.getSysInfo(); if (sysInfo == null) { return ResponseValue.error("登录用户信息不存在"); } FormInventoryVO formInventoryVO = new FormInventoryVO(); LWhFormInventory lWhFormInventory = new LWhFormInventory(); lWhFormInventory.setId(id); LWhFormInventory item = this.lWhFormInventoryService.get(lWhFormInventory); if (Objects.isNull(item)) { return ResponseValue.error("盘点单不存在"); } BeanUtils.copyProperties(item, formInventoryVO); List formInventoryGoodsVOS = this.lWhFormInventoryService.selectDetailById(id); formInventoryVO.setFormInventoryGoodsList(formInventoryGoodsVOS); return ResponseValue.success(formInventoryVO); } }