SMT-ERP 项目初始提交
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package com.reallin.smt.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.reallin.smt.datasource.entities.DepotHeadVo4Body;
|
||||
import com.reallin.smt.service.DepotHeadService;
|
||||
import com.reallin.smt.service.SmtInboundService;
|
||||
import com.reallin.smt.utils.BaseResponseInfo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/headquartersInbound")
|
||||
public class HeadquartersInboundController {
|
||||
@Resource private SmtInboundService inboundService;
|
||||
@Resource private DepotHeadService depotHeadService;
|
||||
|
||||
@GetMapping("/nextNumber")
|
||||
public BaseResponseInfo nextNumber(@RequestParam(required = false) String businessDate) {
|
||||
return ok(Collections.singletonMap("number", inboundService.nextNumber(businessDate)));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save", method = {RequestMethod.POST, RequestMethod.PUT})
|
||||
public BaseResponseInfo save(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) {
|
||||
Long id = inboundService.save(JSONObject.parseObject(body.getInfo()), JSONArray.parseArray(body.getRows()), inboundService.creatorId(request));
|
||||
return ok(Collections.singletonMap("id", id));
|
||||
}
|
||||
|
||||
@GetMapping("/details")
|
||||
public BaseResponseInfo details(@RequestParam Long headerId) {
|
||||
List<Map<String, Object>> rows = inboundService.details(headerId);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("rows", rows); data.put("total", rows.size());
|
||||
return ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("/importExcel")
|
||||
public BaseResponseInfo importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception {
|
||||
return ok(inboundService.importExcel(file, inboundService.creatorId(request)));
|
||||
}
|
||||
|
||||
@GetMapping("/template")
|
||||
public void template(HttpServletResponse response) throws Exception { inboundService.exportTemplate(response); }
|
||||
|
||||
@PostMapping("/sync")
|
||||
public BaseResponseInfo sync(@RequestBody List<JSONObject> payload, HttpServletRequest request) {
|
||||
return ok(inboundService.sync(payload, inboundService.creatorId(request)));
|
||||
}
|
||||
|
||||
@PostMapping("/createMaterial")
|
||||
public BaseResponseInfo createMaterial(@RequestBody JSONObject item) {
|
||||
return ok(inboundService.createMaterialIfMissing(item));
|
||||
}
|
||||
|
||||
@PostMapping("/batchSetStatus")
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public BaseResponseInfo batchSetStatus(@RequestBody JSONObject body) throws Exception {
|
||||
String status = body.getString("status");
|
||||
String ids = body.getString("ids");
|
||||
if ("1".equals(status)) {
|
||||
for (String id : ids.split(",")) if (!id.trim().isEmpty()) inboundService.prepareForApproval(Long.valueOf(id.trim()));
|
||||
}
|
||||
depotHeadService.batchSetStatus(status, ids);
|
||||
return ok(null);
|
||||
}
|
||||
|
||||
private BaseResponseInfo ok(Object data) {
|
||||
BaseResponseInfo response = new BaseResponseInfo(); response.code = 200; response.data = data; return response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user