|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.szwl.constant.ResponseCodesEnum;
|
|
|
import com.szwl.model.bean.CommonParamVo;
|
|
|
import com.szwl.model.bean.EquipmentDTO;
|
|
|
import com.szwl.model.bean.EquipmentVo;
|
|
@@ -12,6 +13,7 @@ import com.szwl.model.bean.ProductVo;
|
|
|
import com.szwl.model.bo.JsonMessage;
|
|
|
import com.szwl.model.bo.JsonUtils;
|
|
|
import com.szwl.model.bo.R;
|
|
|
+import com.szwl.model.bo.ResponseModel;
|
|
|
import com.szwl.model.entity.*;
|
|
|
import com.szwl.model.utils.AdminUtils;
|
|
|
import com.szwl.model.utils.HttpClientSslUtils;
|
|
@@ -165,23 +167,25 @@ public class IndexController { ;
|
|
|
@ResponseBody
|
|
|
public String initNew(String clientId, String managerId, String gtClientId, String equimentType) {
|
|
|
String machineType = "0";
|
|
|
+ String status = "0";
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
- query.eq(TEquipment::getClientId,clientId);
|
|
|
+ query.like(TEquipment::getClientId,clientId);
|
|
|
List<TEquipment> list = equipmentService.list(query);
|
|
|
if (list.size() > 0) {
|
|
|
TEquipment equipment = list.get(0);
|
|
|
- String managerId1 = equipment.getManagerId();
|
|
|
- if(!managerId.equals(managerId1)){
|
|
|
- return "该设备未脱离";
|
|
|
-// return JsonMessage.error("该设备已经初始化");
|
|
|
+ if(equipment.getAdminId()!=31){
|
|
|
+ String managerId1 = equipment.getManagerId();
|
|
|
+ if(!managerId.equals(managerId1)){
|
|
|
+ return "该设备未脱离";
|
|
|
+ }else {
|
|
|
+ return "该设备已经初始化";
|
|
|
+ }
|
|
|
}else {
|
|
|
-// return JsonMessage.error("该设备已经初始化");
|
|
|
- return "该设备已经初始化";
|
|
|
+ status = "1";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(gtClientId)) {
|
|
|
-// return JsonMessage.error("设备不能为空");
|
|
|
return "设备不能为空";
|
|
|
}
|
|
|
LambdaQueryWrapper<TEquipmentApply> query1 = Wrappers.lambdaQuery();
|
|
@@ -211,7 +215,6 @@ public class IndexController { ;
|
|
|
|
|
|
TAdmin admin = adminService.getById(adminId);
|
|
|
if (admin == null) {
|
|
|
-// return JsonMessage.error("找不到商家");
|
|
|
return "找不到商家";
|
|
|
}
|
|
|
//所属商家
|
|
@@ -223,7 +226,7 @@ public class IndexController { ;
|
|
|
equipmentApply.setCreateDate(new Date());
|
|
|
equipmentApply.setModifyDate(new Date());
|
|
|
equipmentApplyService.save(equipmentApply);
|
|
|
- if(String.valueOf(adminId).equals("3")||String.valueOf(adminId).equals("31")||String.valueOf(adminId).equals("506")||String.valueOf(adminId).equals("1090")){
|
|
|
+ if(status.equals("1")||String.valueOf(adminId).equals("3")||String.valueOf(adminId).equals("31")||String.valueOf(adminId).equals("506")||String.valueOf(adminId).equals("1090")){
|
|
|
Long id = equipmentApply.getId();
|
|
|
agree(id);
|
|
|
return "设备申请成功";
|
|
@@ -235,12 +238,10 @@ public class IndexController { ;
|
|
|
if(now.getTime()>applyStartTime.getTime()&&now.getTime()<applyEndTime.getTime()){
|
|
|
Long id = equipmentApply.getId();
|
|
|
agree(id);
|
|
|
-// return JsonMessage.success("设备申请成功");
|
|
|
return "设备申请成功";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// return JsonMessage.success("设备申请中,请耐心等待");
|
|
|
return "设备申请中,请耐心等待";
|
|
|
|
|
|
}
|
|
@@ -258,10 +259,6 @@ public class IndexController { ;
|
|
|
if (status.equals("agreed")) {
|
|
|
String clientId = equipmentApply.getClientId();
|
|
|
//判断是否设备初始化
|
|
|
-// if (equipmentService.findByClientId(clientId) != null) {
|
|
|
-// addFlashMessage(redirectAttributes, Message.error("该设备已经初始化"));
|
|
|
-// return "redirect:listInit.htm";
|
|
|
-// }
|
|
|
Long adminId = equipmentApply.getAdminId();
|
|
|
String adminLevel = equipmentApply.getAdminLevel();
|
|
|
String adminUserName = equipmentApply.getAdminUserName();
|
|
@@ -270,18 +267,24 @@ public class IndexController { ;
|
|
|
String machineType = equipmentApply.getMachineType();
|
|
|
|
|
|
String old = "";
|
|
|
-// ArrayList<Filter> filters = new ArrayList<>();
|
|
|
-// filters.add(Filter.eq("clientId", clientId + "xxx"));
|
|
|
-// List<TEquipment> list = equipmentService.findList(null, filters, null);
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
query.like(TEquipment::getClientId,clientId+"xxx");
|
|
|
List<TEquipment> list = equipmentService.list(query);
|
|
|
+ LambdaQueryWrapper<TEquipment> query0 = Wrappers.lambdaQuery();
|
|
|
+ query0.eq(TEquipment::getClientId,clientId);
|
|
|
+ List<TEquipment> list2 = equipmentService.list(query0);
|
|
|
equipmentApply.setStatusType(3);
|
|
|
- if (list.size() > 0) {
|
|
|
+ if (list.size() > 0||list2.size()>0) {
|
|
|
//表示设备第二次申请了:主要为了区分脱离以及初始化
|
|
|
old = "1";
|
|
|
//重新修改设备名称
|
|
|
- TEquipment equipment = list.get(0);
|
|
|
+// TEquipment equipment = list.get(0);
|
|
|
+ TEquipment equipment = new TEquipment();
|
|
|
+ if(list2.size()>0){
|
|
|
+ equipment = list2.get(0);
|
|
|
+ }else {
|
|
|
+ equipment = list.get(0);
|
|
|
+ }
|
|
|
equipment.setClientId(clientId);
|
|
|
equipment.setGtClientId(gtClientId);
|
|
|
equipment.setAdminId(adminId);
|
|
@@ -290,9 +293,6 @@ public class IndexController { ;
|
|
|
equipment.setMachineType(machineType);
|
|
|
if(equipmentApply.getEquimentType().equals("MG320-1")){
|
|
|
if(!equipmentApply.getEquimentType().equals(equipment.getEquimentType())&&equipment.getEquimentType().equals("MG320")){
|
|
|
-// List<Filter> filter = new ArrayList<>();
|
|
|
-// filter.add(Filter.eq("equipmentId", equipment.getId()));
|
|
|
-// List<Product> productList = productService.findList(null, filter, null);
|
|
|
LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
|
|
|
queryProduct.eq(TProduct::getEquipmentId,equipment.getId());
|
|
|
List<TProduct> productList = productService.list(queryProduct);
|
|
@@ -317,33 +317,22 @@ public class IndexController { ;
|
|
|
proportionService.removeById(proportion.getId());
|
|
|
}
|
|
|
}
|
|
|
-// String data = com.alibaba.fastjson.JSON.toJSONString(equipment);
|
|
|
+// if(String.valueOf(adminId).equals("3")||String.valueOf(adminId).equals("31")||String.valueOf(adminId).equals("506")||String.valueOf(adminId).equals("1090")){
|
|
|
+// //自动设置分销
|
|
|
+// setProportion(adminId,equipment.getId(),clientId);
|
|
|
+// }
|
|
|
try {
|
|
|
-// String result = HttpClientUtils.sentData(HttpClientUtils.Update_Equipment_Url, data);
|
|
|
-// if(!result.equals("200")){
|
|
|
-// result = HttpClientUtils.sentData(HttpClientUtils.Update_Equipment_Url, data);
|
|
|
-// if(!result.equals("200")){
|
|
|
-// result = HttpClientUtils.sentData(HttpClientUtils.Update_Equipment_Url, data);
|
|
|
-// if(!result.equals("200")){
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
esTEquipmentService.updateDataById(equipment);
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-// addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
|
|
|
equipmentService.sentMessage(clientId,PushUtils.buildJson("statusType", "agreed" + old).toString());
|
|
|
PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
|
|
|
-// equipmentApplyService.update(equipmentApply);
|
|
|
if(equipment.getEquimentType().equals("280")){
|
|
|
equipmentService.sentMessage(clientId,PushUtils.buildJson("endDate",String.valueOf(equipment.getEndDate().getTime()) ).toString());
|
|
|
PushUtils.push(equipmentApply.getGtClientId(), "", "", PushUtils.buildJson("endDate",String.valueOf(equipment.getEndDate().getTime()) ).toString());
|
|
|
}
|
|
|
-// equipmentService.sentMessage(clientId,PushUtils.buildJson("endDate",String.valueOf(equipment.getEndDate().getTime()) ).toString());
|
|
|
-// PushUtils.push(equipmentApply.getGtClientId(), "", "", PushUtils.buildJson("endDate",String.valueOf(equipment.getEndDate().getTime()) ).toString());
|
|
|
-// return "redirect:listInit.htm";
|
|
|
- return;
|
|
|
+
|
|
|
}else{
|
|
|
|
|
|
TEquipment equipment = new TEquipment();
|
|
@@ -388,25 +377,14 @@ public class IndexController { ;
|
|
|
PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "同意", PushUtils.buildJson("statusType", "agreed" + old).toString());
|
|
|
// Equipment byClientId = equipmentService.findByClientId(equipment.getClientId());
|
|
|
// String data = com.alibaba.fastjson.JSON.toJSONString(byClientId);
|
|
|
- LambdaQueryWrapper<TEquipment> query1 = Wrappers.lambdaQuery();
|
|
|
- query1.eq(TEquipment::getClientId,clientId);
|
|
|
- List<TEquipment> list1 = equipmentService.list(query1);
|
|
|
+ LambdaQueryWrapper<TEquipment> query3 = Wrappers.lambdaQuery();
|
|
|
+ query3.eq(TEquipment::getClientId,clientId);
|
|
|
+ List<TEquipment> list1 = equipmentService.list(query3);
|
|
|
try {
|
|
|
if(list1.size()>0){
|
|
|
TEquipment tEquipment = list1.get(0);
|
|
|
esTEquipmentService.insertData(tEquipment);
|
|
|
}
|
|
|
-// String result = HttpClientUtils.sentData(HttpClientUtils.Equipment_Url, data);
|
|
|
-// if(!result.equals("200")){
|
|
|
-// byClientId = equipmentService.findByClientId(equipment.getClientId());
|
|
|
-// result = HttpClientUtils.sentData(HttpClientUtils.Equipment_Url, data);
|
|
|
-// if(!result.equals("200")){
|
|
|
-// byClientId = equipmentService.findByClientId(equipment.getClientId());
|
|
|
-// result = HttpClientUtils.sentData(HttpClientUtils.Equipment_Url, data);
|
|
|
-// if(!result.equals("200")){
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -436,14 +414,11 @@ public class IndexController { ;
|
|
|
setProportion(adminId,equipmentId,clientId);
|
|
|
}
|
|
|
} else if (status.equals("rejected")) {
|
|
|
- equipmentApply.setStatusType(3);
|
|
|
+ equipmentApply.setStatusType(2);
|
|
|
equipmentService.sentMessage(equipmentApply.getClientId(),PushUtils.buildJson("statusType", "rejected").toString());
|
|
|
// PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "拒绝", PushUtils.buildJson("statusType", "rejected").toString());
|
|
|
}
|
|
|
equipmentApplyService.updateById(equipmentApply);
|
|
|
-
|
|
|
-// addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1920,7 +1895,38 @@ public class IndexController { ;
|
|
|
|
|
|
return "更新失败error";
|
|
|
}
|
|
|
+ /**
|
|
|
+ *上传机器状态之门的状态:
|
|
|
+ * type(类型,0:外门,1:内门),
|
|
|
+ * status(状态:0:关闭,1:开启)
|
|
|
+ * @param clientId
|
|
|
|
|
|
+ * @return status(状态:0:关闭,1:开启)
|
|
|
+ */
|
|
|
+ @GetMapping("/updateEquipmentStatus")
|
|
|
+ public ResponseModel<?> updateEquipmentStatus(String clientId, String type, String status){
|
|
|
+ if(StringUtils.isEmpty(clientId)||StringUtils.isEmpty(type)||StringUtils.isEmpty(status)){
|
|
|
+ return R.fail(ResponseCodesEnum.A0001,"adminId为空");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TEquipment::getClientId,clientId);
|
|
|
+ TEquipment equipment = equipmentService.getOnly(query);
|
|
|
+ if(equipment!=null&&equipment.getId()!=null){
|
|
|
+ if(type.equals("0")){
|
|
|
+ TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
|
|
|
+ equipmentDesc.setOutDoor(status);
|
|
|
+ equipmentDescService.updateById(equipmentDesc);
|
|
|
+ return R.ok();
|
|
|
+ }else if(type.equals("1")){
|
|
|
+ TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
|
|
|
+ equipmentDesc.setInDoor(status);
|
|
|
+ equipmentDescService.updateById(equipmentDesc);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.fail(ResponseCodesEnum.A0002);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|