|
|
@ -1,34 +1,40 @@ |
|
|
|
package com.win.module.wms.controller.purchasereceiptRecord; |
|
|
|
|
|
|
|
import com.win.framework.common.pojo.CommonResult; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.dict.core.util.DictFrameworkUtils; |
|
|
|
import com.win.framework.excel.core.util.ExcelUtils; |
|
|
|
import com.win.framework.operatelog.core.annotations.OperateLog; |
|
|
|
import com.win.module.system.api.user.AdminUserApi; |
|
|
|
import com.win.module.system.api.user.dto.AdminUserRespDTO; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainExcelVO; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainExportReqVO; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainPageReqVO; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainRespVO; |
|
|
|
import com.win.module.wms.convert.purchasereceiptRecord.PurchasereceiptRecordMainConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRecord.PurchasereceiptRecordDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRecord.PurchasereceiptRecordMainDO; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.service.purchasereceiptRecord.PurchasereceiptRecordDetailService; |
|
|
|
import com.win.module.wms.service.purchasereceiptRecord.PurchasereceiptRecordMainService; |
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.validation.*; |
|
|
|
import javax.servlet.http.*; |
|
|
|
import java.util.*; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.common.pojo.CommonResult; |
|
|
|
import static com.win.framework.common.pojo.CommonResult.success; |
|
|
|
|
|
|
|
import com.win.framework.excel.core.util.ExcelUtils; |
|
|
|
|
|
|
|
import com.win.framework.operatelog.core.annotations.OperateLog; |
|
|
|
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; |
|
|
|
|
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRecord.PurchasereceiptRecordMainDO; |
|
|
|
import com.win.module.wms.convert.purchasereceiptRecord.PurchasereceiptRecordMainConvert; |
|
|
|
import com.win.module.wms.service.purchasereceiptRecord.PurchasereceiptRecordMainService; |
|
|
|
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 采购收货记录主") |
|
|
|
@RestController |
|
|
@ -38,24 +44,12 @@ public class PurchasereceiptRecordMainController { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private PurchasereceiptRecordMainService purchasereceiptRecordMainService; |
|
|
|
@Resource |
|
|
|
private PurchasereceiptRecordDetailService purchasereceiptRecordDetailService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AdminUserApi userApi; |
|
|
|
|
|
|
|
@PostMapping("/create") |
|
|
|
@Operation(summary = "创建采购收货记录主") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:purchasereceipt-record-main:create')") |
|
|
|
public CommonResult<Long> createPurchasereceiptRecordMain(@Valid @RequestBody PurchasereceiptRecordMainCreateReqVO createReqVO) { |
|
|
|
return success(purchasereceiptRecordMainService.createPurchasereceiptRecordMain(createReqVO)); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/update") |
|
|
|
@Operation(summary = "更新采购收货记录主") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:purchasereceipt-record-main:update')") |
|
|
|
public CommonResult<Boolean> updatePurchasereceiptRecordMain(@Valid @RequestBody PurchasereceiptRecordMainUpdateReqVO updateReqVO) { |
|
|
|
purchasereceiptRecordMainService.updatePurchasereceiptRecordMain(updateReqVO); |
|
|
|
return success(true); |
|
|
|
} |
|
|
|
@PostMapping("/senior") |
|
|
|
@Operation(summary = "高级搜索获得采购收货记录主信息分页") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:PurchasereceiptRecordMain:query')") |
|
|
@ -69,32 +63,6 @@ public class PurchasereceiptRecordMainController { |
|
|
|
} |
|
|
|
return success(result); |
|
|
|
} |
|
|
|
@DeleteMapping("/delete") |
|
|
|
@Operation(summary = "删除采购收货记录主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:purchasereceipt-record-main:delete')") |
|
|
|
public CommonResult<Boolean> deletePurchasereceiptRecordMain(@RequestParam("id") Long id) { |
|
|
|
purchasereceiptRecordMainService.deletePurchasereceiptRecordMain(id); |
|
|
|
return success(true); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/get") |
|
|
|
@Operation(summary = "获得采购收货记录主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:purchasereceipt-record-main:query')") |
|
|
|
public CommonResult<PurchasereceiptRecordMainRespVO> getPurchasereceiptRecordMain(@RequestParam("id") Long id) { |
|
|
|
PurchasereceiptRecordMainDO purchasereceiptRecordMain = purchasereceiptRecordMainService.getPurchasereceiptRecordMain(id); |
|
|
|
return success(PurchasereceiptRecordMainConvert.INSTANCE.convert(purchasereceiptRecordMain)); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/list") |
|
|
|
@Operation(summary = "获得采购收货记录主列表") |
|
|
|
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:purchasereceipt-record-main:query')") |
|
|
|
public CommonResult<List<PurchasereceiptRecordMainRespVO>> getPurchasereceiptRecordMainList(@RequestParam("ids") Collection<Long> ids) { |
|
|
|
List<PurchasereceiptRecordMainDO> list = purchasereceiptRecordMainService.getPurchasereceiptRecordMainList(ids); |
|
|
|
return success(PurchasereceiptRecordMainConvert.INSTANCE.convertList(list)); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/page") |
|
|
|
@Operation(summary = "获得采购收货记录主分页") |
|
|
@ -108,17 +76,48 @@ public class PurchasereceiptRecordMainController { |
|
|
|
@Operation(summary = "导出采购收货记录主 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:purchasereceipt-record-main:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportPurchasereceiptRecordMainExcel(@Valid PurchasereceiptRecordMainExportReqVO exportReqVO, |
|
|
|
HttpServletResponse response) throws IOException { |
|
|
|
public void exportPurchasereceiptRecordMainExcel(@Valid PurchasereceiptRecordMainExportReqVO exportReqVO, HttpServletResponse response) throws IOException { |
|
|
|
List<PurchasereceiptRecordMainDO> list = purchasereceiptRecordMainService.getPurchasereceiptRecordMainList(exportReqVO); |
|
|
|
// 导出 Excel
|
|
|
|
List<PurchasereceiptRecordMainExcelVO> datas = PurchasereceiptRecordMainConvert.INSTANCE.convertList02(list); |
|
|
|
for(PurchasereceiptRecordMainExcelVO vo : datas) { |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(vo.getCreator())); |
|
|
|
//后端创建个字段作为前端展示的虚拟字段
|
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<PurchasereceiptRecordMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
ExcelUtils.write(response, "采购收货记录主.xls", "数据", PurchasereceiptRecordMainExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/export-excel-senior") |
|
|
|
@Operation(summary = "导出采购收货记录主 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:purchasereceipt-record-main:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportPurchasereceiptRecordMainSeniorExcel(@Valid @RequestBody CustomConditions conditions, HttpServletResponse response) throws IOException { |
|
|
|
List<PurchasereceiptRecordMainDO> list = purchasereceiptRecordMainService.getPurchasereceiptRecordMainList(conditions); |
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<PurchasereceiptRecordMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
ExcelUtils.write(response, "采购收货记录主.xls", "数据", PurchasereceiptRecordMainExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
private List<PurchasereceiptRecordMainExcelVO> getExcelVo(List<PurchasereceiptRecordMainDO> list, Map<Integer, String[]> mapDropDown) { |
|
|
|
//组装vo
|
|
|
|
String[] transferMode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRANSFER_MODE); |
|
|
|
mapDropDown.put(7, transferMode); |
|
|
|
String[] locationType = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.LOCATION_TYPE); |
|
|
|
mapDropDown.put(22, locationType); |
|
|
|
mapDropDown.put(23, locationType); |
|
|
|
String[] packUnit = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.PACK_UNIT); |
|
|
|
mapDropDown.put(44, packUnit); |
|
|
|
String[] uom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM); |
|
|
|
mapDropDown.put(46, uom); |
|
|
|
mapDropDown.put(48, uom); |
|
|
|
String[] failedReason = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.FAILED_REASON); |
|
|
|
mapDropDown.put(52, failedReason); |
|
|
|
List<PurchasereceiptRecordMainExcelVO> resultList = new ArrayList<>(); |
|
|
|
// 导出
|
|
|
|
for(PurchasereceiptRecordMainDO mainDO : list) { |
|
|
|
List<PurchasereceiptRecordDetailDO> subList = purchasereceiptRecordDetailService.selectList(mainDO.getId()); |
|
|
|
for(PurchasereceiptRecordDetailDO detailDO : subList) { |
|
|
|
PurchasereceiptRecordMainExcelVO vo = PurchasereceiptRecordMainConvert.INSTANCE.convert(mainDO, detailDO); |
|
|
|
resultList.add(vo); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtils.write(response, "采购收货记录主.xls", "数据", PurchasereceiptRecordMainExcelVO.class, datas); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|