|  | @@ -186,6 +186,12 @@ public class MaterialUpdateApi {
 | 
	
		
			
				|  |  |              List<Map> mapEntrys = (List<Map>) newDatas.get("pznm_materialzm");
 | 
	
		
			
				|  |  |              initMaterialZMByMaterial(mapEntrys, resultData, material);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //财务信息
 | 
	
		
			
				|  |  | +        if (newDatas.get("pznm_materialfinance") != null) {
 | 
	
		
			
				|  |  | +            List<Map> mapEntrys = (List<Map>) newDatas.get("pznm_materialfinance");
 | 
	
		
			
				|  |  | +            initMaterialFinanceByMaterial(mapEntrys, resultData, material);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void initMaterialBizInfoByMaterial(List<Map> mapEntrys, Map resultData,DynamicObject material,String bizInfoFormId) throws ParseException {
 | 
	
	
		
			
				|  | @@ -419,16 +425,17 @@ public class MaterialUpdateApi {
 | 
	
		
			
				|  |  |                  WebApiUtils.setDateField(true, "modifytime", "modifytime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  |                  //修改人
 | 
	
		
			
				|  |  |                  WebApiUtils.setDynamicField(true,"modifier_number","pznm_modifier_xh","bos_user",  mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | -                //来源系统id
 | 
	
		
			
				|  |  | -                WebApiUtils.setTextField(true,"pznm_sourcesysid","pznm_sourcesysid",mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                  //审核人
 | 
	
		
			
				|  |  |                  //WebApiUtils.setDynamicField(true, "auditor_number", "auditor", "bos_user", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  |                  //审核时间
 | 
	
		
			
				|  |  |                  //WebApiUtils.setDateField(true, "audittime", "audittime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  //使用状态
 | 
	
		
			
				|  |  | -                WebApiUtils.setTextField(true, "enable", "enable", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //WebApiUtils.setTextField(true, "enable", "enable", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                //来源系统id
 | 
	
		
			
				|  |  | +                WebApiUtils.setTextField(true,"pznm_sourcesysid","pznm_sourcesysid",mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  update_entrys.add(materialBizInfo);
 | 
	
		
			
				|  |  |              }else{
 | 
	
	
		
			
				|  | @@ -511,6 +518,132 @@ public class MaterialUpdateApi {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    public void initMaterialFinanceByMaterial(List<Map> mapEntrys, Map resultData,DynamicObject material) throws ParseException {
 | 
	
		
			
				|  |  | +        logger.info("initMaterialFinanceByMaterial, materialList size:" + mapEntrys.size());
 | 
	
		
			
				|  |  | +        List<String> createOrgs = (List)mapEntrys.stream().map((m) -> {
 | 
	
		
			
				|  |  | +            return m.get("pznm_fiet_org_number");
 | 
	
		
			
				|  |  | +        }).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<String> selectFields =BusinessDataServiceHelper.newDynamicObject("pznm_materialfinance").getDataEntityType().getProperties().stream().map(IMetadata:: getName).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        QFilter materialfilter=new QFilter("pznm_material",QCP.equals,material.getPkValue());
 | 
	
		
			
				|  |  | +        QFilter orgfilter=new QFilter("pznm_fiet_org.number",QCP.in,createOrgs);
 | 
	
		
			
				|  |  | +        DynamicObject[] findbizInfoForm=BusinessDataServiceHelper.load("pznm_materialfinance", StringUtils.join(selectFields.toArray(), ','),new QFilter[]{materialfilter,orgfilter});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //查询过滤条件,缓存存在的字码Map记录
 | 
	
		
			
				|  |  | +        Map isHaveOrgs_number = new HashMap();
 | 
	
		
			
				|  |  | +        for(DynamicObject obj : findbizInfoForm){
 | 
	
		
			
				|  |  | +            DynamicObject org =  obj.getDynamicObject("pznm_fiet_org");
 | 
	
		
			
				|  |  | +            isHaveOrgs_number.put(org.getString("number"),obj);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //区分并拼接需更新和新增的记录
 | 
	
		
			
				|  |  | +        DynamicObjectCollection add_entrys = new DynamicObjectCollection();
 | 
	
		
			
				|  |  | +        DynamicObjectCollection update_entrys = new DynamicObjectCollection();
 | 
	
		
			
				|  |  | +        for(Map mapEntry : mapEntrys){
 | 
	
		
			
				|  |  | +            String orgNum = mapEntry.get("pznm_fiet_org_number").toString();
 | 
	
		
			
				|  |  | +            if(isHaveOrgs_number.get(orgNum)!=null && !"".equals(isHaveOrgs_number.get(orgNum))) {
 | 
	
		
			
				|  |  | +                //已存在,缓存修改对象
 | 
	
		
			
				|  |  | +                DynamicObject materialBizInfo = (DynamicObject) isHaveOrgs_number.get(orgNum);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //创建人
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "creator_number", "creator", "bos_user", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //创建时间
 | 
	
		
			
				|  |  | +                WebApiUtils.setDateField(true, "createtime", "createtime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //修改人
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "modifier_number", "modifier", "bos_user", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //修改时间
 | 
	
		
			
				|  |  | +                WebApiUtils.setDateField(true, "modifytime", "modifytime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //修改人
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true,"modifier_number","pznm_modifier_xh","bos_user",  mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //进项税
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "pznm_inputtaxrate_number", "pznm_inputtaxrate", "bd_taxrate", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //销项税
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "pznm_outputtaxrate_number", "pznm_outputtaxrate", "bd_taxrate", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //审核人
 | 
	
		
			
				|  |  | +                //WebApiUtils.setDynamicField(true, "auditor_number", "auditor", "bos_user", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //审核时间
 | 
	
		
			
				|  |  | +                //WebApiUtils.setDateField(true, "audittime", "audittime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //使用状态
 | 
	
		
			
				|  |  | +                //WebApiUtils.setTextField(true, "enable", "enable", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                update_entrys.add(materialBizInfo);
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                //不存在,缓存新增对象
 | 
	
		
			
				|  |  | +                DynamicObject materialBizInfo = BusinessDataServiceHelper.newDynamicObject("pznm_materialfinance");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //materialBizInfo.set("masterid", material);
 | 
	
		
			
				|  |  | +                materialBizInfo.set("pznm_material", material);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                materialBizInfo.set("status", StatusEnum.SAVE.getCode());
 | 
	
		
			
				|  |  | +                materialBizInfo.set("enable", EnableEnum.ENABLE.getCode());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //创建人
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "creator_number", "creator", "bos_user", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //创建时间
 | 
	
		
			
				|  |  | +                WebApiUtils.setDateField(true, "createtime", "createtime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //修改人
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "modifier_number", "modifier", "bos_user", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //修改时间
 | 
	
		
			
				|  |  | +                WebApiUtils.setDateField(true, "modifytime", "modifytime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //修改人
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true,"modifier_number","pznm_modifier_xh","bos_user",  mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //进项税
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "pznm_inputtaxrate_number", "pznm_inputtaxrate", "bd_taxrate", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //销项税
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "pznm_outputtaxrate_number", "pznm_outputtaxrate", "bd_taxrate", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //审核人
 | 
	
		
			
				|  |  | +                //WebApiUtils.setDynamicField(true, "auditor_number", "auditor", "bos_user", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //审核时间
 | 
	
		
			
				|  |  | +                // WebApiUtils.setDateField(true, "audittime", "audittime", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //创建组织
 | 
	
		
			
				|  |  | +                WebApiUtils.setDynamicField(true, "pznm_fiet_org_number", "pznm_fiet_org", "bos_org", mapEntry, resultData, materialBizInfo);
 | 
	
		
			
				|  |  | +                //数据状态
 | 
	
		
			
				|  |  | +                materialBizInfo.set("status","A");
 | 
	
		
			
				|  |  | +                //使用状态
 | 
	
		
			
				|  |  | +                materialBizInfo.set("enable","1");
 | 
	
		
			
				|  |  | +                add_entrys.add(materialBizInfo);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        DynamicObject[] real_update_entrys = new DynamicObject[update_entrys.size()];
 | 
	
		
			
				|  |  | +        for(int i=0;i< update_entrys.size();i++){
 | 
	
		
			
				|  |  | +            real_update_entrys[i] = update_entrys.get(i);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        DynamicObject[] real_add_entrys = new DynamicObject[add_entrys.size()];
 | 
	
		
			
				|  |  | +        for(int i=0;i< add_entrys.size();i++){
 | 
	
		
			
				|  |  | +            real_add_entrys[i] = add_entrys.get(i);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if(resultData.get("errors")==null || "".equals(resultData.get("errors"))){
 | 
	
		
			
				|  |  | +            //执行更新
 | 
	
		
			
				|  |  | +            if (real_update_entrys.length > 0) {
 | 
	
		
			
				|  |  | +                SaveServiceHelper.update(real_update_entrys);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //执行新增
 | 
	
		
			
				|  |  | +            if (real_add_entrys.length > 0) {
 | 
	
		
			
				|  |  | +                OperateOption option=OperateOption.create();
 | 
	
		
			
				|  |  | +                //传入自定义参数
 | 
	
		
			
				|  |  | +                //设置该操作已经验权,无需再次验权
 | 
	
		
			
				|  |  | +                option.setVariableValue(OperateOptionConst.ISHASRIGHT,"true");
 | 
	
		
			
				|  |  | +                OperationResult result_submit = OperationServiceHelper.executeOperate("submit", "pznm_materialfinance",
 | 
	
		
			
				|  |  | +                        real_add_entrys, option);
 | 
	
		
			
				|  |  | +                if (result_submit.isSuccess()) {
 | 
	
		
			
				|  |  | +                    OperationResult result_audit = OperationServiceHelper.executeOperate("audit", "pznm_materialfinance",
 | 
	
		
			
				|  |  | +                            real_add_entrys, option);
 | 
	
		
			
				|  |  | +                    if (!result_audit.isSuccess()) {
 | 
	
		
			
				|  |  | +                        resultData.put("errors", "pznm_materialfinance"+"审核失败");
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    resultData.put("errors", "pznm_materialfinance"+"创建失败");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void doAddNew(Map resultData, DynamicObject material) {
 | 
	
		
			
				|  |  |          OperateOption option=OperateOption.create();
 | 
	
		
			
				|  |  |          //传入自定义参数
 | 
	
	
		
			
				|  | @@ -631,6 +764,8 @@ public class MaterialUpdateApi {
 | 
	
		
			
				|  |  |          WebApiUtils.setTextField(false, "description", "description", newDatas, resultData, material);
 | 
	
		
			
				|  |  |          //默认税率
 | 
	
		
			
				|  |  |          WebApiUtils.setDynamicField(false, "taxrate_number", "taxrate", "bd_taxrate", newDatas, resultData, material);
 | 
	
		
			
				|  |  | +        //税收分类编码
 | 
	
		
			
				|  |  | +        WebApiUtils.setDynamicField(false, "pznm_taxclasscode_number", "pznm_taxclasscode", "er_taxclasscode", newDatas, resultData, material);
 | 
	
		
			
				|  |  |          //启用辅助属性
 | 
	
		
			
				|  |  |          WebApiUtils.setBooleanField(true, "isuseauxpty", "isuseauxpty", true, newDatas, resultData, material);
 | 
	
		
			
				|  |  |          //开启辅助属性
 |