|
@@ -86,23 +86,38 @@ public class CostModelWxPriceController extends JeecgController<CostModelWxPrice
|
|
|
@PostMapping(value = "/add")
|
|
|
public Result<String> add(@RequestBody CostModelWxPrice costModelWxPrice) {
|
|
|
try {
|
|
|
- CostModelWxPrice wxp = costModelWxPrice;
|
|
|
+// CostModelWxPrice wxp = costModelWxPrice;
|
|
|
boolean noRepeat = true;
|
|
|
//前端就不会让录入为null
|
|
|
-// if((wxp.getWxProject()==null)&(wxp.getDanjia()==null)&(wxp.getUnit()==null)&(wxp.getWxCompany()==null)){
|
|
|
+// if((wxp.getWxProject()==null)&(wxpNew.getWxCompany()!=null)&(wxp.getDanjia()==null)&(wxp.getUnit()==null)&(wxp.getWxCompany()==null)){
|
|
|
// System.out.println("当前数据内容都为空,不能录入");
|
|
|
// noRepeat = false;
|
|
|
// }
|
|
|
// List<CostModelWxPrice> list = costModelWxPriceService.getWXPAllDetailList();
|
|
|
- List<CostModelWxPrice> list = costModelWxPriceService.getWXPFProDetailList(wxp.getWxProject());
|
|
|
+ List<CostModelWxPrice> list = costModelWxPriceService.getWXPFProDetailList(costModelWxPrice.getWxProject());
|
|
|
for (CostModelWxPrice wxp1 : list) {
|
|
|
- if((Objects.equals(wxp.getDanjia(), wxp1.getDanjia()))&(Objects.equals(wxp.getUnit(), wxp1.getUnit()))&(Objects.equals(wxp.getWxCompany(), wxp1.getWxCompany()))){
|
|
|
+ //因为根据外协项目查找的数据库数据,所以不用再比较外协项目
|
|
|
+ if((Objects.equals(costModelWxPrice.getMaxPrice(), wxp1.getMaxPrice()))&(Objects.equals(costModelWxPrice.getMinPrice(), wxp1.getMinPrice()))&(Objects.equals(costModelWxPrice.getUnit(), wxp1.getUnit()))&(Objects.equals(costModelWxPrice.getWxCompany(), wxp1.getWxCompany()))){
|
|
|
noRepeat = false;
|
|
|
- //System.out.println("当前元素重复,进行删除");
|
|
|
+// System.out.println("当前元素重复,进行删除");
|
|
|
break;//因为wxpNew元素已经被删除了,所有此段循环可以跳过了
|
|
|
}
|
|
|
}
|
|
|
if (noRepeat) {
|
|
|
+// System.out.println("数据不重复,计算平均值");
|
|
|
+ try{
|
|
|
+ //计算平均值并写入list
|
|
|
+ costModelWxPrice.setAvePrice(Float.toString((Float.parseFloat(costModelWxPrice.getMaxPrice())+Float.parseFloat(costModelWxPrice.getMinPrice()))/2));
|
|
|
+// System.out.println("写入数据成功");
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ System.out.println("Float.parseFloat(String)方法执行异常");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+// System.out.println("最终需要存入的数据");
|
|
|
+// System.out.println(costModelWxPrice);
|
|
|
+// System.out.println(costModelWxPrice.getClass());
|
|
|
+// System.out.println(costModelWxPrice.getClass().getName());
|
|
|
costModelWxPriceService.save(costModelWxPrice);
|
|
|
return Result.OK("添加成功!");
|
|
|
} else {
|
|
@@ -127,6 +142,7 @@ public class CostModelWxPriceController extends JeecgController<CostModelWxPrice
|
|
|
//@RequiresPermissions("org.jeecg.modules:kzks_cost_model_wx_price:edit")
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
public Result<String> edit(@RequestBody CostModelWxPrice costModelWxPrice) {
|
|
|
+ costModelWxPrice.setAvePrice(Float.toString((Float.parseFloat(costModelWxPrice.getMaxPrice())+Float.parseFloat(costModelWxPrice.getMinPrice()))/2));
|
|
|
costModelWxPriceService.updateById(costModelWxPrice);
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|