zhaowenxuan
4 天以前 2b2763c83e352f8ffd2ac0b5c46b60c49ee78439
ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjOrderDetailServiceImpl.java
@@ -1,13 +1,20 @@
package com.ltkj.hosp.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.utils.DateUtils;
import com.ltkj.hosp.domain.TjProject;
import com.ltkj.hosp.vo.ProFcListVo;
import com.ltkj.hosp.vodomain.ShenGaoTiZhongVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -15,6 +22,7 @@
import com.ltkj.hosp.domain.TjOrderDetail;
import com.ltkj.hosp.service.ITjOrderDetailService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
/**
 * 体检项目明细Service业务层处理
@@ -244,4 +252,55 @@
    public void updateTjOrderDetailsFlowingWaterIdByJxbzisnull(String orderId,String ls) {
        tjOrderDetailMapper.updateTjOrderDetailsFlowingWaterIdByJxbzisnull(orderId,ls);
    }
    @Override
    public List<ProFcListVo> getFcList(Long orderId, Integer type) {
        return tjOrderDetailMapper.getFcList(orderId,type);
    }
    @Transactional
    @Override
    public AjaxResult updFcPro(String json) {
        try {
            JSONObject entries = JSONUtil.parseObj(json);
            System.out.println(JSONUtil.toJsonStr(entries));
            String orderId = entries.getStr("orderId");
            JSONArray array = entries.getJSONArray("data");
            ArrayList<String> fcList = new ArrayList<>();
            ArrayList<String> notFcList = new ArrayList<>();
            for (Object o : array) {
                JSONObject object = (JSONObject) o;
                String proId = object.getStr("proId");
                Integer type = object.getInt("type");
                if (type == 1) {
                    fcList.add(proId);
                } else {
                    notFcList.add(proId);
                }
            }
//            System.out.println("fcList = " + fcList);
//            System.out.println("notFcList = " + notFcList);
//            if (true)
//                return AjaxResult.error();
            if (!fcList.isEmpty()){
                LambdaUpdateWrapper<TjOrderDetail> wrapper = new LambdaUpdateWrapper<>();
                wrapper.set(TjOrderDetail::getIsReturn,1);
                wrapper.eq(TjOrderDetail::getOrderId,orderId);
                wrapper.in(TjOrderDetail::getProId,fcList);
                update(wrapper);
            }
            if (!notFcList.isEmpty()){
                LambdaUpdateWrapper<TjOrderDetail> wrapper = new LambdaUpdateWrapper<>();
                wrapper.set(TjOrderDetail::getIsReturn,0);
                wrapper.eq(TjOrderDetail::getOrderId,orderId);
                wrapper.in(TjOrderDetail::getProId,notFcList);
                update(wrapper);
            }
        }catch (Exception e){
            log.error(String.valueOf(e)+e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjaxResult.error();
        }
        return AjaxResult.success();
    }
}