| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.asrs.entity.AgvWarn; |
| | | import com.zy.asrs.entity.AgvWrkMast; |
| | | import com.zy.asrs.entity.param.AgvWarnBody; |
| | |
| | | import com.zy.asrs.service.AgvWarnService; |
| | | import com.zy.asrs.service.AgvWrkMastService; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.utils.AppAuthUtil; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/agv") |
| | | public class AgvWarnController extends BaseController { |
| | | |
| | | |
| | |
| | | @AppAuth(memo = "AGV告警回调") |
| | | public Object taskEventStaus(@RequestBody AgvWarnCallBackParam param, HttpServletRequest request) { |
| | | log.info("AGV告警回调:{}", JSON.toJSONString(param)); |
| | | List<AgvWarnBody> data = param.getData(); |
| | | AppAuthUtil.auth("", param, request); |
| | | List<AgvWarnBody> agvWarnBodies = param.getData(); |
| | | // List<AgvWarnBody> agvWarnBodies = JSONArray.parseArray(data, AgvWarnBody.class); |
| | | AgvWarn agvWarn = null; |
| | | List<AgvWarn> agvWarns = new ArrayList<>(); |
| | | List<AgvWarn> updates = new ArrayList<>(); |
| | | for (AgvWarnBody body : data) { |
| | | for (AgvWarnBody body : agvWarnBodies) { |
| | | List<AgvWarn> agvWarnList = agvWarnService.selectList(new EntityWrapper<AgvWarn>().eq("robot_code", body.getRobotCode()).eq("begin_time", body.getBeginTime()).eq("warn_content", body.getWarnContent())); |
| | | if (Cools.isEmpty(agvWarnList)) { |
| | | agvWarn = new AgvWarn(); |
| | | agvWarn.setBeginTime(body.getBeginTime()); |
| | | agvWarn.setAppeTime(new Date()); |
| | | agvWarn.setTimes(0); |
| | | agvWarn.setModiTime(DateUtils.convert(body.getBeginTime(), DateUtils.yyyyMMddHHmmss_F)); |
| | | agvWarn.setRobotCode(body.getRobotCode()); |
| | | agvWarn.setWarnContent(body.getWarnContent()); |
| | | if (body.getTaskCode() != null) { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(body.getTaskCode()); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | try { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(Math.abs(Integer.parseInt(body.getTaskCode()))); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("任务不存在"); |
| | | } |
| | | } |
| | | agvWarns.add(agvWarn); |
| | |
| | | agvWarn.setWarnContent(agvWarn.getWarnContent().contains(body.getWarnContent()) ? body.getWarnContent() : agvWarn.getWarnContent() + "、" + body.getWarnContent()); |
| | | agvWarn.setModiTime(new Date()); |
| | | if (body.getTaskCode() != null) { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(body.getTaskCode()); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | try { |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectById(body.getTaskCode()); |
| | | if (agvWrkMast != null) { |
| | | agvWarn.setLocNo(agvWrkMast.getLocNo()); |
| | | agvWarn.setSourceLocNo(agvWrkMast.getSourceLocNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("任务不存在"); |
| | | } |
| | | } |
| | | updates.add(agvWarn); |
| | |
| | | agvWarnService.updateBatchById(updates); |
| | | } |
| | | Map<String, Object> result = new HashMap<>(); |
| | | logPost(param, JSONObject.toJSONString(result), true); |
| | | logPost(JSONObject.toJSONString(param), JSONObject.toJSONString(result), true); |
| | | result.put("code", 0); |
| | | result.put("message", "成功"); |
| | | result.put("reqCode", param.getReqCode()); |
| | | return result; |
| | | } |
| | | |
| | | private void logPost(AgvWarnCallBackParam param, String response, boolean success) { |
| | | private void logPost(String param, String response, boolean success) { |
| | | apiLogService.save( |
| | | "ESS任务回调", |
| | | "/phyzwms/agv/task/event/status", |
| | | null, |
| | | null, |
| | | JSONObject.toJSONString(param), |
| | | param, |
| | | response, |
| | | success |
| | | ); |
New file |
| | |
| | | package com.zy.asrs.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @TableName("agv_bas") |
| | | @Data |
| | | public class Agv implements Serializable { |
| | | |
| | | @TableId("agv_no") |
| | | private String agvNo; |
| | | |
| | | @TableField("region") |
| | | private String region; |
| | | } |
| | |
| | | @TableField("modi_time") |
| | | private Date modiTime; |
| | | |
| | | // @TableField("report_time") |
| | | // private Date reportTime; |
| | | |
| | | @TableField("memo") |
| | | private String memo; |
| | | |
| | |
| | | package com.zy.asrs.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import lombok.Data; |
| | | |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("id") |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * 上报次数 |
| | | */ |
| | | @TableField("times") |
| | | private Integer times; |
| | | |
| | | @TableField("robot_code") |
| | | private String robotCode; |
| | |
| | | @TableField("begin_time") |
| | | private String beginTime; |
| | | |
| | | @TableField("warnContent") |
| | | private String warn_content; |
| | | @TableField("warn_content") |
| | | private String warnContent; |
| | | |
| | | @TableField("task_code") |
| | | private String taskCode; |
| | |
| | | @TableField("loc_no") |
| | | private String locNo; |
| | | |
| | | @TableField("source_locNo") |
| | | @TableField("source_loc_no") |
| | | private String sourceLocNo; |
| | | |
| | | @TableField("appe_time") |
| | |
| | | |
| | | @TableField("modi_time") |
| | | private Date modiTime; |
| | | |
| | | // @TableField("report_time") |
| | | // private Date reportTime; |
| | | |
| | | @TableField("memo") |
| | | private String memo; |
| | | |
| | | } |
| | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value= "库位号") |
| | | @TableId |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "库位号") |
| | | @TableField("loc_no") |
| | | private String locNo; |
| | | |
| | | @ApiModelProperty(value= "托盘条码") |
| | | @ApiModelProperty(value = "托盘条码") |
| | | private String zpallet; |
| | | |
| | | @ApiModelProperty(value= "数量") |
| | | @ApiModelProperty(value = "数量") |
| | | @ExcelProperty("数量") |
| | | private Double anfme; |
| | | |
| | | @ApiModelProperty(value= "物料号") |
| | | @ApiModelProperty(value = "物料号") |
| | | @ExcelProperty("物料号") |
| | | private String matnr; |
| | | |
| | | @ApiModelProperty(value= "物料号") |
| | | @ApiModelProperty(value = "物料号") |
| | | @ExcelProperty("物料号") |
| | | private String maktx; |
| | | |
| | | @ApiModelProperty(value= "序列码") |
| | | @ApiModelProperty(value = "序列码") |
| | | @ExcelProperty("序列码") |
| | | private String batch; |
| | | |
| | | @ApiModelProperty(value= "单据编号") |
| | | @ApiModelProperty(value = "单据编号") |
| | | @ExcelProperty("单据编号") |
| | | @TableField("order_no") |
| | | private String orderNo; |
| | | |
| | | @ApiModelProperty(value= "规格") |
| | | @ApiModelProperty(value = "规格") |
| | | private String specs; |
| | | |
| | | @ApiModelProperty(value= "批次") |
| | | @ApiModelProperty(value = "批次") |
| | | private String model; |
| | | |
| | | @ApiModelProperty(value= "颜色") |
| | | @ApiModelProperty(value = "颜色") |
| | | private String color; |
| | | |
| | | @ApiModelProperty(value= "品牌") |
| | | @ApiModelProperty(value = "品牌") |
| | | private String brand; |
| | | |
| | | @ApiModelProperty(value= "单位") |
| | | @ApiModelProperty(value = "单位") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty(value= "单价") |
| | | @ApiModelProperty(value = "单价") |
| | | private Double price; |
| | | |
| | | @ApiModelProperty(value= "sku") |
| | | @ApiModelProperty(value = "sku") |
| | | private String sku; |
| | | |
| | | @ApiModelProperty(value= "包数") |
| | | @ApiModelProperty(value = "包数") |
| | | private Double units; |
| | | |
| | | @ApiModelProperty(value= "条码") |
| | | @ApiModelProperty(value = "条码") |
| | | private String barcode; |
| | | |
| | | @ApiModelProperty(value= "物料状态") |
| | | @ApiModelProperty(value = "物料状态") |
| | | private String origin; |
| | | |
| | | @ApiModelProperty(value= "厂家") |
| | | @ApiModelProperty(value = "厂家") |
| | | private String manu; |
| | | |
| | | @ApiModelProperty(value= "单据时间") |
| | | @ApiModelProperty(value = "单据时间") |
| | | @TableField("manu_date") |
| | | private String manuDate; |
| | | |
| | | @ApiModelProperty(value= "品项数") |
| | | @ApiModelProperty(value = "品项数") |
| | | @TableField("item_num") |
| | | private String itemNum; |
| | | |
| | | @ApiModelProperty(value= "安全库存量") |
| | | @ApiModelProperty(value = "安全库存量") |
| | | @TableField("safe_qty") |
| | | private Double safeQty; |
| | | |
| | | @ApiModelProperty(value= "重量") |
| | | @ApiModelProperty(value = "重量") |
| | | private Double weight; |
| | | |
| | | @ApiModelProperty(value= "长度") |
| | | @ApiModelProperty(value = "长度") |
| | | private Double length; |
| | | |
| | | @ApiModelProperty(value= "体积") |
| | | @ApiModelProperty(value = "体积") |
| | | private Double volume; |
| | | |
| | | @ApiModelProperty(value= "三方编码") |
| | | @ApiModelProperty(value = "三方编码") |
| | | @TableField("three_code") |
| | | private String threeCode; |
| | | |
| | | @ApiModelProperty(value= "供应商") |
| | | @ApiModelProperty(value = "供应商") |
| | | private String supp; |
| | | |
| | | @ApiModelProperty(value= "供应商编码") |
| | | @ApiModelProperty(value = "供应商编码") |
| | | @TableField("supp_code") |
| | | private String suppCode; |
| | | |
| | | @ApiModelProperty(value= "是否批次 1: 是 0: 否 ") |
| | | @ApiModelProperty(value = "是否批次 1: 是 0: 否 ") |
| | | @TableField("be_batch") |
| | | private Integer beBatch; |
| | | |
| | | @ApiModelProperty(value= "保质期") |
| | | @ApiModelProperty(value = "保质期") |
| | | @TableField("dead_time") |
| | | private String deadTime; |
| | | |
| | | @ApiModelProperty(value= "预警天数") |
| | | @ApiModelProperty(value = "预警天数") |
| | | @TableField("dead_warn") |
| | | private Integer deadWarn; |
| | | |
| | | @ApiModelProperty(value= "制购 1: 制造 2: 采购 3: 外协 ") |
| | | @ApiModelProperty(value = "制购 1: 制造 2: 采购 3: 外协 ") |
| | | private Integer source; |
| | | |
| | | @ApiModelProperty(value= "要求检验 1: 是 0: 否 ") |
| | | @ApiModelProperty(value = "要求检验 1: 是 0: 否 ") |
| | | private Integer inspect; |
| | | |
| | | @ApiModelProperty(value= "危险品 1: 是 0: 否 ") |
| | | @ApiModelProperty(value = "危险品 1: 是 0: 否 ") |
| | | private Integer danger; |
| | | |
| | | @ApiModelProperty(value= "修改人员") |
| | | @ApiModelProperty(value = "修改人员") |
| | | @TableField("modi_user") |
| | | private Long modiUser; |
| | | |
| | | @ApiModelProperty(value= "修改时间") |
| | | @ApiModelProperty(value = "修改时间") |
| | | @TableField("modi_time") |
| | | private Date modiTime; |
| | | |
| | | @ApiModelProperty(value= "创建者") |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("appe_user") |
| | | private Long appeUser; |
| | | |
| | | @ApiModelProperty(value= "添加时间") |
| | | @ApiModelProperty(value = "添加时间") |
| | | @TableField("appe_time") |
| | | private Date appeTime; |
| | | |
| | | @ApiModelProperty(value= "备注") |
| | | @ApiModelProperty(value = "备注") |
| | | private String memo; |
| | | |
| | | @TableField("stock_freeze") |
| | | @ApiModelProperty(value= "库存冻结{1:正常,0:冻结}") |
| | | @ApiModelProperty(value = "库存冻结{1:正常,0:冻结}") |
| | | private Integer stockFreeze; |
| | | |
| | | /** |
| | | * 库存数量 |
| | | */ |
| | | @ApiModelProperty(value= "可出数量") |
| | | @ApiModelProperty(value = "可出数量") |
| | | @TableField(exist = false) |
| | | private Double stock; |
| | | |
| | | /** |
| | | * 库存数量 |
| | | */ |
| | | @ApiModelProperty(value= "可出数量") |
| | | @ApiModelProperty(value = "可出数量") |
| | | @TableField(exist = false) |
| | | private String locSts; |
| | | |
| | | /** |
| | | * 库存数量 |
| | | */ |
| | | @ApiModelProperty(value= "可出数量") |
| | | @ApiModelProperty(value = "可出数量") |
| | | @TableField(exist = false) |
| | | private String locSts$; |
| | | |
| | | /** |
| | | * 工序状态 |
| | | */ |
| | | @ApiModelProperty(value= "工序状态 1:待加工,2:已加工,3:无需加工") |
| | | @ApiModelProperty(value = "工序状态 1:待加工,2:已加工,3:无需加工") |
| | | @TableField("process_sts") |
| | | private Integer processSts; |
| | | |
| | | |
| | | public String getProcessSts$(){ |
| | | if (null == this.processSts){ return null; } |
| | | switch (this.processSts){ |
| | | public String getProcessSts$() { |
| | | if (null == this.processSts) { |
| | | return null; |
| | | } |
| | | switch (this.processSts) { |
| | | case 0: |
| | | return "其他"; |
| | | case 1: |
| | |
| | | } |
| | | } |
| | | |
| | | public String getLocNo$(){ |
| | | public String getLocNo$() { |
| | | LocMastService service = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = service.selectById(this.locNo); |
| | | if (!Cools.isEmpty(locMast)){ |
| | | if (!Cools.isEmpty(locMast)) { |
| | | return String.valueOf(locMast.getLocNo()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getBeBatch$(){ |
| | | if (null == this.beBatch){ return null; } |
| | | switch (this.beBatch){ |
| | | public String getBeBatch$() { |
| | | if (null == this.beBatch) { |
| | | return null; |
| | | } |
| | | switch (this.beBatch) { |
| | | case 1: |
| | | return "是"; |
| | | case 0: |
| | |
| | | } |
| | | } |
| | | |
| | | public String getSource$(){ |
| | | if (null == this.source){ return null; } |
| | | switch (this.source){ |
| | | public String getSource$() { |
| | | if (null == this.source) { |
| | | return null; |
| | | } |
| | | switch (this.source) { |
| | | case 1: |
| | | return "制造"; |
| | | case 2: |
| | |
| | | } |
| | | } |
| | | |
| | | public String getInspect$(){ |
| | | if (null == this.inspect){ return null; } |
| | | switch (this.inspect){ |
| | | public String getInspect$() { |
| | | if (null == this.inspect) { |
| | | return null; |
| | | } |
| | | switch (this.inspect) { |
| | | case 1: |
| | | return "是"; |
| | | case 0: |
| | |
| | | } |
| | | } |
| | | |
| | | public String getDanger$(){ |
| | | if (null == this.danger){ return null; } |
| | | switch (this.danger){ |
| | | public String getDanger$() { |
| | | if (null == this.danger) { |
| | | return null; |
| | | } |
| | | switch (this.danger) { |
| | | case 1: |
| | | return "是"; |
| | | case 0: |
| | |
| | | } |
| | | } |
| | | |
| | | public String getModiUser$(){ |
| | | public String getModiUser$() { |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.selectById(this.modiUser); |
| | | if (!Cools.isEmpty(user)){ |
| | | if (!Cools.isEmpty(user)) { |
| | | return String.valueOf(user.getUsername()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getModiTime$(){ |
| | | if (Cools.isEmpty(this.modiTime)){ |
| | | public String getModiTime$() { |
| | | if (Cools.isEmpty(this.modiTime)) { |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.modiTime); |
| | | } |
| | | |
| | | public String getAppeUser$(){ |
| | | public String getAppeUser$() { |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.selectById(this.appeUser); |
| | | if (!Cools.isEmpty(user)){ |
| | | if (!Cools.isEmpty(user)) { |
| | | return String.valueOf(user.getUsername()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getAppeTime$(){ |
| | | if (Cools.isEmpty(this.appeTime)){ |
| | | public String getAppeTime$() { |
| | | if (Cools.isEmpty(this.appeTime)) { |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.appeTime); |
| | |
| | | } |
| | | |
| | | public String getStockFreeze$() { |
| | | if (Cools.isEmpty(this.stockFreeze)){ |
| | | if (Cools.isEmpty(this.stockFreeze)) { |
| | | return ""; |
| | | } |
| | | return this.stockFreeze == 1 ? "正常" : "冻结"; |
| | |
| | | |
| | | private String tokenCode; |
| | | |
| | | |
| | | private List<AgvWarnBody> data; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.zy.asrs.entity.Agv; |
| | | import com.zy.asrs.entity.AgvBasDevp; |
| | | import org.apache.ibatis.annotations.Delete; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface AgvBasMapper extends BaseMapper<Agv> { |
| | | |
| | | |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.Agv; |
| | | import com.zy.asrs.entity.AgvWarn; |
| | | import com.zy.asrs.mapper.AgvBasMapper; |
| | | import com.zy.asrs.service.AgvWarnService; |
| | | import com.zy.asrs.task.handler.AgvWarnHandler; |
| | | import com.zy.common.utils.HttpHandler; |
| | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Autowired |
| | | private AgvBasMapper agvBasMapper; |
| | | |
| | | /** |
| | | * 超过 |
| | | * 超过一分钟没更新的,删除 |
| | | */ |
| | | @Scheduled(fixedDelay = 30000) |
| | | @Scheduled(fixedDelay = 10000) |
| | | private void del() { |
| | | String format = DateUtil.format(DateUtil.offsetMinute(new Date(), -3), "yyyy-MM-dd HH:mm:ss"); |
| | | List<AgvWarn> agvWarnList = agvWarnService.selectList(new EntityWrapper<AgvWarn>().ge("modi_time", format)); |
| | | String format = DateUtil.format(DateUtil.offsetMinute(new Date(), -1), "yyyy-MM-dd HH:mm:ss"); |
| | | List<AgvWarn> agvWarnList = agvWarnService.selectList(new EntityWrapper<AgvWarn>().le("modi_time", format)); |
| | | for (AgvWarn agvWarn : agvWarnList) { |
| | | agvWarnHandler.start(agvWarn); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 10000) |
| | | @Scheduled(fixedDelay = 20000) |
| | | private void report() { |
| | | List<Config> config = configService.selectList(new EntityWrapper<Config>().eq("code", "AGV_WARN_REPORT_URL")); |
| | | List<Agv> agvs = agvBasMapper.selectList(new EntityWrapper<Agv>()); |
| | | Config first = configService.selectOne(new EntityWrapper<Config>().eq("code", "AGV_WARN_RATE1")); |
| | | Config second = configService.selectOne(new EntityWrapper<Config>().eq("code", "AGV_WARN_RATE2")); |
| | | Config third = configService.selectOne(new EntityWrapper<Config>().eq("code", "AGV_WARN_RATE3")); |
| | | Config url = configService.selectOne(new EntityWrapper<Config>().eq("code", "AGV_WARN_REPORT_URL")); |
| | | List<AgvWarn> agvWarnList = agvWarnService.selectList(new EntityWrapper<AgvWarn>()); |
| | | StringBuffer buffer; |
| | | for (AgvWarn agvWarn : agvWarnList) { |
| | | Integer warnTime = getWarnTime(agvWarn.getTimes()); |
| | | Integer warnTime = getWarnTime(agvWarn.getTimes(), first.getValue(), second.getValue(), third.getValue()); |
| | | DateTime begin = DateUtil.parse(agvWarn.getBeginTime(), "yyyy-MM-dd HH:mm:ss"); |
| | | if (DateUtil.offsetMinute(begin, warnTime).after(new Date())) { |
| | | if (DateUtil.offsetMinute(begin, warnTime).before(new Date())) { |
| | | buffer = new StringBuffer(); |
| | | buffer.append(agvWarn.getRobotCode() + "号AGV小车报警:"); |
| | | buffer.append(agvWarn.getWarnContent()); |
| | | buffer.append(processRegion(agvs, agvWarn.getRobotCode()) + "[" + agvWarn.getRobotCode() + "]号AGV小车报警了\n"); |
| | | buffer.append("报警类型:" + agvWarn.getWarnContent() + "\n"); |
| | | if (!Cools.isEmpty(agvWarn.getSourceLocNo())) { |
| | | buffer.append("从:[" + agvWarn.getSourceLocNo() + "]到[" + agvWarn.getLocNo() + "]\n"); |
| | | } |
| | | buffer.append("开始时间:" + agvWarn.getBeginTime() + "\n"); |
| | | int i = agvWarn.getTimes() + 1; |
| | | buffer.append("第[" + i + "]次报警"); |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | data.put("content", buffer.toString()); |
| | | param.put("msgtype", "text"); |
| | | param.put("text", data); |
| | | log.info("发送报警信息:{}", JSON.toJSONString(param)); |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(config.get(0).getValue()) |
| | | .setUri(url.getValue()) |
| | | .setJson(JSON.toJSONString(param)) |
| | | .setHttps(true) |
| | | .build() |
| | |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.get("errmsg").equals("ok")) { |
| | | agvWarn.setTimes(agvWarn.getTimes() + 1); |
| | | agvWarnService.updateById(agvWarn); |
| | | //发送成功 |
| | | return; |
| | | } else { |
| | |
| | | * @param times |
| | | * @return |
| | | */ |
| | | private Integer getWarnTime(Integer times) { |
| | | try { |
| | | List<Config> config = configService.selectList(new EntityWrapper<Config>().eq("code", "AGV_WARN_RATE1")); |
| | | if (!Cools.isEmpty(config)) { |
| | | String value = config.get(0).getValue(); |
| | | if (Cools.isEmpty(value)) { |
| | | return 5; |
| | | } else { |
| | | String[] split = value.split(","); |
| | | if (split.length < times + 1) { |
| | | Config config2 = configService.selectOne(new EntityWrapper<Config>().eq("code", "AGV_WARN_RATE2")); |
| | | int t = 0; |
| | | for (String s : split) { |
| | | t = t + Integer.parseInt(s); |
| | | } |
| | | return t + Integer.parseInt(config2.getValue()) * (times + 1 - split.length); |
| | | } else { |
| | | return Integer.parseInt(split[times]); |
| | | } |
| | | } |
| | | } |
| | | return 5; |
| | | } catch (Exception e) { |
| | | return 5; |
| | | private Integer getWarnTime(Integer times, String first, String second, String thrid) { |
| | | switch (times) { |
| | | case 0: |
| | | return Integer.parseInt(first); |
| | | case 1: |
| | | return Integer.parseInt(second); |
| | | case 2: |
| | | return Integer.parseInt(thrid); |
| | | default: |
| | | return (times - 2) * Integer.parseInt(thrid) + Integer.parseInt(first) + Integer.parseInt(second) + Integer.parseInt(thrid); |
| | | } |
| | | } |
| | | |
| | | private String processRegion(List<Agv> agvs, String agvNo) { |
| | | if (agvNo == null) { |
| | | return "未知小车"; |
| | | } |
| | | for (Agv agv : agvs) { |
| | | if (agv.getAgvNo() != null && agv.getAgvNo().equals(agvNo)) { |
| | | return agv.getRegion(); |
| | | } |
| | | } |
| | | return "未知"; |
| | | } |
| | | |
| | | } |
| | |
| | | private String stock; |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | @Scheduled(fixedDelay = 30000) |
| | | public void execute() { |
| | | log.info("定时任务开始执行"); |
| | | if (!flag) { |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 1000 * 60 * 30) |
| | | public void executeStock() { |
| | | log.info("Stock定时任务开始执行"); |
| | | if (!flag) { |
| | | return; |
| | | } |
| | | // if (!flag) { |
| | | // return; |
| | | // } |
| | | Map<String, Object> mesTokenInfo = getMesTokenInfo(); |
| | | reportDataHandler.stock(mesTokenInfo); |
| | | log.info("Stock定时任务结束执行"); |
| | |
| | | return SUCCESS; |
| | | } catch (Exception e) { |
| | | //TODO |
| | | log.error("修改AGV入库通知档状态入出状态为Y,{}", e.getMessage()); |
| | | //log.error("修改AGV入库通知档状态入出状态为Y,{}", e.getMessage()); |
| | | } |
| | | return FAIL; |
| | | } |
| | |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/7 |
| | |
| | | throw new CoolException("mes接口调用失败,返回信息:" + jsonObject); |
| | | } |
| | | success = true; |
| | | return null; |
| | | return response; |
| | | |
| | | } catch (Exception e) { |
| | | log.error("mes接口调用失败,返回信息:{}", e.getMessage()); |
| | |
| | | |
| | | @Transactional |
| | | public ReturnT<String> stock(Map<String, Object> mesTokenInfo) { |
| | | mesLocDetlService.delete(new EntityWrapper<MesLocDetl>().eq("1", 1)); |
| | | List<MesLocDetl> all = mesLocDetlService.selectList(new EntityWrapper<>()); |
| | | if (all != null) { |
| | | List<Long> collect = all.stream().map(MesLocDetl::getId).collect(Collectors.toList()); |
| | | boolean del = true; |
| | | int d = 1; |
| | | while (del && collect.size() > 0) { |
| | | if (collect.size() > d * 1000) { |
| | | mesLocDetlService.deleteBatchIds(collect.subList((d - 1) * 1000, d * 1000)); |
| | | } else { |
| | | mesLocDetlService.deleteBatchIds(collect.subList((d - 1) * 1000, collect.size())); |
| | | del = false; |
| | | } |
| | | d++; |
| | | } |
| | | } |
| | | |
| | | boolean flag = true; |
| | | Map<String, Object> req = new HashMap<>(); |
| | | int i = 1; |
| | |
| | | mesLocDetl.setBatch(mesStock.getBatchNo()); |
| | | mesLocDetl.setAnfme(mesStock.getOpAmount().getAmount().getAmount()); |
| | | mesLocDetls.add(mesLocDetl); |
| | | mesLocDetlService.insert(mesLocDetl); |
| | | } |
| | | } else { |
| | | flag = false; |
| | | } |
| | | } |
| | | if (!mesLocDetls.isEmpty()) { |
| | | mesLocDetlService.insertBatch(mesLocDetls); |
| | | //mesLocDetlService.insertBatch(mesLocDetls); |
| | | } |
| | | i++; |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | #dev loc prod |
| | | active: prod |
| | | active: loc |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.mapper.AgvWarnMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.asrs.entity.Agv"> |
| | | <id column="agv_no" property="agvNo" /> |
| | | <result column="region" property="region" /> |
| | | |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | <mapper namespace="com.zy.asrs.mapper.AgvWarnLogMapper"> |
| | | |
| | | |
| | | |
| | | </mapper> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.mapper.MesLocDetlMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.asrs.entity.AgvLocDetl"> |
| | | <result column="loc_no" property="locNo"/> |
| | | <result column="zpallet" property="zpallet"/> |
| | | <result column="anfme" property="anfme"/> |
| | | <result column="matnr" property="matnr"/> |
| | | <result column="maktx" property="maktx"/> |
| | | <result column="batch" property="batch"/> |
| | | <result column="order_no" property="orderNo"/> |
| | | |
| | | <result column="specs" property="specs"/> |
| | | <result column="model" property="model"/> |
| | | <result column="color" property="color"/> |
| | | <result column="brand" property="brand"/> |
| | | <result column="unit" property="unit"/> |
| | | <result column="price" property="price"/> |
| | | <result column="sku" property="sku"/> |
| | | <result column="units" property="units"/> |
| | | <result column="barcode" property="barcode"/> |
| | | <result column="origin" property="origin"/> |
| | | <result column="manu" property="manu"/> |
| | | <result column="manu_date" property="manuDate"/> |
| | | <result column="item_num" property="itemNum"/> |
| | | <result column="safe_qty" property="safeQty"/> |
| | | <result column="weight" property="weight"/> |
| | | <result column="length" property="length"/> |
| | | <result column="volume" property="volume"/> |
| | | <result column="three_code" property="threeCode"/> |
| | | <result column="supp" property="supp"/> |
| | | <result column="supp_code" property="suppCode"/> |
| | | <result column="be_batch" property="beBatch"/> |
| | | <result column="dead_time" property="deadTime"/> |
| | | <result column="dead_warn" property="deadWarn"/> |
| | | <result column="source" property="source"/> |
| | | <result column="inspect" property="inspect"/> |
| | | <result column="danger" property="danger"/> |
| | | |
| | | <result column="modi_user" property="modiUser"/> |
| | | <result column="modi_time" property="modiTime"/> |
| | | <result column="appe_user" property="appeUser"/> |
| | | <result column="appe_time" property="appeTime"/> |
| | | <result column="memo" property="memo"/> |
| | | <result column="stock_freeze" property="stockFreeze"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | var pageCurr; |
| | | |
| | | function getCol() { |
| | | var cols = [ |
| | | {field: 'anfme', align: 'center',title: '库存数量', style: 'font-weight: bold'} |
| | | {field: 'anfme', align: 'center', title: 'WMS库存数量', style: 'font-weight: bold'} |
| | | , {field: 'anfme2', align: 'center', title: 'MES库存数量', style: 'font-weight: bold'} |
| | | , {field: 'matnr', align: 'center', title: '编码'} |
| | | , {field: 'maktx', align: 'center', title: '物料名称'} |
| | | ]; |
| | | arrRemove(detlCols, "field", "anfme"); |
| | | arrRemove(detlCols,"field","suppCode"); |
| | | arrRemove(detlCols, "field", "zpallet"); |
| | | arrRemove(detlCols, "field", "orderNo"); |
| | | arrRemove(detlCols, "field", "threeCode"); |
| | | arrRemove(detlCols, "field", "deadTime"); |
| | | arrRemove(detlCols, "field", "batch"); |
| | | cols.push.apply(cols, detlCols); |
| | | // arrRemove(detlCols, "field", "anfme"); |
| | | // arrRemove(detlCols,"field","suppCode"); |
| | | // arrRemove(detlCols, "field", "zpallet"); |
| | | // arrRemove(detlCols, "field", "orderNo"); |
| | | // arrRemove(detlCols, "field", "threeCode"); |
| | | // arrRemove(detlCols, "field", "deadTime"); |
| | | // arrRemove(detlCols, "field", "batch"); |
| | | //cols.push.apply(cols, detlCols); |
| | | // cols.push({field: 'anfme', align: 'center',title: '数量', style: 'font-weight: bold'} |
| | | // ) |
| | | return cols; |
| | | |
| | | } |
| | | |
| | | layui.use(['table','laydate', 'form'], function(){ |
| | | layui.use(['table', 'laydate', 'form'], function () { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | |
| | | tableIns = table.render({ |
| | | elem: '#locDetlStatis', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/agv/locDetl/statis/auth', |
| | | url: baseUrl + '/agv/locDetl/statis/auth', |
| | | page: true, |
| | | limit: 20, |
| | | limits: [20, 30, 50, 100, 200, 500], |
| | |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } |
| | | pageCurr=curr; |
| | | pageCurr = curr; |
| | | limit(); |
| | | form.on('checkbox(tableCheckbox)', function (data) { |
| | | var _index = $(data.elem).attr('table-index')||0; |
| | | if(data.elem.checked){ |
| | | var _index = $(data.elem).attr('table-index') || 0; |
| | | if (data.elem.checked) { |
| | | res.data[_index][data.value] = 'Y'; |
| | | }else{ |
| | | } else { |
| | | res.data[_index][data.value] = 'N'; |
| | | } |
| | | }); |
| | |
| | | * 显示库存总数量 |
| | | */ |
| | | $.ajax({ |
| | | url: baseUrl+"/agv/locDetl/count", |
| | | url: baseUrl + "/agv/locDetl/count", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | contentType:'application/json;charset=UTF-8', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | $("#countNum").text(res.data + '个'); |
| | |
| | | // 监听排序事件 |
| | | table.on('sort(locDetlStatis)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | searchData['orderByField'] = obj.field; |
| | |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } |
| | | pageCurr=curr; |
| | | pageCurr = curr; |
| | | limit(); |
| | | } |
| | | }); |
| | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(locDetlStatis)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | | switch(obj.event) { |
| | | switch (obj.event) { |
| | | case 'exportAll': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function () { |
| | | var titles = []; |
| | | var fields = []; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | |
| | | }; |
| | | var loadIndex = layer.msg('正在导出...', {icon: 16, shade: 0.01, time: false}); |
| | | $.ajax({ |
| | | url: baseUrl+"/agv/locDetl/statis/export", |
| | | url: baseUrl + "/agv/locDetl/statis/export", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | table.exportFile(titles, res.data, 'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | |
| | | }); |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function () { |
| | | var titles = []; |
| | | var fields = []; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | |
| | | 'fields': fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/agv/locDetl/export/auth", |
| | | url: baseUrl + "/agv/locDetl/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | table.exportFile(titles, res.data, 'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(locDetlStatis)', function(obj){ |
| | | table.on('tool(locDetlStatis)', function (obj) { |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | // 详情 |
| | |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'locDetl_detail.html', |
| | | success: function(layero, index){ |
| | | success: function (layero, index) { |
| | | setFormVal(layer.getChildFrame('#detail', index), data, true); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | layer.iframeAuto(index); |
| | | layer.style(index, {top: (($(window).height() - layer.getChildFrame('#data-detail', index).height()) / 3) + "px"}); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('select'); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); |
| | | } |
| | |
| | | }); |
| | | |
| | | // 关闭动作 |
| | | $(document).on('click','#data-detail-close', function () { |
| | | $(document).on('click', '#data-detail-close', function () { |
| | | parent.layer.closeAll(); |
| | | }); |
| | | |
| | | function tableReload(child) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | $.each($('#search-box [name]').serializeArray(), function () { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | (child ? parent.tableIns : tableIns).reload({ |
| | |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | top.location.href = baseUrl + "/"; |
| | | } |
| | | pageCurr=curr; |
| | | pageCurr = curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: pageCurr-1 |
| | | curr: pageCurr - 1 |
| | | } |
| | | }); |
| | | pageCurr -= 1; |
| | |
| | | |
| | | function detailScreen(index) { |
| | | var detail = layer.getChildFrame('#data-detail', index); |
| | | var height = detail.height()+60; |
| | | if (height > ($(window).height()*0.9)) { |
| | | height = ($(window).height()*0.8); |
| | | var height = detail.height() + 60; |
| | | if (height > ($(window).height() * 0.9)) { |
| | | height = ($(window).height() * 0.8); |
| | | } |
| | | layer.style(index, { |
| | | // top: (($(window).height()-height)/3)+"px", |
| | | height: height+'px' |
| | | height: height + 'px' |
| | | }); |
| | | } |
| | | |
| | |
| | | <button id="reset" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="reset">重置 |
| | | </button> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <fieldset class="layui-elem-field"> |
| | | <legend>总计数量</legend> |
| | | <div class="layui-field-box" id="countNum"> |
| | | 请稍等 |
| | | </div> |
| | | </fieldset> |
| | | </div> |
| | | <!-- <div class="layui-inline">--> |
| | | <!-- <fieldset class="layui-elem-field">--> |
| | | <!-- <legend>总计数量</legend>--> |
| | | <!-- <div class="layui-field-box" id="countNum">--> |
| | | <!-- 请稍等--> |
| | | <!-- </div>--> |
| | | <!-- </fieldset>--> |
| | | <!-- </div>--> |
| | | </div> |
| | | |
| | | <!-- 表格 --> |
| | |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/agvLocDetlStatis/locDetlStatis.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/agvLocDetlStatis/locDetlStatis.js?v=1" charset="utf-8"></script> |
| | | |
| | | </body> |
| | | </html> |