| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import lombok.AllArgsConstructor; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.stock.entity.Stock; |
| | | import org.springblade.modules.stock.service.IStockService; |
| | | import org.springblade.modules.system.entity.DictBiz; |
| | | import org.springblade.modules.system.service.IDictBizService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import org.springblade.modules.stockrecord.vo.StockrecordVO; |
| | | import org.springblade.modules.stockrecord.service.IStockrecordService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 出入库记录 控制器 |
| | |
| | | public class StockrecordController extends BladeController { |
| | | |
| | | private final IStockrecordService stockrecordService; |
| | | private final IStockService stockService; |
| | | private final IDictBizService dictService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入stockrecord") |
| | | public R<IPage<StockrecordVO>> page(StockrecordVO stockrecord, Query query) { |
| | | IPage<StockrecordVO> pages = stockrecordService.selectStockrecordPage(Condition.getPage(query), stockrecord); |
| | | IPage<StockrecordVO> pages = stockrecordService.seletStockRecordList(Condition.getPage(query), stockrecord); |
| | | for (int i = 0; i < pages.getRecords().size(); i++) { |
| | | String specs = pages.getRecords().get(i).getSpecs1(); |
| | | String dic1 = pages.getRecords().get(i).getDic1(); |
| | | String dic2 = pages.getRecords().get(i).getDic2(); |
| | | String s = specs + dic1 + "/" + dic2; |
| | | //出库 |
| | | if (pages.getRecords().get(i).getStockType1() == 0) { |
| | | String count = "-" + pages.getRecords().get(i).getAmount1() + dic2; |
| | | pages.getRecords().get(i).setCount(count); |
| | | } else { |
| | | String count = "+" + pages.getRecords().get(i).getAmount1() + dic2; |
| | | pages.getRecords().get(i).setCount(count); |
| | | } |
| | | pages.getRecords().get(i).setSpn(s); |
| | | //获取农资出入库类型 0:出库 1:入库 |
| | | Integer stockType1 = pages.getRecords().get(i).getStockType1(); |
| | | String type1 = pages.getRecords().get(i).getType1(); |
| | | if (stockType1 == 0) { |
| | | List<DictBiz> tree = dictService.getList("stockPurchase1"); |
| | | for (int j = 0; j < tree.size(); j++) { |
| | | if (tree.get(j).getDictKey().equals(type1)) { |
| | | pages.getRecords().get(i).setType1(tree.get(j).getDictValue()); |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | List<DictBiz> tree = dictService.getList("stockPurchase"); |
| | | for (int j = 0; j < tree.size(); j++) { |
| | | if (tree.get(j).getDictKey().equals(type1)) { |
| | | pages.getRecords().get(i).setType1(tree.get(j).getDictValue()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.data(pages); |
| | | } |
| | | |
| | |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入stockrecord") |
| | | public R save(@Valid @RequestBody Stockrecord stockrecord) { |
| | | public R save(@Valid @RequestBody StockrecordVO stockrecord) { |
| | | Integer stockType1 = stockrecord.getStockType1(); |
| | | //出库 |
| | | if (stockType1 == 0) { |
| | | //库存量 |
| | | Integer num = stockrecord.getNum(); |
| | | //出库量 |
| | | Integer amount1 = stockrecord.getAmount1(); |
| | | //当前总量 |
| | | int i = num - amount1; |
| | | Stock stock = new Stock(); |
| | | stock.setStockId(stockrecord.getStockId1()); |
| | | stock.setAmount(i); |
| | | if (i == 0) { |
| | | stock.setState("1"); |
| | | stockService.UpdaeAmountc(stock); |
| | | } else { |
| | | stock.setState("0"); |
| | | stockService.UpdaeAmountc(stock); |
| | | } |
| | | } |
| | | //入库 |
| | | else { |
| | | //库存量 |
| | | Integer num = stockrecord.getNum(); |
| | | //入库量 |
| | | Integer amount1 = stockrecord.getAmount1(); |
| | | //当前总量 |
| | | int i = num + amount1; |
| | | Stock stock = new Stock(); |
| | | stock.setStockId(stockrecord.getStockId1()); |
| | | stock.setAmount(i); |
| | | stock.setState("0"); |
| | | stockService.UpdaeAmountc(stock); |
| | | } |
| | | return R.status(stockrecordService.save(stockrecord)); |
| | | } |
| | | |