75 lines
2.1 KiB
Java
75 lines
2.1 KiB
Java
package com.sipai.controller.bim;
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.util.List;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import com.sipai.entity.app.AppDataConfigure;
|
|
import com.sipai.entity.bim.BIMCurrency;
|
|
import com.sipai.entity.scada.MPoint;
|
|
import com.sipai.service.bim.BIMCurrencyService;
|
|
import com.sipai.service.scada.MPointService;
|
|
import com.sipai.tools.CommUtil;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
@Controller
|
|
@RequestMapping("/bim/bIMCurrency")
|
|
public class BIMCurrencyController {
|
|
@Resource
|
|
private MPointService mPointService;
|
|
@Resource
|
|
private BIMCurrencyService bIMCurrencyService;
|
|
|
|
@RequestMapping("getdata.do")
|
|
public String getdata(HttpServletRequest request,Model model){
|
|
String unitId=request.getParameter("bizid");
|
|
|
|
JSONArray jsonArray=new JSONArray();
|
|
|
|
List<BIMCurrency> bList=this.bIMCurrencyService.selectListByWhere(" where 1=1 ");
|
|
if(bList!=null&&bList.size()>0){
|
|
for (int i = 0; i < bList.size(); i++) {
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
|
String mpid=bList.get(i).getMpointCode();
|
|
MPoint mPoint=this.mPointService.selectById(unitId, mpid);
|
|
|
|
if(mPoint!=null){
|
|
BigDecimal vale=mPoint.getParmvalue();
|
|
String unit=mPoint.getUnit();
|
|
String numtail=mPoint.getNumtail();
|
|
double endValue=0;
|
|
if(vale!=null){
|
|
endValue=CommUtil.round(vale.doubleValue(),Integer.valueOf(numtail));
|
|
}
|
|
|
|
String locationId=bList.get(i).getLocationId();
|
|
|
|
jsonObject.put("name",bList.get(i).getTagName());
|
|
jsonObject.put("value", endValue);
|
|
jsonObject.put("unit", unit);
|
|
jsonObject.put("locationId", locationId);
|
|
jsonObject.put("tagId", bList.get(i).getTagId());
|
|
jsonArray.add(jsonObject);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
model.addAttribute("result", jsonArray);
|
|
return "result";
|
|
}
|
|
|
|
}
|