| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.service.TaskWrkService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.TaskWrkService; |
| | | import com.zy.asrs.service.ToWmsService; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @Slf4j |
| | | public class TaskWrkController extends BaseController { |
| | | |
| | | |
| | | @Autowired |
| | | private TaskWrkService taskWrkService; |
| | | |
| | | |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | |
| | | |
| | | @Autowired |
| | | private ToWmsService toWmsService; |
| | | |
| | | public static String getTaskType(Integer paramIoType) { |
| | | switch (paramIoType) { |
| | | case 1: |
| | | return "RK"; |
| | | case 2: |
| | | return "CK"; |
| | | case 3: |
| | | return "YK"; |
| | | default: |
| | | return "未知"; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/{wrkNo}/auth") |
| | | @ManagerAuth |
| | |
| | | |
| | | @RequestMapping(value = "/taskWrk/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | public R list(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | EntityWrapper<TaskWrk> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | if (!Cools.isEmpty(orderByField)) { |
| | | wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); |
| | | } |
| | | return R.ok(taskWrkService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | if (val.contains(RANGE_TIME_LINK)) { |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/update/auth") |
| | | @ManagerAuth |
| | | public R update(TaskWrk taskWrk){ |
| | | if (Cools.isEmpty(taskWrk) || null==taskWrk.getTaskNo()){ |
| | | @RequestMapping(value = "/taskWrk/update/auth") |
| | | @ManagerAuth |
| | | public R update(TaskWrk taskWrk) { |
| | | if (Cools.isEmpty(taskWrk) || null == taskWrk.getTaskNo()) { |
| | | return R.error(); |
| | | } |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/updatePoint/auth") |
| | | @ManagerAuth |
| | | public R updatePoint(TaskWrk taskWrk) { |
| | | if (Cools.isEmpty(taskWrk) || null == taskWrk.getTaskNo()) { |
| | | return R.error(); |
| | | } |
| | | TaskWrk taskWrk1 = taskWrkService.selectByTaskNo(taskWrk.getTaskNo()); |
| | | if (taskWrk1 == null) { |
| | | return R.error(); |
| | | } |
| | | taskWrk1.setStartPoint(taskWrk.getStartPoint()); |
| | | taskWrk1.setTargetPoint(taskWrk.getTargetPoint()); |
| | | taskWrk1.setModiTime(new Date()); |
| | | taskWrk1.setModiUser(getUserId()); |
| | | taskWrkService.updateById(taskWrk1); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | public R delete(@RequestParam(value = "ids[]") Long[] ids) { |
| | | for (Long id : ids) { |
| | | taskWrkService.deleteById(id); |
| | | } |
| | | return R.ok(); |
| | |
| | | |
| | | @RequestMapping(value = "/taskWrk/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | public R export(@RequestBody JSONObject param) { |
| | | EntityWrapper<TaskWrk> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("taskWrk")); |
| | |
| | | wrapper.like("id", condition); |
| | | Page<TaskWrk> page = taskWrkService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (TaskWrk taskWrk : page.getRecords()){ |
| | | for (TaskWrk taskWrk : page.getRecords()) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", taskWrk.getTaskNo()); |
| | | map.put("value", taskWrk.getTaskNo()); |
| | |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<TaskWrk> wrapper = new EntityWrapper<TaskWrk>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != taskWrkService.selectOne(wrapper)){ |
| | | if (null != taskWrkService.selectOne(wrapper)) { |
| | | return R.parse(BaseRes.REPEAT).add(getComment(TaskWrk.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | |
| | | @ManagerAuth(memo = "手动完成任务") |
| | | public R complete(@RequestParam String taskNo) { |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); |
| | | if (taskWrk == null) { |
| | | return R.error(); |
| | | if (Cools.isEmpty(taskWrk) || taskWrk.getStatus() >= 3) { |
| | | return R.error("已完结或已取消"); |
| | | } |
| | | if (taskWrk.getStatus().equals(TaskStatusType.COMPLETE.id)) { |
| | | return R.error(taskWrk.getTaskNo() + "已完结"); |
| | | LocMast locMast = new LocMast(); |
| | | if (taskWrk.getIoType() == 1) {//入库任务完成库位为F |
| | | locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("F"); |
| | | locMast.setModiTime(new Date()); |
| | | locMast.setBarcode(taskWrk.getBarcode()); |
| | | } else if (taskWrk.getIoType() == 2) {//出库任务完成库位为O |
| | | locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(new Date()); |
| | | } else if (taskWrk.getIoType() == 3) { |
| | | locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(new Date()); |
| | | locMastService.updateById(locMast); |
| | | locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("F"); |
| | | locMast.setModiTime(new Date()); |
| | | locMast.setBarcode(taskWrk.getBarcode()); |
| | | |
| | | } |
| | | Date now = new Date(); |
| | | taskWrk.setStatus(TaskStatusType.COMPLETE.id); |
| | | taskWrk.setModiTime(now);//操作时间 |
| | | try{ |
| | | taskWrk.setModiUser(getUserId());//操作员 |
| | | }catch (Exception e){ |
| | | taskWrk.setModiUser(9999L);//操作员 |
| | | } |
| | | taskWrk.setCompleteTime(now);//完结时间 |
| | | // toWmsService.addReportLog(taskWrk); |
| | | locMastService.updateById(locMast); |
| | | taskWrk.setCompleteTime(new Date()); |
| | | taskWrk.setStatus(7);//手动完成任务 |
| | | taskWrk.setModiTime(new Date()); |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping(value = "/taskWrk/returnWorkingCondition/auth") |
| | | @ManagerAuth(memo = "重新给堆垛机下发任务") |
| | | public R returnWorkingCondition(@RequestParam String taskNo) { |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); |
| | | if (!Cools.isEmpty(taskWrk) && taskWrk.getWrkSts() == 12) { |
| | | taskWrk.setWrkSts(11); |
| | | if (!taskWrkService.updateById(taskWrk)) { |
| | | return R.error("更新任务状态失败"); |
| | | } |
| | | return R.ok(); |
| | | } else if (!Cools.isEmpty(taskWrk) && taskWrk.getWrkSts() == 3) { |
| | | taskWrk.setWrkSts(2); |
| | | taskWrkService.updateById(taskWrk); |
| | | if (!taskWrkService.updateById(taskWrk)) { |
| | | return R.error("更新任务状态失败"); |
| | | } |
| | | return R.ok(); |
| | | } else { |
| | | return R.error("任务状态不对无法重新给堆垛机下发任务"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @PostMapping(value = "/taskWrk/cancel/auth") |
| | |
| | | Date now = new Date(); |
| | | taskWrk.setStatus(TaskStatusType.CANCEL.id); |
| | | taskWrk.setModiTime(now);//操作时间 |
| | | try{ |
| | | try { |
| | | taskWrk.setModiUser(getUserId());//操作员 |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | taskWrk.setModiUser(9999L);//操作员 |
| | | } |
| | | taskWrk.setCompleteTime(now);//完结时间 |
| | | // toWmsService.addReportLog(taskWrk); |
| | | |
| | | taskWrk.setCancelTime(now);//完结时间 |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | | } |