/*
|
* Copyright (c) 2018-2025, ztt All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the pig4cloud.com developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: ztt
|
*/
|
|
package com.chinaztt.mes.warehouse.controller;
|
|
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.ExcelWriter;
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
|
import com.chinaztt.mes.warehouse.dto.PackageReportDTO;
|
import com.chinaztt.mes.warehouse.dto.PackagingDTO;
|
import com.chinaztt.mes.warehouse.dto.PackagingItemDTO;
|
import com.chinaztt.mes.warehouse.service.PackagingItemService;
|
import com.chinaztt.mes.warehouse.service.PackagingService;
|
import com.chinaztt.mes.warehouse.state.constant.LocationTypeStringValues;
|
import com.chinaztt.ztt.common.core.util.R;
|
import com.chinaztt.ztt.common.log.annotation.SysLog;
|
import com.chinaztt.ztt.common.security.annotation.Inner;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.net.URLEncoder;
|
import java.util.List;
|
|
|
/**
|
* 包装主表
|
*
|
* @author sunxl
|
* @date 2021-06-03 13:56:52
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/packaging")
|
@Api(value = "packaging", tags = "包装主表管理")
|
public class PackagingController {
|
|
private final PackagingService packagingService;
|
private final PackagingItemService packagingItemService;
|
|
/**
|
* 分页查询
|
*
|
* @param page 分页对象
|
* @param packagingDTO 包装主表
|
* @return
|
*/
|
@ApiOperation(value = "分页查询", notes = "分页查询")
|
@GetMapping("/page")
|
public R getPackagingPage(Page page, PackagingDTO packagingDTO) {
|
return R.ok(packagingService.getPackagingPage(page, QueryWrapperUtil.gen(packagingDTO)));
|
}
|
|
|
/**
|
* 通过id查询包装主表
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
@GetMapping("/{id}")
|
public R getById(@PathVariable("id") Long id) {
|
return R.ok(packagingService.getPackingById(id));
|
}
|
|
/**
|
* 新增包装主表
|
*
|
* @param packagingDTO 包装主表
|
* @return R
|
*/
|
@ApiOperation(value = "新增包装主表", notes = "新增包装主表")
|
@SysLog("新增包装主表")
|
@PostMapping
|
public R save(@RequestBody PackagingDTO packagingDTO) {
|
return R.ok(packagingService.fullSave(packagingDTO));
|
}
|
|
/**
|
* 修改包装主表
|
*
|
* @param packagingDTO 包装主表
|
* @return R
|
*/
|
@ApiOperation(value = "修改包装主表", notes = "修改包装主表")
|
@SysLog("修改包装主表")
|
@PutMapping
|
public R updateById(@RequestBody PackagingDTO packagingDTO) {
|
return R.ok(packagingService.fullUpdate(packagingDTO));
|
}
|
|
/**
|
* 通过id删除包装主表
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id删除包装主表", notes = "通过id删除包装主表")
|
@SysLog("通过id删除包装主表")
|
@DeleteMapping("/{id}")
|
public R removeById(@PathVariable Long id) {
|
return R.ok(packagingService.removePackagingById(id));
|
}
|
|
/**
|
* 添加包装的明细
|
*
|
* @param packagingDTO
|
* @return R
|
*/
|
@ApiOperation(value = "添加包装的明细", notes = "添加包装的明细")
|
@SysLog("添加包装的明细")
|
@PostMapping("addPackagingStock")
|
public R addPackagingStock(@RequestBody PackagingDTO packagingDTO) {
|
return R.ok(packagingService.addPackagingStock(packagingDTO));
|
}
|
|
/**
|
* 分页查询
|
*
|
* @param page 分页对象
|
* @param packagingItemDTO 包装从表
|
* @return
|
*/
|
@ApiOperation(value = "分页查询", notes = "分页查询")
|
@GetMapping("/getPackagingItemPage")
|
public R getPackagingItemPage(Page page, PackagingItemDTO packagingItemDTO) {
|
return R.ok(packagingItemService.getPackagingItemPage(page, QueryWrapperUtil.gen(packagingItemDTO)));
|
}
|
|
/**
|
* 通过id删除包装从表
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id删除包装从表", notes = "通过id删除包装从表")
|
@SysLog("通过id删除包装从表")
|
@DeleteMapping("/removePackagingItemById/{id}")
|
public R removePackagingItemById(@PathVariable Long id) {
|
return R.ok(packagingItemService.removePackagingItemById(id));
|
}
|
|
/**
|
* 创建分割包装任务
|
*
|
* @param packagingDTOList
|
* @return
|
*/
|
@ApiOperation(value = "创建分割包装任务", notes = "创建分割包装任务")
|
@PostMapping("/batchSave")
|
public R batchSave(@RequestBody List<PackagingDTO> packagingDTOList) {
|
return R.ok(packagingService.batchSave(packagingDTOList));
|
}
|
|
/**
|
* 提交分割包装
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value = "提交分割包装", notes = "提交分割包装")
|
@GetMapping("/submit/{id}")
|
public R submit(@PathVariable Long id) {
|
return R.ok(packagingService.submit(id));
|
}
|
|
|
|
/**
|
* 跳线包装称重防呆
|
*
|
* @param packaging 包装主表
|
* @return R
|
*/
|
@ApiOperation(value = "跳线包装称重防呆", notes = "跳线包装称重防呆")
|
@SysLog("跳线包装称重防呆")
|
@PostMapping("/weighVerifyCheck")
|
public R weighVerifyCheck(@RequestBody PackagingDTO packaging) {
|
return packagingService.weighVerifyCheck(packaging);
|
}
|
|
|
/**
|
* 称重更新包装的重量
|
* 移植跳线
|
*
|
* @param packaging 包装主表
|
* @return R
|
*/
|
@ApiOperation(value = "称重更新包装的重量", notes = "称重更新包装的重量")
|
@SysLog("称重更新包装的重量")
|
@PostMapping("/getWeight")
|
public R getWeight(@RequestBody PackagingDTO packaging) {
|
return packagingService.getWeight(packaging);
|
}
|
|
/**
|
* 包装每日统计
|
* 移植跳线
|
*
|
* @param packageReportDTO 工步
|
* @return R
|
*/
|
@ApiOperation(value = "查询每日工步执行情况", notes = "查询每日工步执行情况")
|
@GetMapping("/getEveryDayReport")
|
@Inner(value = false)
|
public R getEveryDayReport(Page page, PackageReportDTO packageReportDTO) {
|
return R.ok(packagingService.getEveryDayReport(page, packageReportDTO));
|
}
|
|
/**
|
* 导出每日工步信息
|
* 移植跳线
|
*
|
* @return
|
*/
|
@ApiOperation(value = "导出", notes = "导出")
|
@Inner(false)
|
@GetMapping("/exprotEveryDayReport")
|
public void exportStock(HttpServletResponse response, Page page, PackageReportDTO packageReportDTO) throws IOException {
|
response.setContentType("application/vnd.ms-excel");
|
response.setCharacterEncoding("UTF-8");
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
String fileName = URLEncoder.encode("每日包装统计", "UTF-8");
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
try {
|
//新建ExcelWriter
|
ExcelWriter excelWriter =
|
EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build();
|
//获取sheet0对象
|
WriteSheet mainSheet = EasyExcel.writerSheet(0, "每日包装统计").head(PackageReportDTO.class).build();
|
List<PackageReportDTO> list = packagingService.getEveryDayReport(page, packageReportDTO).getRecords();
|
excelWriter.write(list, mainSheet);
|
//关闭文件流
|
excelWriter.finish();
|
} catch (IOException e) {
|
throw new RuntimeException("导出失败");
|
}
|
}
|
|
|
/**
|
* 批量更新包装明细的【移入库位】字段
|
*
|
* @param packagingItemDTOList
|
* @return
|
*/
|
@ApiOperation(value = "批量更新包装明细【移入库位】字段信息", notes = "批量更新包装明细【移入库位】字段信息")
|
@PostMapping("/updateInLocationNoBatch")
|
public R updateInLocationNoBatch(@RequestBody List<PackagingItemDTO> packagingItemDTOList) {
|
return packagingItemService.updateInLocationNoBatch(packagingItemDTOList);
|
}
|
|
/**
|
* 获取可用的成品库位列表
|
*
|
* @return
|
*/
|
@ApiOperation(value = "获取可用的成品库位列表", notes = "获取可用的成品库位列表")
|
@GetMapping("/getEnableFinishProdList")
|
public R getEnableFinishProdList() {
|
return packagingItemService.getEnableFinishProdList(LocationTypeStringValues.FINISHLOCATIONCODE);
|
}
|
|
/**
|
* 根据报表code获取积木报表url(1:光电混合缆-华为合格证;2:称重标签)
|
*
|
* @param reportCode
|
* @return
|
*/
|
@ApiOperation(value = "根据报表code获取包装模块积木报表url(1:光电混合缆-华为合格证;2:称重标签)", notes = "根据报表code获取包装模块积木报表url(1:光电混合缆-华为合格证;" +
|
"2:称重标签)")
|
@GetMapping("/getPackJmreportUrl/{reportCode}")
|
public R getPackJmreportUrl(@PathVariable String reportCode) {
|
return packagingService.getPackJmreportUrl(reportCode);
|
}
|
|
/**
|
* 根据包装主表记录行id修改包装主表状态为:已确认
|
*
|
* @return
|
*/
|
@ApiOperation(value = "包装确认", notes = "包装确认")
|
@PostMapping("/packConfirm/{id}")
|
public R packConfirm(@PathVariable Long id) {
|
return packagingService.packConfirm(id);
|
}
|
|
/**
|
* 根据包装主表记录行id修改包装主表状态为:未确认
|
*
|
* @return
|
*/
|
@ApiOperation(value = "取消包装确认", notes = "取消包装确认")
|
@PostMapping("/packCancelConfirm/{id}")
|
public R packCancelConfirm(@PathVariable Long id) {
|
return packagingService.packCancelConfirm(id);
|
}
|
|
/**
|
* 获取成品包装表头所需基础信息list
|
*
|
* @return
|
*/
|
@ApiOperation(value = "【PDA包装】获取成品包装表头所需基础信息list", notes = "查询包材、包装尺寸、包装重量及成品库位编号[无需传参]")
|
@GetMapping("/getPackHeadBasicInfoList")
|
public R getPackHeadBasicInfoList() {
|
return packagingService.getPackHeadBasicInfoList();
|
}
|
|
|
/**
|
* 跳线车间pda扫码入库
|
*
|
* @param packagingNo
|
* @param inLocationNo
|
* @return
|
*/
|
@ApiOperation(value = "跳线车间pda扫码入库", notes = "跳线车间pda扫码入库")
|
@GetMapping("/updateInLocationByPda")
|
public R updateInLocationByPda(String packagingNo, String inLocationNo) {
|
return packagingItemService.updateInLocationByPda(packagingNo, inLocationNo);
|
}
|
|
|
/**
|
* 根据箱码得到包装明细和包装明细数量
|
*
|
* @param packagingNo
|
* @return
|
*/
|
@ApiOperation(value = "根据箱码得到包装明细和包装明细数量", notes = "根据箱码得到包装明细和包装明细数量")
|
@GetMapping("/getPackagingAndSizeByPackagingNo")
|
public R getPackagingAndSizeByPackagingNo(String packagingNo) {
|
return packagingService.getPackagingAndSizeByPackagingNo(packagingNo);
|
}
|
|
@ApiOperation(value = "校验中兴跳线入库是否重复扫描", notes = "校验中兴跳线入库是否重复扫描")
|
@GetMapping("/validatePackagingCodeRepeat")
|
public R validatePackagingNoRepeat(String packagingCode, String pkgCode) {
|
return packagingItemService.validatePackagingNoRepeat(packagingCode, pkgCode);
|
}
|
|
@GetMapping("/updateZxInLocationByPda")
|
public R updateZxInLocationByPda(String packagingCode, String pkgCode, String inLocationNo) {
|
return packagingItemService.updateZxInLocationByPda(packagingCode, pkgCode, inLocationNo);
|
}
|
}
|