53 changed files with 680 additions and 329 deletions
@ -0,0 +1,67 @@ |
|||
package com.dreamchaser.depository_manage; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.Inventory; |
|||
import com.dreamchaser.depository_manage.pojo.RestResponse; |
|||
import com.dreamchaser.depository_manage.service.DepositoryRecordService; |
|||
import com.dreamchaser.depository_manage.service.MaterialService; |
|||
import com.dreamchaser.depository_manage.utils.DateUtil; |
|||
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.concurrent.*; |
|||
|
|||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) |
|||
@RunWith(SpringRunner.class) |
|||
public class LineChartForInventoryTest { |
|||
|
|||
|
|||
@Autowired |
|||
private MaterialService materialService; |
|||
|
|||
@Autowired |
|||
private DepositoryRecordService depositoryRecordService; |
|||
|
|||
/** |
|||
* 用于获取当前物料的本月出入库记录 |
|||
* |
|||
* @param id 带查询库存id |
|||
*/ |
|||
public RestResponse getInventoryApplication(Integer id) { |
|||
// 获取本月至今的日期
|
|||
Map<String, Object> monthBeginToNow = DateUtil.getMonthBeginToNow(); |
|||
// 获取至今的日期名称
|
|||
List<String> dayNames = ObjectFormatUtil.objToList(monthBeginToNow.get("dayName"), String.class); |
|||
// 获取至今的日期时间戳
|
|||
List<Long> dayTimeSpaces = ObjectFormatUtil.objToList(monthBeginToNow.get("dayTimeSpace"), Long.class); |
|||
// 获取当前物料的入库总额与数量
|
|||
Map<String, List<Double>> resultForApplicationIn = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 1); |
|||
List<Double> amountListForIn = resultForApplicationIn.get("amountList"); |
|||
List<Double> countListForIn = resultForApplicationIn.get("countList"); |
|||
|
|||
// 获取当前物料的出库总额与数量
|
|||
Map<String, List<Double>> resultForApplicationOut = depositoryRecordService.getApplicationByMaterial(id, dayTimeSpaces, 2); |
|||
List<Double> amountListForOut = resultForApplicationOut.get("amountList"); |
|||
List<Double> countListForOut = resultForApplicationOut.get("countList"); |
|||
|
|||
Map<String, Object> result = new HashMap<>(); |
|||
result.put("applicationInAmount", amountListForIn); |
|||
result.put("applicationInCount", countListForIn); |
|||
result.put("applicationOutAmount", amountListForOut); |
|||
result.put("applicationOutCount", countListForOut); |
|||
return new RestResponse(result); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void Test() { |
|||
getInventoryApplication(136); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue