|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.szwl.constant.OperationType;
|
|
|
import com.szwl.constant.ResponseCodesEnum;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
@@ -64,87 +65,6 @@ public class TSugarDoController {
|
|
|
TProductService productService;
|
|
|
|
|
|
@ApiOperation(value = "远程做糖")
|
|
|
- @PostMapping("/doSugar")
|
|
|
- public ResponseModel<?> doSugar(@RequestBody DoSugarParam param) {
|
|
|
- Long equipmentId = param.getEquipmentId();
|
|
|
- String productName = param.getProductName();
|
|
|
- String makeCodes = param.getMakeCodes();
|
|
|
- if (equipmentId != null) {
|
|
|
- TEquipment equipment = tEquipmentService.getById(equipmentId);
|
|
|
- Long equipmentAdminId = equipment.getAdminId();
|
|
|
-
|
|
|
- // 判断是否是海外账户,海外账户不限制制作数量
|
|
|
- TAdmin admin = tAdminService.getById(equipmentAdminId);
|
|
|
- String ifForeign = admin.getIfForeign();
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(ifForeign) && ifForeign.equals("0")) {
|
|
|
- //判断本日是否已做二十个糖
|
|
|
- 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<TProduct> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(TProduct::getEquipmentId, equipmentId);
|
|
|
- queryWrapper.eq(TProduct::getProductName, productName);
|
|
|
- TProduct product = productService.getOne(queryWrapper);
|
|
|
- if (product != null) {
|
|
|
- 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());
|
|
|
- }
|
|
|
- return R.ok(sugarDo);
|
|
|
- }
|
|
|
- return R.fail(ResponseCodesEnum.A0001);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "远程做糖")
|
|
|
@PostMapping("/remoteProduction")
|
|
|
public ResponseModel<?> remoteProduction(@RequestBody DoSugarParam param) {
|
|
|
Long equipmentId = param.getEquipmentId();
|