|
@@ -335,4 +335,61 @@ public class ApprovalController {
|
|
|
return rj;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加入库信息
|
|
|
+ * @param request
|
|
|
+ * @param inventoryRecordss
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "/addInventoryRecords")
|
|
|
+ public ResponseJson addInventoryRecords(HttpServletRequest request, String inventoryRecordss){
|
|
|
+ ResponseJson rj =new ResponseJson(200, "添加成功", 200);
|
|
|
+ if (inventoryRecordss == null || inventoryRecordss.equals("")) {
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
+ }
|
|
|
+ //获取openid,根据openid查询当前登录人信息
|
|
|
+ String openId = WechatUtils.getUserBySession(request).getUserOpenid();
|
|
|
+ Admin admin = sysService.getByOpenid(openId);
|
|
|
+ if(admin == null){
|
|
|
+ return new ResponseJson(200, "未查询到登录人信息", 500);
|
|
|
+ }
|
|
|
+ JSONArray jsonRecordss = JSONArray.fromObject(inventoryRecordss);
|
|
|
+ for (int i = 0; i < jsonRecordss.size(); i++) {
|
|
|
+ JSONObject jsonRecords = jsonRecordss.getJSONObject(i);
|
|
|
+ //封装入库信息
|
|
|
+ ApprovalInventoryRecords records = new ApprovalInventoryRecords();
|
|
|
+ if(jsonRecords.get("shouldStorage") == null || jsonRecords.get("actualStorage") == null){
|
|
|
+ if(jsonRecords.getInt("shouldStorage") < jsonRecords.getInt("actualStorage")){
|
|
|
+ return new ResponseJson(200, "实际入库数量不得大于应入库数量", 500);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ records.setStorageState(jsonRecords.getInt("shouldStorage") > jsonRecords.getInt("actualStorage") ? 1 : 2);
|
|
|
+ records.setApprovalId(jsonRecords.getInt("approvalId"));
|
|
|
+ records.setProductName(jsonRecords.getString("productName"));
|
|
|
+ records.setColorName(jsonRecords.getString("colorName"));
|
|
|
+ records.setActualStorage(jsonRecords.getInt("actualStorage"));
|
|
|
+ records.setShouldStorage(jsonRecords.getInt("shouldStorage"));
|
|
|
+ records.setLackNumber(jsonRecords.getInt("lackNumber"));
|
|
|
+ records.setOperatingAdminId(admin.getAdminId());
|
|
|
+ if(approvalOrderService.insertInventoryRecords(records) < 1){
|
|
|
+ return new ResponseJson(200, "添加入库记录失败", 500);
|
|
|
+ }
|
|
|
+ //修改订单项信息
|
|
|
+ if(jsonRecords.get("itemId") == null || jsonRecords.get("itemId").equals("")){
|
|
|
+ return new ResponseJson(200, "产品项id不能为空", 500);
|
|
|
+ }
|
|
|
+
|
|
|
+ ApprovalProductionItem productionItem = approvalOrderService.getProductionItem(jsonRecords.getInt("itemId"));
|
|
|
+ if(productionItem.getItemActualStorage() < productionItem.getItemShouldStorage() + jsonRecords.getInt("shouldStorage")){
|
|
|
+ return new ResponseJson(200, "产品项id不能为空", 500);
|
|
|
+ }
|
|
|
+ productionItem.setItemShouldStorage(productionItem.getItemShouldStorage() + jsonRecords.getInt("shouldStorage"));
|
|
|
+ productionItem.setItemLackNumber(productionItem.getItemActualStorage() - (productionItem.getItemShouldStorage() + jsonRecords.getInt("shouldStorage")));
|
|
|
+ if(approvalOrderService.updateProductionItem(productionItem) < 1){
|
|
|
+ return new ResponseJson(200, "修改审批产品项失败", 500);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rj;
|
|
|
+ }
|
|
|
}
|