diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/controller/ApiController.java b/ruoyi-api/src/main/java/com/ruoyi/api/controller/ApiController.java index 4f805af..100c8b5 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/controller/ApiController.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/controller/ApiController.java @@ -1,22 +1,27 @@ package com.ruoyi.api.controller; import com.alibaba.fastjson.JSONObject; +import com.ruoyi.api.domain.CheckTaskInfo; import com.ruoyi.api.domain.InStoreDto; import com.ruoyi.api.domain.OutStoreDto; import com.ruoyi.api.domain.StockDto; import com.ruoyi.api.service.impl.ApiService; +import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.domain.AjaxResult; import static com.ruoyi.common.core.domain.AjaxResult.*; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.manage.domain.*; import com.ruoyi.manage.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.unit.DataUnit; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.*; @@ -55,7 +60,7 @@ public class ApiController { public AjaxResult instoreSubmit(@RequestBody InStoreDto inStore) { List epcList = inStore.getEpcList(); int size = epcList.size(); - System.out.println("数据条数:"+size); + System.out.println("数据条数:" + size); Iterator iterator = epcList.iterator(); while (iterator.hasNext()) { String epc = iterator.next(); @@ -66,13 +71,13 @@ public class ApiController { } int size1 = epcList.size(); int i = size - size1; - if (size1>0){ + if (size1 > 0) { apiService.submintInsertRecordIn(inStore); apiService.submintInsertLedger(inStore); } - return success("本次入库成功:" + size1 +"条,屏蔽重复入库:"+ i +"条"); + return success("本次入库成功:" + size1 + "条,屏蔽重复入库:" + i + "条"); } @@ -88,13 +93,13 @@ public class ApiController { @PostMapping("/outStore/submit") public AjaxResult outStoreSubmit(@RequestBody OutStoreDto outStoreDto) { try { - List epcList = outStoreDto.getEpcList(); - //int i=0; - for (String epc:epcList ) { + List epcList = outStoreDto.getEpcList(); + //int i=0; + for (String epc : epcList) { String tag = apiService.selectLedgerbyEpcForOutStore(epc); - if (tag!=null){ - apiService.submitInsertRecordOut(outStoreDto,epc); - apiService.updataLedgerFoyOut(outStoreDto,epc); + if (tag != null) { + apiService.submitInsertRecordOut(outStoreDto, epc); + apiService.updataLedgerFoyOut(outStoreDto, epc); //i++; } @@ -118,7 +123,7 @@ public class ApiController { }*/ return success(); - }catch (Exception e){ + } catch (Exception e) { return error(); } @@ -180,16 +185,9 @@ public class ApiController { return success(); } - @PostMapping("/xj/select") - public AjaxResult xjSelect(String user) { - List list = apiService.xjSelect(user); - if (list == null) { - return error("没有维护巡检区域"); - } - return success(list); - } - @PostMapping("/xj/selectLite") - public String xjSelectLite(String user) { + + @PostMapping("/xj/selectLite") + public String xjSelectLite(String user) { List list = apiService.xjSelect(user); if (list == null) { return "null"; @@ -201,15 +199,81 @@ public class ApiController { private IRecordInspectionService inspectionService; @PostMapping("/xj/submit") - public AjaxResult inspectionSubmit(String json, String user) { + public AjaxResult inspectionSubmit(long tableId, String json, long inspectionId, List files) { + //插入 info 表 + List list = JSONObject.parseArray(json, StockDto.class); + apiService.insertInspectionInfo(list, inspectionId); + //修改task状态 + apiService.updataInspectionTaskByObjid(tableId); + + //存储图片,插库 + String filePath = RuoYiConfig.getUploadPath() + "/inspection"; + Date date = new Date(); + + if (files != null && files.size() > 0) { + for (MultipartFile multipartFile : files) { + String pathName = null; + try { + pathName = FileUploadUtils.upload(filePath, multipartFile); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("上传图片路径:" + pathName); + //apiService.confirmSubment(inspectionId, tableId, pathName); + } + } + + return success(); + + } + + /** + * 查询巡检机位 + * + * @param user + * @return + */ + @PostMapping("/inspection/selectTask") + public AjaxResult inspectionSelectTask(String user) { + List list = apiService.inspectionSelectTask(user); + if (list == null || list.isEmpty()) { + return error("需要创建"); + } + return success(list); + } + + /** + * 根据机位查询轮挡 + * + * @param + * @return + */ + @PostMapping("/inspection/select") + public AjaxResult inspectionSelect(String code) { + List list = apiService.inspectionSelectLocation(code); + if (list == null) { + return error("没有领用轮挡"); + } + return success(list); + } + + /** + * 创建巡检机位列表和巡检任务 + * + * @param user + * @return + */ + @PostMapping("/xj/createTask") + public AjaxResult inspectionCreateTask(String user) { + List list = apiService.selectLocationByAreaUser(user); + if (list == null || list.isEmpty()) { + return error("没有维护巡检区域"); + } RecordInspection recordInspection = new RecordInspection(); recordInspection.setInspectionUser(user); int insertNumber = inspectionService.insertRecordInspection(recordInspection); - if (insertNumber == 1) { - List list = JSONObject.parseArray(json, StockDto.class); - apiService.insertInspectionInfo(list,recordInspection.getInspectionId()); - } - return success(); + apiService.insertCheckTask(Math.toIntExact(recordInspection.getInspectionId()), list); + return success("创建成功", insertNumber); } @@ -233,6 +297,7 @@ public class ApiController { apiService.updataLedgerIn(epc, subCode); return success(); } + @PostMapping("/fpout/select") public AjaxResult fpOutSelect() { List list = apiService.fpOutSelect(); @@ -246,10 +311,10 @@ public class ApiController { public AjaxResult fpoutSubmit(String json, String user) { try { List list = JSONObject.parseArray(json, StockDto.class); - apiService.insertWasreOutRecord(list,user); - apiService.updataLedgerForWasreOut(list,user); + apiService.insertWasreOutRecord(list, user); + apiService.updataLedgerForWasreOut(list, user); return success(); - }catch (Exception e){ + } catch (Exception e) { return error(); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/domain/CheckTaskInfo.java b/ruoyi-api/src/main/java/com/ruoyi/api/domain/CheckTaskInfo.java new file mode 100644 index 0000000..34eece0 --- /dev/null +++ b/ruoyi-api/src/main/java/com/ruoyi/api/domain/CheckTaskInfo.java @@ -0,0 +1,71 @@ +package com.ruoyi.api.domain; + +import com.ruoyi.common.annotation.Log; + +public class CheckTaskInfo { + private int index; + private Long id; + private Long areaId; + private String locationCode; + private String areaName; + private String taskState; + + private Long inspectionId; + + + public Long getInspectionId() { + return inspectionId; + } + + public void setInspectionId(Long inspectionId) { + this.inspectionId = inspectionId; + } + + public Long getAreaId() { + return areaId; + } + + public void setAreaId(Long areaId) { + this.areaId = areaId; + } + + public String getTaskState() { + return taskState; + } + + public void setTaskState(String taskState) { + this.taskState = taskState; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getLocationCode() { + return locationCode; + } + + public void setLocationCode(String locationCode) { + this.locationCode = locationCode; + } + + public String getAreaName() { + return areaName; + } + + public void setAreaName(String areaName) { + this.areaName = areaName; + } +} diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ApiMapper.java b/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ApiMapper.java index 8ce98ff..ca7d9e3 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ApiMapper.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/mapper/ApiMapper.java @@ -1,5 +1,6 @@ package com.ruoyi.api.mapper; +import com.ruoyi.api.domain.CheckTaskInfo; import com.ruoyi.api.domain.InStoreDto; import com.ruoyi.api.domain.OutStoreDto; import com.ruoyi.api.domain.StockDto; @@ -53,4 +54,14 @@ public interface ApiMapper { String selectLedgerbyEpcForOutStore(String epc); int updataLedgerFoyOut(@Param("outStoreDto") OutStoreDto outStoreDto, @Param("epc") String epc); + + List selectLocationByAreaUser(String user); + + void insertCheckTask(@Param("id") int id,@Param("list") List list); + + List inspectionSelectTask(String user); + + List inspectionSelectLocation(String code); + + void updataInspectionTaskByObjid(long tableId); } diff --git a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/ApiService.java b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/ApiService.java index 1c0ad05..701caa6 100644 --- a/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/ApiService.java +++ b/ruoyi-api/src/main/java/com/ruoyi/api/service/impl/ApiService.java @@ -1,5 +1,6 @@ package com.ruoyi.api.service.impl; +import com.ruoyi.api.domain.CheckTaskInfo; import com.ruoyi.api.domain.InStoreDto; import com.ruoyi.api.domain.OutStoreDto; import com.ruoyi.api.domain.StockDto; @@ -19,17 +20,19 @@ import java.util.List; public class ApiService { @Autowired private ApiMapper mapper; -@Transactional + + @Transactional public int submintInsertRecordIn(InStoreDto inStore) { return mapper.submintInsertRecordIn(inStore); } + @Transactional public int submintInsertLedger(InStoreDto inStore) { return mapper.submintInsertLedger(inStore); } - public int submitInsertRecordOut(OutStoreDto outStoreDto,String epc) { - return mapper.submitInsertRecordOut(outStoreDto,epc); + public int submitInsertRecordOut(OutStoreDto outStoreDto, String epc) { + return mapper.submitInsertRecordOut(outStoreDto, epc); } public int updataLedger(OutStoreDto outStoreDto) { @@ -41,7 +44,7 @@ public class ApiService { } public void insertCheckInfo(List list, Long checkId) { - mapper.insertCheckInfo(list,checkId); + mapper.insertCheckInfo(list, checkId); } public List xjSelect(String user) { @@ -53,7 +56,7 @@ public class ApiService { } public void updataLedgerForBf(String epc, String state) { - mapper.updataLedgerForBf(epc,state); + mapper.updataLedgerForBf(epc, state); } public LedgerRfid fpInSelect(String epc) { @@ -61,38 +64,60 @@ public class ApiService { } public int fpInSubmit(String epc, String localtionCode, String user, String bf, String subCode) { - return mapper.fpInSubmit(epc,localtionCode,user,bf,subCode); + return mapper.fpInSubmit(epc, localtionCode, user, bf, subCode); } public void updataLedgerIn(String epc, String locationCode) { - mapper.updataLedgerIn(epc,locationCode); + mapper.updataLedgerIn(epc, locationCode); } public void insertInspectionInfo(List list, Long inspectionId) { - mapper.insertInspectionInfo(list,inspectionId); + mapper.insertInspectionInfo(list, inspectionId); } public List fpOutSelect() { return mapper.fpOutSelect(); } -@Transactional + + @Transactional public void insertWasreOutRecord(List list, String user) { - mapper.insertWasreOutRecord(list,user); + mapper.insertWasreOutRecord(list, user); } + @Transactional public void updataLedgerForWasreOut(List list, String user) { mapper.updataLedgerForWasreOut(list); } public String selectLedgerbyEpcForInStore(String epc) { - return mapper.selectLedgerbyEpcForInStore(epc); + return mapper.selectLedgerbyEpcForInStore(epc); } public String selectLedgerbyEpcForOutStore(String epc) { - return mapper.selectLedgerbyEpcForOutStore(epc); + return mapper.selectLedgerbyEpcForOutStore(epc); + } + + public int updataLedgerFoyOut(OutStoreDto outStoreDto, String epc) { + return mapper.updataLedgerFoyOut(outStoreDto, epc); + } + + public List selectLocationByAreaUser(String user) { + return mapper.selectLocationByAreaUser(user); + } + + public void insertCheckTask(int id, List list) { + mapper.insertCheckTask(id, list); + } + + public List inspectionSelectTask(String user) { + return mapper.inspectionSelectTask(user); + } + + public List inspectionSelectLocation(String code) { + return mapper.inspectionSelectLocation(code); } - public int updataLedgerFoyOut(OutStoreDto outStoreDto,String epc) { - return mapper.updataLedgerFoyOut(outStoreDto,epc); + public void updataInspectionTaskByObjid(long tableId) { + mapper.updataInspectionTaskByObjid(tableId); } } diff --git a/ruoyi-api/src/main/resources/mapper/ApiMapper.xml b/ruoyi-api/src/main/resources/mapper/ApiMapper.xml index f9f944a..a251cef 100644 --- a/ruoyi-api/src/main/resources/mapper/ApiMapper.xml +++ b/ruoyi-api/src/main/resources/mapper/ApiMapper.xml @@ -3,7 +3,6 @@ - + select bs.store_id as objid , + bs.store_name, + location_code + from base_location bl + left join base_store bs on bl.store_id = bs.store_id + right join base_area_user bau on bau.area_id = bl.store_id + where bl.stote_tag = 2 and bau.user_id=#{user} + + + INSERT INTO record_inspection_task (inspection_id, area_id,area_name, plane_position) VALUES + + (#{id}, #{data.id}, #{data.areaName}, #{data.locationCode}) + + + + + + + + + + UPDATE record_inspection_task SET task_state = '完成' WHERE objid = #{tableId}; + \ No newline at end of file diff --git a/ruoyi-manage/src/main/java/com/ruoyi/manage/controller/BaseAreaUserController.java b/ruoyi-manage/src/main/java/com/ruoyi/manage/controller/BaseAreaUserController.java index 2f42193..3d6b729 100644 --- a/ruoyi-manage/src/main/java/com/ruoyi/manage/controller/BaseAreaUserController.java +++ b/ruoyi-manage/src/main/java/com/ruoyi/manage/controller/BaseAreaUserController.java @@ -1,6 +1,7 @@ package com.ruoyi.manage.controller; import java.util.List; + import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -21,14 +22,13 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * 机场区域用户绑定Controller - * + * * @author wangh * @date 2024-01-25 */ @Controller @RequestMapping("/manage/base_area_user") -public class BaseAreaUserController extends BaseController -{ +public class BaseAreaUserController extends BaseController { private String prefix = "manage/base_area_user"; @Autowired @@ -36,8 +36,7 @@ public class BaseAreaUserController extends BaseController @RequiresPermissions("manage:base_area_user:view") @GetMapping() - public String base_area_user() - { + public String base_area_user() { return prefix + "/base_area_user"; } @@ -47,8 +46,7 @@ public class BaseAreaUserController extends BaseController @RequiresPermissions("manage:base_area_user:list") @PostMapping("/list") @ResponseBody - public TableDataInfo list(BaseAreaUser baseAreaUser) - { + public TableDataInfo list(BaseAreaUser baseAreaUser) { startPage(); List list = baseAreaUserService.selectBaseAreaUserList(baseAreaUser); return getDataTable(list); @@ -61,8 +59,7 @@ public class BaseAreaUserController extends BaseController @Log(title = "机场区域用户绑定", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody - public AjaxResult export(BaseAreaUser baseAreaUser) - { + public AjaxResult export(BaseAreaUser baseAreaUser) { List list = baseAreaUserService.selectBaseAreaUserList(baseAreaUser); ExcelUtil util = new ExcelUtil(BaseAreaUser.class); return util.exportExcel(list, "机场区域用户绑定数据"); @@ -72,8 +69,7 @@ public class BaseAreaUserController extends BaseController * 新增机场区域用户绑定 */ @GetMapping("/add") - public String add() - { + public String add() { return prefix + "/add"; } @@ -84,9 +80,12 @@ public class BaseAreaUserController extends BaseController @Log(title = "机场区域用户绑定", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(BaseAreaUser baseAreaUser) - { - return toAjax(baseAreaUserService.insertBaseAreaUser(baseAreaUser)); + public AjaxResult addSave(BaseAreaUser baseAreaUser) { + List list = baseAreaUserService.selectBaseAreaUserList(baseAreaUser); + if (list == null || list.isEmpty()) { + return toAjax(baseAreaUserService.insertBaseAreaUser(baseAreaUser)); + } + return error("数据已经维护"); } /** @@ -94,8 +93,7 @@ public class BaseAreaUserController extends BaseController */ @RequiresPermissions("manage:base_area_user:edit") @GetMapping("/edit/{objid}") - public String edit(@PathVariable("objid") Long objid, ModelMap mmap) - { + public String edit(@PathVariable("objid") Long objid, ModelMap mmap) { BaseAreaUser baseAreaUser = baseAreaUserService.selectBaseAreaUserByObjid(objid); mmap.put("baseAreaUser", baseAreaUser); return prefix + "/edit"; @@ -108,10 +106,12 @@ public class BaseAreaUserController extends BaseController @Log(title = "机场区域用户绑定", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody - public AjaxResult editSave(BaseAreaUser baseAreaUser) - { - - return toAjax(baseAreaUserService.updateBaseAreaUser(baseAreaUser)); + public AjaxResult editSave(BaseAreaUser baseAreaUser) { + List list = baseAreaUserService.selectBaseAreaUserList(baseAreaUser); + if (list == null || list.isEmpty()) { + return toAjax(baseAreaUserService.updateBaseAreaUser(baseAreaUser)); + } + return error("数据已经维护"); } /** @@ -119,10 +119,9 @@ public class BaseAreaUserController extends BaseController */ @RequiresPermissions("manage:base_area_user:remove") @Log(title = "机场区域用户绑定", businessType = BusinessType.DELETE) - @PostMapping( "/remove") + @PostMapping("/remove") @ResponseBody - public AjaxResult remove(String ids) - { + public AjaxResult remove(String ids) { return toAjax(baseAreaUserService.deleteBaseAreaUserByObjids(ids)); } }