| | |
| | | package com.consum.base.controller; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.pojo.LWhFormInventoryParam; |
| | | import com.consum.base.pojo.LWhFormScrappedParam; |
| | | import com.consum.base.pojo.*; |
| | | import com.consum.base.service.LWhFormScrappedGoodsService; |
| | | import com.consum.base.service.LWhFormScrappedServiceImpl; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | 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.web.ResponseValue; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description 报废单 |
| | |
| | | |
| | | @Autowired |
| | | private LWhFormScrappedServiceImpl lWhFormScrappedService; |
| | | @Autowired |
| | | private LWhFormScrappedGoodsService scrappedGoodsService; |
| | | |
| | | /** |
| | | * @Description 新增报废单 |
| | |
| | | */ |
| | | @PostMapping("/add") |
| | | public ResponseValue add(@RequestBody LWhFormScrappedParam param) { |
| | | //根据盘点人id查询盘点人 |
| | | S_user_core operatorUser = this.getUser(param.getOperatorId()); |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | int result = this.lWhFormScrappedService.add(param, sysInfo,operatorUser); |
| | | int result = this.lWhFormScrappedService.add(param, this.getCurrentUser(),sysInfo); |
| | | if (result > 0) return ResponseValue.success(1); |
| | | return ResponseValue.error("新增失败!"); |
| | | } |
| | | |
| | | /** |
| | | * @Description 列表查询 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/11/02 |
| | | */ |
| | | //1.查询报废单 |
| | | //2.查询报废单物品 |
| | | @GetMapping("/list") |
| | | public ResponseValue queryList(LWhFormScrappedParam param) { |
| | | FinSysTenantUser sysInfo = getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | |
| | | GenericPager genericPager = lWhFormScrappedService.queryList(param,sysInfo); |
| | | List<LWhFormScrapped> datas = genericPager.getDatas(); |
| | | ArrayList<LWhFormScrappedExtend> newDatas = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(datas)) { |
| | | datas.forEach(item -> { |
| | | // 查询报废单物品 |
| | | LWhFormScrappedGoods scrappedGoods = new LWhFormScrappedGoods(); |
| | | scrappedGoods.setFormScrappedId(item.getId()); |
| | | List<LWhFormScrappedGoods> scrappedGoodsList = scrappedGoodsService.select(scrappedGoods); |
| | | LWhFormScrappedExtend formScrappedExtend = new LWhFormScrappedExtend(); |
| | | BeanUtils.copyProperties(item, formScrappedExtend); |
| | | formScrappedExtend.setScrappedGoodsList(scrappedGoodsList); |
| | | newDatas.add(formScrappedExtend); |
| | | }); |
| | | } |
| | | 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/11/2 |
| | | */ |
| | | @GetMapping("/detail") |
| | | public ResponseValue getById(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("报废单id为空"); |
| | | } |
| | | LWhFormScrappedExtend scrappedExtend = this.lWhFormScrappedService.getById(id); |
| | | return ResponseValue.success(scrappedExtend); |
| | | } |
| | | |
| | | /** |
| | | * 报废明细 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @GetMapping("/list/detailList") |
| | | public ResponseValue queryDetailList(LWhFormScrappedParam param) { |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | GenericPager<Map<String, Object>> genericPager = lWhFormScrappedService.queryDetailList(param,sysInfo); |
| | | return ResponseValue.success(genericPager); |
| | | } |
| | | |
| | | /** |
| | | * @Description 导出报废登记单 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/11/2 |
| | | */ |
| | | @GetMapping("/export") |
| | | public ResponseValue export(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("报废单id为空"); |
| | | } |
| | | LWhFormScrappedExtend scrappedExtend = this.lWhFormScrappedService.export(id,this.getSysInfo()); |
| | | return ResponseValue.success(scrappedExtend); |
| | | } |
| | | |
| | | |
| | | } |