package com.consum.base.controller;
|
|
import com.consum.base.BaseController;
|
import com.consum.base.core.CodeGeneratorEnum;
|
import com.consum.base.core.CodeGeneratorService;
|
import com.consum.base.core.WhBusinessEnum;
|
import com.consum.base.pojo.*;
|
import com.consum.base.service.*;
|
import com.consum.model.po.*;
|
import com.consum.model.vo.LWhFormOutputVo;
|
import com.consum.model.vo.LWhFormTransferVo;
|
import com.iplatform.model.po.S_user_core;
|
import com.walker.db.page.GenericPager;
|
import com.walker.infrastructure.utils.CollectionUtils;
|
import com.walker.infrastructure.utils.DateUtils;
|
import com.walker.infrastructure.utils.NumberGenerator;
|
import com.walker.web.ResponseValue;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.lang.reflect.Field;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @Description 调拨管理
|
* @Author 卢庆阳
|
* @Date 2023/10/30
|
*/
|
@RestController
|
@RequestMapping("/pc/l/wh/form/transfer")
|
public class LWhFormTransferController extends BaseController {
|
|
@Autowired
|
private LWhFormTransferServiceImpl lWhFormTransferService;
|
@Autowired
|
private BaseWarehouseServiceImpl baseWarehouseService;
|
@Autowired
|
private LWhProcureModelService lWhProcureModelService;
|
@Autowired
|
private LWhFormTransferCoreService lWhFormTransferCoreService;
|
|
/**
|
* @Description 新增
|
*/
|
@PostMapping("/add")
|
public ResponseValue add(@RequestBody LWhFormTransferParam param) {
|
S_user_core currentUser = this.getCurrentUser();
|
if (currentUser == null) {
|
return ResponseValue.error("登录用户信息不存在");
|
}
|
List<LWhProcureModelParams> transferGoods = param.getModels();
|
if (CollectionUtils.isEmpty(transferGoods)) {
|
return ResponseValue.error("调拨单不能为空");
|
}
|
int result = this.lWhFormTransferService.add(param, currentUser,this.getSysInfo());
|
if (result > 0) return ResponseValue.success(1);
|
return ResponseValue.error("新增失败!");
|
}
|
|
/**
|
* @Description 列表查询(调拨明细)
|
* @Author 卢庆阳
|
* @Date 2023/10/30
|
*/
|
// 1.查询调拨单
|
// 2.查询物品型号
|
@GetMapping("/list")
|
public ResponseValue queryFormTransferList(LWhFormTransferParam param) {
|
S_user_core currentUser = this.getCurrentUser();
|
if (currentUser == null) {
|
return ResponseValue.error("登录用户信息不存在");
|
}
|
FinSysTenantUser sysInfo = getSysInfo();
|
|
//只能查询本级 及以下机构的调拨单
|
//??????
|
|
GenericPager genericPager = lWhFormTransferService.queryFormTransferList(param);
|
List<LWhFormTransfer> datas = genericPager.getDatas();
|
ArrayList<LWhFormProcureExtend> newDatas = new ArrayList<>();
|
if (!CollectionUtils.isEmpty(datas)) {
|
datas.forEach(item -> {
|
// 查询型号数量
|
LWhProcureModel lWhProcureModel = new LWhProcureModel();
|
lWhProcureModel.setBusinessType(2);
|
lWhProcureModel.setBusinessId(item.getId());
|
List<LWhProcureModel> models = lWhProcureModelService.select(lWhProcureModel);
|
LWhFormProcureExtend formProcureExtend = new LWhFormProcureExtend();
|
BeanUtils.copyProperties(item, formProcureExtend);
|
formProcureExtend.setModels(models);
|
newDatas.add(formProcureExtend);
|
});
|
}
|
try {
|
Field fieldDatas = GenericPager.class.getDeclaredField("datas");
|
fieldDatas.setAccessible(true);
|
fieldDatas.set(genericPager, newDatas);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
// genericPager.setDatas(newDatas);
|
return ResponseValue.success(genericPager);
|
}
|
|
/**
|
* @Description 根据id查询详情
|
* @Author 卢庆阳
|
* @Date 2023/10/30
|
*/
|
@GetMapping("/detail")
|
public ResponseValue getById(Long id) {
|
if (id == null) {
|
return ResponseValue.error("调拨单id为空");
|
}
|
LWhFormTransferVo vo = this.lWhFormTransferService.getById(id);
|
return ResponseValue.success(vo);
|
}
|
|
/**
|
* 撤销
|
* @author 卢庆阳
|
* @date 2023/10/31
|
*/
|
@PostMapping("/updStatus")
|
public ResponseValue updateStatus(Long id) {
|
if (id == null) {
|
return ResponseValue.error("参数错误");
|
}
|
|
int num = this.lWhFormTransferService.updateStatus(id);
|
return num > 0 ? ResponseValue.success(1) : ResponseValue.error("修改失败!");
|
}
|
|
/**
|
* @Description 调拨入库
|
* @Author 卢庆阳
|
* @Date 2023/10/31
|
*/
|
@PostMapping("/income")
|
public ResponseValue income(Long id) {
|
lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser());
|
return ResponseValue.success();
|
}
|
|
/**
|
* @Description 调拨出库
|
* @Author 卢庆阳
|
* @Date 2023/10/31
|
*/
|
@PostMapping("/output")
|
public ResponseValue output(Long id) {
|
lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser());
|
return ResponseValue.success();
|
}
|
|
/**
|
* @Description 导出调拨出库单
|
* @Author 卢庆阳
|
* @Date 2023/10/31
|
*/
|
@GetMapping("/export")
|
public ResponseValue export(Long id) {
|
if (id == null) {
|
return ResponseValue.error("调拨单id为空");
|
}
|
LWhFormOutputVo vo = this.lWhFormTransferService.export(id,this.getCurrentUser());
|
return ResponseValue.success(vo);
|
}
|
|
|
}
|