|
@@ -16,10 +16,14 @@ import com.szwl.model.utils.HttpClientSslUtils;
|
|
|
import com.szwl.model.utils.PushUtils;
|
|
|
import com.szwl.service.*;
|
|
|
import com.szwl.service.es.EsTEquipmentService;
|
|
|
+import com.szwl.util.IDGenerator;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.amqp.core.AmqpAdmin;
|
|
|
+import org.springframework.amqp.core.Binding;
|
|
|
+import org.springframework.amqp.core.Queue;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -36,29 +40,45 @@ import java.util.*;
|
|
|
@Api(value = "/indexController", tags = {"设备信息上传接口"})
|
|
|
@RestController
|
|
|
@RequestMapping("/api/app_equipment/index")
|
|
|
-public class IndexController { ;
|
|
|
+public class IndexController {
|
|
|
+
|
|
|
@Autowired
|
|
|
TAdminService adminService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TEquipmentService equipmentService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TEquipmentApplyService equipmentApplyService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TProductService productService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TProportionService proportionService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TEquipmentDescService equipmentDescService;
|
|
|
+
|
|
|
@Autowired
|
|
|
EsTEquipmentService esTEquipmentService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TParametersService parametersService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TPriceService priceService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TPromoCodeService promoCodeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TDiyFlowerService diyFlowerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AmqpAdmin amqpAdmin;
|
|
|
+
|
|
|
@ApiOperation(value = "心跳")
|
|
|
-// @PostMapping("/heart.htm")
|
|
|
@RequestMapping(value = "/heart.htm", method = RequestMethod.POST, produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public String heart(@RequestBody EquipmentVo equipmentVo) {
|
|
@@ -76,13 +96,15 @@ public class IndexController { ;
|
|
|
Integer eqeStatus = equipmentVo.getEqeStatus();
|
|
|
Boolean is_sleep = equipmentVo.getIs_sleep();
|
|
|
String netWorkingMode = equipmentVo.getNetWorkingMode();
|
|
|
+ String numberOne = equipmentVo.getNumberOne();
|
|
|
+ String candyGeneratorTm = equipmentVo.getCandyGeneratorTm();
|
|
|
+ String outsideTm = equipmentVo.getOutsideTm();
|
|
|
+ String outsideHd = equipmentVo.getOutsideHd();
|
|
|
+
|
|
|
//有记录,则进行修改
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
query.eq(TEquipment::getClientId,clientId);
|
|
|
-// List<TEquipment> list = equipmentService.list(query);
|
|
|
-// TEquipment _new = list.get(0);
|
|
|
TEquipment _new = equipmentService.getOne(query);
|
|
|
-// Equipment _new = equipmentService.findByClientId(clientId);
|
|
|
if (_new != null) {
|
|
|
_new.setNetWorkingMode(netWorkingMode);
|
|
|
if(StringUtils.isNotEmpty(cabinetTm)){
|
|
@@ -152,11 +174,21 @@ public class IndexController { ;
|
|
|
if(StringUtils.isNotEmpty(equipmentVo.getCornGeneratorTm())){
|
|
|
equipmentDesc.setCornGeneratorTm(equipmentVo.getCornGeneratorTm());
|
|
|
}
|
|
|
+ if(StringUtils.isNotEmpty(numberOne)){
|
|
|
+ equipmentDesc.setNumberOne(numberOne);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(candyGeneratorTm)){
|
|
|
+ equipmentDesc.setCandyGeneratorTm(candyGeneratorTm);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(outsideHd)){
|
|
|
+ equipmentDesc.setOutsideHd(outsideHd);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(outsideTm)){
|
|
|
+ equipmentDesc.setOutsideTm(outsideTm);
|
|
|
+ }
|
|
|
equipmentDescService.updateById(equipmentDesc);
|
|
|
-// return JsonMessage.success("心跳成功");
|
|
|
return "心跳成功";
|
|
|
}
|
|
|
-// return JsonMessage.error("心跳失败");
|
|
|
return "心跳失败";
|
|
|
}
|
|
|
/**
|
|
@@ -311,8 +343,6 @@ public class IndexController { ;
|
|
|
//从18种变成30种花型
|
|
|
saveProductMG12(equipment.getId());
|
|
|
}
|
|
|
- //从18种变成30种花型
|
|
|
-// saveProductMG12(equipment.getId());
|
|
|
}
|
|
|
equipment.setEquimentType("MG320");
|
|
|
}
|
|
@@ -331,10 +361,6 @@ public class IndexController { ;
|
|
|
proportionService.removeById(proportion.getId());
|
|
|
}
|
|
|
}
|
|
|
-// 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 {
|
|
|
esTEquipmentService.updateDataById(equipment);
|
|
|
}catch (Exception e) {
|
|
@@ -355,6 +381,7 @@ public class IndexController { ;
|
|
|
}else{
|
|
|
|
|
|
TEquipment equipment = new TEquipment();
|
|
|
+ equipment.setId(IDGenerator.commonID());
|
|
|
equipment.setCreateDate(new Date());
|
|
|
equipment.setModifyDate(new Date());
|
|
|
equipment.setClientId(clientId);
|
|
@@ -377,12 +404,6 @@ public class IndexController { ;
|
|
|
}else {
|
|
|
equipment.setEquimentType(equimentType);
|
|
|
}
|
|
|
-// if(equimentType.equals("MG330")){
|
|
|
-// equipment.setEquimentType("MG330");
|
|
|
-// }
|
|
|
-// if(equimentType.equals("POP320")){
|
|
|
-// equipment.setEquimentType(equimentType);
|
|
|
-// }
|
|
|
if(!StringUtils.isEmpty(equimentType)&&equimentType.equals("MG280")){
|
|
|
Long monthBegin = getMonthBegin(new Date());
|
|
|
long time = System.currentTimeMillis();
|
|
@@ -404,17 +425,10 @@ public class IndexController { ;
|
|
|
equipmentService.sentMessage(clientId,PushUtils.buildJson("statusType", "agreed" + old).toString());
|
|
|
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> query3 = Wrappers.lambdaQuery();
|
|
|
query3.eq(TEquipment::getClientId,clientId);
|
|
|
TEquipment tEquipment = equipmentService.getOne(query3);
|
|
|
-// List<TEquipment> list1 = equipmentService.list(query3);
|
|
|
try {
|
|
|
-// if(list1.size()>0){
|
|
|
-// TEquipment tEquipment = list1.get(0);
|
|
|
-// esTEquipmentService.insertData(tEquipment);
|
|
|
-// }
|
|
|
if(tEquipment != null) {
|
|
|
esTEquipmentService.insertData(tEquipment);
|
|
|
}
|
|
@@ -426,13 +440,10 @@ public class IndexController { ;
|
|
|
equipmentDescService.save(equipmentDesc);
|
|
|
}
|
|
|
//获取设备的id
|
|
|
-// Long equipmentId = equipmentService.findByClientId(clientId).getId();
|
|
|
LambdaQueryWrapper<TEquipment> query1 = Wrappers.lambdaQuery();
|
|
|
query1.eq(TEquipment::getClientId,clientId);
|
|
|
-// List<TEquipment> list1 = equipmentService.list(query1);
|
|
|
TEquipment equipment = equipmentService.getOne(query1);
|
|
|
Long equipmentId = equipment.getId();
|
|
|
-// if (!productService.exists(Filter.eq("equipmentId", equipmentId))) {
|
|
|
if(StringUtils.isEmpty(machineType) || machineType.equals("0")) {
|
|
|
if(equipmentApply.getEquimentType()!=null&&equipmentApply.getEquimentType().equals("MG280")){
|
|
|
saveProductMG280(equipmentId);
|
|
@@ -454,7 +465,6 @@ public class IndexController { ;
|
|
|
} else if (status.equals("rejected")) {
|
|
|
equipmentApply.setStatusType(2);
|
|
|
equipmentService.sentMessage(equipmentApply.getClientId(),PushUtils.buildJson("statusType", "rejected").toString());
|
|
|
-// PushUtils.push(equipmentApply.getGtClientId(), "【棉花糖】设备初始化申请", "拒绝", PushUtils.buildJson("statusType", "rejected").toString());
|
|
|
}
|
|
|
equipmentApplyService.updateById(equipmentApply);
|
|
|
}
|
|
@@ -490,11 +500,6 @@ public class IndexController { ;
|
|
|
case 2:
|
|
|
equipmentProportion.setProportion(adminProportion.getMerchantProportion());
|
|
|
equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
|
|
|
-// if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
-// equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
-// TAdmin byId = adminService.getById(admin.getAgencyId());
|
|
|
-// equipmentProportion.setAgencyName(byId.getUsername());
|
|
|
-// }
|
|
|
equipmentProportion.setAgencyId(adminProportion.getAgencyId());
|
|
|
TAdmin byId = adminService.getById(adminProportion.getAgencyId());
|
|
|
equipmentProportion.setAgencyName(byId.getUsername());
|
|
@@ -505,20 +510,10 @@ public class IndexController { ;
|
|
|
case 3:
|
|
|
equipmentProportion.setProportion(adminProportion.getPersonageProportion());
|
|
|
equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
|
|
|
-// if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
-// equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
-// TAdmin byId = adminService.getById(admin.getAgencyId());
|
|
|
-// equipmentProportion.setAgencyName(byId.getUsername());
|
|
|
-// }
|
|
|
equipmentProportion.setAgencyId(adminProportion.getAgencyId());
|
|
|
TAdmin byId1 = adminService.getById(adminProportion.getAgencyId());
|
|
|
equipmentProportion.setAgencyName(byId1.getUsername());
|
|
|
equipmentProportion.setMerchantProportion(adminProportion.getMerchantProportion());
|
|
|
-// if(adminProportion.getMerchantProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
-// equipmentProportion.setMerchantId(admin.getMerchantId());
|
|
|
-// TAdmin byId = adminService.getById(admin.getMerchantId());
|
|
|
-// equipmentProportion.setMerchantName(byId.getUsername());
|
|
|
-// }
|
|
|
equipmentProportion.setMerchantId(adminProportion.getMerchantId());
|
|
|
TAdmin byId2 = adminService.getById(adminProportion.getMerchantId());
|
|
|
equipmentProportion.setMerchantName(byId2.getUsername());
|
|
@@ -710,6 +705,7 @@ public class IndexController { ;
|
|
|
// 获取本月第一天的时间戳
|
|
|
return c.getTimeInMillis();
|
|
|
}
|
|
|
+
|
|
|
public static Date nextMonthDate() {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.set(Calendar.DAY_OF_MONTH,10);
|
|
@@ -777,6 +773,7 @@ public class IndexController { ;
|
|
|
return "error";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 设备类型 开机时上传
|
|
|
*
|
|
@@ -794,10 +791,9 @@ public class IndexController { ;
|
|
|
equipment.setEquimentType(equimentType);
|
|
|
equipmentService.updateById(equipment);
|
|
|
}
|
|
|
-
|
|
|
-// return JsonMessage.success("success");
|
|
|
return "success";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 设备地址 开机时上传
|
|
|
* @param clientId 个推
|
|
@@ -814,12 +810,11 @@ public class IndexController { ;
|
|
|
equipment.setLongitude(Double.valueOf(longitude));
|
|
|
equipment.setFullName(fullName+"-");
|
|
|
equipmentService.updateById(equipment);
|
|
|
-// return JsonMessage.success("success");
|
|
|
return "success";
|
|
|
}
|
|
|
-// return JsonMessage.success("error");
|
|
|
return "error";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 商品调价
|
|
|
*/
|
|
@@ -864,12 +859,15 @@ public class IndexController { ;
|
|
|
|
|
|
return "调价成功";
|
|
|
}
|
|
|
+
|
|
|
public Double tran(Double d){
|
|
|
return new BigDecimal(d).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
}
|
|
|
+
|
|
|
public Double tran2(Double d){
|
|
|
return new BigDecimal(d).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 密码修改
|
|
|
*
|
|
@@ -895,14 +893,13 @@ public class IndexController { ;
|
|
|
break;
|
|
|
}
|
|
|
equipmentService.updateById(equipment);
|
|
|
-// return JsonMessage.success("更新密码成功");
|
|
|
return "更新密码成功";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-// return JsonMessage.error("更新密码失败");
|
|
|
return "更新密码失败";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 设备获取密码
|
|
|
*/
|
|
@@ -924,6 +921,7 @@ public class IndexController { ;
|
|
|
jsonObject.put("errmsg", "");
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 修改支付方式
|
|
|
*
|
|
@@ -1015,7 +1013,6 @@ public class IndexController { ;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 脱离系统
|
|
|
*
|
|
@@ -1039,6 +1036,7 @@ public class IndexController { ;
|
|
|
equipmentService.updateById(equipment);
|
|
|
return "脱离成功";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 脱离系统
|
|
|
*
|
|
@@ -1063,8 +1061,6 @@ public class IndexController { ;
|
|
|
return "脱离成功";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 修改设备联系人名称以及电话
|
|
|
*/
|
|
@@ -1099,6 +1095,7 @@ public class IndexController { ;
|
|
|
equipmentService.updateById(equipment);
|
|
|
return "修改成功";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取二维码图片
|
|
|
*/
|
|
@@ -1113,6 +1110,7 @@ public class IndexController { ;
|
|
|
}
|
|
|
return "400";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 上传4G卡号
|
|
|
*/
|
|
@@ -1123,14 +1121,13 @@ public class IndexController { ;
|
|
|
query.eq(TEquipment::getClientId,clientId);
|
|
|
TEquipment equipment = equipmentService.getOne(query);
|
|
|
if (equipment == null) {
|
|
|
-// return JsonMessage.error("该设备不存在");
|
|
|
return "该设备不存在";
|
|
|
}
|
|
|
equipment.setSimNo(simNo);
|
|
|
equipmentService.updateById(equipment);
|
|
|
-// return JsonMessage.success("修改成功");
|
|
|
return "修改成功";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 上传机器的apk版本
|
|
|
*/
|
|
@@ -1147,6 +1144,7 @@ public class IndexController { ;
|
|
|
equipmentService.updateById(equipment);
|
|
|
return "success";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 上传机器的做糖状态
|
|
|
*/
|
|
@@ -1165,6 +1163,7 @@ public class IndexController { ;
|
|
|
equipmentDescService.updateById(equipmentDesc);
|
|
|
return "success";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 修改设备状态
|
|
|
*
|
|
@@ -1188,6 +1187,7 @@ public class IndexController { ;
|
|
|
}
|
|
|
return "修改成功";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 新修改设备状态
|
|
|
*
|
|
@@ -1202,7 +1202,6 @@ public class IndexController { ;
|
|
|
query.eq(TEquipment::getClientId,clientId);
|
|
|
TEquipment equipment = equipmentService.getOne(query);
|
|
|
if (equipment == null) {
|
|
|
-// return JsonMessage.error("该设备不存在");
|
|
|
return "该设备不存在";
|
|
|
}
|
|
|
if(eqeStatus!=null){
|
|
@@ -1210,9 +1209,9 @@ public class IndexController { ;
|
|
|
equipment.setEqeStatus(eqeStatus);
|
|
|
equipmentService.updateById(equipment);
|
|
|
}
|
|
|
-// return JsonMessage.success("修改成功");
|
|
|
return "修改成功";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 修改设备锁定状态
|
|
|
*
|
|
@@ -1227,7 +1226,6 @@ public class IndexController { ;
|
|
|
query.eq(TEquipment::getClientId,clientId);
|
|
|
TEquipment equipment = equipmentService.getOne(query);
|
|
|
if (equipment == null) {
|
|
|
-// return JsonMessage.error("该设备不存在");
|
|
|
return "该设备不存在";
|
|
|
}
|
|
|
equipment.setIsBlocked(block);
|
|
@@ -1308,12 +1306,11 @@ public class IndexController { ;
|
|
|
|
|
|
/**
|
|
|
* 修改设备共同参数/进阶参数
|
|
|
- * code 0:通用参数;1:进阶参数;2:调试页参数
|
|
|
+ * code 0:通用参数;1:进阶参数;2:调试页参数;3:湿度参数
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/updateParamNew", method = RequestMethod.POST)
|
|
|
-// @PostMapping(value = "/updateParamNew", produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public String updateParamNew(Integer code, String clientId, @RequestBody List<CommonParamVo> commonParamVos) {
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
@@ -1329,9 +1326,9 @@ public class IndexController { ;
|
|
|
queryParameters.eq(TParameters::getClientId,clientId);
|
|
|
queryParameters.eq(TParameters::getStatus,code);
|
|
|
queryParameters.eq(TParameters::getEquipmentId,equipment.getId());
|
|
|
- List<TParameters> list1 = parametersService.list(queryParameters);
|
|
|
- if(list1.size()>0){
|
|
|
- for(TParameters parameters:list1){
|
|
|
+ List<TParameters> list = parametersService.list(queryParameters);
|
|
|
+ if(list.size()>0){
|
|
|
+ for(TParameters parameters:list){
|
|
|
//删除旧的参数
|
|
|
parametersService.removeById(parameters.getId());
|
|
|
}
|
|
@@ -1353,7 +1350,7 @@ public class IndexController { ;
|
|
|
|
|
|
/**
|
|
|
* 修改单个设备共同参数/进阶参数
|
|
|
- * code 0:通用参数;1:进阶参数;2:调试页参数
|
|
|
+ * code 0:通用参数;1:进阶参数;2:调试页参数;3:湿度参数
|
|
|
* @param
|
|
|
* @return
|
|
|
*/
|
|
@@ -1364,15 +1361,8 @@ public class IndexController { ;
|
|
|
query.eq(TEquipment::getClientId,clientId);
|
|
|
TEquipment equipment = equipmentService.getOne(query);
|
|
|
if (equipment == null) {
|
|
|
-// return JsonMessage.error("设备不存在");
|
|
|
return "设备不存在";
|
|
|
}
|
|
|
-// ArrayList<Filter> filters = new ArrayList<>();
|
|
|
-// filters.add(Filter.eq("status", code));
|
|
|
-// filters.add(Filter.eq("clientId", clientId));
|
|
|
-// filters.add(Filter.eq("equipmentId", equipment.getId()));
|
|
|
-// filters.add(Filter.eq("name", name));
|
|
|
-// List<Parameters> list = parametersService.findList(null, filters, null);
|
|
|
LambdaQueryWrapper<TParameters> queryParameters = Wrappers.lambdaQuery();
|
|
|
queryParameters.eq(TParameters::getClientId,clientId);
|
|
|
queryParameters.eq(TParameters::getStatus,code);
|
|
@@ -1388,6 +1378,7 @@ public class IndexController { ;
|
|
|
|
|
|
return "修改成功";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取机器列表
|
|
|
*/
|
|
@@ -1405,7 +1396,6 @@ public class IndexController { ;
|
|
|
jsonObject.put("errmsg", "name为空");
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
-// Admin admin = adminService.find(Long.valueOf(adminId));
|
|
|
TAdmin admin = adminService.getById(adminId);
|
|
|
if(!admin.getUsername().equals(name)){
|
|
|
jsonObject.put("code", 1);
|
|
@@ -1416,7 +1406,6 @@ public class IndexController { ;
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
query.eq(TEquipment::getAdminId,Long.valueOf(adminId));
|
|
|
List<TEquipment> equipmentList = equipmentService.list(query);
|
|
|
-// List<TEquipment> equipmentList = equipmentService.findByAdminId(Long.valueOf(adminId));
|
|
|
for(TEquipment equipment:equipmentList){
|
|
|
EquipmentDTO equipmentDTO = new EquipmentDTO();
|
|
|
equipmentDTO.setClientId(equipment.getClientId());
|
|
@@ -1453,27 +1442,21 @@ public class IndexController { ;
|
|
|
jsonObject.put("errmsg", "clientId为空");
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
-// KafkaProperties.Admin admin = adminService.find(Long.valueOf(adminId));
|
|
|
TAdmin admin = adminService.getById(Long.valueOf(adminId));
|
|
|
|
|
|
LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
query.eq(TEquipment::getClientId,clientId);
|
|
|
TEquipment equipment = equipmentService.getOne(query);
|
|
|
-// Equipment equipment = equipmentService.findByClientId(clientId);
|
|
|
|
|
|
if(!equipment.getAdminId().toString().equals(admin.getId().toString())){
|
|
|
jsonObject.put("code", 1);
|
|
|
jsonObject.put("errmsg", "clientId与adminId不匹配");
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
-// ArrayList<Filter> filters = new ArrayList<>();
|
|
|
-// filters.add(Filter.eq("equipmentId", equipment.getId()));
|
|
|
-// List<Product> products = productService.findList(null, filters, null);
|
|
|
List<String> list = new ArrayList<>();
|
|
|
LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
|
|
|
queryProduct.eq(TProduct::getEquipmentId,equipment.getId());
|
|
|
List<TProduct> products = productService.list(queryProduct);
|
|
|
-// TProduct tProduct = products.get(0);
|
|
|
for (TProduct product:products){
|
|
|
list.add(product.getProductName());
|
|
|
}
|
|
@@ -1503,58 +1486,16 @@ public class IndexController { ;
|
|
|
LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
|
|
|
queryProduct.eq(TProduct::getEquipmentId,equipment.getId());
|
|
|
List<TProduct> products = productService.list(queryProduct);
|
|
|
-// TProduct tProduct = products.get(0);
|
|
|
for (TProduct product:products){
|
|
|
product.setCreateDate(null);
|
|
|
product.setModifyDate(null);
|
|
|
}
|
|
|
-// jsonObject.put("code", 0);
|
|
|
-// jsonObject.put("productions", JsonUtils.toJson(list));
|
|
|
-// jsonObject.put("errmsg", "");
|
|
|
-// jsonObject.put("total", list.size());
|
|
|
-// return jsonObject.toJSONString();
|
|
|
JSONObject jsonObject1 = new JSONObject();
|
|
|
jsonObject1.put("code", 0);
|
|
|
jsonObject1.put("data", JSONObject.toJSON(products).toString());
|
|
|
jsonObject1.put("errmsg", "");
|
|
|
-// return jsonObject1.toString();
|
|
|
return JSONObject.toJSON(products).toString();
|
|
|
}
|
|
|
-// @ApiOperation(value = "分页查询")
|
|
|
-// @GetMapping("/testPage")
|
|
|
-// public ResponseModel<IPage<?>> testPage(TAdminParam param) {
|
|
|
-// LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
|
|
|
-// query.eq(TAdmin::getIsEnabled,true);
|
|
|
-// if(StrUtil.isNotBlank(param.getName())){
|
|
|
-// query.like(TAdmin::getName,param.getName());
|
|
|
-// }
|
|
|
-// query.orderByDesc(TAdmin::getApplyStartTime);
|
|
|
-// Page<TAdmin> page = new Page<>(param.getCurrent(), param.getSize(), true);
|
|
|
-// IPage<TAdmin> iPage = tAdminService.page(page, query);
|
|
|
-// return R.ok(iPage);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @ApiOperation(value = "列表查询")
|
|
|
-// @GetMapping("/testList")
|
|
|
-// public ResponseModel<List<?>> testList(TAdminParam param) {
|
|
|
-// LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
|
|
|
-// query.eq(TAdmin::getIsEnabled,true);
|
|
|
-// if(StrUtil.isNotBlank(param.getName())){
|
|
|
-// query.like(TAdmin::getName,param.getName());
|
|
|
-// }
|
|
|
-// query.orderByDesc(TAdmin::getApplyStartTime);
|
|
|
-// List<TAdmin> list = tAdminService.list(query);
|
|
|
-// return R.ok(list);
|
|
|
-// }
|
|
|
-// @ApiOperation(value = "返回失败")
|
|
|
-// @GetMapping("/testError")
|
|
|
-// public ResponseModel<List<?>> testError(boolean success) {
|
|
|
-// if(success){
|
|
|
-// return R.ok();
|
|
|
-// }else{
|
|
|
-// return R.fail(ResponseCodesEnum.B0001,"你的错误信息");
|
|
|
-// }
|
|
|
-// }
|
|
|
|
|
|
/**
|
|
|
*是否启用物料监控功能
|
|
@@ -1605,6 +1546,7 @@ public class IndexController { ;
|
|
|
promoCodeService.updateById(promoCode);
|
|
|
return "success";
|
|
|
}
|
|
|
+
|
|
|
//验证优惠码
|
|
|
@RequestMapping(value = "/selectCode.htm", method = RequestMethod.GET, produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
@@ -1620,7 +1562,6 @@ public class IndexController { ;
|
|
|
TPromoCode promoCode = new TPromoCode();
|
|
|
if (codeList.size() == 0) {
|
|
|
//不存在
|
|
|
-// return JsonMessage.success("1");
|
|
|
return "1";
|
|
|
}
|
|
|
for (TPromoCode cod : codeList) {
|
|
@@ -1636,7 +1577,6 @@ public class IndexController { ;
|
|
|
}
|
|
|
if(promoCode.getAdminId()==null){
|
|
|
//不是本机
|
|
|
-// return JsonMessage.success("3");
|
|
|
return "3";
|
|
|
}
|
|
|
Date lastUseDate = null;
|
|
@@ -1648,17 +1588,14 @@ public class IndexController { ;
|
|
|
promoCode.setIsUse("2");
|
|
|
promoCodeService.updateById(promoCode);
|
|
|
//过期
|
|
|
-// return JsonMessage.success("4");
|
|
|
return "4";
|
|
|
}
|
|
|
if (promoCode.getId() == null) {
|
|
|
//不存在
|
|
|
-// return JsonMessage.success("1");
|
|
|
return "1";
|
|
|
}
|
|
|
if (promoCode.getIsUse().equals("1")) {
|
|
|
//被使用
|
|
|
-// return JsonMessage.success("2");
|
|
|
return "2";
|
|
|
}
|
|
|
if(!promoCode.getAdminId().equals("1")){
|
|
@@ -1666,23 +1603,20 @@ public class IndexController { ;
|
|
|
|
|
|
} else {
|
|
|
//不是本机
|
|
|
-// return JsonMessage.success("3");
|
|
|
return "3";
|
|
|
}
|
|
|
}
|
|
|
if (promoCode.getDiscount() == null) {
|
|
|
//旧优惠码
|
|
|
-// return JsonMessage.success("0");
|
|
|
return "0";
|
|
|
}
|
|
|
if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
//0折
|
|
|
-// return JsonMessage.success("0");
|
|
|
return "0";
|
|
|
}
|
|
|
-// return JsonMessage.success("success");
|
|
|
return "success";
|
|
|
}
|
|
|
+
|
|
|
//修改机器的分销
|
|
|
@RequestMapping(value = "/updateProportion.htm", method = RequestMethod.GET, produces = "text/html;charset=utf-8")
|
|
|
@ResponseBody
|
|
@@ -1741,11 +1675,6 @@ public class IndexController { ;
|
|
|
case 2:
|
|
|
equipmentProportion.setProportion(adminProportion.getMerchantProportion());
|
|
|
equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
|
|
|
-// if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
-// equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
-// TAdmin byId = adminService.getById(admin.getAgencyId());
|
|
|
-// equipmentProportion.setAgencyName(byId.getUsername());
|
|
|
-// }
|
|
|
equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
TAdmin byId = adminService.getById(admin.getAgencyId());
|
|
|
equipmentProportion.setAgencyName(byId.getUsername());
|
|
@@ -1756,20 +1685,10 @@ public class IndexController { ;
|
|
|
case 3:
|
|
|
equipmentProportion.setProportion(adminProportion.getPersonageProportion());
|
|
|
equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
|
|
|
-// if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
-// equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
-// TAdmin byId = adminService.getById(admin.getAgencyId());
|
|
|
-// equipmentProportion.setAgencyName(byId.getUsername());
|
|
|
-// }
|
|
|
equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
TAdmin byId1 = adminService.getById(admin.getAgencyId());
|
|
|
equipmentProportion.setAgencyName(byId1.getUsername());
|
|
|
equipmentProportion.setMerchantProportion(adminProportion.getMerchantProportion());
|
|
|
-// if(adminProportion.getMerchantProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
-// equipmentProportion.setMerchantId(admin.getMerchantId());
|
|
|
-// TAdmin byId = adminService.getById(admin.getMerchantId());
|
|
|
-// equipmentProportion.setMerchantName(byId.getUsername());
|
|
|
-// }
|
|
|
equipmentProportion.setMerchantId(admin.getMerchantId());
|
|
|
TAdmin byId2 = adminService.getById(admin.getMerchantId());
|
|
|
equipmentProportion.setMerchantName(byId2.getUsername());
|
|
@@ -1788,6 +1707,7 @@ public class IndexController { ;
|
|
|
}
|
|
|
return "success";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*
|
|
@@ -1818,8 +1738,9 @@ public class IndexController { ;
|
|
|
}
|
|
|
return "error";
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- *修改优惠券开关状态
|
|
|
+ * 修改优惠券开关状态
|
|
|
*
|
|
|
* @param clientId
|
|
|
|
|
@@ -1984,5 +1905,116 @@ public class IndexController { ;
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传DIY花型功能开关状态
|
|
|
+ * @param clientId:设备编号
|
|
|
+ * @param DIYFlowerStatus:开关状态, 0: 关闭, 1: 开启
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/updateDIYFlowerStatus")
|
|
|
+ @ResponseBody
|
|
|
+ public String updateDIYFlowerStatus(String clientId, String DIYFlowerStatus){
|
|
|
+ if(StringUtils.isNotEmpty(clientId)&&StringUtils.isNotEmpty(DIYFlowerStatus)){
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TEquipment::getClientId,clientId);
|
|
|
+ TEquipment equipment = equipmentService.getOne(query);
|
|
|
+ TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
|
|
|
+ equipmentDesc.setDiyFlowerStatus(DIYFlowerStatus);
|
|
|
+ equipmentDescService.updateById(equipmentDesc);
|
|
|
+ // 如果为开启状态
|
|
|
+ if (DIYFlowerStatus.equals("1")) {
|
|
|
+ LambdaQueryWrapper<TDiyFlower> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(TDiyFlower::getEquipmentId, equipment.getId());
|
|
|
+ List<TDiyFlower> list = diyFlowerService.list(queryWrapper);
|
|
|
+ // 如何为空就添加新的花型形状和颜色
|
|
|
+ if (list.size() == 0) {
|
|
|
+ saveDIYProduct(equipment.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+ return "error";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加DIY花型产品
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ private void saveDIYProduct(Long id) {
|
|
|
+ String[] str = {"圆五花-S01", "圆心-S02", "心-S03", "圆蝴蝶-S04", "圆四叶草-S05", "圆六花瓣-S06", "圆三叶草-A07", "圆三花瓣-S08", "蘑菇-S09",
|
|
|
+ "白糖-T01", "红糖-T02", "黄糖-T03", "蓝糖-T04"};
|
|
|
+
|
|
|
+ for (int i = 0; i < str.length; i++) {
|
|
|
+ TDiyFlower diyFlower = new TDiyFlower();
|
|
|
+ diyFlower.setCreateDate(new Date());
|
|
|
+ diyFlower.setModifyDate(new Date());
|
|
|
+ diyFlower.setEquipmentId(id);
|
|
|
+ String[] split = str[i].split("-");
|
|
|
+ diyFlower.setName(split[0]);
|
|
|
+ diyFlower.setNo(split[1]);
|
|
|
+ diyFlower.setShowType("1");
|
|
|
+ diyFlowerService.save(diyFlower);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传DIY花型形状/糖显示状态
|
|
|
+ * @param clientId 设备编号
|
|
|
+ * @param tProductBean 包含形状/糖的编号和状态
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateDIYFlowerShow", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public String updateDIYFlowerShow(@RequestParam String clientId, @RequestBody List<TProductBean> tProductBean) {
|
|
|
+ if(StringUtils.isEmpty(clientId)||tProductBean == null) {
|
|
|
+ return "参数为空";
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TEquipment::getClientId,clientId);
|
|
|
+ TEquipment equipment = equipmentService.getOnly(query);
|
|
|
+ if (equipment==null) {
|
|
|
+ return "找不到设备信息";
|
|
|
+ }
|
|
|
+ Long equipmentId = equipment.getId();
|
|
|
+ ArrayList<TDiyFlower> diyFlowers = new ArrayList<>();
|
|
|
+ for (TProductBean productBean : tProductBean) {
|
|
|
+ String no = productBean.getNo();
|
|
|
+ String showType = productBean.getShowType();
|
|
|
+ LambdaQueryWrapper<TDiyFlower> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TDiyFlower::getEquipmentId,equipmentId);
|
|
|
+ wrapper.eq(TDiyFlower::getNo,no);
|
|
|
+ TDiyFlower diyFlower = diyFlowerService.getOne(wrapper);
|
|
|
+ diyFlower.setShowType(showType);
|
|
|
+ diyFlowers.add(diyFlower);
|
|
|
+ }
|
|
|
+ boolean res = diyFlowerService.updateBatchById(diyFlowers);
|
|
|
+ if (!res) {
|
|
|
+ return "error";
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 花型数目 开机时上传
|
|
|
+ *
|
|
|
+ * @param clientId 个推
|
|
|
+
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/flowerNumber", method = RequestMethod.POST, produces = "text/html;charset=utf-8")
|
|
|
+ @ResponseBody
|
|
|
+ public String flowerNumber(String clientId, String flowerNumber){
|
|
|
+ if(!StringUtils.isEmpty(flowerNumber)){
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TEquipment::getClientId,clientId);
|
|
|
+ TEquipment equipment = equipmentService.getOne(query);
|
|
|
+ equipment.setFlowers(flowerNumber);
|
|
|
+ equipmentService.updateById(equipment);
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+ return "fail";
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|