Merge remote-tracking branch 'origin/jx-gt-crn-wcs' into jx-gt-crn-wcs
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 com.baomidou.mybatisplus.enums.IdType; |
| | | import com.core.common.Cools; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("man_api_log") |
| | | public class ApiLog implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 日志编号 |
| | | */ |
| | | @ApiModelProperty(value= "日志编号") |
| | | private String uuid; |
| | | |
| | | /** |
| | | * 名称空间 |
| | | */ |
| | | @ApiModelProperty(value= "名称空间") |
| | | private String namespace; |
| | | |
| | | /** |
| | | * 接口地址 |
| | | */ |
| | | @ApiModelProperty(value= "接口地址") |
| | | private String url; |
| | | |
| | | /** |
| | | * 平台密钥 |
| | | */ |
| | | @ApiModelProperty(value= "平台密钥") |
| | | private String appkey; |
| | | |
| | | /** |
| | | * 时间戳 |
| | | */ |
| | | @ApiModelProperty(value= "时间戳") |
| | | private String timestamp; |
| | | |
| | | /** |
| | | * 客户端IP |
| | | */ |
| | | @ApiModelProperty(value= "客户端IP") |
| | | @TableField("client_ip") |
| | | private String clientIp; |
| | | |
| | | /** |
| | | * 请求内容 |
| | | */ |
| | | @ApiModelProperty(value= "请求内容") |
| | | private String request; |
| | | |
| | | /** |
| | | * 响应内容 |
| | | */ |
| | | @ApiModelProperty(value= "响应内容") |
| | | private String response; |
| | | |
| | | /** |
| | | * 异常内容 |
| | | */ |
| | | @ApiModelProperty(value= "异常内容") |
| | | private String err; |
| | | |
| | | /** |
| | | * 结果 1: 成功 0: 失败 |
| | | */ |
| | | @ApiModelProperty(value= "结果 1: 成功 0: 失败 ") |
| | | private Integer result; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 禁用 |
| | | */ |
| | | @ApiModelProperty(value= "状态 1: 正常 0: 禁用 ") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @ApiModelProperty(value= "添加时间") |
| | | @TableField("create_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @ApiModelProperty(value= "修改时间") |
| | | @TableField("update_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | public ApiLog() {} |
| | | |
| | | public ApiLog(String uuid, String namespace, String url, String appkey, String timestamp, String clientIp, String request, String response, String err, Integer result, Integer status, Date createTime, Date updateTime, String memo) { |
| | | this.uuid = uuid; |
| | | this.namespace = namespace; |
| | | this.url = url; |
| | | this.appkey = appkey; |
| | | this.timestamp = timestamp; |
| | | this.clientIp = clientIp; |
| | | this.request = request; |
| | | this.response = response; |
| | | this.err = err; |
| | | this.result = result; |
| | | this.status = status; |
| | | this.createTime = createTime; |
| | | this.updateTime = updateTime; |
| | | this.memo = memo; |
| | | } |
| | | |
| | | // ApiLog apiLog = new ApiLog( |
| | | // null, // 日志编号 |
| | | // null, // 名称空间 |
| | | // null, // 接口地址 |
| | | // null, // 平台密钥 |
| | | // null, // 时间戳 |
| | | // null, // 客户端IP |
| | | // null, // 请求内容 |
| | | // null, // 响应内容 |
| | | // null, // 异常内容 |
| | | // null, // 结果 |
| | | // null, // 状态 |
| | | // null, // 添加时间 |
| | | // null, // 修改时间 |
| | | // null // 备注 |
| | | // ); |
| | | |
| | | public String getResult$(){ |
| | | if (null == this.result){ return null; } |
| | | switch (this.result){ |
| | | case 1: |
| | | return "成功"; |
| | | case 0: |
| | | return "失败"; |
| | | default: |
| | | return String.valueOf(this.result); |
| | | } |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "正常"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | public String getUpdateTime$(){ |
| | | if (Cools.isEmpty(this.updateTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.zy.asrs.entity.ApiLog; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface ApiLogMapper extends BaseMapper<ApiLog> { |
| | | |
| | | int clearWeekBefore(); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.service; |
| | | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.zy.asrs.entity.ApiLog; |
| | | |
| | | public interface ApiLogService extends IService<ApiLog> { |
| | | |
| | | void save(String namespace, String url, String appkey, String ip, String request, String response, boolean success); |
| | | |
| | | boolean clearWeekBefore(); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.entity.ApiLog; |
| | | import com.zy.asrs.mapper.ApiLogMapper; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Slf4j |
| | | @Service("apiLogService") |
| | | public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements ApiLogService { |
| | | |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | @Async |
| | | @Override |
| | | public void save(String namespace, String url, String appkey, String ip, String request, String response, boolean success) { |
| | | Date now = new Date(); |
| | | ApiLog apiLog = new ApiLog( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 日志编号 |
| | | namespace, // 名称空间 |
| | | url, // 接口地址 |
| | | appkey, // 平台密钥 |
| | | String.valueOf(now.getTime()), // 时间戳 |
| | | ip, // 客户端IP |
| | | request, // 请求内容 |
| | | response, |
| | | null, // 异常内容 |
| | | success?1:0 , // 结果 |
| | | 1, // 状态 |
| | | now, // 添加时间 |
| | | null, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | if (!this.insert(apiLog)) { |
| | | log.error("接口调用日志保存失败!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean clearWeekBefore() { |
| | | return this.baseMapper.clearWeekBefore() > 0; |
| | | } |
| | | } |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @Resource |
| | | private ApiLogService apiLogService; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | // log.info("转发agv任务:请求体:"+JSONObject.toJSONString(requestParam)+",返回值:"+jsonObject); |
| | | }catch (Exception e){ |
| | | |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "出库呼叫agv", |
| | | url + path, |
| | | null, |
| | | "127.0.0.1", |
| | | JSONObject.toJSONString(requestParam), |
| | | response, |
| | | success.equals("SUCCESS") |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | return success; |
| | | } |
| | |
| | | public class AgvSiteConstant { |
| | | |
| | | public static final Map<String,String> SiteMap = new HashMap<String,String>(){{ |
| | | put("a100","304620BB388490");put("a101","306220BB388474");put("a102","307820BB388474");put("a103","309420BB388454"); |
| | | put("a104","311020BB388444");put("a105","312620BB388404");put("a106","314220BB388424");put("a107","315820BB388414"); |
| | | put("a108","317420BB388404");put("a109","319020BB388394");put("a110","320620BB388374");put("a111","322220BB388374"); |
| | | put("a112","323820BB388354");put("a113","325420BB388344");put("a114","327020BB388354"); |
| | | put("a200","304620BB392785");put("a201","306220BB392750");put("a202","307820BB392740");put("a203","309420BB392720"); |
| | | put("a204","311020BB392715");put("a205","312620BB392720");put("a206","314220BB392685");put("a207","315820BB392700"); |
| | | put("a208","317420BB392705");put("a209","319020BB392675");put("a210","320620BB392670");put("a211","322220BB392670"); |
| | | put("a212","323820BB392670");put("a213","325420BB392670");put("a214","327020BB392650"); |
| | | put("a300","304620BB393960");put("a301","306220BB393960");put("a302","307820BB393950");put("a303","309420BB393935"); |
| | | put("a304","311020BB393945");put("a305","312620BB393940");put("a306","314220BB393950");put("a307","315820BB393930"); |
| | | put("a308","317420BB393915");put("a309","319020BB393900");put("a310","320620BB393920");put("a311","322220BB393900"); |
| | | put("a312","323820BB393890");put("a313","325420BB393890");put("a314","327020BB393885"); |
| | | put("a400","307287BB398282");put("a401","308887BB398267");put("a402","310487BB398247");put("a403","312087BB398227"); |
| | | put("a404","313687BB398247");put("a405","315287BB398227");put("a406","316887BB398217");put("a407","318487BB398227"); |
| | | put("a408","320087BB398217");put("a409","321687BB398217");put("a410","323287BB398197");put("a411","324887BB398217"); |
| | | put("a412","326487BB398187"); |
| | | put("a500","300350BB392785");put("a501","302000BB392770");put("a502","300350BB394020");put("a503","302000BB394010"); |
| | | put("aa11","300350BB388510");put("aa22","302000BB388490"); |
| | | put("a100","700000EE501013");put("a101","700001EE501013");put("a102","700002EE501013");put("a103","700003EE501013"); |
| | | put("a104","700004EE501013");put("a105","700005EE501013");put("a106","700006EE501013");put("a107","700007EE501013"); |
| | | put("a108","700008EE501013");put("a109","700009EE501013");put("a110","700010EE501013");put("a111","700046EE501013"); |
| | | put("a112","700047EE501013");put("a113","700048EE501013");put("a114","700049EE501013"); |
| | | put("a200","700032EE501013");put("a201","700011EE501013");put("a202","700012EE501013");put("a203","700013EE501013"); |
| | | put("a204","700014EE501013");put("a205","700015EE501013");put("a206","700016EE501013");put("a207","700017EE501013"); |
| | | put("a208","700018EE501013");put("a209","700019EE501013");put("a210","700020EE501013");put("a211","700050EE501013"); |
| | | put("a212","700051EE501013");put("a213","700052EE501013");put("a214","700053EE501013"); |
| | | put("a300","700031EE501013");put("a301","700021EE501013");put("a302","700022EE501013");put("a303","700023EE501013"); |
| | | put("a304","700024EE501013");put("a305","700025EE501013");put("a306","700026EE501013");put("a307","700027EE501013"); |
| | | put("a308","700028EE501013");put("a309","700029EE501013");put("a310","700030EE501013");put("a311","700054EE501013"); |
| | | put("a312","700055EE501013");put("a313","700056EE501013");put("a314","700057EE501013"); |
| | | put("a400","700033EE501013");put("a401","700034EE501013");put("a402","700035EE501013");put("a403","700036EE501013"); |
| | | put("a404","700037EE501013");put("a405","700038EE501013");put("a406","700039EE501013");put("a407","700040EE501013"); |
| | | put("a408","700041EE501013");put("a409","700058EE501013");put("a410","700059EE501013");put("a411","700060EE501013"); |
| | | put("a412","700061EE501013"); |
| | | put("a500","700042EE501013");put("a501","700043EE501013");put("a502","700044EE501013");put("a503","700045EE501013"); |
| | | put("aa11","700062EE501013");put("aa22","700063EE501013"); |
| | | put("b1","820001EE501013");put("b2","820002EE501013");put("b3","820003EE501013");put("b4","820004EE501013"); |
| | | put("b5","820005EE501013");put("b6","820006EE501013"); |
| | | put("c1","830001EE501013");put("c2","830002EE501013");put("c3","830003EE501013");put("c4","830004EE501013"); |
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.ApiLogMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.asrs.entity.ApiLog"> |
| | | <id column="id" property="id" /> |
| | | <result column="uuid" property="uuid" /> |
| | | <result column="namespace" property="namespace" /> |
| | | <result column="url" property="url" /> |
| | | <result column="appkey" property="appkey" /> |
| | | <result column="timestamp" property="timestamp" /> |
| | | <result column="client_ip" property="clientIp" /> |
| | | <result column="request" property="request" /> |
| | | <result column="response" property="response" /> |
| | | <result column="err" property="err" /> |
| | | <result column="result" property="result" /> |
| | | <result column="status" property="status" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="memo" property="memo" /> |
| | | |
| | | </resultMap> |
| | | |
| | | <delete id="clearWeekBefore"> |
| | | delete from man_api_log |
| | | where 1=1 |
| | | and datediff(week,create_time,getdate()) >= 1 |
| | | and result != 1 |
| | | </delete> |
| | | |
| | | </mapper> |