叶松
2023-12-06 1b004047f00cc846924209051ee654619c56a249
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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);
    }
}