package com.kingdee.eas.custom.shuiyou.six.osf;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.bsf.service.app.IHRMsfService;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.shuiyou.task.MessageResult;
import com.kingdee.eas.custom.shuiyou.uitls.ISYUtilsFacade;
import com.kingdee.eas.custom.shuiyou.uitls.SYUtilsFacadeFactory;
import com.kingdee.eas.custom.shuiyou.uitls.URLConfigEnum;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.shr.base.syssetting.app.filter.HRFilterUtils;
import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
import com.kingdee.shr.compensation.app.tax.TaxUnitCollection;
import com.kingdee.shr.compensation.app.tax.TaxUnitFactory;
import com.kingdee.shr.compensation.app.tax.TaxUnitInfo;
import com.kingdee.shr.compensation.app.taxCal.TaxUnitDeductionCollection;
import com.kingdee.shr.compensation.app.taxCal.TaxUnitDeductionFactory;
import com.kingdee.shr.compensation.app.taxCal.TaxUnitDeductionInfo;
import com.kingdee.shr.compensation.util.CmpStrUtil;
import com.kingdee.shr.compensation.util.lock.CmpDistributedLockUtils;
import java.sql.Timestamp;
import java.util.*;
/**
* 获取人员名单
* description: QueryPreDeductService
* date: 2024/9/25 16:24
* author: lhbj
* version: 1.0
*/
public class QueryPreDeductService implements IHRMsfService {
@Override
public Object process(Context context, Map map) throws EASBizException, BOSException {
String this_taskid= (String) map.get("this_taskId");
String paramData= (String) map.get("paramData");
ISYUtilsFacade facade = SYUtilsFacadeFactory.getLocalInstance(context);
Map config =facade.getConfig();
MessageResult msg=null;
try {
String result = facade.post(config.get("ip") + URLConfigEnum.QUERYPREDEDUCT_VALUE, paramData);
JSONObject paramJSON = JSONUtil.parseObj(paramData);
String id = paramJSON.getStr("TAXUNITID");
int year = paramJSON.getInt("skssnd");
String oql = "select id,name,number,taxNumber,areaCode,regNumber,declPassword,realPassword,isAutoDeduct where id = '" + id + "'";
TaxUnitCollection taxUnitCollection = TaxUnitFactory.getLocalInstance(context).getTaxUnitCollection(oql);
if (null != taxUnitCollection && taxUnitCollection.size() > 0) {
TaxUnitInfo taxUnitInfo = taxUnitCollection.get(0);
String taxUnitDeductionId = this.saveTaxUnitDeduction(context, taxUnitInfo, year);
Object[] param = new Object[]{null, taxUnitDeductionId, BOSUuid.create("46E337F4").toString()};
if (null != result) {
//成功写入人员是否6w
msg = this._saveStaffCollection(context, taxUnitInfo, result);
} else {
msg = MessageResult.ERROR("接口调用异常");
}
}
}catch (Exception e){
e.printStackTrace();
}
return msg;
}
protected String getTaxUnitDeduction(Context ctx, TaxUnitInfo taxUnit, int year) throws BOSException {
String oql = "select id where taxUnit.id = '" + taxUnit.getId().toString() + "' and year = " + year;
TaxUnitDeductionCollection collection = TaxUnitDeductionFactory.getLocalInstance(ctx).getTaxUnitDeductionCollection(oql);
if (null != collection && !collection.isEmpty()) {
return collection.get(0).getId().toString();
} else {
throw new BOSException("没有找到纳税单位归集信息");
}
}
protected synchronized MessageResult _saveStaffCollection(Context ctx, TaxUnitInfo taxUnit, String result) throws BOSException, ShrWebBizException {
MessageResult msg=null;
JSONObject object = JSONUtil.parseObj(result);
JSONObject head = object.getJSONObject("head");
Map headMap = (Map)object.get("head");
Map bodyMap = (Map)object.get("body");
if ("00000000".equals(head.getStr("code"))) {
System.out.println("_saveStaffCollection:start"+result);
List