|
@@ -6,13 +6,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.szwl.model.entity.TEquipment;
|
|
|
+import com.szwl.model.entity.TNameDictionary;
|
|
|
+import com.szwl.model.entity.TProduct;
|
|
|
import com.szwl.model.entity.TSugarDo;
|
|
|
import com.szwl.model.utils.PushUtils;
|
|
|
-import com.szwl.service.TAdminService;
|
|
|
-import com.szwl.service.TEquipmentService;
|
|
|
-import com.szwl.service.TSugarDoService;
|
|
|
+import com.szwl.service.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -36,24 +37,29 @@ import java.util.*;
|
|
|
@RestController
|
|
|
@RequestMapping("/tSugarDo")
|
|
|
public class TSugarDoController {
|
|
|
+
|
|
|
@Autowired
|
|
|
TEquipmentService tEquipmentService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TAdminService tAdminService;
|
|
|
+
|
|
|
@Autowired
|
|
|
TSugarDoService tSugarDoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TNameDictionaryService nameDictionaryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TProductService productService;
|
|
|
+
|
|
|
@ApiOperation(value = "远程做糖")
|
|
|
@GetMapping("/doSugar")
|
|
|
public ResponseEntity<?> doSugar(Long equipmentId,String productName){
|
|
|
-
|
|
|
if(equipmentId!=null){
|
|
|
TEquipment equipment = tEquipmentService.getById(equipmentId);
|
|
|
Long equipmentAdminId = equipment.getAdminId();
|
|
|
//判断本日是否已做十个糖
|
|
|
-// TSugarDoExample sugarDoExample = new TSugarDoExample();
|
|
|
-// TSugarDoExample.Criteria criteria = sugarDoExample.createCriteria();
|
|
|
-// criteria.andAdminIdEqualTo(String.valueOf(adminId));
|
|
|
-// criteria.andClientIdEqualTo(equipment.getClientId());
|
|
|
LambdaQueryWrapper<TSugarDo> query = Wrappers.lambdaQuery();
|
|
|
query.eq(TSugarDo::getAdminId,Long.valueOf(equipmentAdminId));
|
|
|
|
|
@@ -63,16 +69,12 @@ public class TSugarDoController {
|
|
|
todayStart.set(Calendar.MINUTE, 0);
|
|
|
todayStart.set(Calendar.SECOND, 0);
|
|
|
query.gt(TSugarDo::getCreateDate,todayStart.getTime());
|
|
|
-// criteria.andCreateDateGreaterThanOrEqualTo(todayStart.getTime());
|
|
|
Calendar todayEnd = Calendar.getInstance();
|
|
|
todayEnd.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
todayEnd.set(Calendar.MINUTE, 59);
|
|
|
todayEnd.set(Calendar.SECOND, 59);
|
|
|
-// criteria.andCreateDateLessThanOrEqualTo(todayEnd.getTime());
|
|
|
query.le(TSugarDo::getCreateDate,todayEnd.getTime());
|
|
|
query.eq(TSugarDo::getStatus,"1");
|
|
|
-// criteria.andStatusEqualTo("1");
|
|
|
-// List<TSugarDo> sugarDoList = tSugarDoService.selectByOption(sugarDoExample);
|
|
|
List<TSugarDo> sugarDoList = tSugarDoService.list(query);
|
|
|
if(sugarDoList.size()>20){
|
|
|
return ResponseEntity.status(HttpStatus.OK)
|
|
@@ -95,10 +97,20 @@ public class TSugarDoController {
|
|
|
sugarDo.setModifyDate(date);
|
|
|
tSugarDoService.save(sugarDo);
|
|
|
JSONObject kindData = new JSONObject();
|
|
|
+ LambdaQueryWrapper<TProduct> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(TProduct::getEquipmentId, equipmentId);
|
|
|
+ queryWrapper.eq(TProduct::getProductName, productName);
|
|
|
+ TProduct product = productService.getOne(queryWrapper);
|
|
|
+ if (product != null && StringUtils.isEmpty(product.getName())) {
|
|
|
+ LambdaQueryWrapper<TNameDictionary> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TNameDictionary::getNo, product.getNo());
|
|
|
+ wrapper.eq(TNameDictionary::getLanguage, "zh");
|
|
|
+ TNameDictionary nameDictionary = nameDictionaryService.getOne(wrapper);
|
|
|
+ productName = nameDictionary.getName();
|
|
|
+ }
|
|
|
kindData.put("productName" , productName);
|
|
|
kindData.put("no" , sugarDo.getNo());
|
|
|
tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("dosugar", kindData.toString()).toString());
|
|
|
-// PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("dosugar", kindData.toString()).toString());
|
|
|
return ResponseEntity.status(HttpStatus.OK)
|
|
|
.body(new ResultMessage().setCode(true).setData(sugarDo).setMessage("SUCCESS"));
|
|
|
}
|