浏览代码

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/SCCommon

qinlaiqiao 4 年之前
父节点
当前提交
afe193cfa7

+ 6 - 4
types/src/interface/base.ts

@@ -73,10 +73,12 @@ export enum BRType { // 1 :大项费用 2:分部 3分项 4清单;5补项   6 
   BX = 5, // 这个补项因为旧版本是后定义的,所以放在后面,为了统一不混淆
   CS = 6, // 分类
   DT = 7, // 费用明细
-  RATION = 10, // 定额
-  INST = 11, // 安装增加费生成的定额
-  VP = 12, // 量价
-  GLJ = 13, // 工料机
+  RATION = 20, // 定额
+  INST = 21, // 安装增加费生成的定额
+  VP = 22, // 量价
+  GLJ = 23, // 工料机
+  OH = 24, // 超高子目
+  ITEM = 25, // 子目增加
 }
 
 export enum supplyType {

+ 104 - 1
types/src/interface/glj.ts

@@ -1,4 +1,9 @@
-import { fromType, supplyType } from './base';
+/*
+ * @Descripttion:
+ * @Author: vian
+ * @Date: 2021-05-26 17:37:16
+ */
+import { fromType, ITreeScm, supplyType } from './base';
 
 // 工料机类型
 export enum GljType {
@@ -157,3 +162,101 @@ export interface IProjectGljs {
   projectID: string;
   projectGljs: IProjectGlj[];
 }
+
+/* 标准人材机相关 ↓ */
+// 标准、补充人材机共用属性(原始数据)
+export interface IBaseRationGlj {
+  code: string;
+  name: string;
+  specs?: string;
+  basePrice: number;
+  priceProperty: any; // 多单价的情况
+  gljClass: number;
+  model: number; // 机型
+  shortName: string;
+  unit: string;
+  adjCoe: number;
+  materialType: MaterialType; // 三材类别
+  materialCoe: number; // 三材系数
+  // 经济指标数据
+  materialIndexType: string; // 工料指标类别
+  materialIndexUnit: string; // 工料指标单位
+  materialIndexCoe: number; // 单位转换系数
+  taxRate: string; // 税率
+}
+
+// 标准人材机组成物
+export interface IStdComponent {
+  ID: number;
+  consumeAmt: number;
+  consumeAmtProperty: any; // 多消耗量的情况
+}
+
+// 标准人材机(原始数据)
+export interface IRawStdGlj extends IBaseRationGlj {
+  ID: number;
+  repositoryId: number;
+  gljType: number;
+  component: IStdComponent[];
+}
+
+// 标准人材机
+export interface IStdGlj extends IBaseRationGlj {
+  ID: number;
+  repositoryID: number;
+  type: number;
+  components: IStdComponent[];
+  from: fromType;
+}
+
+// 标准人材机分类树(原始数据)
+export interface IRawStdGljTree {
+  ID: number;
+  ParentID: number;
+  NextSiblingID: number;
+  repositoryId: number;
+  Name: string;
+}
+
+// 标准人材机分类树
+export interface IStdGljTree extends ITreeScm {
+  repositoryID: number;
+  name: string;
+}
+/* 标准人材机相关 ↑ */
+
+/* 补充人材机相关 ↓ */
+export interface ICptComponent {
+  ID: string; // 补充的ID改成了UUID ,标准的不变,但是这里
+  consumeAmt: number;
+  consumeAmtProperty: any; // 多消耗量的情况
+  from: fromType;
+}
+
+export interface ICptGlj extends IBaseRationGlj {
+  ID: string;
+  ownerID: string;
+  type: number;
+  compilationID: string;
+  components: ICptComponent[];
+  from: fromType;
+}
+/* 补充人材机相关 ↑ */
+
+/* 选择人材机相关 ↓ */
+// 库下拉项
+export interface ISelectGljLibItem {
+  name: string;
+  repositoryID: number | string;
+  key: string; // 与gljLibID拼接的形成的唯一值
+  isPrior: boolean; // 优先的
+  from: fromType;
+}
+
+// 选择人材机接口返回数据格式
+export interface ISelectGljResult {
+  libData: ISelectGljLibItem[]; // 库下拉项
+  treeData: IStdGljTree[]; // 人材机分类树
+}
+
+/* 选择人材机相关 ↑ */

+ 14 - 0
types/src/interface/project.ts

@@ -157,6 +157,19 @@ export interface IEconomicIndex {
   value: string;
 }
 
+// 面积增加类型
+export enum AreaIncreaseType {
+  LABOUR = 'labour',
+  MATERIAL = 'material',
+  MACHINE = 'machine',
+}
+
+export interface IAreaIncreaseSetting {
+  [AreaIncreaseType.LABOUR]: number;
+  [AreaIncreaseType.MATERIAL]: number;
+  [AreaIncreaseType.MACHINE]: number;
+}
+
 // 项目属性
 export interface IProperty {
   constructionID?: string; // 建设项目ID
@@ -174,6 +187,7 @@ export interface IProperty {
   isItemIncrease?: boolean; // 是否是子目增加
   itemIncreaseSetting?: IIncreaseSetting;
   isAreaIncrease?: boolean; // 是否是面积增加
+  areaIncreaseSetting?: IAreaIncreaseSetting; // 面积增加费设置
   indexName?: string; // 指标名称
   lockBills?: boolean; // 锁定清单
   decimal?: IDecimal; // 小数位数

+ 13 - 53
types/src/interface/ration.ts

@@ -7,9 +7,18 @@ import {
   BRType,
 } from './base';
 import { IBookmark } from './bill';
-import { GljType, MaterialType } from './glj';
+import { GljType, ICptGlj, IStdGlj, MaterialType } from './glj';
 import { IQuantityDetail } from './quantityDetail';
 
+// 标准定额库
+export interface IStdRationLib {
+  dispName: string;
+  compilationId: string;
+  compilationName: string;
+  gljLib: number;
+  ID: number;
+}
+
 export interface IStdRationChapter {
   rationRepId: number; // 标准库的属性
   ID: string; // 补充库的直接用新结构,所以有两种类型
@@ -128,7 +137,7 @@ export interface IStdCoeItem extends IBaseCoeItem {
 
 export interface IRationCoe {
   ID: string;
-  stdID?: number | string; // 库里的ID
+  stdID?: number; // 库里的ID
   name: string;
   content?: string;
   originalCode?: string;
@@ -176,40 +185,6 @@ export interface ICptRation extends IBaseRation {
   chapter?: ICptRationChapter;
 }
 
-export interface IStdComponent {
-  ID: number;
-  consumeAmt: number;
-  consumeAmtProperty: any; // 多消耗量的情况
-}
-export interface ICptComponent {
-  ID: string; // 补充的ID改成了UUID ,标准的不变,但是这里
-  consumeAmt: number;
-  consumeAmtProperty: any; // 多消耗量的情况
-  from: fromType;
-}
-
-export interface IBaseRationGlj {
-  code: string;
-  name: string;
-  specs?: string;
-  basePrice: number;
-  priceProperty: any; // 多单价的情况
-  gljClass: number;
-  type: number; // 这个要和项目工料机等统一,所以在查找项目工料机的时候转一下,
-  gljType: number;
-  model: number; // 机型
-  shortName: string;
-  unit: string;
-  adjCoe: number;
-  materialType: MaterialType; // 三材类别
-  materialCoe: number; // 三材系数
-  // 经济指标数据
-  materialIndexType: string; // 工料指标类别
-  materialIndexUnit: string; // 工料指标单位
-  materialIndexCoe: number; // 单位转换系数
-  taxRate: string; // 税率
-}
-
 // 保存到项目下的定额工料机
 export interface IRationGlj {
   ID: string;
@@ -228,25 +203,10 @@ export interface IRationGlj {
   customQuantity?: number;
   rationQuantity?: number;
   tenderQuantity?: number; // 调整后消耗量
-  marketPrice?: number; // 市场价 - 不保存至数据库
-  basePrice?: number; // 定额价 - 不保存至数据库
   createType: gljCreateType; // normal、add、replace  正常、添加工料机、替换工料机
   from: fromType; // std, cpt  来自标准工料机库、补充工料机库
 }
 
-export interface IStdRationGlj extends IBaseRationGlj {
-  ID: number;
-  repositoryId: number;
-  components: IStdComponent[];
-}
-
-export interface ICptRationGlj extends IBaseRationGlj {
-  ID: string;
-  userID: string;
-  compilationID: string;
-  components: ICptComponent[];
-}
-
 export interface IGljQtyCoe {
   labour: number; // 人工
   material: number; // 材料
@@ -306,7 +266,7 @@ export interface IRation {
   code?: string;
   name?: string;
   unit?: string;
-  type?: number; // 子类型:1人工、201材料、301机械、4主材、5设备
+  type?: GljType; // 子类型:1人工、201材料、301机械、4主材、5设备
   quantity?: number;
   contain?: number; // 含量
   quantityEXP?: string; // 工程量表达式
@@ -369,7 +329,7 @@ export interface IRations {
 
 export interface IStdRationsAndGljs {
   rations: (IStdRation | ICptRation)[];
-  rationGljs: (IStdRationGlj | ICptRationGlj)[];
+  rationGljs: (IStdGlj | ICptGlj)[];
 }
 
 export enum RationListType {

+ 1 - 0
util/.eslintrc.js

@@ -26,6 +26,7 @@ module.exports = {
     'import/no-unresolved': 'off',
     '@typescript-eslint/no-empty-function': 'off',
     '@typescript-eslint/no-explicit-any': 'off',
+    '@typescript-eslint/explicit-module-boundary-types': 'off',
     'no-unused-expressions': [
       'error',
       {

+ 5 - 2
util/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/util",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "description": "共用的工具包",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",
@@ -24,6 +24,7 @@
     "@types/chai": "^4.2.14",
     "@types/mocha": "^8.0.4",
     "@types/ms": "^0.7.31",
+    "@types/lodash": "^4.14.168",
     "@typescript-eslint/eslint-plugin": "^4.4.1",
     "@typescript-eslint/parser": "^4.4.1",
     "chai": "^4.2.0",
@@ -46,5 +47,7 @@
     "tslib": "^2.0.3",
     "typescript": "^4.0.3"
   },
-  "dependencies": {}
+  "dependencies": {
+    "lodash": "^4.17.21"
+  }
 }

+ 1 - 0
util/prettier.config.js

@@ -3,4 +3,5 @@ module.exports = {
   trailingComma: 'es5', // 对象末尾以逗号结束
   arrowParens: 'avoid', // 箭头函数只有一个参数的时候,不使用()
   endOfLine: 'auto', // CRLF,LF都可以
+  printWidth: 120,
 };

+ 4 - 17
util/src/bill.ts

@@ -1,10 +1,4 @@
-import {
-  IJobContent,
-  IItemCharacter,
-  IStdBill,
-  IStdJobContent,
-  IStdItemCharacter,
-} from '@sc/types';
+import { IJobContent, IItemCharacter, IStdBill, IStdJobContent, IStdItemCharacter } from '@sc/types';
 
 interface IJobsAndCharacterText {
   jobContentText: string;
@@ -34,8 +28,7 @@ export const getJobsAndCharacterText = (
   const textArray: string[] = ['[项目特征]'];
   let i = 1;
   for (const item of itemCharacters) {
-    if (item.isChecked)
-      textArray.push(`${i}. ${item.character || ''}: ${item.eigenvalue || ''}`);
+    if (item.isChecked) textArray.push(`${i}. ${item.character || ''}: ${item.eigenvalue || ''}`);
     i += 1;
   }
 
@@ -49,10 +42,7 @@ export const getJobsAndCharacterText = (
   return { jobContentText, itemCharacterText };
 };
 
-export const getJobContents = (
-  stdBill: IStdBill,
-  stdJobContentMap: IJobContentMap
-): IJobContent[] => {
+export const getJobContents = (stdBill: IStdBill, stdJobContentMap: IJobContentMap): IJobContent[] => {
   const jobs: IJobContent[] = [];
   let i = 1;
   for (const j of stdBill.jobs) {
@@ -66,10 +56,7 @@ export const getJobContents = (
   return jobs;
 };
 
-export const getItemCharacters = (
-  stdBill: IStdBill,
-  itemCharacterMap: IItemCharacterMap
-): IItemCharacter[] => {
+export const getItemCharacters = (stdBill: IStdBill, itemCharacterMap: IItemCharacterMap): IItemCharacter[] => {
   const characters: IItemCharacter[] = [];
   let i = 1;
   for (const item of stdBill.items) {

+ 1 - 0
util/src/index.ts

@@ -1,2 +1,3 @@
 export * from './math';
 export * from './bill';
+export * from './rationAss';

+ 3 - 13
util/src/math.ts

@@ -5,11 +5,7 @@ export const isNumber = (value: string | number): boolean => {
   return /^(-|\+)?\d+(\.\d+)?$/.test(value as string);
 };
 
-export const innerRound = (
-  num: number,
-  length: number,
-  decimal: number
-): number => {
+export const innerRound = (num: number, length: number, decimal: number): number => {
   let value;
   let pre = 1;
   if (length === 0) return num;
@@ -25,10 +21,7 @@ export const innerRound = (
 };
 
 // 4舍5入
-export const roundForObj = (
-  obj: string | number | undefined | null,
-  decimal: number
-): number => {
+export const roundForObj = (obj: string | number | undefined | null, decimal: number): number => {
   let value;
   if (obj === undefined || obj === null || isNaN(obj as number)) return 0;
   const length = 10;
@@ -40,10 +33,7 @@ export const roundForObj = (
   return value;
 };
 
-export const roundToString = (
-  obj: string | number,
-  decimal: number
-): string => {
+export const roundToString = (obj: string | number, decimal: number): string => {
   const value = roundForObj(obj, decimal);
   return value.toFixed(decimal);
 };

+ 115 - 0
util/src/rationAss.ts

@@ -0,0 +1,115 @@
+import { IRationAss, IThirdRation } from '@sc/types';
+import { ceil, floor, round, sortBy } from 'lodash';
+import { roundForObj } from './math';
+
+export interface IAssTime {
+  times: number;
+  ass: IRationAss | IThirdRation;
+}
+
+export interface IStateList {
+  index: number;
+  content: string;
+  addCode?: string; // 添加工料机的编号,用来标记,如果是子目换算中的单个人材机生成的,改成 调:...
+}
+
+export const stateSeq = {
+  ass: 1,
+  replace: 2,
+  coe: 3,
+  add: 4,
+  cusQuantity: 5,
+  cusCoe: 6,
+  area: 7,
+  adjMak: 8,
+};
+// 处理多个辅助定额的情况
+export const handleMulAss = (rationAssList: IRationAss[]) => {
+  const assList = [];
+  for (const ass of rationAssList) {
+    // 处理多个辅助定额的情况
+    if (ass.groupList && ass.groupList.length > 0) {
+      const newAss = { ...ass };
+      const newList = sortBy(ass.groupList, item => parseFloat(item.param)); // 按参数排序
+      let pre = 0;
+      for (const tem of newList) {
+        if (ass.actualValue) {
+          if (ass.actualValue > pre && ass.actualValue <= parseFloat(tem.param)) {
+            // 落在中间,则用组里的这条定额
+            newAss.param = tem.param;
+            newAss.paramName = tem.paramName;
+            newAss.assistCode = tem.assistCode;
+            break;
+          }
+          pre = parseFloat(tem.param);
+        }
+      }
+      assList.push(newAss);
+    } else {
+      assList.push(ass);
+    }
+  }
+  return assList;
+};
+
+export const calcAssTime = (ass: IRationAss) => {
+  if (ass.isAdjust === false) return undefined;
+  const actualValue = ass.actualValue ? ass.actualValue : 0;
+  const stdValue = ass.stdValue ? parseInt(ass.stdValue, 10) : 0;
+  const stepValue = ass.stepValue ? parseInt(ass.stepValue, 10) : 1;
+  let times = (actualValue - stdValue) / stepValue;
+  let r = false; // 是否负数
+  if (times < 0) {
+    r = true;
+    times *= -1;
+  }
+
+  if (ass.carryBit === '四舍五入') {
+    times = round(times, ass.decimal);
+  } else if (ass.carryBit === '进一') {
+    times = ceil(times, ass.decimal);
+  } else if (ass.carryBit === '舍一') {
+    times = floor(times, ass.decimal);
+  }
+  if (r) {
+    times *= -1;
+  }
+  return roundForObj(times, 6);
+};
+
+export const calcRationAssTimes = (
+  rationAssList?: IRationAss[],
+  thirdRation?: IThirdRation,
+  stateList?: IStateList[]
+) => {
+  const timeList: IAssTime[] = [];
+  if (rationAssList) {
+    const assList = handleMulAss(rationAssList);
+    const temTimes = [];
+    const thirdRationCodes = [];
+    for (const rationAss of assList) {
+      const times = calcAssTime(rationAss);
+      if (times) {
+        const { thirdRationCode } = rationAss;
+        if (thirdRationCode) {
+          temTimes.push(times);
+          thirdRationCodes.push(thirdRationCode);
+        }
+        timeList.push({ times, ass: rationAss });
+        if (stateList)
+          stateList.push({
+            index: stateSeq.ass,
+            content: `${rationAss.name} ${rationAss.actualValue} : ${rationAss.assistCode}x${times}`,
+          });
+      }
+    }
+    if (thirdRation && temTimes.length === 2 && thirdRationCodes[0] === thirdRationCodes[1]) {
+      // 说明有第三定额
+      const timesT = temTimes[0] * temTimes[1];
+      timeList.push({ times: timesT, ass: thirdRation });
+      if (stateList) stateList.push({ index: stateSeq.ass, content: `+${thirdRationCodes[0]}x${timesT}` });
+    }
+  }
+
+  return timeList;
+};