|
|
@ -7,11 +7,16 @@ import com.lzbi.asset.mapper.DcBaseAssetInfoMapper; |
|
|
|
import com.lzbi.bill.domain.DcBusiTargetInputMaster; |
|
|
|
import com.lzbi.bill.domain.DcBusiTargetInputSub; |
|
|
|
import com.lzbi.bill.mapper.DcBusiTargetInputMasterMapper; |
|
|
|
import com.lzbi.bill.mapper.DcBusiTargetInputSubMapper; |
|
|
|
import com.lzbi.common.core.domain.AjaxResult; |
|
|
|
import com.lzbi.common.utils.DateUtils; |
|
|
|
import com.lzbi.common.utils.SecurityUtils; |
|
|
|
import com.lzbi.draft.domain.DcBusiTargetAdjustDayMasterDao; |
|
|
|
import com.lzbi.draft.domain.DcBusiTargetDraftDaynew; |
|
|
|
import com.lzbi.draft.domain.req.ConfirmReq; |
|
|
|
import com.lzbi.draft.domain.req.ProductionDailySheetReq; |
|
|
|
import com.lzbi.draft.domain.vo.ProductionDailySheetVO; |
|
|
|
import com.lzbi.draft.mapper.DcBusiTargetDraftDaynewMapper; |
|
|
|
import com.lzbi.targetFolder.domain.DcBaseAssetTarget; |
|
|
|
import com.lzbi.targetFolder.mapper.DcBaseAssetTargetMapper; |
|
|
|
import org.apache.commons.collections4.IteratorUtils; |
|
|
@ -23,6 +28,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
@ -35,6 +41,9 @@ import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.locks.Lock; |
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -53,6 +62,14 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu |
|
|
|
@Resource |
|
|
|
private DcBaseAssetTargetMapper dcBaseAssetTargetMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private DcBusiTargetInputSubMapper dcBusiTargetInputSubMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private DcBusiTargetDraftDaynewMapper dcBusiTargetDraftDaynewMapper; |
|
|
|
|
|
|
|
private static final Lock lock = new ReentrantLock(); |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询指标录入单 |
|
|
|
* |
|
|
@ -64,6 +81,16 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu |
|
|
|
return baseMapper.selectDcBusiTargetInputMasterById(id); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public DcBusiTargetInputMaster selectDcBusiTargetInputMasterByBillNo(String billNo) { |
|
|
|
DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo); |
|
|
|
DcBusiTargetInputSub params = new DcBusiTargetInputSub(); |
|
|
|
params.setBillNoMaster(billNo); |
|
|
|
List<DcBusiTargetInputSub> subList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(params); |
|
|
|
master.setSubList(subList); |
|
|
|
return master; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询指标录入单列表 |
|
|
|
* |
|
|
@ -81,10 +108,14 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu |
|
|
|
* @param dcBusiTargetInputMaster 指标录入单 |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int insertDcBusiTargetInputMaster(DcBusiTargetInputMaster dcBusiTargetInputMaster) |
|
|
|
{ |
|
|
|
dcBusiTargetInputSubMapper.batchInsertDcBusiTargetInputSub(dcBusiTargetInputMaster.getSubList()); |
|
|
|
dcBusiTargetInputMaster.setCreatedTime(DateUtils.getNowDate()); |
|
|
|
dcBusiTargetInputMaster.setDeptId(SecurityUtils.getDeptId()); |
|
|
|
dcBusiTargetInputMaster.setUserId(SecurityUtils.getUserId()); |
|
|
|
dcBusiTargetInputMaster.setCreatedBy(SecurityUtils.getUsername()); |
|
|
|
return baseMapper.insertDcBusiTargetInputMaster(dcBusiTargetInputMaster); |
|
|
|
} |
|
|
|
|
|
|
@ -200,22 +231,26 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu |
|
|
|
Map<String, DcBaseAssetTarget> dcBaseAssetTargetMap = targetMap.get(name); |
|
|
|
List<List<String>> data = productionDailySheetReq.getData(); |
|
|
|
if (!CollectionUtils.isEmpty(data)) { |
|
|
|
Map<Integer, Integer> dayMap = new HashMap<>(); |
|
|
|
Map<String, Integer> dayMap = new HashMap<>(); |
|
|
|
boolean sign = false; |
|
|
|
for (int i = 0, leni = data.size(); i < leni; i++) { |
|
|
|
List<String> row = data.get(i); |
|
|
|
if ("日期".equals(row.get(0))) { |
|
|
|
Map<String, Integer> columnMap = new HashMap<>(); |
|
|
|
int lenj = row.size(); |
|
|
|
for (int j = 1; j < lenj; j++) { |
|
|
|
if (!columnMap.containsKey(row.get(j))) { |
|
|
|
columnMap.put(row.get(j), j); |
|
|
|
String column = row.get(j); |
|
|
|
if ("合计".equals(column)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
for (int j = 1; j <= 31 && j < lenj; j++) { |
|
|
|
String key = j + "日"; |
|
|
|
if (columnMap.containsKey(key) && !dayMap.containsKey(key)) { |
|
|
|
dayMap.put(j, columnMap.get(key)); |
|
|
|
if (Pattern.matches("\\d+[日]+", column)) { |
|
|
|
String day = column.substring(0, column.length() - 1); |
|
|
|
if (Integer.parseInt(day) > confirmReq.getDays()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (dayMap.containsKey(day)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
dayMap.put(day, j); |
|
|
|
} |
|
|
|
} |
|
|
|
sign = true; |
|
|
@ -232,16 +267,22 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu |
|
|
|
String v = row.get(index); |
|
|
|
if (StringUtils.isNotBlank(v)) { |
|
|
|
DcBusiTargetInputSub dcBusiTargetInputSub = new DcBusiTargetInputSub(); |
|
|
|
BeanUtils.copyProperties(dcBaseAssetTarget, dcBusiTargetInputSub); |
|
|
|
dcBusiTargetInputSub.setTargetCode(dcBaseAssetTarget.getTargetCode()); |
|
|
|
dcBusiTargetInputSub.setTargetName(dcBaseAssetTarget.getTargetName()); |
|
|
|
dcBusiTargetInputSub.setTagetUnit(dcBaseAssetTarget.getFieldUnit()); |
|
|
|
dcBusiTargetInputSub.setFieldCode(dcBaseAssetTarget.getFieldCode()); |
|
|
|
dcBusiTargetInputSub.setFieldName(dcBaseAssetTarget.getFieldName()); |
|
|
|
dcBusiTargetInputSub.setAssetCode(dcBaseAssetInfo.getAssetCode()); |
|
|
|
dcBusiTargetInputSub.setAssetName(dcBaseAssetInfo.getAssetName()); |
|
|
|
dcBusiTargetInputSub.setAssetNameAlias(dcBaseAssetInfo.getAssetNameAlias()); |
|
|
|
dcBusiTargetInputSub.setCompanyId(dcBaseAssetInfo.getComanyId()); |
|
|
|
dcBusiTargetInputSub.setOragnizeId(dcBaseAssetInfo.getOrgId()); |
|
|
|
// dcBusiTargetInputSub.setCompanyName();
|
|
|
|
// dcBusiTargetInputSub.setOrganizeName();
|
|
|
|
dcBusiTargetInputSub.setCompanyName(dcBaseAssetInfo.getComanyName()); |
|
|
|
dcBusiTargetInputSub.setOrganizeName(dcBaseAssetInfo.getOrgName()); |
|
|
|
dcBusiTargetInputSub.setTagetUnit(dcBaseAssetTarget.getFieldUnit()); |
|
|
|
dcBusiTargetInputSub.setDay(String.valueOf(day)); |
|
|
|
dcBusiTargetInputSub.setValResult(new BigDecimal(v)); |
|
|
|
dcBusiTargetInputSub.setBillNoMaster(confirmReq.getBillNo()); |
|
|
|
result.add(dcBusiTargetInputSub); |
|
|
|
} |
|
|
|
}); |
|
|
@ -252,4 +293,139 @@ public class DcBusiTargetInputMasterService extends ServiceImpl<DcBusiTargetInpu |
|
|
|
} |
|
|
|
return AjaxResult.success(result); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int checkBack(String billNo) { |
|
|
|
lock.lock(); |
|
|
|
try { |
|
|
|
DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo); |
|
|
|
if ("2".equals(master.getCheckStatus())) { |
|
|
|
throw new RuntimeException("审核失败,单据已审核"); |
|
|
|
} |
|
|
|
master.setUpdatedBy(SecurityUtils.getUsername()); |
|
|
|
master.setCreatedTime(DateUtils.getNowDate()); |
|
|
|
master.setCheckStatus("9"); |
|
|
|
return baseMapper.updateDcBusiTargetInputMaster(master); |
|
|
|
} catch (RuntimeException e) { |
|
|
|
log.error("处理异常", e); |
|
|
|
throw e; |
|
|
|
} finally { |
|
|
|
lock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int checkPass(String billNo) { |
|
|
|
lock.lock(); |
|
|
|
try { |
|
|
|
DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo); |
|
|
|
if (ObjectUtils.isEmpty(master)) { |
|
|
|
throw new RuntimeException("单据不存在"); |
|
|
|
} |
|
|
|
if ("2".equals(master.getCheckStatus())) { |
|
|
|
throw new RuntimeException("审核失败,单据已审核"); |
|
|
|
} |
|
|
|
DcBusiTargetInputSub subParams = new DcBusiTargetInputSub(); |
|
|
|
subParams.setBillNoMaster(billNo); |
|
|
|
List<DcBusiTargetInputSub> dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams); |
|
|
|
List<DcBusiTargetDraftDaynew> newList = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) { |
|
|
|
String year = master.getYear(); |
|
|
|
String month = master.getMonth(); |
|
|
|
List<String> targetCodeList = dcBusiTargetInputSubList.stream().map(DcBusiTargetInputSub::getTargetCode).collect(Collectors.toList()); |
|
|
|
List<DcBaseAssetTarget> dcBaseAssetTargets = dcBaseAssetTargetMapper.selectDcBaseAssetTargetByTargetCodeList(targetCodeList); |
|
|
|
Map<String, String> targetModelCodeMap = dcBaseAssetTargets.stream().collect(Collectors.toMap(DcBaseAssetTarget::getTargetCode, DcBaseAssetTarget::getTargetModelCode)); |
|
|
|
for (DcBusiTargetInputSub dcBusiTargetInputSub : dcBusiTargetInputSubList) { |
|
|
|
String day = dcBusiTargetInputSub.getDay(); |
|
|
|
DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew = new DcBusiTargetDraftDaynew(); |
|
|
|
dcBusiTargetDraftDaynew.setCompanyId(dcBusiTargetInputSub.getCompanyId()); |
|
|
|
dcBusiTargetDraftDaynew.setOrganizeId(dcBusiTargetInputSub.getOragnizeId()); |
|
|
|
dcBusiTargetDraftDaynew.setAssetCode(dcBusiTargetInputSub.getAssetCode()); |
|
|
|
dcBusiTargetDraftDaynew.setFieldCode(dcBusiTargetInputSub.getFieldCode()); |
|
|
|
dcBusiTargetDraftDaynew.setTargetCode(dcBusiTargetInputSub.getTargetCode()); |
|
|
|
dcBusiTargetDraftDaynew.setDateYear(year); |
|
|
|
dcBusiTargetDraftDaynew.setDateMonth(month); |
|
|
|
dcBusiTargetDraftDaynew.setDateDay(day); |
|
|
|
List<DcBusiTargetDraftDaynew> dcBusiTargetDraftDaynewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewList(dcBusiTargetDraftDaynew); |
|
|
|
if (CollectionUtils.isEmpty(dcBusiTargetDraftDaynewList)) { |
|
|
|
dcBusiTargetDraftDaynew.setCompanyName(dcBusiTargetInputSub.getCompanyName()); |
|
|
|
dcBusiTargetDraftDaynew.setOrganizeName(dcBusiTargetInputSub.getOrganizeName()); |
|
|
|
dcBusiTargetDraftDaynew.setAssetName(dcBusiTargetInputSub.getAssetName()); |
|
|
|
dcBusiTargetDraftDaynew.setFieldName(dcBusiTargetInputSub.getFieldName()); |
|
|
|
dcBusiTargetDraftDaynew.setTagetName(dcBusiTargetInputSub.getTargetName()); |
|
|
|
dcBusiTargetDraftDaynew.setValueResult(dcBusiTargetInputSub.getValResult()); |
|
|
|
dcBusiTargetDraftDaynew.setTargetModelCode(targetModelCodeMap.get(dcBusiTargetInputSub.getTargetCode())); |
|
|
|
newList.add(dcBusiTargetDraftDaynew); |
|
|
|
} else { |
|
|
|
String msg = "{} 中 {} {}-{}-{},已存在"; |
|
|
|
throw new RuntimeException(String.format(msg, dcBusiTargetInputSub.getAssetNameAlias(), dcBusiTargetInputSub.getTargetName(), year, month, StringUtils.leftPad(day, 2, "0"))); |
|
|
|
} |
|
|
|
} |
|
|
|
dcBusiTargetDraftDaynewMapper.batchInsertDcBusiTargetDraftDaynew(newList); |
|
|
|
} |
|
|
|
// 修改审核状态为已处理
|
|
|
|
master.setCheckStatus("2"); |
|
|
|
master.setUpdatedBy(SecurityUtils.getUsername()); |
|
|
|
master.setCreatedTime(DateUtils.getNowDate()); |
|
|
|
return baseMapper.updateDcBusiTargetInputMaster(master); |
|
|
|
} catch (RuntimeException e) { |
|
|
|
log.error("处理异常", e); |
|
|
|
throw e; |
|
|
|
} finally { |
|
|
|
lock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public int checkRevert(String billNo) { |
|
|
|
lock.lock(); |
|
|
|
try { |
|
|
|
DcBusiTargetInputMaster master = baseMapper.selectDcBusiTargetInputMasterByBillSerial(billNo); |
|
|
|
if ("0".equals(master.getCheckStatus())) { |
|
|
|
throw new RuntimeException("反审核失败,单据未提交"); |
|
|
|
} |
|
|
|
if ("1".equals(master.getCheckStatus())) { |
|
|
|
throw new RuntimeException("反审核失败,单据未审核通过"); |
|
|
|
} |
|
|
|
DcBusiTargetInputSub subParams = new DcBusiTargetInputSub(); |
|
|
|
subParams.setBillNoMaster(billNo); |
|
|
|
List<DcBusiTargetInputSub> dcBusiTargetInputSubList = dcBusiTargetInputSubMapper.selectDcBusiTargetInputSubList(subParams); |
|
|
|
List<DcBusiTargetDraftDaynew> newList = new ArrayList<>(); |
|
|
|
if (!CollectionUtils.isEmpty(dcBusiTargetInputSubList)) { |
|
|
|
String year = master.getYear(); |
|
|
|
String month = master.getMonth(); |
|
|
|
for (DcBusiTargetInputSub dcBusiTargetInputSub : dcBusiTargetInputSubList) { |
|
|
|
String day = dcBusiTargetInputSub.getDay(); |
|
|
|
DcBusiTargetDraftDaynew dcBusiTargetDraftDaynew = new DcBusiTargetDraftDaynew(); |
|
|
|
dcBusiTargetDraftDaynew.setCompanyId(dcBusiTargetInputSub.getCompanyId()); |
|
|
|
dcBusiTargetDraftDaynew.setOrganizeId(dcBusiTargetInputSub.getOragnizeId()); |
|
|
|
dcBusiTargetDraftDaynew.setAssetCode(dcBusiTargetInputSub.getAssetCode()); |
|
|
|
dcBusiTargetDraftDaynew.setFieldCode(dcBusiTargetInputSub.getFieldCode()); |
|
|
|
dcBusiTargetDraftDaynew.setTargetCode(dcBusiTargetInputSub.getTargetCode()); |
|
|
|
dcBusiTargetDraftDaynew.setDateYear(year); |
|
|
|
dcBusiTargetDraftDaynew.setDateMonth(month); |
|
|
|
dcBusiTargetDraftDaynew.setDateDay(day); |
|
|
|
List<DcBusiTargetDraftDaynew> dcBusiTargetDraftDaynewList = dcBusiTargetDraftDaynewMapper.selectDcBusiTargetDraftDaynewList(dcBusiTargetDraftDaynew); |
|
|
|
if (!CollectionUtils.isEmpty(dcBusiTargetDraftDaynewList)) { |
|
|
|
newList.addAll(dcBusiTargetDraftDaynewList); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(newList)) { |
|
|
|
List<Long> idList = newList.stream().map(DcBusiTargetDraftDaynew::getId).collect(Collectors.toList()); |
|
|
|
Long[] ids = idList.toArray(new Long[]{}); |
|
|
|
dcBusiTargetDraftDaynewMapper.deleteDcBusiTargetDraftDaynewByIds(ids); |
|
|
|
} |
|
|
|
} |
|
|
|
// 修改审核状态为已处理
|
|
|
|
master.setCheckStatus("1"); |
|
|
|
master.setUpdatedBy(SecurityUtils.getUsername()); |
|
|
|
master.setCreatedTime(DateUtils.getNowDate()); |
|
|
|
return baseMapper.updateDcBusiTargetInputMaster(master); |
|
|
|
} catch (RuntimeException e) { |
|
|
|
log.error("处理异常", e); |
|
|
|
throw e; |
|
|
|
} finally { |
|
|
|
lock.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|