| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.production.dto.ProductionProductMainDto; |
| | | import com.ruoyi.production.bean.dto.ProductionProductMainDto; |
| | | import com.ruoyi.production.bean.vo.DeviceOutputStatVo; |
| | | import com.ruoyi.production.bean.vo.PieceWageSummaryVo; |
| | | import com.ruoyi.production.service.ProductionProductMainService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | |
| | | @RequestMapping("productionProductMain") |
| | | @RequestMapping("/productionProductMain") |
| | | @RestController |
| | | @Api(value = "生产报工") |
| | | @Tag(name = "生产报工") |
| | | @AllArgsConstructor |
| | | public class ProductionProductMainController { |
| | | |
| | | @Autowired |
| | | private ProductionProductMainService productionProductMainService; |
| | | |
| | | /** |
| | |
| | | * @param productionProductMainDto |
| | | * @return |
| | | */ |
| | | @GetMapping("listPage") |
| | | @GetMapping("/listPage") |
| | | public R page(Page<ProductionProductMainDto> page, ProductionProductMainDto productionProductMainDto) { |
| | | return R.ok(productionProductMainService.listPageProductionProductMainDto(page, productionProductMainDto)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "生产报工分页查询") |
| | | public R pageProductionProductMain(Page<ProductionProductMainDto> page, ProductionProductMainDto productionProductMainDto) { |
| | | return R.ok(productionProductMainService.pageProductionProductMain(page, productionProductMainDto)); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @Operation(summary = "生产报工详情") |
| | | public R getInfo(@PathVariable("id") Long id) { |
| | | return R.ok(productionProductMainService.getProductionProductMainInfo(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param productionProductMainDto |
| | | * @return |
| | | */ |
| | | @PostMapping("addProductMain") |
| | | @PostMapping("/addProductMain") |
| | | @PreAuthorize("@ss.hasPermi('productionProductMain:add')") |
| | | public R addProductMain(@RequestBody ProductionProductMainDto productionProductMainDto) { |
| | | return R.ok(productionProductMainService.addProductMain(productionProductMainDto)); |
| | | } |
| | | |
| | | @ApiOperation("删除报工") |
| | | @DeleteMapping("/{ids}") |
| | | public R delete(@PathVariable("ids") Long[] ids) { |
| | | return R.ok(productionProductMainService.removeBatchByIds(Arrays.asList(ids))); |
| | | @PostMapping |
| | | @Operation(summary = "新增生产报工") |
| | | public R add(@RequestBody ProductionProductMainDto productionProductMainDto) { |
| | | return R.ok(productionProductMainService.saveProductionProductMain(productionProductMainDto)); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Operation(summary = "修改生产报工") |
| | | public R edit(@RequestBody ProductionProductMainDto productionProductMainDto) { |
| | | return R.ok(productionProductMainService.saveProductionProductMain(productionProductMainDto)); |
| | | } |
| | | |
| | | @Operation(summary = "删除报工") |
| | | @DeleteMapping("/delete") |
| | | public R delete(@RequestBody ProductionProductMainDto productionProductMainDto) { |
| | | return R.ok(productionProductMainService.removeProductMain(productionProductMainDto.getId())); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @Operation(summary = "删除生产报工") |
| | | public R remove(@PathVariable("id") Long id) { |
| | | return R.ok(productionProductMainService.removeProductMain(id)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出 |
| | | */ |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ProductionProductMainDto productionProductMainDto) { |
| | | List<ProductionProductMainDto> list; |
| | | list = productionProductMainService.listPageProductionProductMainDto(new Page<>(1, -1), productionProductMainDto).getRecords(); |
| | | ExcelUtil<ProductionProductMainDto> util = new ExcelUtil<ProductionProductMainDto>(ProductionProductMainDto.class); |
| | | util.exportExcel(response, list, "生产报工数据"); |
| | | } |
| | | |
| | | @GetMapping("/wageSummary") |
| | | @Operation(summary = "计件工资汇总(按人员,计件单价优先)") |
| | | public R<List<PieceWageSummaryVo>> wageSummary( |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate, |
| | | @RequestParam(required = false) String userName) { |
| | | return R.ok(productionProductMainService.wageSummary(startDate, endDate, userName)); |
| | | } |
| | | |
| | | @GetMapping("/wageSummary/export") |
| | | @Operation(summary = "计件工资汇总导出") |
| | | public void wageSummaryExport(HttpServletResponse response, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate, |
| | | @RequestParam(required = false) String userName) { |
| | | List<PieceWageSummaryVo> list = productionProductMainService.wageSummary(startDate, endDate, userName); |
| | | ExcelUtil<PieceWageSummaryVo> util = new ExcelUtil<>(PieceWageSummaryVo.class); |
| | | util.exportExcel(response, list, "计件工资汇总"); |
| | | } |
| | | |
| | | @GetMapping("/outputStat") |
| | | @Operation(summary = "产量统计(dimension: device设备/operation工序/product产品)") |
| | | public R<List<DeviceOutputStatVo>> outputStat( |
| | | @RequestParam(required = false, defaultValue = "device") String dimension, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate, |
| | | @RequestParam(required = false) Long deviceId) { |
| | | return R.ok(productionProductMainService.outputStat(dimension, startDate, endDate, deviceId)); |
| | | } |
| | | |
| | | @GetMapping("/outputStat/export") |
| | | @Operation(summary = "产量统计导出") |
| | | public void outputStatExport(HttpServletResponse response, |
| | | @RequestParam(required = false, defaultValue = "device") String dimension, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate, |
| | | @RequestParam(required = false) Long deviceId) { |
| | | List<DeviceOutputStatVo> list = productionProductMainService.outputStat(dimension, startDate, endDate, deviceId); |
| | | ExcelUtil<DeviceOutputStatVo> util = new ExcelUtil<>(DeviceOutputStatVo.class); |
| | | util.exportExcel(response, list, "产量统计"); |
| | | } |
| | | } |