| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.common.utils.CommonUtil; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.controller.params.AsnOrderItemParams; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItem; |
| | | import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import com.vincent.rsf.server.system.entity.Fields; |
| | | import com.vincent.rsf.server.system.entity.FieldsItem; |
| | | import com.vincent.rsf.server.system.service.FieldsItemService; |
| | | import com.vincent.rsf.server.system.service.FieldsService; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api(tags = "ASN单明细") |
| | | @RestController |
| | | public class AsnOrderItemController extends BaseController { |
| | | |
| | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:save')") |
| | | @OperationLog("Create ASN单据") |
| | | @PostMapping("/asnOrderItem/save") |
| | | public R save(@RequestBody AsnOrderItem asnOrderItem) { |
| | | asnOrderItem.setCreateBy(getLoginUserId()); |
| | | asnOrderItem.setUpdateBy(getLoginUserId()); |
| | | String code = SerialRuleUtils.generateRuleCode("sys_ans_order", asnOrderItem); |
| | | if (!Objects.isNull(code)) { |
| | | asnOrderItem.setAsnCode(code); |
| | | public R save(@RequestBody Map<String, Object> params) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("信息不能为空!!"); |
| | | } |
| | | if (!asnOrderItemService.save(asnOrderItem)) { |
| | | params.put("createBy", getLoginUserId()); |
| | | params.put("updateBy", getLoginUser()); |
| | | |
| | | if (!asnOrderItemService.fieldsSave(params)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(asnOrderItem); |
| | | return R.ok("Save Success"); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:update')") |
| | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderItem:list')") |
| | | @PostMapping("/asnOrderItem/export") |
| | | @ApiOperation("收货通知单明细") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(asnOrderItemService.list(), AsnOrderItem.class), response); |
| | | AsnOrderTemplate template = ExcelUtil.mockData(AsnOrderTemplate.class); |
| | | List<AsnOrderTemplate> list = new ArrayList<>(); |
| | | list.add(template); |
| | | ExcelUtil.build(ExcelUtil.create(list, AsnOrderTemplate.class, true), response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping("/asnOrder/import") |
| | | @ApiOperation("ASN导入接口") |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:update')") |
| | | public R importExcel(@RequestParam(value = "file") MultipartFile file, HttpServletRequest request) throws Exception { |
| | | public R importExcel(@RequestParam(value = "file") MultipartFile file, @RequestParam String asnId) throws Exception { |
| | | if (Objects.isNull(file)) { |
| | | throw new CoolException("文件不能为空!!"); |
| | | } |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | if (!Objects.isNull(request.getParameter("asnId"))) { |
| | | hashMap.put("asnId", request.getParameter("asnId")); |
| | | if (!Objects.isNull(asnId)) { |
| | | hashMap.put("asnId", asnId); |
| | | } |
| | | return asnOrderItemService.excelImport(file, hashMap); |
| | | } |