Jelajahi Sumber

Merge branch 'dev' of wangzhinan/wlyy2.0 into dev

huangwenjie 6 tahun lalu
induk
melakukan
82366bfbb8

+ 2 - 2
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistHospitalServiceItemController.java

@ -50,7 +50,7 @@ public class SpecialistHospitalServiceItemController extends EnvelopRestEndpoint
            List<HospitalServiceItemDO> hospitalServiceItemDOS = new ArrayList<>();
            List<HospitalServiceItemDO> hospitalServiceItemDOS = new ArrayList<>();
            for (int i =0 ; i<array.size();i++){
            for (int i =0 ; i<array.size();i++){
                JSONObject object = array.getJSONObject(i);
                JSONObject object = array.getJSONObject(i);
                object.replace("expense", DataUtils.doubleTransferInteger(object.getDouble("expense"),"0.00"));
                object.replace("expense", DataUtils.doubleToInt(object.getDouble("expense")));
                HospitalServiceItemDO hospitalServiceItemDO = toEntity(object.toJSONString(),HospitalServiceItemDO.class);
                HospitalServiceItemDO hospitalServiceItemDO = toEntity(object.toJSONString(),HospitalServiceItemDO.class);
                hospitalServiceItemDOS.add(hospitalServiceItemDO);
                hospitalServiceItemDOS.add(hospitalServiceItemDO);
            }
            }
@ -234,7 +234,7 @@ public class SpecialistHospitalServiceItemController extends EnvelopRestEndpoint
            List<HospitalServiceItemDO> hospitalServiceItemDOList = new ArrayList<>();
            List<HospitalServiceItemDO> hospitalServiceItemDOList = new ArrayList<>();
            for (int i = 0;i<array.size();i++){
            for (int i = 0;i<array.size();i++){
                JSONObject object = array.getJSONObject(i);
                JSONObject object = array.getJSONObject(i);
                object.replace("expense", DataUtils.doubleTransferInteger(object.getDouble("expense"),"0.00"));
                object.replace("expense", DataUtils.doubleToInt(object.getDouble("expense")));
                HospitalServiceItemDO hospitalServiceItemDO = toEntity(object.toJSONString(),HospitalServiceItemDO.class);
                HospitalServiceItemDO hospitalServiceItemDO = toEntity(object.toJSONString(),HospitalServiceItemDO.class);
                hospitalServiceItemDOList.add(hospitalServiceItemDO);
                hospitalServiceItemDOList.add(hospitalServiceItemDO);
            }
            }

+ 9 - 9
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistServiceItemController.java

@ -90,13 +90,13 @@ public class SpecialistServiceItemController extends EnvelopRestEndpoint {
        try {
        try {
            JSONObject object = JSON.parseObject(serviceItem);
            JSONObject object = JSON.parseObject(serviceItem);
            if (object.getDouble("threeHospitals")!=null){
            if (object.getDouble("threeHospitals")!=null){
                object.replace("threeHospitals", DataUtils.doubleTransferInteger(object.getDouble("threeHospitals"),"0.00"));
                object.replace("threeHospitals", DataUtils.doubleToInt(object.getDouble("threeHospitals")));
            }
            }
            if (object.getDouble("twoHospitals")!=null){
            if (object.getDouble("twoHospitals")!=null){
                object.replace("twoHospitals",DataUtils.doubleTransferInteger(object.getDouble("twoHospitals"),"0.00"));
                object.replace("twoHospitals",DataUtils.doubleToInt(object.getDouble("twoHospitals")));
            }
            }
            if (object.getDouble("oneHospitals")!=null){
            if (object.getDouble("oneHospitals")!=null){
                object.replace("oneHospitals",DataUtils.doubleTransferInteger(object.getDouble("oneHospitals"),"0.00"));
                object.replace("oneHospitals",DataUtils.doubleToInt(object.getDouble("oneHospitals")));
            }
            }
            SpecialistServiceItemDO serviceItemDO = toEntity(object.toJSONString(),SpecialistServiceItemDO.class);
            SpecialistServiceItemDO serviceItemDO = toEntity(object.toJSONString(),SpecialistServiceItemDO.class);
            return specialistServiceItemService.insert(serviceItemDO);
            return specialistServiceItemService.insert(serviceItemDO);
@ -148,13 +148,13 @@ public class SpecialistServiceItemController extends EnvelopRestEndpoint {
        try {
        try {
            JSONObject object = JSON.parseObject(serviceItem);
            JSONObject object = JSON.parseObject(serviceItem);
            if (object.getDouble("threeHospitals")!=null){
            if (object.getDouble("threeHospitals")!=null){
                object.replace("threeHospitals", DataUtils.doubleTransferInteger(object.getDouble("threeHospitals"),"0.00"));
                object.replace("threeHospitals", DataUtils.doubleToInt(object.getDouble("threeHospitals")));
            }
            }
            if (object.getDouble("twoHospitals")!=null){
            if (object.getDouble("twoHospitals")!=null){
                object.replace("twoHospitals",DataUtils.doubleTransferInteger(object.getDouble("twoHospitals"),"0.00"));
                object.replace("twoHospitals",DataUtils.doubleToInt(object.getDouble("twoHospitals")));
            }
            }
            if (object.getDouble("oneHospitals")!=null){
            if (object.getDouble("oneHospitals")!=null){
                object.replace("oneHospitals",DataUtils.doubleTransferInteger(object.getDouble("oneHospitals"),"0.00"));
                object.replace("oneHospitals",DataUtils.doubleToInt(object.getDouble("oneHospitals")));
            }
            }
            SpecialistServiceItemDO serviceItemDO = toEntity(object.toJSONString(),SpecialistServiceItemDO.class);
            SpecialistServiceItemDO serviceItemDO = toEntity(object.toJSONString(),SpecialistServiceItemDO.class);
            return specialistServiceItemService.update(serviceItemDO);
            return specialistServiceItemService.update(serviceItemDO);
@ -214,13 +214,13 @@ public class SpecialistServiceItemController extends EnvelopRestEndpoint {
            for (int i = 0;i<array.size();i++){
            for (int i = 0;i<array.size();i++){
                JSONObject object = array.getJSONObject(i);
                JSONObject object = array.getJSONObject(i);
                if (object.getDouble("threeHospitals")!=null){
                if (object.getDouble("threeHospitals")!=null){
                    object.replace("threeHospitals", DataUtils.doubleTransferInteger(object.getDouble("threeHospitals"),"0.00"));
                    object.replace("threeHospitals", DataUtils.doubleToInt(object.getDouble("threeHospitals")));
                }
                }
                if (object.getDouble("twoHospitals")!=null){
                if (object.getDouble("twoHospitals")!=null){
                    object.replace("twoHospitals",DataUtils.doubleTransferInteger(object.getDouble("twoHospitals"),"0.00"));
                    object.replace("twoHospitals",DataUtils.doubleToInt(object.getDouble("twoHospitals")));
                }
                }
                if (object.getDouble("oneHospitals")!=null){
                if (object.getDouble("oneHospitals")!=null){
                    object.replace("oneHospitals",DataUtils.doubleTransferInteger(object.getDouble("oneHospitals"),"0.00"));
                    object.replace("oneHospitals",DataUtils.doubleToInt(object.getDouble("oneHospitals")));
                }
                }
                SpecialistServiceItemDO specialistServiceItemDO = toEntity(object.toJSONString(),SpecialistServiceItemDO.class);
                SpecialistServiceItemDO specialistServiceItemDO = toEntity(object.toJSONString(),SpecialistServiceItemDO.class);
                specialistServiceItemDOS.add(specialistServiceItemDO);
                specialistServiceItemDOS.add(specialistServiceItemDO);

+ 71 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/util/DataUtils.java

@ -0,0 +1,71 @@
package com.yihu.jw.util;/**
 * Created by nature of king on 2018/9/17.
 */
/**
 * @author wangzhinan
 * @create 2018-09-17 15:32
 * @desc 数据转换工具
 **/
public class DataUtils {
    public static Integer doubleToInt(Double d) {
        if (d == null) {
            return 0;
        }
        String currency = String.valueOf(d);
        int index = currency.indexOf(".");
        int length = currency.length();
        Integer amLong = 0;
        if (index == -1) {
            amLong = Integer.valueOf(currency + "00");
        } else if (length - index >= 3) {
            amLong = Integer.valueOf((currency.substring(0, index + 3)).replace(".", ""));
            if (length - index > 3) {
                if (Integer.valueOf(currency.substring(index + 3, index + 4)) >= 5) {
                    amLong++;
                }
            }
        } else if (length - index == 2) {
            amLong = Integer.valueOf((currency.substring(0, index + 2)).replace(".", "") + 0);
        } else {
            amLong = Integer.valueOf((currency.substring(0, index + 1)).replace(".", "") + "00");
        }
        return amLong;
    }
    public static String integerTransferDouble(Integer amount){
        try {
            if(!amount.toString().matches("\\-?[0-9]+"));
        }catch (Exception e) {
            e.printStackTrace();
        }
        int flag = 0;
        String amString = amount.toString();
        if(amString.charAt(0)=='-'){
            flag = 1;
            amString = amString.substring(1);
        }
        StringBuffer result = new StringBuffer();
        if(amString.length()==1){
            result.append("0.0").append(amString);
        }else if(amString.length() == 2){
            result.append("0.").append(amString);
        }else{
            String intString = amString.substring(0,amString.length()-2);
            for(int i=1; i<=intString.length();i++){
                if( (i-1)%3 == 0 && i !=1){
//                    result.append(",");
                }
                result.append(intString.substring(intString.length()-i,intString.length()-i+1));
            }
            result.reverse().append(".").append(amString.substring(amString.length()-2));
        }
        if(flag == 1){
            return "-"+result.toString();
        }else{
            return result.toString();
        }
    }
}