package com.hzya.frame.grpU8.nxproof.glZtcs.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.grpU8.nxproof.glZtcs.dao.ISenderGlZtcsDao;
import com.hzya.frame.grpU8.nxproof.glZtcs.entity.SenderGlZtcsEntity;
import com.hzya.frame.grpU8.nxproof.glZtcs.service.ISenderGlZtcsService;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * (GlZtcs)表服务实现类
 *
 * @author makejava
 * @since 2024-06-20 09:45:04
 */
@Service(value = "SenderGlZtcsServiceImpl")
public class SenderGlZtcsServiceImpl extends BaseService<SenderGlZtcsEntity, String> implements ISenderGlZtcsService {


    private ISenderGlZtcsDao senderGlZtcsDao;



    
    @Autowired
	public void setSenderGlZtcsDao(ISenderGlZtcsDao dao) {
		this.senderGlZtcsDao = dao;
		this.dao = dao;
	}

	@Override
	public Object glZtcsSynchronization(JSONObject json) {
		JSONObject jsonObject = json.getJSONObject("jsonStr");
		SenderGlZtcsEntity senderGlZtcsEntity = jsonObject.toJavaObject(SenderGlZtcsEntity.class);
		List<SenderGlZtcsEntity> senderGlZtcsEntities=new ArrayList<>();
		String result=null;
		try {
			//如果没有传入年度，则查询当年得，避免数据查询太大
			if(senderGlZtcsEntity.getKjnd()==null){
				senderGlZtcsEntity.setKjnd(DateUtil.format(new Date(),"yyyy"));
			}
			/*try {
				//同步南浔区人民医院001账套信息
				senderGlZtcsEntity.setZtbh("001");
				senderGlZtcsEntity.setHsdwdm("0101010101");
				logger.info("===========开始查询南浔区人民医院账套信息=============");
				senderGlZtcsEntities= sqlSessionNxrm.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("南浔区人民医院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("南浔区人民医院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}*/
			try {
				//同步南浔区练市人民医院003账套信息
				senderGlZtcsEntity.setZtbh("003");
				senderGlZtcsEntity.setHsdwdm("0101010103");
				logger.info("===========开始查询南浔区练市人民医院账套信息=============");
				senderGlZtcsEntities= senderGlZtcsDao.querySenderGlZtcsEntity(senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("南浔区人民医院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("南浔区人民医院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}
			/*try {
				//同步练市镇中心卫生院005账套信息
				senderGlZtcsEntity.setZtbh("005");
				senderGlZtcsEntity.setHsdwdm("0101010202");
				logger.info("===========开始查询南浔区练市镇中心卫生院账套信息=============");
				senderGlZtcsEntities= sqlSessionNxrm.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("南浔区练市镇中心卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("南浔区练市镇中心卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}*/
			/*try {
				//同步善琏镇卫生院007账套信息
				senderGlZtcsEntity.setZtbh("007");
				senderGlZtcsEntity.setHsdwdm("0101010204");
				logger.info("===========开始查询南浔区善琏镇卫生院账套信息=============");
				senderGlZtcsEntities= sqlSessionNxrm.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("南浔区善琏镇卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("南浔区善琏镇卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}*/
			/*try {
				//同步双林镇中心卫生院004账套信息
				senderGlZtcsEntity.setZtbh("004");
				senderGlZtcsEntity.setHsdwdm("0101010201");
				senderGlZtcsEntities= sqlSessionSlz.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("双林镇中心卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("双林镇中心卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}
			try {
				//同步菱湖镇中心卫生院009账套信息
				senderGlZtcsEntity.setZtbh("009");
				senderGlZtcsEntity.setHsdwdm("0101020201");
				senderGlZtcsEntities= sqlSessionLhz.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("菱湖镇中心卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("菱湖镇中心卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}
			try {
				//同步和孚镇卫生院010账套信息
				senderGlZtcsEntity.setZtbh("010");
				senderGlZtcsEntity.setHsdwdm("0101020202");
				senderGlZtcsEntities= sqlSessionHfz.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("和孚镇卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("和孚镇卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}
			try {
				//同步千金镇卫生院011账套信息
				senderGlZtcsEntity.setZtbh("011");
				senderGlZtcsEntity.setHsdwdm("0101020203");
				senderGlZtcsEntities= sqlSessionQjz.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("千金镇卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("千金镇卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}
			try {
				//同步石崇镇卫生院012账套信息
				senderGlZtcsEntity.setZtbh("012");
				senderGlZtcsEntity.setHsdwdm("0101020204");
				senderGlZtcsEntities= sqlSessionScz.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("石崇镇卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("石崇镇卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}
			try {
				//同步南浔镇中心卫生院014账套信息
				senderGlZtcsEntity.setZtbh("014");
				senderGlZtcsEntity.setHsdwdm("010202");
				senderGlZtcsEntities= sqlSessionNxz.selectList("SenderGlZtcsEntity_list_base",senderGlZtcsEntity);
				result=sendZtcsToHealthBureau(senderGlZtcsEntities);
				logger.info("南浔镇中心卫生院GRPU8账套信息同步结果为:{}",result);
			}catch (Exception e){
				logger.info("南浔镇中心卫生院GRPU8账套信息同步失败:{}",e.getMessage());
				e.printStackTrace();
			}*/
		}catch (Exception e){
			logger.info("GRPU8账套信息同步失败:{}",e.getMessage());
			e.printStackTrace();
		}
		JSONObject jsonObject1=new JSONObject();
		jsonObject1.put("status","200");
		jsonObject1.put("result",result);
		return jsonObject1;
	}

	private String sendZtcsToHealthBureau(List<SenderGlZtcsEntity> senderGlZtcsEntities){
			if (CollectionUtils.isEmpty(senderGlZtcsEntities)) {
				logger.info("GRPU8没有需要同步得账套信息信息");
				return "GRPU8没有需要同步得账套信息信息";
			} else {
				for (SenderGlZtcsEntity ztcsEntity : senderGlZtcsEntities) {
					 //ztcsEntity.setKjnd("2021");
					 //ztcsEntity.setQykjqj(ztcsEntity.getQykjqj().replace("2024","2021"));
					//根据会计年度，公司代码，核算单位代码查询数据是否已经同步过
					SenderGlZtcsEntity receiverGlZtcsEntity = new SenderGlZtcsEntity();
					receiverGlZtcsEntity.setKjnd(ztcsEntity.getKjnd());
					receiverGlZtcsEntity.setZtbh(ztcsEntity.getZtbh());
					receiverGlZtcsEntity.setHsdwdm(ztcsEntity.getHsdwdm());
					try {
						List<SenderGlZtcsEntity> receiverGlZtcsEntities = queryEntityPageHealthBureau(receiverGlZtcsEntity);
						//设置id为会计年度，账套号，核算单位代码拼接，测试时候这样，具体看情况
						ztcsEntity.setId(ztcsEntity.getKjnd() + '-' + ztcsEntity.getZtbh() + '-' + ztcsEntity.getHsdwdm());
						JsonResultEntity jsonResultEntity=null;
						if (CollectionUtils.isEmpty(receiverGlZtcsEntities)) {
							//将数据保存
							JSONObject jsonObjectStr = new JSONObject();
							jsonObjectStr.put("jsonStr", ztcsEntity);
							logger.info("===========开始将账套编码为：{}得GRPU8账套数据同步新增到卫生局GRPU8账套信息中=============",ztcsEntity.getZtmc());
							Object o = saveEntityHealthBureau(jsonObjectStr);
							JSONObject json = (JSONObject) JSON.toJSON(o);
							if(json.getString("status").equals("200")){
								//JSONObject jsonObjectAttribute = (JSONObject) JSONObject.toJSON(jsonResultEntity.getAttribute());
								logger.info("========账套编码{}得GROU8账套信息同步保存返回结果为:{}======",ztcsEntity.getZtmc(),json.getString("ztcs"));
							}
							/*if (jsonObjectAttribute != null && jsonResultEntity.getStatus().equals("200")) {
								logger.info("===========开始将发送方得GRPU8账套数据新增到账套信息日志中=============");
								//保存发送方得日志
								ztcsEntity.setDataSourceCode(grp_data_source_code);
								senderGlZtcsDao.saveSenderGlZtcsEntity(ztcsEntity);
							}*/
						} else {
							//将数据更新
							JSONObject jsonObjectStr = new JSONObject();
							jsonObjectStr.put("jsonStr", ztcsEntity);
							logger.info("===========开始将账套编码为：{}得GRPU8账套数据同步更新到卫生局GRPU8账套信息中=============",ztcsEntity.getZtmc());
							Object o = updateEntityHealthBureau(jsonObjectStr);
							JSONObject json = (JSONObject) JSON.toJSON(o);
							if(json.getString("status").equalsIgnoreCase("200")){
								//JSONObject jsonObjectAttribute = (JSONObject) JSONObject.toJSON(jsonResultEntity.getAttribute());
								logger.info("========账套编码：{}得GROU8账套信息同步更新返回结果为:{}======",ztcsEntity.getZtmc(),json.getString("ztcs"));
							}
							/*if (jsonObjectAttribute != null && jsonResultEntity.getStatus().equals("200")) {
								logger.info("===========开始将发送方得GRPU8账套数据更新到账套信息日志中=============");
								//保存发送方得日志
								ztcsEntity.setDataSourceCode(grp_data_source_code);
								senderGlZtcsDao.updateSenderGlZtcsEntity(ztcsEntity);
							}*/
						}
					} catch (Exception e) {
						logger.info("账套编码：{}得GRPU8账套信息同步失败:{}",ztcsEntity.getZtmc(), e.getMessage());
						e.printStackTrace();
					}
				}
				return "同步GROU8账套信息成功";
			}
	}

	//查询账套信息
	@Override
	public Object queryEntityPage(JSONObject json) {
		JSONObject jsonObject = json.getJSONObject("jsonStr");
		SenderGlZtcsEntity senderGlZtcsEntity = jsonObject.toJavaObject(SenderGlZtcsEntity.class);
		List<SenderGlZtcsEntity> senderGlZtcsEntities=new ArrayList<>();
		//如果没有传入年度，则查询当年得，避免数据查询太大
		if(senderGlZtcsEntity.getKjnd()==null){
			senderGlZtcsEntity.setKjnd(DateUtil.format(new Date(),"yyyy"));
		}
		if(StrUtil.isEmpty(senderGlZtcsEntity.getZtbh())){
			logger.info("======根据账套号:{}查询账套信息为空",senderGlZtcsEntity.getZtbh());
			return BaseResult.getFailureMessageEntity("请传递账套号");
		}
		try {
			/*switch (senderGlZtcsEntity.getZtbh()){
				case "003"://练市人民医院
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "004"://双林镇中心卫生院
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "005"://练市镇中心卫生院
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "007"://善琏镇卫生院
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "009":
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "010":
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "011":
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "012":
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				case "001"://南浔区人民医院
					senderGlZtcsEntities = senderGlZtcsDao.queryByLike(senderGlZtcsEntity);
					break;
				default:
					break;
			}*/
			senderGlZtcsEntities = senderGlZtcsDao.querySenderGlZtcsEntity(senderGlZtcsEntity);
			PageInfo pageInfo=new PageInfo(senderGlZtcsEntities);
			JSONObject jsonObject1=new JSONObject();
			jsonObject1.put("status","200");
			jsonObject1.put("pageInfo",pageInfo);
			return jsonObject1;
		}catch (Exception e){
			logger.info("账套编码：{}查询GROU8账套信息失败:{}",senderGlZtcsEntity.getZtbh(),e.getMessage());
			return BaseResult.getFailureMessageEntity("查询GROU8账套信息失败");
		}
	}


	//查询账套信息
	@Override
	public List<SenderGlZtcsEntity> queryEntityPageHealthBureau(SenderGlZtcsEntity senderGlZtcsEntity) {
		try {
			logger.info("=======根据账套号：{}查询卫生局得账套信息======",senderGlZtcsEntity.getZtbh());
			List<SenderGlZtcsEntity> receiverGlZtcsEntities = senderGlZtcsDao.queryGlZtcsHealthBureau(senderGlZtcsEntity);
			return receiverGlZtcsEntities;
		}catch (Exception e){
			logger.info("查询卫生局GROU8账套信息失败:{}",e.getMessage());
			e.printStackTrace();
		}
		return null;
	}

	//保存账套信息
	@Override
	public Object saveEntityHealthBureau(JSONObject json) {
		JSONObject jsonObject = json.getJSONObject("jsonStr");
		SenderGlZtcsEntity receiverGlZtcsEntity = jsonObject.toJavaObject(SenderGlZtcsEntity.class);
		if (!checkStr(jsonObject.getString("kjnd"))) {
			logger.info("===========保存账套信息时会计年度为空=========");
			return BaseResult.getFailureMessageEntity("会计年度为空");
		}
		if (!checkStr(jsonObject.getString("ztbh"))) {
			logger.info("===========保存账套信息时账套编号为空=========");
			return BaseResult.getFailureMessageEntity("账套编号为空");
		}
		if (!checkStr(jsonObject.getString("ztmc"))) {
			logger.info("===========保存账套信息时账套名称为空=========");
			return BaseResult.getFailureMessageEntity("账套名称为空");
		}
		if (!checkStr(jsonObject.getString("ztmce"))) {
			logger.info("===========保存账套信息时账套全称为空=========");
			return BaseResult.getFailureMessageEntity("账套全称为空");
		}
		if (!checkStr(jsonObject.getString("hsdwdm"))) {
			logger.info("===========保存账套信息时核算单位代码为空=========");
			return BaseResult.getFailureMessageEntity("核算单位代码为空");
		}
		if (!checkStr(jsonObject.getString("hsdwmc"))) {
			logger.info("===========保存账套信息时核算单位名称为空=========");
			return BaseResult.getFailureMessageEntity("核算单位名称为空");
		}
		if (!checkStr(jsonObject.getString("bwbdm"))) {
			logger.info("===========保存账套信息时本位币代码为空=========");
			return BaseResult.getFailureMessageEntity("本位币代码为空");
		}
		if (!checkStr(jsonObject.getString("bwbmc"))) {
			logger.info("===========保存账套信息时本位币名称为空=========");
			return BaseResult.getFailureMessageEntity("本位币名称为空");
		}
		try {
			receiverGlZtcsEntity.setCwzg("1");
			receiverGlZtcsEntity.setKjqjs(12);
			receiverGlZtcsEntity.setWbhs("0");
			receiverGlZtcsEntity.setHllx("G");
			receiverGlZtcsEntity.setSfyjz("1");
			receiverGlZtcsEntity.setYskz("0");
			receiverGlZtcsEntity.setYspzkz("0");
			receiverGlZtcsEntity.setSlxsws(4);
			receiverGlZtcsEntity.setDjxsws(2);
			receiverGlZtcsEntity.setAnyibz("1");
			receiverGlZtcsEntity.setXjbmfa("8");
			receiverGlZtcsEntity.setBkdtd("0");
			receiverGlZtcsEntity.setGkjzzf("0");
			receiverGlZtcsEntity.setZbkzmb("0");
			receiverGlZtcsEntity.setKzfs("0");
			receiverGlZtcsEntity.setKzqj("0");
			receiverGlZtcsEntity.setKzyj("0");
			receiverGlZtcsEntity.setYbksy("01");
			receiverGlZtcsEntity.setYbjsy("03");
			receiverGlZtcsEntity.setZfpzbh("M");
			receiverGlZtcsEntity.setBkdbh("M");
			receiverGlZtcsEntity.setBkhskm("0");
			receiverGlZtcsEntity.setBkyhkmyz("0");
			receiverGlZtcsEntity.setZfscbkd("0");
			receiverGlZtcsEntity.setBkdscpz("0");
			receiverGlZtcsEntity.setSzqxkz("0");
			receiverGlZtcsEntity.setDjxg("0");
			receiverGlZtcsEntity.setDjsh("0");
			receiverGlZtcsEntity.setDybz("0");
			receiverGlZtcsEntity.setJhsh("0");
			receiverGlZtcsEntity.setZpscbk("0");
			receiverGlZtcsEntity.setZphs("0");
			receiverGlZtcsEntity.setHeadbkdh("0");
			receiverGlZtcsEntity.setBkdfs("0");
			receiverGlZtcsEntity.setLrzy("0");
			receiverGlZtcsEntity.setMjxsxsws(2);
			receiverGlZtcsEntity.setNeedjfzb("0");
			receiverGlZtcsEntity.setNeedyskm("5");
			receiverGlZtcsEntity.setPzbtdf("0");
			receiverGlZtcsEntity.setYkjhyskm("0");
			receiverGlZtcsEntity.setBkdxssjkm("0");
			receiverGlZtcsEntity.setBkdxyfscz("0");
			receiverGlZtcsEntity.setDelmaxdh("0");
			receiverGlZtcsEntity.setBkddataqxqy("0");
			receiverGlZtcsEntity.setYkjhcs("0");
			receiverGlZtcsEntity.setYkjhfs("0");
			receiverGlZtcsEntity.setBkdxszhmc("0");
			receiverGlZtcsEntity.setMaxzdycount(20);
			SenderGlZtcsEntity senderGlZtcsEntity=new SenderGlZtcsEntity();
			senderGlZtcsEntity.setKjnd(receiverGlZtcsEntity.getKjnd());
			senderGlZtcsEntity.setZtbh(receiverGlZtcsEntity.getZtbh());
			senderGlZtcsEntity.setHsdwdm(receiverGlZtcsEntity.getHsdwdm());
			List<SenderGlZtcsEntity> senderGlZtcsEntities = queryEntityPageHealthBureau(senderGlZtcsEntity);
			if(CollectionUtils.isEmpty(senderGlZtcsEntities)){
				receiverGlZtcsEntity.setId(receiverGlZtcsEntity.getKjnd()+'-'+receiverGlZtcsEntity.getZtbh()+'-'+receiverGlZtcsEntity.getHsdwdm());
				logger.info("==========开始根据账套号为:{}保存账套信息，id为:{}=========",receiverGlZtcsEntity.getZtbh(),receiverGlZtcsEntity.getId());
				SenderGlZtcsEntity receiverGlZtcsEntity1 = senderGlZtcsDao.saveGlZtcsHealthBureau(receiverGlZtcsEntity);
				JSONObject jsonObject1=new JSONObject();
				jsonObject1.put("status","200");
				jsonObject1.put("ztcs",receiverGlZtcsEntity1);
				return jsonObject1;
			}else {
				SenderGlZtcsEntity receiverGlZtcsEntity1 = senderGlZtcsDao.updateGlZtcsHealthBureau(receiverGlZtcsEntity);
				JSONObject jsonObject1=new JSONObject();
				jsonObject1.put("status","200");
				jsonObject1.put("ztcs",receiverGlZtcsEntity1);
				return jsonObject1;
			}
		}catch (Exception e){
			logger.info("根据账套编号:{}保存GROU8账套信息失败:{}",receiverGlZtcsEntity.getZtbh(),e.getMessage());
			return BaseResult.getFailureMessageEntity("保存GROU8账套信息失败");
		}
	}

	//更新账套信息
	@Override
	public Object updateEntityHealthBureau(JSONObject json) {
		JSONObject jsonObject = json.getJSONObject("jsonStr");
		SenderGlZtcsEntity receiverGlZtcsEntity = jsonObject.toJavaObject(SenderGlZtcsEntity.class);
		if (!checkStr(jsonObject.getString("kjnd"))) {
			logger.info("===========更新账套信息时会计年度为空=========");
			return BaseResult.getFailureMessageEntity("会计年度为空");
		}
		if (!checkStr(jsonObject.getString("ztbh"))) {
			logger.info("===========更新账套信息时账套编号为空=========");
			return BaseResult.getFailureMessageEntity("账套编号为空");
		}
		if (!checkStr(jsonObject.getString("hsdwdm"))) {
			logger.info("===========更新账套信息时核算单位代码=========");
			return BaseResult.getFailureMessageEntity("核算单位代码");
		}
		try {
			receiverGlZtcsEntity.setId(receiverGlZtcsEntity.getKjnd()+'-'+receiverGlZtcsEntity.getZtbh()+'-'+receiverGlZtcsEntity.getHsdwdm());
			logger.info("==========开始根据账套号：{}更新账套信息，id为:{}=========",receiverGlZtcsEntity.getZtbh(),receiverGlZtcsEntity.getId());
			SenderGlZtcsEntity receiverGlZtcsEntity1 = senderGlZtcsDao.updateGlZtcsHealthBureau(receiverGlZtcsEntity);
			JSONObject jsonObject1=new JSONObject();
			jsonObject1.put("status","200");
			jsonObject1.put("ztcs",receiverGlZtcsEntity1);
			return jsonObject1;
		}catch (Exception e){
			logger.info("根据账套编号:{}更新GROU8账套信息失败:{}",receiverGlZtcsEntity.getZtbh(),e.getMessage());
			return BaseResult.getFailureMessageEntity("更新GROU8账套信息失败");
		}
	}

	//删除账套信息
	@Override
	public Object deleteEntityHealthBureau(JSONObject json) {
		JSONObject jsonObject = json.getJSONObject("jsonStr");
		SenderGlZtcsEntity receiverGlZtcsEntity = jsonObject.toJavaObject(SenderGlZtcsEntity.class);
		if (!checkStr(jsonObject.getString("kjnd"))) {
			logger.info("===========删除账套信息时会计年度为空=========");
			return BaseResult.getFailureMessageEntity("会计年度为空");
		}
		if (!checkStr(jsonObject.getString("ztbh"))) {
			logger.info("===========删除账套信息时账套编号为空=========");
			return BaseResult.getFailureMessageEntity("账套编号为空");
		}
		if (!checkStr(jsonObject.getString("hsdwdm"))) {
			logger.info("===========删除账套信息时核算单位代码=========");
			return BaseResult.getFailureMessageEntity("核算单位代码");
		}
		try {
			receiverGlZtcsEntity.setId(receiverGlZtcsEntity.getKjnd()+'-'+receiverGlZtcsEntity.getZtbh()+'-'+receiverGlZtcsEntity.getHsdwdm());
			logger.info("==========开始根据账套号：{}和会计年度:{}删除账套信息=========",receiverGlZtcsEntity.getZtbh(),receiverGlZtcsEntity.getKjnd());
			Integer integer = senderGlZtcsDao.deleteGlZtcsHealthBureau(receiverGlZtcsEntity);
			JSONObject jsonObject1=new JSONObject();
			jsonObject1.put("status","200");
			jsonObject1.put("ztcs",integer);
			return jsonObject1;
		}catch (Exception e){
			logger.info("根据账套编号:{}删除GROU8账套信息失败:{}",receiverGlZtcsEntity.getZtbh(),e.getMessage());
			return BaseResult.getFailureMessageEntity("删除GROU8账套信息失败");
		}
	}


}
