|  |  | 
 |  |  | package com.vincent.rsf.server.manager.controller; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONArray; | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | 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.ExcelUtil; | 
 |  |  | import com.vincent.rsf.server.common.annotation.OperationLog; | 
 |  |  | import com.vincent.rsf.server.common.domain.BaseParam; | 
 |  |  | import com.vincent.rsf.server.common.domain.KeyValVo; | 
 |  |  | import com.vincent.rsf.server.common.domain.PageParam; | 
 |  |  | import com.vincent.rsf.server.manager.entity.DeliveryItem; | 
 |  |  | import com.vincent.rsf.server.manager.entity.*; | 
 |  |  | import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate; | 
 |  |  | import com.vincent.rsf.server.manager.entity.excel.DeliveryTemplate; | 
 |  |  | import com.vincent.rsf.server.manager.enums.OrderType; | 
 |  |  | import com.vincent.rsf.server.manager.enums.OrderWorkType; | 
 |  |  | import com.vincent.rsf.server.manager.service.CompanysService; | 
 |  |  | import com.vincent.rsf.server.manager.service.DeliveryItemService; | 
 |  |  | import com.vincent.rsf.server.manager.service.impl.DeliveryServiceImpl; | 
 |  |  | import com.vincent.rsf.server.system.controller.BaseController; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  | import org.springframework.web.multipart.MultipartFile; | 
 |  |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | import java.util.*; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private DeliveryItemService deliveryItemService; | 
 |  |  |     @Autowired | 
 |  |  |     private CompanysService companysService; | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:deliveryItem:list')") | 
 |  |  |     @PostMapping("/deliveryItem/page") | 
 |  |  |     public R page(@RequestBody Map<String, Object> map) { | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<DeliveryItem, BaseParam> pageParam = new PageParam<>(baseParam, DeliveryItem.class); | 
 |  |  |         return R.ok().add(deliveryItemService.page(pageParam, pageParam.buildWrapper(true))); | 
 |  |  |         QueryWrapper<DeliveryItem> wrapper = pageParam.buildWrapper(true); | 
 |  |  |         return R.ok().add(deliveryItemService.page(pageParam, wrapper)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:deliveryItem:list')") | 
 |  |  |     @PostMapping("/deliveryItem/filters/page") | 
 |  |  |     public R filter(@RequestBody Map<String, Object> map) { | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<DeliveryItem, BaseParam> pageParam = new PageParam<>(baseParam, DeliveryItem.class); | 
 |  |  |         QueryWrapper<DeliveryItem> wrapper = pageParam.buildWrapper(true); | 
 |  |  |         wrapper.apply("anfme > work_qty + qty "); | 
 |  |  |         return R.ok().add(deliveryItemService.page(pageParam, wrapper)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:deliveryItem:list')") | 
 |  |  |     @ApiOperation("分页获取列表") | 
 |  |  |     @PostMapping("/deliveryItem/edit/page") | 
 |  |  |     public R byPoIdspage(@RequestBody Map<String, Object> map) { | 
 |  |  |         List<Long> poDetlIds = new ArrayList<>(); | 
 |  |  |         if (!Objects.isNull(map.get("ids"))) { | 
 |  |  |             poDetlIds = JSONArray.parseArray(JSONArray.toJSONString(map.get("ids")), Long.class); | 
 |  |  |             map.remove("ids"); | 
 |  |  |         } | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<DeliveryItem, BaseParam> pageParam = new PageParam<>(baseParam, DeliveryItem.class); | 
 |  |  |         QueryWrapper<DeliveryItem> queryWrapper = pageParam.buildWrapper(true); | 
 |  |  |         if (!poDetlIds.isEmpty()) { | 
 |  |  |             queryWrapper.in("id", poDetlIds); | 
 |  |  |         } else { | 
 |  |  |             return R.ok(); | 
 |  |  |         } | 
 |  |  |         return R.ok().add(deliveryItemService.page(pageParam, queryWrapper)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:deliveryItem:list')") | 
 |  |  |     @PostMapping("/deliveryItem/list") | 
 |  |  | 
 |  |  |         deliveryItem.setCreateTime(new Date()); | 
 |  |  |         deliveryItem.setUpdateBy(getLoginUserId()); | 
 |  |  |         deliveryItem.setUpdateTime(new Date()); | 
 |  |  |         if (StringUtils.isNotBlank(deliveryItem.getSplrName())) { | 
 |  |  |             Companys companys = companysService.getById(deliveryItem.getSplrName()); | 
 |  |  |             deliveryItem.setSplrName(companys.getName()).setSplrCode(companys.getCode()); | 
 |  |  |         } | 
 |  |  |         if (!deliveryItemService.save(deliveryItem)) { | 
 |  |  |             return R.error("Save Fail"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         ); | 
 |  |  |         return R.ok().add(vos); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:deliveryItem:list')") | 
 |  |  |     @PostMapping("/deliveryItem/export") | 
 |  |  |     public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
 |  |  |         ExcelUtil.build(ExcelUtil.create(deliveryItemService.list(), DeliveryItem.class), response); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |