package com.thhy.mobile.modules.biz.pipeinfo.controller;
|
|
import com.thhy.general.common.BasicResult;
|
import com.thhy.general.config.SysUserInfo;
|
import com.thhy.general.utils.UserInfoUtils;
|
import com.thhy.mobile.modules.biz.pipeinfo.entity.*;
|
import com.thhy.mobile.modules.biz.pipeinfo.service.PipeInfoService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@RestController
|
@RequestMapping("pipecreen")
|
public class PipeScreenController {
|
|
@Autowired
|
private PipeInfoService pipeInfoService;
|
|
//thing.js 管片加工列表
|
@RequestMapping("pipeThingJsInfo")
|
public BasicResult pipeThingJsInfo(String token){
|
List<PipeListVo> pipeInfoList = pipeInfoService.pipeThingJsInfo(token);
|
return BasicResult.success(pipeInfoList);
|
}
|
|
@RequestMapping("pipePlanProduct")
|
public BasicResult pipePlanProduct(String token){
|
List<ScreenPipeCompare> list = pipeInfoService.pipePlanProduct(token);
|
return BasicResult.success(list);
|
}
|
|
@RequestMapping("materialRecord")
|
public BasicResult materialRecord(String token){
|
SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token);
|
Map<String,Object> mapto = new HashMap<>();
|
List<MaterialInfo> materialInfoList = pipeInfoService.materialTotalStock(userInfo.getCompanyId());
|
mapto.put("totalStock",materialInfoList);
|
List<HashMap<String,Object>> headers = pipeInfoService.TableHeader();
|
List<HashMap<String,Object>> dataMapList = new ArrayList<>();
|
for(int i=0;i<headers.size();i++){
|
HashMap<String,Object> map = headers.get(i);
|
map.put("fieldName","field"+i);
|
}
|
|
List<HashMap<String,Object>> list = pipeInfoService.queryMaterias(userInfo.getCompanyId());
|
for(int i =0;i<list.size();i++){
|
HashMap<String,Object> data = list.get(i);
|
HashMap<String,Object> dataMap = new HashMap<>();
|
dataMap.put("createDate",data.get("createDate"));
|
String nameValue = data.get("namevalue").toString();
|
String[] nvArray = new String[]{nameValue};
|
if(nameValue.contains(","))nvArray = nameValue.split(",");
|
for(int j=0;j<headers.size();j++){
|
dataMap.put(headers.get(j).get("fieldName").toString(),0);
|
for(String nv : nvArray){
|
if(nv.split(":")[0].equals(headers.get(j).get("dictId").toString())){
|
dataMap.put(headers.get(j).get("fieldName").toString(),new BigDecimal(nv.split(":")[1]).setScale(2, RoundingMode.HALF_UP));
|
continue;
|
}
|
}
|
|
}
|
dataMapList.add(dataMap);
|
}
|
mapto.put("headers",headers);
|
mapto.put("data",dataMapList);
|
return BasicResult.success(mapto);
|
}
|
|
//thing.js 原料实际消耗数量列表 前10条数据
|
@RequestMapping("/materialInfo")
|
public BasicResult materialInfo(){
|
return BasicResult.success(pipeInfoService.materialInfo());
|
}
|
//thing.js 原料消耗总量
|
@RequestMapping("/materialNumInfo")
|
public BasicResult materialNumInfo(){
|
List<MaterialThingNumDto> materialInfo = pipeInfoService.materialNumInfo();
|
return BasicResult.success(materialInfo);
|
}
|
}
|