123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- package com.steerinfo.dil.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.steerinfo.dil.mapper.AmsSaleMaterialMapper;
- import com.steerinfo.dil.mapper.RmsReceivePlaceMapper;
- import com.steerinfo.dil.model.RmsReceivePlace;
- import com.steerinfo.dil.service.impl.OyeWarehouseServiceImpl;
- import com.steerinfo.dil.util.BaseRESTfulController;
- import com.steerinfo.dil.util.ColumnDataUtil;
- import com.steerinfo.dil.util.DataChange;
- import com.steerinfo.dil.util.PageListAdd;
- import com.steerinfo.framework.controller.RESTfulResult;
- import com.steerinfo.framework.service.pagehelper.PageHelper;
- import io.swagger.annotations.ApiModelProperty;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import javax.annotation.Resource;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping("/${api.version}/OyeWarehouse")
- public class OyeWarehouseController extends BaseRESTfulController {
- private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- @Resource
- RmsReceivePlaceMapper rmsReceivePlaceMapper;
- @Resource
- ColumnDataUtil columnDataUtil;
- @Resource
- OyeWarehouseServiceImpl oyeWarehouseService;
- @Resource
- AmsSaleMaterialMapper amsSaleMaterialMapper;
- @ApiOperation("新增欧冶具体库房")
- @PostMapping("/insertOyeWarehouse")
- public RESTfulResult insertOyeWarehouse(@RequestBody Map<String,Object> map) {
- RmsReceivePlace rmsReceivePlace = new RmsReceivePlace();
- rmsReceivePlace.setPlaceId(rmsReceivePlaceMapper.selectMaxId());
- rmsReceivePlace.setAddressId(new BigDecimal(3));
- rmsReceivePlace.setAddressDeliveryAddress(map.get("warehouseName").toString());
- rmsReceivePlace.setInsertUpdateRemark(map.get("carrierName").toString());
- rmsReceivePlaceMapper.insertSelective(rmsReceivePlace);
- return success("新增成功");
- }
- @ApiOperation("新增欧冶具体库房")
- @PostMapping("/insertOyeWarehouseSide")
- public RESTfulResult insertOyeWarehouseSide(@RequestBody Map<String,Object> map) {
- RmsReceivePlace rmsReceivePlace = new RmsReceivePlace();
- rmsReceivePlace.setPlaceId(rmsReceivePlaceMapper.selectMaxId());
- rmsReceivePlace.setAddressId(new BigDecimal(5));
- rmsReceivePlace.setAddressDeliveryAddress(map.get("warehouseName").toString());
- rmsReceivePlace.setInsertUpdateRemark(map.get("carrierName").toString());
- rmsReceivePlaceMapper.insertSelective(rmsReceivePlace);
- rmsReceivePlaceMapper.insertWarehouse(map);
- return success("新增成功");
- }
- @ApiOperation("查询欧冶库具体库房信息")
- @PostMapping("getOyeWarehouse")
- public RESTfulResult getOyeWarehouse(@RequestBody(required = false) Map<String,Object> mapValue,
- Integer pageNum,
- Integer pageSize,
- Integer apiId) {
- PageHelper.startPage(pageNum,pageSize);
- //分页数据
- List<Map<String, Object>> mapList = rmsReceivePlaceMapper.getOyeWarehouse(mapValue);
- PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,mapList);
- return success(pageList);
- }
- @ApiOperation("查询欧冶库具体库房信息")
- @PostMapping("getOyeWarehouseSide")
- public RESTfulResult getOyeWarehouseSide(@RequestBody(required = false) Map<String,Object> mapValue,
- Integer pageNum,
- Integer pageSize,
- Integer apiId) {
- PageHelper.startPage(pageNum,pageSize);
- //分页数据
- List<Map<String, Object>> mapList = rmsReceivePlaceMapper.getOyeWarehouseSide(mapValue);
- PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,mapList);
- return success(pageList);
- }
- @ApiModelProperty(value = "新增欧冶转运计划")
- @PostMapping("/addTransPlan")
- public RESTfulResult addTransPlan(@RequestBody Map<String,Object> mapValue){
- JSONObject jsonObject = new JSONObject(mapValue);
- System.out.println(new Date() + "=======================");
- System.out.println(jsonObject);
- System.out.println(new Date() + "=======================");
- try {
- // 成功
- int result = oyeWarehouseService.addTransPlan(mapValue);
- return success(result);
- } catch (Exception e) {
- // 失败
- return failed(e.getMessage());
- }
- }
- @ApiOperation("批量新增欧冶转运计划")
- @PostMapping("addTransPlanList")
- @Transactional(rollbackFor = Exception.class)
- public RESTfulResult addTransPlanList(@RequestBody List<Map<String,Object>> mapList) throws Exception {
- int count = 0;
- String saleOrderNo = null;
- System.out.println("------新增欧冶转运计划Excel导入-----" + new Date());
- try {
- Map<String, Object> logMap = new HashMap<>();
- logMap.put("mapList",mapList);
- JSONObject jsonObject = new JSONObject(logMap);
- System.out.println(jsonObject);
- }catch (Exception e){
- e.printStackTrace();
- }
- System.out.println("------销售订单批量导入Excel导入-----" + new Date());
- try {
- for (Map<String,Object> map:mapList
- ) {
- saleOrderNo = map.get("saleOrderNo").toString();
- count++;
- oyeWarehouseService.addTransPlan(map);
- //根据销售订单ID再去查询汇总一遍
- }
- } catch (Exception e) {
- System.out.println(e);
- throw new Exception("销售订单编号为:" + saleOrderNo + e.getMessage());
- }
- return success(count);
- }
- @ApiOperation("查询转运计划")
- @PostMapping("/getTransPlan")
- public RESTfulResult getTransPlan(@RequestBody(required=false) Map<String,Object> mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- String startTime,
- String endTime){
- DataChange.queryDataByDateTime(startTime, endTime, mapValue, sdfDateTime);//根据时间段查询数据
- if (mapValue.containsKey("saler")) {
- String saler = mapValue.get("saler").toString();
- List<String> saleAreaRemark = amsSaleMaterialMapper.getSaleAreaRemark(saler);
- if(saleAreaRemark.size() > 0) {
- mapValue.put("saleAreaRemark",saleAreaRemark);
- }
- mapValue.put("salers",saler);
- }
- PageHelper.startPage(pageNum,pageSize);
- List<Map<String, Object>> mapList = oyeWarehouseService.getTransPlan(mapValue);
- PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,mapList);
- return success(pageList);
- }
- @ApiOperation("审核转运计划")
- @PostMapping("approveTransPlan")
- public RESTfulResult approveTransPlan(@RequestBody Map<String,Object> map) {
- try {
- String s = oyeWarehouseService.approveTransPlan(map);
- return success(s);
- } catch (Exception e) {
- e.printStackTrace();
- return failed(e.getMessage());
- }
- }
- }
|