|
|
@@ -11,16 +11,8 @@ import com.minpay.common.service.ILogService;
|
|
|
import com.minpay.common.service.IPublicService;
|
|
|
import com.minpay.common.util.DataUtil;
|
|
|
import com.minpay.common.util.DateUtil;
|
|
|
-import com.minpay.db.table.mapper.VmDeliveryInfMapper;
|
|
|
-import com.minpay.db.table.mapper.VmEquipmentInfMapper;
|
|
|
-import com.minpay.db.table.mapper.VmProEquRelMapper;
|
|
|
-import com.minpay.db.table.mapper.VmPushNewsMapper;
|
|
|
-import com.minpay.db.table.model.VmDeliveryInf;
|
|
|
-import com.minpay.db.table.model.VmEquipmentInf;
|
|
|
-import com.minpay.db.table.model.VmEquipmentInfExample;
|
|
|
-import com.minpay.db.table.model.VmProEquRel;
|
|
|
-import com.minpay.db.table.model.VmProEquRelExample;
|
|
|
-import com.minpay.db.table.model.VmPushNews;
|
|
|
+import com.minpay.db.table.mapper.*;
|
|
|
+import com.minpay.db.table.model.*;
|
|
|
import com.startup.minpay.frame.business.IMINAction;
|
|
|
import com.startup.minpay.frame.business.MINHttpServletRequestContext;
|
|
|
import com.startup.minpay.frame.business.res.MINActionResult;
|
|
|
@@ -50,7 +42,13 @@ public class VendingMachineAction implements IMINAction {
|
|
|
/**
|
|
|
* 推送温度
|
|
|
*/
|
|
|
- public final static String PUSH_TEMPERATURE = "pushTemperature";
|
|
|
+ public final static String PUSH_TEMPERATURE = "pushTemperature";
|
|
|
+ /**
|
|
|
+ * 推货(测试)
|
|
|
+ */
|
|
|
+ public final static String CE_PUSH_GOODS = "cePushGoods";
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -74,48 +72,55 @@ public class VendingMachineAction implements IMINAction {
|
|
|
MINHttpServletRequestContext MINRequest
|
|
|
) throws MINBusinessException, InterruptedException {
|
|
|
MINActionResult res = new MINActionResult();
|
|
|
-
|
|
|
- //校验是否有此机器
|
|
|
- VmEquipmentInfExample veiExample = new VmEquipmentInfExample();
|
|
|
- veiExample.createCriteria().andImeiAddrEqualTo(imeiAddr).andStateEqualTo("00");
|
|
|
-
|
|
|
- List<VmEquipmentInf> veiList = Service.lookup(IMINDataBaseService.class)
|
|
|
- .getMybatisMapper(VmEquipmentInfMapper.class)
|
|
|
- .selectByExample(veiExample);
|
|
|
+
|
|
|
//设置返回值
|
|
|
Map<String, String> returnData = new HashMap<String, String> ();
|
|
|
String code = "200";
|
|
|
- //增加接收消息
|
|
|
- VmPushNews vpn = new VmPushNews();
|
|
|
- vpn.setState("01");
|
|
|
- // 机器存在
|
|
|
- if(veiList.size() != 1){
|
|
|
+ // 查询推货数量
|
|
|
+ VmDeliveryInf vdi = Service.lookup(IMINDataBaseService.class)
|
|
|
+ .getMybatisMapper(VmDeliveryInfMapper.class)
|
|
|
+ .selectByPrimaryKey(deliveryNo);
|
|
|
+ if(vdi == null){
|
|
|
+ returnData.put("code", "999");
|
|
|
+ returnData.put("msg", "提货编号不存在");
|
|
|
+ res.set("returnData", returnData);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询货道
|
|
|
+ VmProEquRel vmProEquRel = Service.lookup(IMINDataBaseService.class)
|
|
|
+ .getMybatisMapper(VmProEquRelMapper.class).selectByPrimaryKey(vdi.getProEquRelId());
|
|
|
+ if(vmProEquRel == null){
|
|
|
+ returnData.put("code", "999");
|
|
|
+ returnData.put("msg", "货道不存在");
|
|
|
+ res.set("returnData", returnData);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验是否有此机器
|
|
|
+ VmEquipmentInf vmEquipmentInf = Service.lookup(IMINDataBaseService.class)
|
|
|
+ .getMybatisMapper(VmEquipmentInfMapper.class)
|
|
|
+ .selectByPrimaryKey(vmProEquRel.getEquipmentId());
|
|
|
+
|
|
|
+ if(vmEquipmentInf == null){
|
|
|
returnData.put("code", "999");
|
|
|
returnData.put("msg", "机器异常");
|
|
|
res.set("returnData", returnData);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- // 查询当前货物数量
|
|
|
- VmProEquRelExample exp = new VmProEquRelExample();
|
|
|
- // VCI_AISLE varchar(5) COMMENT '货道指令',
|
|
|
- // VCI_EQUIPMENT_ID varchar(20) COMMENT '设备Id',
|
|
|
- exp.createCriteria().andAisleEqualTo(cargoNo).andEquipmentIdEqualTo(veiList.get(0).getId()).andExeitStateEqualTo("00");
|
|
|
- List<VmProEquRel> relList = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmProEquRelMapper.class).selectByExample(exp);
|
|
|
- // 机器存在
|
|
|
- if(relList.size() != 1){
|
|
|
+ if(!vmProEquRel.getAisle().equals(cargoNo) || !imeiAddr.equals(vmEquipmentInf.getImeiAddr())){
|
|
|
returnData.put("code", "999");
|
|
|
- returnData.put("msg", "机器货道异常,不存在货道或者多个货道指令。");
|
|
|
+ returnData.put("msg", "所传货道或机器不一致");
|
|
|
res.set("returnData", returnData);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
- // 查询推货数量
|
|
|
- VmDeliveryInf vdi = Service.lookup(IMINDataBaseService.class)
|
|
|
- .getMybatisMapper(VmDeliveryInfMapper.class)
|
|
|
- .selectByPrimaryKey(deliveryNo);
|
|
|
+
|
|
|
+ //增加接收消息
|
|
|
+ VmPushNews vpn = new VmPushNews();
|
|
|
+ vpn.setState("01");
|
|
|
+
|
|
|
// 商品剩余量VCI_PRODUCT_NUMS
|
|
|
- int proYuliang = CommonUtil.objToint(relList.get(0).getProductNums());
|
|
|
+ int proYuliang = CommonUtil.objToint(vmProEquRel.getProductNums());
|
|
|
if(proYuliang <= 0){
|
|
|
returnData.put("code", "999");
|
|
|
returnData.put("msg", "商品余量不足,推货失败");
|
|
|
@@ -309,6 +314,67 @@ public class VendingMachineAction implements IMINAction {
|
|
|
) throws MINBusinessException {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 推货(测试专用)
|
|
|
+ * @param imeiAddr 机器imei编码
|
|
|
+ * @param cargoNo 货道指令编号
|
|
|
+ * @param deliveryNo 推货编号
|
|
|
+ * @param returnUrl 回调地址
|
|
|
+ * @param openId
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws InterruptedException
|
|
|
+ */
|
|
|
+ @MINAction(value = CE_PUSH_GOODS,session=false)
|
|
|
+ public MINActionResult cePushGoods(
|
|
|
+ @MINParam(key = "imeiAddr") String imeiAddr,
|
|
|
+ @MINParam(key = "cargoNo") String cargoNo,
|
|
|
+ @MINParam(key = "deliveryNo") String deliveryNo,
|
|
|
+ @MINParam(key = "returnUrl") String returnUrl,
|
|
|
+ @MINParam(key = "openId") String openId,
|
|
|
+ MINHttpServletRequestContext MINRequest
|
|
|
+ ) throws MINBusinessException, InterruptedException {
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+ //设置返回值
|
|
|
+ Map<String, String> returnData = new HashMap<String, String> ();
|
|
|
+ String code = "200";
|
|
|
+ //校验openid 和机器的关系
|
|
|
+
|
|
|
+ //进行推货
|
|
|
+ List<String> restList = new ArrayList<String>();
|
|
|
+ restList.add("[a|");
|
|
|
+
|
|
|
+ restList.add(imeiAddr); //机台号
|
|
|
+ restList.add("|");
|
|
|
+ restList.add(deliveryNo); //订单号
|
|
|
+ restList.add("]");
|
|
|
+ restList.add("(bFA 00 06 00 24");
|
|
|
+ String cargoNo16 = DataUtil.str10ToStr16(Integer.valueOf(cargoNo));
|
|
|
+ if(cargoNo16.length() == 1){
|
|
|
+ cargoNo16 = "0".concat(cargoNo16);
|
|
|
+ }
|
|
|
+ restList.add(" ".concat(cargoNo16));
|
|
|
+ restList.add(")");
|
|
|
+ String param = DataUtil.listToString(restList);
|
|
|
+ try {//进行通知
|
|
|
+ code = Service.lookup(IClientService.class).sendMsg(param, imeiAddr);
|
|
|
+ if(!"200".equals(code)){
|
|
|
+ returnData.put("code", code);
|
|
|
+ returnData.put("msg", "推货失败");
|
|
|
+ }else{
|
|
|
+ returnData.put("code", code);
|
|
|
+ returnData.put("msg", "推货成功");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ returnData.put("code", "999");
|
|
|
+ returnData.put("msg", "推货失败");
|
|
|
+ }
|
|
|
+ res.set("returnData", returnData);
|
|
|
+ //记录操作日志
|
|
|
+ String logInfo = "测试推货》》售货机:"+imeiAddr+"货单号:"+cargoNo+",货状态:"+returnData.get("code");
|
|
|
+ Log.info(logInfo);
|
|
|
+ Service.lookup(ILogService.class).logging(null, logInfo);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
}
|