| | |
| | | package com.consum.base.controller; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.LWhFormScrappedParam; |
| | | import com.consum.base.pojo.excel.ScrappedInfoExcelTemplate; |
| | | import com.consum.base.pojo.query.LWhFormScrappedQry; |
| | | import com.consum.base.pojo.response.FromTransferTemplateInfoVO; |
| | | import com.consum.base.pojo.response.LWhFormScrappedExtendVO; |
| | | import com.consum.base.pojo.response.LWhFormScrappedVO; |
| | | import com.consum.base.service.LWhFormScrappedServiceImpl; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormScrapped; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | 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 java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.LWhFormScrappedParam; |
| | | import com.consum.base.pojo.excel.ScrappedInfoExcelTemplate; |
| | | import com.consum.base.pojo.query.LWhFormScrappedQry; |
| | | import com.consum.base.pojo.response.GoodsTemplateCountVO; |
| | | import com.consum.base.pojo.response.LWhFormScrappedExtendVO; |
| | | import com.consum.base.pojo.response.LWhFormScrappedVO; |
| | | import com.consum.base.service.LWhFormScrappedService; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormScrapped; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.web.ResponseValue; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | /** |
| | | * @Description 报废单 |
| | |
| | | public class LWhFormScrappedController extends BaseController { |
| | | |
| | | @Autowired |
| | | private LWhFormScrappedServiceImpl lWhFormScrappedService; |
| | | |
| | | private LWhFormScrappedService lWhFormScrappedService; |
| | | |
| | | /** |
| | | * @Description 新增报废单 |
| | |
| | | * @Date 2023/11/1 |
| | | */ |
| | | @ApiOperation(value = "新增报废单", notes = "新增报废单") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "param") |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "param")}) |
| | | @PostMapping("/add") |
| | | public ResponseValue add() { |
| | | LWhFormScrappedParam param = CommonUtil.getObjFromReqBody(LWhFormScrappedParam.class); |
| | |
| | | /** |
| | | * @Description 列表查询 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/11/02 1.查询报废单 2.查询报废单物品 |
| | | * @Date 2023/11/02 |
| | | * <p> |
| | | * </>1.查询报废单 2.查询报废单物品 |
| | | */ |
| | | @ApiOperation(value = "列表查询", notes = "列表查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "param", value = "查询条件", dataType = "LWhFormScrappedQry", paramType = "query") |
| | | }) |
| | | @ApiImplicitParam(name = "param", value = "查询条件", dataType = "LWhFormScrappedQry", paramType = "query")}) |
| | | @GetMapping("/list") |
| | | public ResponseValue queryList() { |
| | | LWhFormScrappedQry param = CommonUtil.getObjFromReq(LWhFormScrappedQry.class); |
| | |
| | | data.forEach(item -> { |
| | | LWhFormScrappedVO lWhFormScrappedVO = new LWhFormScrappedVO(); |
| | | BeanUtils.copyProperties(item, lWhFormScrappedVO); |
| | | List<FromTransferTemplateInfoVO> list = Lists.newArrayList(); |
| | | // 查询型号数量 |
| | | String sql = |
| | | "SELECT fsg.id,fsg.BASE_GOODS_TEMPLATE_ID goodsTemplatesId,fsg.GOODS_TEMPLATE_NAME goodsName,sum(counts) count FROM l_wh_form_scrapped fs left join l_wh_form_scrapped_goods fsg on fs.id = fsg.FORM_SCRAPPED_ID " |
| | | + "where fsg.FORM_SCRAPPED_ID =:id group by fsg.BASE_GOODS_TEMPLATE_ID"; |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("id", item.getId()); |
| | | List<Map<String, Object>> procureModelList = lWhFormScrappedService.select(sql, paramMap, new MapperUtil()); |
| | | for (Map<String, Object> map : procureModelList) { |
| | | FromTransferTemplateInfoVO fromTransferTemplateInfoVO = MapUtils.convertMapToObj(map, FromTransferTemplateInfoVO.class); |
| | | list.add(fromTransferTemplateInfoVO); |
| | | } |
| | | lWhFormScrappedVO.setGoodTemplateInfo(list); |
| | | List<GoodsTemplateCountVO> scrappedCount = |
| | | lWhFormScrappedService.getScrappedCountByBusinessId(item.getId()); |
| | | lWhFormScrappedVO.setGoodTemplateInfo(scrappedCount); |
| | | result.add(lWhFormScrappedVO); |
| | | }); |
| | | } |
| | |
| | | * @Date 2023/11/2 |
| | | */ |
| | | @ApiOperation(value = "根据id查询详情", notes = "根据id查询详情") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query") |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query")}) |
| | | @GetMapping("/detail") |
| | | public ResponseValue getById(Long id) { |
| | | if (id == null) { |
| | |
| | | */ |
| | | @ApiOperation(value = "报废明细", notes = "报废明细") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "param", value = "查询条件", dataType = "LWhFormScrappedQry", paramType = "query") |
| | | }) |
| | | @ApiImplicitParam(name = "param", value = "查询条件", dataType = "LWhFormScrappedQry", paramType = "query")}) |
| | | @GetMapping("/list/detailList") |
| | | public ResponseValue queryDetailList() { |
| | | LWhFormScrappedQry param = CommonUtil.getObjFromReq(LWhFormScrappedQry.class); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "导出报废单", notes = "导出报废单") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query") |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "报废单id", dataType = "Long", paramType = "query")}) |
| | | @GetMapping("/list/export") |
| | | public void export(Long id, HttpServletResponse response) throws Exception { |
| | | public ResponseValue<String> export(Long id, HttpServletResponse response) throws Exception { |
| | | if (id == null) { |
| | | throw new RuntimeException("报废单id为空"); |
| | | } |
| | |
| | | String operatorName = scrappedInfoExcelTemplate.getOperatorName(); |
| | | String businessFormCode = scrappedInfoExcelTemplate.getBusinessFormCode(); |
| | | |
| | | int countNum = export.stream().filter(item -> item.getNum() != null).mapToInt(ScrappedInfoExcelTemplate::getNum).sum(); |
| | | int totalAmount = export.stream().filter(item -> item.getTotalAmount() != null).mapToInt(ScrappedInfoExcelTemplate::getTotalAmount).sum(); |
| | | int countNum = |
| | | export.stream().filter(item -> item.getNum() != null).mapToInt(ScrappedInfoExcelTemplate::getNum).sum(); |
| | | double totalAmount = export.stream().filter(item -> item.getTotalAmount() != null) |
| | | .mapToDouble(ScrappedInfoExcelTemplate::getAmount).sum(); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("code", businessFormCode); |
| | |
| | | map.put("totalAmount", totalAmount); |
| | | |
| | | Workbook sheets = ExcelExportUtil.exportExcel(exportParams, ScrappedInfoExcelTemplate.class, export, map); |
| | | downLoadExcel("报废登记单", response, sheets); |
| | | String filePath = downLoadExcel("报废登记单", sheets); |
| | | return ResponseValue.success("导出成功", filePath); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |