|  | @@ -1,44 +1,34 @@
 | 
	
		
			
				|  |  |  package com.ruoyi.web.controller.warehouse.check;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.Date;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import com.ruoyi.basicData.service.ITWarehouseService;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.annotation.Log;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.core.controller.BaseController;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.core.domain.AjaxResult;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.core.domain.entity.TWarehouse;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.core.page.TableDataInfo;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.enums.BusinessType;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.SecurityUtils;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.utils.poi.ExcelUtil;
 | 
	
		
			
				|  |  | +import com.ruoyi.warehouse.check.domain.TWarehouseCheck;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouse.check.domain.TWarehouseCheckItems;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouse.check.domain.TWarehouseCheckItemsDetails;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouse.check.service.ITWarehouseCheckItemsDetailsService;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouse.check.service.ITWarehouseCheckItemsService;
 | 
	
		
			
				|  |  | -import org.springframework.security.access.prepost.PreAuthorize;
 | 
	
		
			
				|  |  | -import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.GetMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.PostMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.PutMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.DeleteMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.PathVariable;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RequestBody;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  | -import com.ruoyi.common.annotation.Log;
 | 
	
		
			
				|  |  | -import com.ruoyi.common.core.controller.BaseController;
 | 
	
		
			
				|  |  | -import com.ruoyi.common.core.domain.AjaxResult;
 | 
	
		
			
				|  |  | -import com.ruoyi.common.enums.BusinessType;
 | 
	
		
			
				|  |  | -import com.ruoyi.warehouse.check.domain.TWarehouseCheck;
 | 
	
		
			
				|  |  |  import com.ruoyi.warehouse.check.service.ITWarehouseCheckService;
 | 
	
		
			
				|  |  | -import com.ruoyi.common.utils.poi.ExcelUtil;
 | 
	
		
			
				|  |  | -import com.ruoyi.common.core.page.TableDataInfo;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.security.access.prepost.PreAuthorize;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 巡检checkController
 | 
	
		
			
				|  |  | - * 
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  |   * @author dongyongwei
 | 
	
		
			
				|  |  |   * @date 2021-07-21
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  @RestController
 | 
	
		
			
				|  |  |  @RequestMapping("/warehouse/check")
 | 
	
		
			
				|  |  | -public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | +public class TWarehouseCheckController extends BaseController {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ITWarehouseCheckService tWarehouseCheckService;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -49,16 +39,12 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |      private ITWarehouseCheckItemsDetailsService tWarehouseCheckItemsDetailsService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * 获取表内存在的仓库列表
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  |       * 查询巡检check列表
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    //@PreAuthorize("@ss.hasPermi('warehouse:check:list')")
 | 
	
		
			
				|  |  | +    // @PreAuthorize("@ss.hasPermi('warehouse:check:list')")
 | 
	
		
			
				|  |  |      @GetMapping("/selectTWarehouseListInCheck")
 | 
	
		
			
				|  |  | -    public TableDataInfo list()
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | -//        startPage();
 | 
	
		
			
				|  |  | +    public TableDataInfo list() {
 | 
	
		
			
				|  |  | +        // startPage();
 | 
	
		
			
				|  |  |          List<TWarehouse> list = tWarehouseCheckService.selectTWarehouseListInCheck();
 | 
	
		
			
				|  |  |          return getDataTable(list);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -69,8 +55,7 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:list')")
 | 
	
		
			
				|  |  |      @GetMapping("/list")
 | 
	
		
			
				|  |  | -    public TableDataInfo list(TWarehouseCheck tWarehouseCheck)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | +    public TableDataInfo list(TWarehouseCheck tWarehouseCheck) {
 | 
	
		
			
				|  |  |          startPage();
 | 
	
		
			
				|  |  |          List<TWarehouseCheck> list = tWarehouseCheckService.selectTWarehouseCheckList(tWarehouseCheck);
 | 
	
		
			
				|  |  |          return getDataTable(list);
 | 
	
	
		
			
				|  | @@ -81,8 +66,7 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:list')")
 | 
	
		
			
				|  |  |      @GetMapping("/listByUser")
 | 
	
		
			
				|  |  | -    public TableDataInfo listByUser(TWarehouseCheck tWarehouseCheck)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | +    public TableDataInfo listByUser(TWarehouseCheck tWarehouseCheck) {
 | 
	
		
			
				|  |  |          tWarehouseCheck.setfInspectorId(SecurityUtils.getLoginUser().getUser().getUserId());
 | 
	
		
			
				|  |  |          startPage();
 | 
	
		
			
				|  |  |          List<TWarehouseCheck> list = tWarehouseCheckService.selectTWarehouseCheckList(tWarehouseCheck);
 | 
	
	
		
			
				|  | @@ -95,8 +79,7 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:export')")
 | 
	
		
			
				|  |  |      @Log(title = "巡检check", businessType = BusinessType.EXPORT)
 | 
	
		
			
				|  |  |      @GetMapping("/export")
 | 
	
		
			
				|  |  | -    public AjaxResult export(TWarehouseCheck tWarehouseCheck)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | +    public AjaxResult export(TWarehouseCheck tWarehouseCheck) {
 | 
	
		
			
				|  |  |          List<TWarehouseCheck> list = tWarehouseCheckService.selectTWarehouseCheckList(tWarehouseCheck);
 | 
	
		
			
				|  |  |          ExcelUtil<TWarehouseCheck> util = new ExcelUtil<TWarehouseCheck>(TWarehouseCheck.class);
 | 
	
		
			
				|  |  |          return util.exportExcel(list, "check");
 | 
	
	
		
			
				|  | @@ -107,8 +90,7 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:query')")
 | 
	
		
			
				|  |  |      @GetMapping(value = "/{fId}")
 | 
	
		
			
				|  |  | -    public AjaxResult getInfo(@PathVariable("fId") Long fId)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | +    public AjaxResult getInfo(@PathVariable("fId") Long fId) {
 | 
	
		
			
				|  |  |          return AjaxResult.success(tWarehouseCheckService.selectTWarehouseCheckById(fId));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -118,8 +100,7 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:add')")
 | 
	
		
			
				|  |  |      @Log(title = "巡检check", businessType = BusinessType.INSERT)
 | 
	
		
			
				|  |  |      @PostMapping
 | 
	
		
			
				|  |  | -    public AjaxResult add(@RequestBody TWarehouseCheck tWarehouseCheck)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | +    public AjaxResult add(@RequestBody TWarehouseCheck tWarehouseCheck) {
 | 
	
		
			
				|  |  |          return toAjax(tWarehouseCheckService.insertTWarehouseCheck(tWarehouseCheck).intValue());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -129,28 +110,27 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:add')")
 | 
	
		
			
				|  |  |      @Log(title = "巡检saveCheckAndItems", businessType = BusinessType.INSERT)
 | 
	
		
			
				|  |  |      @PostMapping("/saveCheckAndItems")
 | 
	
		
			
				|  |  | -    public AjaxResult saveCheckAndItems(@RequestBody TWarehouseCheck tWarehouseCheck)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | +    public AjaxResult saveCheckAndItems(@RequestBody TWarehouseCheck tWarehouseCheck) {
 | 
	
		
			
				|  |  |          //大计划fId
 | 
	
		
			
				|  |  |          Long fId = 0L;
 | 
	
		
			
				|  |  | -        if (tWarehouseCheck.getfId() != null){
 | 
	
		
			
				|  |  | +        if (tWarehouseCheck.getfId() != null) {
 | 
	
		
			
				|  |  |              //更新大计划
 | 
	
		
			
				|  |  |              fId = tWarehouseCheck.getfId();
 | 
	
		
			
				|  |  |              tWarehouseCheckService.updateTWarehouseCheck(tWarehouseCheck);
 | 
	
		
			
				|  |  | -        }else{
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  |              //新增大计划
 | 
	
		
			
				|  |  | -            fId =tWarehouseCheckService.insertTWarehouseCheck(tWarehouseCheck);
 | 
	
		
			
				|  |  | +            fId = tWarehouseCheckService.insertTWarehouseCheck(tWarehouseCheck);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if(fId>0){
 | 
	
		
			
				|  |  | +        if (fId > 0) {
 | 
	
		
			
				|  |  |              List<TWarehouseCheckItems> tWarehouseCheckItemsList = tWarehouseCheck.gettWarehouseCheckItemsList();
 | 
	
		
			
				|  |  | -            if(tWarehouseCheckItemsList.size()>0){//有数据情况下
 | 
	
		
			
				|  |  | -                for (int j = 0; j < tWarehouseCheckItemsList.size(); j++) {
 | 
	
		
			
				|  |  | -                    TWarehouseCheckItems tWarehouseCheckItems = tWarehouseCheckItemsList.get(j);
 | 
	
		
			
				|  |  | -                    if(tWarehouseCheckItems.getfId() != null){
 | 
	
		
			
				|  |  | +            if (tWarehouseCheckItemsList.size() > 0) {
 | 
	
		
			
				|  |  | +                //有数据情况下
 | 
	
		
			
				|  |  | +                for (TWarehouseCheckItems tWarehouseCheckItems : tWarehouseCheckItemsList) {
 | 
	
		
			
				|  |  | +                    if (tWarehouseCheckItems.getfId() != null) {
 | 
	
		
			
				|  |  |                          //更新数据
 | 
	
		
			
				|  |  |                          itWarehouseCheckItemsService.updateTWarehouseCheckItems(tWarehouseCheckItems);
 | 
	
		
			
				|  |  | -                    }else{
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  |                          //新增数据
 | 
	
		
			
				|  |  |                          tWarehouseCheckItems.setfCheckFid(fId);
 | 
	
		
			
				|  |  |                          itWarehouseCheckItemsService.insertTWarehouseCheckItems(tWarehouseCheckItems);
 | 
	
	
		
			
				|  | @@ -158,7 +138,7 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return AjaxResult.success(fId);
 | 
	
		
			
				|  |  | -        }else{
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  |              return AjaxResult.error("巡检任务更新失败,明细未处理");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -170,8 +150,7 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:edit')")
 | 
	
		
			
				|  |  |      @Log(title = "巡检check", businessType = BusinessType.UPDATE)
 | 
	
		
			
				|  |  |      @PutMapping
 | 
	
		
			
				|  |  | -    public AjaxResult edit(@RequestBody TWarehouseCheck tWarehouseCheck)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | +    public AjaxResult edit(@RequestBody TWarehouseCheck tWarehouseCheck) {
 | 
	
		
			
				|  |  |          return toAjax(tWarehouseCheckService.updateTWarehouseCheck(tWarehouseCheck));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -180,18 +159,24 @@ public class TWarehouseCheckController extends BaseController
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @PreAuthorize("@ss.hasPermi('warehouse:check:remove')")
 | 
	
		
			
				|  |  |      @Log(title = "巡检check", businessType = BusinessType.DELETE)
 | 
	
		
			
				|  |  | -	@DeleteMapping("/{fIds}")
 | 
	
		
			
				|  |  | -    public AjaxResult remove(@PathVariable Long[] fIds)
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | -        for (int f = 0; f < fIds.length; f++) {
 | 
	
		
			
				|  |  | -            Long checkId = fIds[f];
 | 
	
		
			
				|  |  | +    @DeleteMapping("/{fIds}")
 | 
	
		
			
				|  |  | +    public AjaxResult remove(@PathVariable Long[] fIds) {
 | 
	
		
			
				|  |  | +        for (Long checkId : fIds) {
 | 
	
		
			
				|  |  |              TWarehouseCheckItemsDetails tWarehouseCheckItemsDetailsQuery = new TWarehouseCheckItemsDetails();
 | 
	
		
			
				|  |  |              tWarehouseCheckItemsDetailsQuery.setfCheckFid(checkId);
 | 
	
		
			
				|  |  | -            List<TWarehouseCheckItemsDetails> tWarehouseCheckItemsDetailsList =tWarehouseCheckItemsDetailsService.selectTWarehouseCheckItemsDetailsList(tWarehouseCheckItemsDetailsQuery);
 | 
	
		
			
				|  |  | -            if(tWarehouseCheckItemsDetailsList.size()>0){
 | 
	
		
			
				|  |  | -                return AjaxResult.error("任务编号:"+checkId.intValue()+" 已存在巡检记录,无法删除");
 | 
	
		
			
				|  |  | +            List<TWarehouseCheckItemsDetails> tWarehouseCheckItemsDetailsList = tWarehouseCheckItemsDetailsService.selectTWarehouseCheckItemsDetailsList(tWarehouseCheckItemsDetailsQuery);
 | 
	
		
			
				|  |  | +            if (tWarehouseCheckItemsDetailsList.size() > 0) {
 | 
	
		
			
				|  |  | +                return AjaxResult.error("任务编号:" + checkId.intValue() + " 已存在巡检记录,无法删除");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return toAjax(tWarehouseCheckService.deleteTWarehouseCheckByIds(fIds));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * APP新增巡检check
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @PostMapping("/saveCheckItemsDetails")
 | 
	
		
			
				|  |  | +    public AjaxResult saveCheckItemsDetails(@RequestBody TWarehouseCheck tWarehouseCheck) {
 | 
	
		
			
				|  |  | +        return toAjax(tWarehouseCheckService.saveCheckItemsDetails(tWarehouseCheck));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |