Quellcode durchsuchen

批量生成订单接口

LiFei vor 5 Jahren
Ursprung
Commit
ff1484c81a

+ 24 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/api/controller/HlwOrderController.java

@@ -126,6 +126,30 @@ public class HlwOrderController {
         return result;
     }
 
+
+
+    /**
+     * 批量新增-订单
+     *
+     * @param json
+     * @return
+     */
+    @AutoLog(value = "批量新增-订单")
+    @ApiOperation(value = "批量新增-订单", notes = "批量新增-订单")
+    @PostMapping(value = "/batchAdd")
+    public Result<?> batchAdd(@RequestBody String json) {
+        log.info("json========{}", json);
+        //数据解密
+        json = CryptTool.decode(json);
+        JSONObject jsonObject = JSONObject.parseObject(json);
+        //获取应用信息
+        OauthApplication oauthApplication = authService.getApplication(SecurityUtils.getClient());
+        jsonObject.put("applicationId", oauthApplication.getApplicationId());
+        Result<?> result = hlwOrderServiceClient.batchAdd(jsonObject);
+        return result;
+    }
+
+
     /**
      * 订单管理-列表
      *

+ 9 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/feign/client/HlwOrderServiceClient.java

@@ -74,4 +74,13 @@ public interface HlwOrderServiceClient {
      */
     @PostMapping(value = "/wisdom/hlwOrder/api/updateStatus")
     Result<?> updateStatus(JSONObject jsonObject);
+
+    /**
+     * 批量新增订单
+     *
+     * @param jsonObject
+     * @return
+     */
+    @PostMapping(value = "/wisdom/hlwOrder/api/batchAdd")
+    Result<?> batchAdd(JSONObject jsonObject);
 }

+ 6 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/feign/client/fallback/HlwOrderServiceClientFallbackImpl.java

@@ -49,4 +49,10 @@ public class HlwOrderServiceClientFallbackImpl implements HlwOrderServiceClient
     public Result<?> updateStatus(JSONObject jsonObject) {
         return Result.error("更新订单失败");
     }
+
+
+    @Override
+    public Result<?> batchAdd(JSONObject jsonObject) {
+        return Result.error("批量新增订单失败");
+    }
 }

+ 20 - 0
happy-cloud-wisdom/happy-cloud-wisdom-biz/src/main/java/org/jeecg/modules/api/controller/HlwOrderApiController.java

@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 用户信息表
@@ -130,6 +131,25 @@ public class HlwOrderApiController extends JeecgController<HlwOrder, IHlwOrderSe
         return result;
     }
 
+
+    /**
+     * 批量新增订单
+     *
+     * @param jsonObject
+     * @return
+     */
+    @AutoLog(value = "批量新增订单")
+    @ApiOperation(value = "批量新增订单", notes = "批量新增订单")
+    @PostMapping(value = "/add")
+    public Result<?> batchAdd(@RequestBody JSONObject jsonObject) {
+        Result<?> result = new Result<>();
+        List<Map<String, Object>> orderlist = (List<Map<String, Object>>) jsonObject.get("orderlist");
+        hlwOrderService.saveOrderMany(orderlist);
+        result.success("批量新增订单成功");
+        return result;
+    }
+
+
     /**
      * 订单申请-列表
      *

+ 3 - 0
happy-cloud-wisdom/happy-cloud-wisdom-biz/src/main/java/org/jeecg/modules/hlworder/service/IHlwOrderService.java

@@ -7,6 +7,7 @@ import org.jeecg.modules.hlworder.entity.HlwOrder;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: hlw_order
@@ -31,4 +32,6 @@ public interface IHlwOrderService extends IService<HlwOrder> {
     Page<HlwOrder> queryOrderList(Page<HlwOrder> page, List<String> companyCodeList, HlwOrder hlwOrder, Integer applicationId);
 
     List<HlwOrder> queryOrderListNoPage(List<String> companyCodeList, HlwOrder hlwOrder, Integer applicationId);
+
+    void saveOrderMany(List<Map<String,Object>> orderlist);
 }

+ 25 - 0
happy-cloud-wisdom/happy-cloud-wisdom-biz/src/main/java/org/jeecg/modules/hlworder/service/impl/HlwOrderServiceImpl.java

@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.hlworder.entity.HlwOrder;
+import org.jeecg.modules.hlworder.entity.HlwRequirement;
 import org.jeecg.modules.hlworder.mapper.HlwOrderMapper;
 import org.jeecg.modules.hlworder.service.IHlwOrderService;
+import org.jeecg.modules.hlworder.service.IHlwRequirementService;
 import org.jeecg.modules.hlwuser.entity.HlwUser;
 import org.jeecg.modules.hlwuser.entity.HlwUserSubcontractor;
 import org.jeecg.modules.hlwuser.service.IHlwUserSubcontractorService;
@@ -16,6 +18,7 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -30,6 +33,8 @@ public class HlwOrderServiceImpl extends ServiceImpl<HlwOrderMapper, HlwOrder> i
 
     @Autowired
     private IHlwUserSubcontractorService hlwUserSubcontractorService;
+    @Autowired
+    private IHlwRequirementService hlwRequirementService;
 
     @Override
     public List<HlwOrder> getList(String idcardNumber, Integer subcontractorId, Integer applicationId) {
@@ -153,4 +158,24 @@ public class HlwOrderServiceImpl extends ServiceImpl<HlwOrderMapper, HlwOrder> i
         List<HlwOrder> list = baseMapper.queryOrderListNoPage(companyCodeList, hlwOrder, applicationId);
         return list;
     }
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void saveOrderMany(List<Map<String, Object>> orderlist) {
+        for (int i = 0; i <orderlist.size() ; i++) {
+            String requirementCode =(String) orderlist.get(i).get("requirementCode");
+            String orderCode = (String) orderlist.get(i).get("orderCode");
+            Integer status = (Integer) orderlist.get(i).get("status");
+            String userName = (String) orderlist.get(i).get("userName");
+            HlwRequirement hlwRequirement = hlwRequirementService.getByRequirementCode(requirementCode);
+            HlwOrder hlwOrder = new HlwOrder();
+            hlwOrder.setRequirementId(hlwRequirement.getId());
+            hlwOrder.setOrderCode(orderCode);
+            hlwOrder.setOrderTime(new Date());
+            hlwOrder.setUserName(userName);
+            hlwOrder.setStatus(status);
+            save(hlwOrder);
+        }
+    }
 }