|
@@ -137,6 +137,74 @@ public class TSugarDoController {
|
|
|
return R.fail(ResponseCodesEnum.A0001);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "远程做糖")
|
|
|
+ @PostMapping("/remoteProduction")
|
|
|
+ public ResponseModel<?> remoteProduction(@RequestBody DoSugarParam param) {
|
|
|
+ Long equipmentId = param.getEquipmentId();
|
|
|
+ String productName = param.getProductName();
|
|
|
+ String productNo = param.getProductNo();
|
|
|
+ String makeCodes = param.getMakeCodes();
|
|
|
+ if (equipmentId != null) {
|
|
|
+ TEquipment equipment = tEquipmentService.getById(equipmentId);
|
|
|
+ Long equipmentAdminId = equipment.getAdminId();
|
|
|
+ //判断本日是否已做二十个糖
|
|
|
+ LambdaQueryWrapper<TSugarDo> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TSugarDo::getAdminId, Long.valueOf(equipmentAdminId));
|
|
|
+
|
|
|
+ Calendar todayStart = Calendar.getInstance();
|
|
|
+ todayStart.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ todayStart.set(Calendar.MINUTE, 0);
|
|
|
+ todayStart.set(Calendar.SECOND, 0);
|
|
|
+ query.gt(TSugarDo::getCreateDate, todayStart.getTime());
|
|
|
+ Calendar todayEnd = Calendar.getInstance();
|
|
|
+ todayEnd.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
+ todayEnd.set(Calendar.MINUTE, 59);
|
|
|
+ todayEnd.set(Calendar.SECOND, 59);
|
|
|
+ query.le(TSugarDo::getCreateDate, todayEnd.getTime());
|
|
|
+ query.eq(TSugarDo::getStatus, "1");
|
|
|
+ List<TSugarDo> sugarDoList = tSugarDoService.list(query);
|
|
|
+ if (sugarDoList.size() > 20) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "今日远程制作数量已满");
|
|
|
+ }
|
|
|
+ StringBuilder number = new StringBuilder();
|
|
|
+ Random random = new Random();
|
|
|
+ number.append(String.valueOf(equipmentAdminId)).append("-");
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
+ number.append(String.valueOf(random.nextInt(10)));
|
|
|
+ }
|
|
|
+ TSugarDo sugarDo = new TSugarDo();
|
|
|
+ sugarDo.setAdminId(equipmentAdminId);
|
|
|
+ sugarDo.setClientId(equipment.getClientId());
|
|
|
+ sugarDo.setStatus("0");
|
|
|
+ sugarDo.setNo(number.toString());
|
|
|
+ sugarDo.setProductName(productName);
|
|
|
+ Date date = new Date();
|
|
|
+ sugarDo.setCreateDate(date);
|
|
|
+ sugarDo.setModifyDate(date);
|
|
|
+ tSugarDoService.save(sugarDo);
|
|
|
+ String machineType = equipment.getMachineType();
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ if (StringUtils.isNotEmpty(machineType) && machineType.equals("2")) {
|
|
|
+ // 如果是冰淇淋
|
|
|
+ makeCodes = "[" + makeCodes + "]";
|
|
|
+ kindData.put("makeCodes", makeCodes);
|
|
|
+ kindData.put("no", sugarDo.getNo());
|
|
|
+ tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("dosugar", kindData.toString()).toString());
|
|
|
+ } else {
|
|
|
+ LambdaQueryWrapper<TNameDictionary> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TNameDictionary::getNo, productNo);
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ return R.ok(sugarDo);
|
|
|
+ }
|
|
|
+ return R.fail(ResponseCodesEnum.A0001);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "查询远程做糖状态")
|
|
|
@GetMapping("/selectSugarStatus")
|
|
|
public ResponseEntity<?> selectSugarStatus(String no) {
|