|
@@ -0,0 +1,628 @@
|
|
|
+package com.kingdee.shr.compensation.web.handler.timepiece.bill;
|
|
|
+
|
|
|
+
|
|
|
+import com.kingdee.bos.BOSException;
|
|
|
+import com.kingdee.bos.Context;
|
|
|
+import com.kingdee.bos.metadata.entity.EntityViewInfo;
|
|
|
+import com.kingdee.bos.metadata.entity.FilterInfo;
|
|
|
+import com.kingdee.bos.metadata.entity.FilterItemInfo;
|
|
|
+import com.kingdee.bos.metadata.entity.SelectorItemCollection;
|
|
|
+import com.kingdee.bos.metadata.entity.SelectorItemInfo;
|
|
|
+import com.kingdee.bos.metadata.query.util.CompareType;
|
|
|
+import com.kingdee.eas.common.EASBizException;
|
|
|
+import com.kingdee.eas.custom.calcdailypay.IInspectionRate;
|
|
|
+import com.kingdee.eas.custom.calcdailypay.InspectionRateCollection;
|
|
|
+import com.kingdee.eas.custom.calcdailypay.InspectionRateFactory;
|
|
|
+import com.kingdee.eas.custom.calcdailypay.InspectionRateInfo;
|
|
|
+import com.kingdee.eas.framework.CoreBaseCollection;
|
|
|
+import com.kingdee.eas.framework.CoreBaseInfo;
|
|
|
+import com.kingdee.eas.util.ToolUtils;
|
|
|
+import com.kingdee.eas.util.app.DbUtil;
|
|
|
+import com.kingdee.jdbc.rowset.IRowSet;
|
|
|
+import com.kingdee.shr.base.syssetting.context.SHRContext;
|
|
|
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
|
|
|
+import com.kingdee.shr.compensation.app.integrate.*;
|
|
|
+import com.kingdee.shr.compensation.exception.ExceptionHandle;
|
|
|
+import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 提报单拓展
|
|
|
+ * @author coyle
|
|
|
+ * 20250520
|
|
|
+ */
|
|
|
+public class TimepieceSchemeBillEditHandlerEx extends TimepieceSchemeBillEditHandler {
|
|
|
+
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(TimepieceSchemeBillEditHandlerEx.class);
|
|
|
+ private static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ //完成率
|
|
|
+ private static String COMRATE = "MQ005";
|
|
|
+ //岗位类型
|
|
|
+ private static String JOBTYPE = "MQ004";
|
|
|
+ //技能等级 SKILLLEVEL
|
|
|
+ private static String SKILLLEVEL = "MQ003";
|
|
|
+ //是否现场作业 On site
|
|
|
+ private static String ONSITE = "MQ007";
|
|
|
+ //班组任职 Team app
|
|
|
+ private static String TEAMAPP = "MQ007";
|
|
|
+ //工资序列 Salary seq
|
|
|
+ private static String SALARYSEQ = "MQ007";
|
|
|
+
|
|
|
+ private static String[] ITEMNUMS = {COMRATE,JOBTYPE,SKILLLEVEL,ONSITE,TEAMAPP,SALARYSEQ};
|
|
|
+
|
|
|
+ private static Map<String,String> FEILDS = new HashMap();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public TimepieceSchemeBillEditHandlerEx() throws BOSException {
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ CalSubmitItemCollection subColl = CalSubmitItemFactory.getLocalInstance(ctx)
|
|
|
+ .getCalSubmitItemCollection("SELECT ID,FieldSn,number where number in (" + ToolUtils.aryToStr(ITEMNUMS) + ")");
|
|
|
+ if (subColl != null && subColl.size() > 0) {
|
|
|
+ for (int i =0 ;i<subColl.size();i++) {
|
|
|
+ CalSubmitItemInfo itemInfo = subColl.get(i);
|
|
|
+ if (itemInfo != null) {
|
|
|
+ String columnName = "S" + itemInfo.getFieldSn();
|
|
|
+ FEILDS.put(itemInfo.getNumber() , columnName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ protected void beforeSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model)
|
|
|
+ throws SHRWebException {
|
|
|
+ super.beforeSave(request, response, model);
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ BatchSubmitShemeBillInfo info = (BatchSubmitShemeBillInfo) model;
|
|
|
+ BatchSubmitShemeBillEntryCollection entry = info.getEntry();
|
|
|
+ String billId = "";
|
|
|
+ if(ObjectUtils.allNotNull(info.getId())) {
|
|
|
+ billId = info.getId().toString();
|
|
|
+ }
|
|
|
+ //拉取mes点检率数据
|
|
|
+ exeDataOnDay( request,billId,entry);
|
|
|
+ //先重置点检率标识
|
|
|
+ reductionInspectionRate( ctx, info);
|
|
|
+ //更新点检率数据
|
|
|
+ updateInspectionRate(request, ctx, info);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从中间表获取mes数据
|
|
|
+ */
|
|
|
+ private HashMap<String,HashMap> getMesData(HttpServletRequest request,Context ctx ,HashSet<String> selectPerson,DateRange dateRange) {
|
|
|
+ HashMap<String,HashMap> checkMap = new HashMap();
|
|
|
+ Set<String> checkbillIds = new HashSet();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ try {
|
|
|
+ String sql = " select fid ,CFComrate, cfpersonId, cfpositiontype , cfskillLevel , cfonSite , cfteamApp , cfsalarysEq ,"
|
|
|
+ + " cfbizDate "
|
|
|
+ + " from CT_CAL_InspectionRate where cfpersonid in "
|
|
|
+ + "( "
|
|
|
+ + ToolUtils.aryToStr(selectPerson,true)
|
|
|
+ + " ) "
|
|
|
+ + " and cfbizDate >= '"
|
|
|
+ + dateFormat.format(dateRange.getMinDate())
|
|
|
+ + "' and cfbizDate <= '"
|
|
|
+ + dateFormat.format(dateRange.getMaxDate())
|
|
|
+ +"'" ;
|
|
|
+
|
|
|
+ IRowSet rst = DbUtil.executeQuery(ctx, sql);
|
|
|
+ while( rst.next() ) {
|
|
|
+ //点检率id存入
|
|
|
+ String checkbillId = rst.getString("fid");
|
|
|
+ checkbillIds.add(checkbillId);
|
|
|
+ String pId = rst.getString("cfPersonId");
|
|
|
+ Date bizDate = rst.getDate("cfbizDate");
|
|
|
+ String eDate = SDF.format(bizDate);
|
|
|
+ String key = pId+"_"+eDate;
|
|
|
+ HashMap<String,String> valMap = new HashMap();
|
|
|
+ BigDecimal comrate = rst.getBigDecimal("CFComrate");
|
|
|
+ valMap.put(FEILDS.get(COMRATE), comrate.toString());
|
|
|
+ //
|
|
|
+ valMap.put(FEILDS.get(JOBTYPE), rst.getString("cfpositiontype"));
|
|
|
+ valMap.put(FEILDS.get(SKILLLEVEL), rst.getString("cfskillLevel"));
|
|
|
+ valMap.put(FEILDS.get(ONSITE), rst.getString("cfonSite"));
|
|
|
+ valMap.put(FEILDS.get(TEAMAPP), rst.getString("cfteamApp"));
|
|
|
+ valMap.put(FEILDS.get(SALARYSEQ), rst.getString("cfsalarysEq"));
|
|
|
+ checkMap.put(key, valMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ request.setAttribute("checkbillIds", checkbillIds);
|
|
|
+ }catch(BOSException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return checkMap;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据处理
|
|
|
+ * 校验对应的某一天已存在数据/mes数据获取等
|
|
|
+ * @param billId
|
|
|
+ * @param entrys
|
|
|
+ * @throws SHRWebException
|
|
|
+ */
|
|
|
+ public void exeDataOnDay(HttpServletRequest request,String billId,BatchSubmitShemeBillEntryCollection entrys) throws SHRWebException {
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ Map<String, Set<String>> personDateMap = new HashMap<>();
|
|
|
+ //
|
|
|
+ HashSet<String> selectPerson = new HashSet();
|
|
|
+ HashSet<String> selectDate = new HashSet();
|
|
|
+ for (int i = 0; i < entrys.size(); i++) {
|
|
|
+ BatchSubmitShemeBillEntryInfo entry = entrys.get(i);
|
|
|
+ String personId = entry.getPerson().getId().toString();
|
|
|
+ selectPerson.add(personId);
|
|
|
+ Date effectDate = entry.getEffectDate();
|
|
|
+ // 增加对 effectDate 为 null 的检查
|
|
|
+ if (effectDate == null) {
|
|
|
+ throw new IllegalArgumentException("分录中发生日期不能为空,请检查");
|
|
|
+ }
|
|
|
+ String formattedEffectDate = SDF.format(effectDate);
|
|
|
+ selectDate.add(formattedEffectDate);
|
|
|
+ // 使用 computeIfAbsent 减少冗余代码,并增加重复检查
|
|
|
+ personDateMap.computeIfAbsent(personId, k -> new HashSet<>());
|
|
|
+ if (!personDateMap.get(personId).add(formattedEffectDate)) {
|
|
|
+ // 如果 add 方法返回 false,说明该日期已经存在,抛出异常
|
|
|
+ throw new IllegalArgumentException("分录中" + entry.getPerson().getName() + ",有当日重复提报的数据,请检查");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (personDateMap.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 找出最大日期与最小日期
|
|
|
+ DateRange dateRange = findMinMaxDate(selectDate);
|
|
|
+ //校验重复
|
|
|
+ verifiOneData(ctx, billId, selectPerson, dateRange, personDateMap);
|
|
|
+ //校验完后进行mes数据填充;
|
|
|
+ //获取mes数据
|
|
|
+ HashMap<String, HashMap> mesData = getMesData(request,ctx, selectPerson, dateRange);
|
|
|
+ setMesData( request, entrys, mesData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验当天是否有重复数据
|
|
|
+ * @param ctx
|
|
|
+ * @param billId
|
|
|
+ * @param selectPerson
|
|
|
+ * @param dateRange
|
|
|
+ * @param personDateMap
|
|
|
+ * @throws SHRWebException
|
|
|
+ */
|
|
|
+ public void verifiOneData(Context ctx ,String billId,HashSet<String> selectPerson,DateRange dateRange,Map<String, Set<String>> personDateMap) throws SHRWebException {
|
|
|
+ HashMap<String,String> dataMap = new HashMap();
|
|
|
+ try {
|
|
|
+ IBatchSubmitShemeBillEntry entryIns = BatchSubmitShemeBillEntryFactory.getLocalInstance(ctx);
|
|
|
+ FilterInfo filter = new FilterInfo();
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("person", selectPerson, CompareType.INCLUDE));
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("bill.id", billId , CompareType.NOTEQUALS ));
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMaxDate() , CompareType.LESS_EQUALS));
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMinDate() , CompareType.GREATER_EQUALS ));
|
|
|
+ EntityViewInfo viewInfo = new EntityViewInfo();
|
|
|
+ SelectorItemCollection selector = viewInfo.getSelector();
|
|
|
+ selector.add(new SelectorItemInfo("person.id"));
|
|
|
+ selector.add(new SelectorItemInfo("person.name"));
|
|
|
+ selector.add(new SelectorItemInfo("bill.number"));
|
|
|
+ selector.add(new SelectorItemInfo("effectDate"));
|
|
|
+ viewInfo.setFilter(filter);
|
|
|
+ BatchSubmitShemeBillEntryCollection entryCol = entryIns.getBatchSubmitShemeBillEntryCollection(viewInfo);
|
|
|
+ for(int i = 0;i<entryCol.size();i++) {
|
|
|
+ BatchSubmitShemeBillEntryInfo entryInfo = entryCol.get(i);
|
|
|
+ Date effectDate = entryInfo.getEffectDate();
|
|
|
+ String personId = entryInfo.getPerson().getId().toString();
|
|
|
+ Set<String> pAndDate = personDateMap.get(personId);
|
|
|
+ if(pAndDate.contains(SDF.format(effectDate))) {
|
|
|
+ String personName = entryInfo.getPerson().getName().toString();
|
|
|
+ BatchSubmitShemeBillInfo billInfo = entryInfo.getBill();
|
|
|
+ String billNo = billInfo.getNumber();
|
|
|
+ dataMap.put(personName, billNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (BOSException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //如果dataMap不为空则循环dataMap的数据组成字符串并抛出异常,"存在哪些人,单据编码为:****"
|
|
|
+ if(!dataMap.isEmpty()) {
|
|
|
+ String errorMsg = "存在以下当日重复提报人员,姓名与单据编码为:";
|
|
|
+ for(String personName : dataMap.keySet()) {
|
|
|
+ String billNo = dataMap.get(personName);
|
|
|
+ errorMsg += personName + ":" + billNo + " ";
|
|
|
+ }
|
|
|
+ throw new SHRWebException(errorMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置点检率数据
|
|
|
+ * @param request
|
|
|
+ * @param entrys
|
|
|
+ */
|
|
|
+ public void setMesData(HttpServletRequest request, BatchSubmitShemeBillEntryCollection entrys,
|
|
|
+ HashMap<String, HashMap> mesData) {
|
|
|
+ int assignedRows = 0; // 新增:统计实际赋值的行数
|
|
|
+
|
|
|
+ for (int i = 0; i < entrys.size(); i++) {
|
|
|
+ BatchSubmitShemeBillEntryInfo entry = entrys.get(i);
|
|
|
+ String pId = entry.getPerson().getId().toString();
|
|
|
+ Date effectDate = entry.getEffectDate();
|
|
|
+ String eDate = SDF.format(effectDate);
|
|
|
+ String key = pId + "_" + eDate;
|
|
|
+ HashMap valMap = mesData.get(key);
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(valMap)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean isRowAssigned = false; // 标记当前行是否被赋值
|
|
|
+ for (String field : FEILDS.keySet()) {
|
|
|
+ String sVal = FEILDS.get(field);
|
|
|
+ if (entry.containsKey(sVal)) {
|
|
|
+ entry.put(sVal, valMap.get(sVal));
|
|
|
+ isRowAssigned = true; // 当前行至少有一个字段被赋值
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isRowAssigned) {
|
|
|
+ assignedRows++; // 只有实际赋值的行才计数
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将统计结果存入 request
|
|
|
+ request.setAttribute("assignedRowsCount", assignedRows);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * handler校验,先不启用
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param modelMap
|
|
|
+ * @throws SHRWebException
|
|
|
+ */
|
|
|
+ public void hasDataOnDayAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap)
|
|
|
+ throws SHRWebException {
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ // 获取人员 //格式为[pseron1:2025-04-03,person2:2025-04-03],需要转为map
|
|
|
+ String proposers = request.getParameter("proposers");
|
|
|
+ if (proposers == null || proposers.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] personArr = proposers.split(",");
|
|
|
+ HashSet<String> selectPerson = new HashSet();
|
|
|
+ HashSet<String> selectData = new HashSet();
|
|
|
+ Map<String, Set<String>> personDateMap = new HashMap<>();
|
|
|
+ for (int i = 0; i< personArr.length;i++) {
|
|
|
+ String personIds = personArr[i];
|
|
|
+ String[] parts = personIds.split(":");
|
|
|
+ if (parts.length == 2) {
|
|
|
+ String personId = parts[0].trim();
|
|
|
+ String date = parts[1].trim();
|
|
|
+ selectPerson.add(personId);
|
|
|
+ selectData.add(date);
|
|
|
+ personDateMap.computeIfAbsent(personId, k -> new HashSet<>()).add(date);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (personDateMap.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String,String> dataMap = new HashMap();
|
|
|
+
|
|
|
+ // 找出最大日期与最小日期
|
|
|
+ DateRange dateRange = findMinMaxDate(selectData);
|
|
|
+ IBatchSubmitShemeBillEntry entryIns;
|
|
|
+ try {
|
|
|
+ entryIns = BatchSubmitShemeBillEntryFactory.getLocalInstance(ctx);
|
|
|
+ FilterInfo filter = new FilterInfo();
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("proposer", selectPerson, CompareType.INCLUDE));
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMaxDate() , CompareType.LESS_EQUALS));
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMinDate() , CompareType.GREATER_EQUALS ));
|
|
|
+ EntityViewInfo viewInfo = new EntityViewInfo();
|
|
|
+ viewInfo.setFilter(filter);
|
|
|
+ BatchSubmitShemeBillEntryCollection entryCol = entryIns.getBatchSubmitShemeBillEntryCollection(viewInfo);
|
|
|
+ for(int i = 0;i<entryCol.size();i++) {
|
|
|
+ BatchSubmitShemeBillEntryInfo entryInfo = entryCol.get(i);
|
|
|
+ Date effectDate = entryInfo.getEffectDate();
|
|
|
+ String personId = entryInfo.getPerson().getId().toString();
|
|
|
+ Set<String> pAndDate = personDateMap.get(personId);
|
|
|
+ if(pAndDate.contains(SDF.format(effectDate))) {
|
|
|
+ String personName = entryInfo.getPerson().getName().toString();
|
|
|
+ BatchSubmitShemeBillInfo billInfo = entryInfo.getBill();
|
|
|
+ String billNo = billInfo.getNumber();
|
|
|
+ dataMap.put(personName, billNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (BOSException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Map resultMap = new HashMap();
|
|
|
+ JSONUtils.SUCCESS( resultMap );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private DateRange findMinMaxDate(HashSet<String> subDate) {
|
|
|
+ if (subDate == null || subDate.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Date> dates = new ArrayList<>();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ for (String dateString : subDate) {
|
|
|
+ try {
|
|
|
+ dates.add(dateFormat.parse(dateString.trim()));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // 处理日期格式不正确的情况
|
|
|
+ e.printStackTrace();
|
|
|
+ return null; // 如果有日期格式不正确,直接返回 null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dates.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Date minDate = Collections.min(dates);
|
|
|
+ Date maxDate = Collections.max(dates);
|
|
|
+
|
|
|
+ return new DateRange(minDate, maxDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义一个辅助类来存储日期范围
|
|
|
+ private static class DateRange {
|
|
|
+ private final Date minDate;
|
|
|
+ private final Date maxDate;
|
|
|
+
|
|
|
+ public DateRange(Date minDate, Date maxDate) {
|
|
|
+ this.minDate = minDate;
|
|
|
+ this.maxDate = maxDate;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Date getMinDate() {
|
|
|
+ return minDate;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Date getMaxDate() {
|
|
|
+ return maxDate;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ protected void afterSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model)
|
|
|
+ throws SHRWebException {
|
|
|
+ super.afterSave(request, response, model);
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ BatchSubmitShemeBillInfo info = (BatchSubmitShemeBillInfo) model;
|
|
|
+ BatchSubmitShemeBillEntryCollection entry = info.getEntry();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新点检率
|
|
|
+ * @param request
|
|
|
+ * @param ctx
|
|
|
+ * @param info
|
|
|
+ */
|
|
|
+ private static void updateInspectionRate(HttpServletRequest request, Context ctx, BatchSubmitShemeBillInfo info) {
|
|
|
+ //更新点检率数据
|
|
|
+ Set<String> checkbillIds = (Set<String> ) request.getAttribute("checkbillIds");
|
|
|
+ FilterInfo filter = new FilterInfo();
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("id", checkbillIds, CompareType.INCLUDE));
|
|
|
+ EntityViewInfo viewInfo = new EntityViewInfo( ) ;
|
|
|
+ viewInfo.setFilter(filter);
|
|
|
+ SelectorItemCollection selector = viewInfo.getSelector();
|
|
|
+ selector.add(new SelectorItemInfo("detailNum"));
|
|
|
+ selector.add(new SelectorItemInfo("isSubDetail"));
|
|
|
+ try {
|
|
|
+ IInspectionRate spIns = InspectionRateFactory.getLocalInstance(ctx);
|
|
|
+ InspectionRateCollection inspectionRateCollection = spIns.getInspectionRateCollection(viewInfo);
|
|
|
+ CoreBaseCollection cCol = new CoreBaseCollection();
|
|
|
+ for(int i = 0;i<inspectionRateCollection.size();i++){
|
|
|
+ InspectionRateInfo inspectionRateInfo = inspectionRateCollection.get(i);
|
|
|
+ inspectionRateInfo.setDetailNum(info.getNumber());
|
|
|
+ inspectionRateInfo.setIsSubDetail(true);
|
|
|
+ cCol.add(inspectionRateInfo);
|
|
|
+ }
|
|
|
+ spIns.updateBatchData(cCol);
|
|
|
+ } catch (BOSException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (EASBizException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// public void getDataOnDay(String billId,BatchSubmitShemeBillEntryCollection entrys) throws SHRWebException {
|
|
|
+// Context ctx = SHRContext.getInstance().getContext();
|
|
|
+// Map<String, Set<String>> personDateMap = new HashMap<>();
|
|
|
+// //
|
|
|
+// HashSet<String> selectPerson = new HashSet();
|
|
|
+// HashSet<String> selectDate = new HashSet();
|
|
|
+// for (int i = 0; i < entrys.size(); i++) {
|
|
|
+// BatchSubmitShemeBillEntryInfo entry = entrys.get(i);
|
|
|
+// String personId = entry.getPerson().getId().toString();
|
|
|
+// selectPerson.add(personId);
|
|
|
+// Date effectDate = entry.getEffectDate();
|
|
|
+//
|
|
|
+// String formattedEffectDate = SDF.format(effectDate);
|
|
|
+// selectDate.add(formattedEffectDate);
|
|
|
+// // 使用 computeIfAbsent 减少冗余代码,并增加重复检查
|
|
|
+// personDateMap.computeIfAbsent(personId, k -> new HashSet<>());
|
|
|
+// if (!personDateMap.get(personId).add(formattedEffectDate)) {
|
|
|
+// // 如果 add 方法返回 false,说明该日期已经存在,抛出异常
|
|
|
+// throw new IllegalArgumentException("分录中" + entry.getPerson().getName() + ",有当日重复提报的数据,请检查");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (personDateMap.isEmpty()) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 找出最大日期与最小日期
|
|
|
+// DateRange dateRange = findMinMaxDate(selectDate);
|
|
|
+// //校验重复
|
|
|
+// verifiOneData(ctx, billId, selectPerson, dateRange, personDateMap);
|
|
|
+// //获取mes数据
|
|
|
+// HashMap<String, HashMap> mesData = getMesData(ctx, selectPerson, dateRange);
|
|
|
+// setMesData(ctx, billId, entrys, mesData);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ public String saveAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap)
|
|
|
+ throws SHRWebException {
|
|
|
+ try {
|
|
|
+ BatchSubmitShemeBillInfo model = (BatchSubmitShemeBillInfo) request.getAttribute("dynamic_model");
|
|
|
+ this.doFieldPermFilterSave(request, model);
|
|
|
+ this.doSave(request, response, model);
|
|
|
+ this.afterSave(request, response, model);
|
|
|
+ this.saveAttachment(request, response, model);
|
|
|
+ Object responseData = this.generateResponseDataAfterSave(request, response, model);
|
|
|
+ Map resultMap = new HashMap();
|
|
|
+ resultMap.put("responseData", responseData);
|
|
|
+ resultMap.put("assignedRowsCount", request.getAttribute("assignedRowsCount"));
|
|
|
+ this.writeSuccessData(resultMap);
|
|
|
+ } catch (Exception var6) {
|
|
|
+ ExceptionHandle.handleException(var6);
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重置点检率标识
|
|
|
+ * 将点检率中是否提报标记还原为false;
|
|
|
+ * @param ctx
|
|
|
+ * @param info
|
|
|
+ */
|
|
|
+ private static void reductionInspectionRate(Context ctx, BatchSubmitShemeBillInfo info) {
|
|
|
+ //更新点检率数据
|
|
|
+ String subNum = info.getNumber();
|
|
|
+ if(StringUtils.isEmpty(subNum)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FilterInfo filter = new FilterInfo();
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("detailNum", subNum, CompareType.EQUALS));
|
|
|
+ EntityViewInfo viewInfo = new EntityViewInfo( ) ;
|
|
|
+ viewInfo.setFilter(filter);
|
|
|
+ SelectorItemCollection selector = viewInfo.getSelector();
|
|
|
+ selector.add(new SelectorItemInfo("detailNum"));
|
|
|
+ selector.add(new SelectorItemInfo("isSubDetail"));
|
|
|
+ try {
|
|
|
+ IInspectionRate spIns = InspectionRateFactory.getLocalInstance(ctx);
|
|
|
+ InspectionRateCollection inspectionRateCollection = spIns.getInspectionRateCollection(viewInfo);
|
|
|
+ CoreBaseCollection cCol = new CoreBaseCollection();
|
|
|
+ for(int i = 0;i<inspectionRateCollection.size();i++){
|
|
|
+ InspectionRateInfo inspectionRateInfo = inspectionRateCollection.get(i);
|
|
|
+ inspectionRateInfo.setDetailNum("");
|
|
|
+ inspectionRateInfo.setIsSubDetail(false);
|
|
|
+ cCol.add(inspectionRateInfo);
|
|
|
+ }
|
|
|
+ spIns.updateBatchData(cCol);
|
|
|
+ } catch (BOSException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } catch (EASBizException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除单据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String deleteAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
|
|
|
+ String returnStr = super.deleteAction(request, response, modelMap);
|
|
|
+ reductionAllInsRate(request);
|
|
|
+ return returnStr ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重置所有点检率
|
|
|
+ * @param request
|
|
|
+ * @throws SHRWebException
|
|
|
+ */
|
|
|
+ private void reductionAllInsRate (HttpServletRequest request) throws SHRWebException {
|
|
|
+ String billId = getBillId(request);
|
|
|
+ String[] ids = billId.split(",");
|
|
|
+ //ids转为list集合
|
|
|
+ List<String> idList = Arrays.asList(ids);
|
|
|
+
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ FilterInfo filter = new FilterInfo();
|
|
|
+ filter.getFilterItems().add(new FilterItemInfo("id", ToolUtils.aryToStr(idList,false), CompareType.INCLUDE));
|
|
|
+ EntityViewInfo viewInfo = new EntityViewInfo( ) ;
|
|
|
+ viewInfo.setFilter(filter);
|
|
|
+ SelectorItemCollection selector = viewInfo.getSelector();
|
|
|
+ selector.add(new SelectorItemInfo("number"));
|
|
|
+ try {
|
|
|
+ IBatchSubmitShemeBill subIns = BatchSubmitShemeBillFactory.getLocalInstance(ctx);
|
|
|
+ BatchSubmitShemeBillCollection subCol = subIns.getBatchSubmitShemeBillCollection(viewInfo);
|
|
|
+ for(int i = 0;i<subCol.size();i++){
|
|
|
+ BatchSubmitShemeBillInfo subInfo = subCol.get(i);
|
|
|
+ reductionInspectionRate(ctx, subInfo);
|
|
|
+ }
|
|
|
+ } catch (BOSException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|