package com.product.org.admin.service; import java.util.Date; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.alibaba.druid.util.StringUtils; import com.product.core.dao.BaseDao; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldMetaEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.exception.BaseException; import com.product.core.permission.PermissionService; import com.product.core.service.support.AbstractBaseService; import com.product.core.service.support.QueryFilterService; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.org.admin.config.CmnConst; /** * Copyright LX-BASE * * @Title: CostCenterService * @Project: LX-BASE-SERVER * @Date: 2020年10月09日 下午14:59:26 * @Author: * @Description:成本中心 */ @Component public class CostCenterService extends AbstractBaseService { @Autowired public BaseDao baseDao; @Autowired PermissionService permissionService; @Autowired QueryFilterService queryFilterService; /** * 成本中心详情 * @param fs * @return * @throws BaseException */ public FieldSetEntity findCenter(FieldSetEntity fs) throws BaseException { FieldSetEntity fss = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_COST_CENTER, fs.getString("uuid"), false); return baseDao.listInternationDataTable(fss, null); } /** * 成本中心列表 * @param fs * @return * @throws BaseException */ public DataTableEntity listCenter(FieldSetEntity fs) throws BaseException { String dataFilter=permissionService.getDataFilter(CmnConst.ORG_LEVEL_UUID) ; if(StringUtils.isEmpty(dataFilter)) { //杜洪波 2020-12-28 10:09:00 BUG更改(列表加载错误) dataFilter=""; } // 高级搜索 String filter = queryFilterService.getQueryFilter(fs); //杜洪波 2021-01-13 10:09:00 添加高级搜索 if (!StringUtils.isEmpty(filter)) { if (dataFilter.length() > 0) { dataFilter += " and " + filter; } else { dataFilter = " where " + filter; } } DataTableEntity dt=baseDao.listTable(CmnConst.PRODUCT_SYS_COST_CENTER, dataFilter, new String[] {}, null, null, fs.getInteger("pagesize"), fs.getInteger("cpage")); return baseDao.listInternationDataTable(dt, null); } /** * 成本中心删除 * @param fs * @return * @throws BaseException */ public boolean deleteCenter(FieldSetEntity fs) throws BaseException { return baseDao.delete(CmnConst.PRODUCT_SYS_COST_CENTER, "uuid=?", new String[] { fs.getString("uuid") }); } /** * 新增人员成本中心(一般在新建人员时调用) */ public String addStaffCostCenter(String staff_uuid, String cost_center_uuid, Object effective_start_date) throws BaseException { FieldSetEntity fs = new FieldSetEntity(); FieldMetaEntity fm = new FieldMetaEntity(); fm.setTableName(new Object[] { CmnConst.PRODUCT_SYS_STAFF_COST_CENTER }); fs.setMeta(fm); fs.setValue("staff_uuid", staff_uuid); fs.setValue("cost_center_uuid", cost_center_uuid); fs.setValue("effective_start_date", effective_start_date); fs.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id()); fs.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); return baseDao.add(fs); } /** * 修改人员成本中心 */ public boolean updateStaffCostCenter(String staff_uuid, String cost_center_uuid, Object effective_start_date)throws BaseException { FieldSetEntity fs = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_STAFF_COST_CENTER, "staff_uuid=?",new String[] { staff_uuid }, false); if (fs==null) { return true; } fs.setValue("cost_center_uuid", cost_center_uuid); fs.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id()); fs.setValue(CmnConst.UPDATED_UTC_DATETIME, effective_start_date); return baseDao.update(fs); } /** * 删除成本中心 * @param staff_uuid * @return * @throws BaseException */ public boolean deleteStaffCostCenter(String staff_uuid)throws BaseException{ return baseDao.delete("product_sys_staff_cost_center", "staff_uuid=?", new Object[] {staff_uuid}); } }