|  |  | 
 |  |  | 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.common.utils.FieldsUtils; | 
 |  |  | import com.vincent.rsf.server.manager.entity.TaskItem; | 
 |  |  | import com.vincent.rsf.server.manager.entity.WaitPakinItem; | 
 |  |  | import com.vincent.rsf.server.manager.entity.WarehouseAreasItem; | 
 |  |  | import com.vincent.rsf.server.manager.service.TaskItemService; | 
 |  |  | import com.vincent.rsf.server.manager.service.WaitPakinItemService; | 
 |  |  | import com.vincent.rsf.server.system.controller.BaseController; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | @Api(tags = "组拖档明细") | 
 |  |  | @RestController | 
 |  |  | public class WaitPakinItemController extends BaseController { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private WaitPakinItemService waitPakinItemService; | 
 |  |  |     @Autowired | 
 |  |  |     private TaskItemService taskItemService; | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:waitPakinItem:list')") | 
 |  |  |     @PostMapping("/waitPakinItem/page") | 
 |  |  |     public R page(@RequestBody Map<String, Object> map) { | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<WaitPakinItem, BaseParam> pageParam = new PageParam<>(baseParam, WaitPakinItem.class); | 
 |  |  |         return R.ok().add(waitPakinItemService.page(pageParam, pageParam.buildWrapper(true))); | 
 |  |  |         /**拼接扩展字段*/ | 
 |  |  |         PageParam<WaitPakinItem, BaseParam> page = waitPakinItemService.page(pageParam,  pageParam.buildWrapper(true)); | 
 |  |  |         List<WaitPakinItem> records = page.getRecords(); | 
 |  |  |         for (WaitPakinItem record : records) { | 
 |  |  |             if (!Objects.isNull(record.getFieldsIndex())) { | 
 |  |  |                 Map<String, String> fields = FieldsUtils.getFields(record.getFieldsIndex()); | 
 |  |  |                 record.setExtendFields(fields); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         page.setRecords(records); | 
 |  |  |         return R.ok().add(page); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:waitPakinItem:list')") | 
 |  |  | 
 |  |  |     @OperationLog("Delete 组拖档明细") | 
 |  |  |     @PostMapping("/waitPakinItem/remove/{ids}") | 
 |  |  |     public R remove(@PathVariable Long[] ids) { | 
 |  |  |         if (Objects.isNull(ids) || ids.length < 1) { | 
 |  |  |             return R.error("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getSource, ids)); | 
 |  |  |         if (!taskItems.isEmpty()) { | 
 |  |  |             throw new CoolException("有任务明细未完成"); | 
 |  |  |         } | 
 |  |  |         if (!waitPakinItemService.removeByIds(Arrays.asList(ids))) { | 
 |  |  |             return R.error("Delete Fail"); | 
 |  |  |         } |