tudc 3 سال پیش
والد
کامیت
a8a3bb5a4d

+ 3 - 0
adm/src/main/java/com/minpay/common/util/CommonUtil.java

@@ -294,6 +294,9 @@ public class CommonUtil {
 		if (str2 == null || "".equals(str2) || "null".equals(str2)) {
 			str2 = "0";
 		}
+		if(CommonUtil.compare(str2, "0") == 0) {
+			return "0";
+		}
 		BigDecimal big1 = new BigDecimal(str1);
 		BigDecimal big2 = new BigDecimal(str2);
 		BigDecimal iRet = big1.divide(big2, pointWs, BigDecimal.ROUND_HALF_UP);

+ 11 - 1
adm/src/main/java/com/minpay/guomao/giveoutmanage/giveOutManageAction.java

@@ -61,6 +61,7 @@ import com.minpay.db.table.model.ImUserExample;
 import com.minpay.db.table.model.OwnApCompanyInfExample;
 import com.minpay.db.table.model.PubApppar;
 import com.minpay.db.table.model.PubAppparExample;
+import com.minpay.db.table.model.PubAppparKey;
 import com.minpay.db.table.own.mapper.GiveoutManageMapper;
 import com.startup.minpay.frame.business.IMINAction;
 import com.startup.minpay.frame.business.MINHttpServletRequestContext;
@@ -1939,7 +1940,16 @@ public class giveOutManageAction implements IMINAction {
 			MINSession session
 			) throws MINBusinessException{
 		MINActionResult res = new MINActionResult();
-
+		
+		PubAppparKey appparKey = new PubAppparKey();
+		appparKey.setCode("RECEIVING_UNIT");
+		appparKey.setValue(receivingUnit);
+		PubApppar selectByPrimaryKey = Service.lookup(IMINDataBaseService.class)
+											.getMybatisMapper(PubAppparMapper.class).selectByPrimaryKey(appparKey);
+		if(selectByPrimaryKey != null) {
+			throw new MINBusinessException("收货单位【"+receivingUnit+"】已存在");
+		}
+		
 		PubApppar pa = new PubApppar();
 		pa.setName("收货单位");
 		pa.setCode("RECEIVING_UNIT");

+ 43 - 7
adm/src/main/java/com/minpay/guomao/templateexport/action/TemplateExportAction.java

@@ -14,10 +14,19 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.poi.xwpf.usermodel.XWPFTable;
+import org.apache.poi.xwpf.usermodel.XWPFTableCell;
+import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
+
+import com.deepoove.poi.NiceXWPFDocument;
 import com.deepoove.poi.XWPFTemplate;
 import com.deepoove.poi.data.MiniTableRenderData;
 import com.deepoove.poi.data.RowRenderData;
 import com.deepoove.poi.data.TextRenderData;
+import com.deepoove.poi.data.style.TableStyle;
+import com.deepoove.poi.policy.DynamicTableRenderPolicy;
+import com.deepoove.poi.policy.MiniTableRenderPolicy;
 import com.minpay.common.bean.User;
 import com.minpay.common.format.IFormatService;
 import com.minpay.common.service.IDownloadService;
@@ -79,7 +88,7 @@ public class TemplateExportAction implements IMINAction {
 		map1.put("acicId", acicId);		
 		User u  = session.getUser();
 		//获取部门
-		String brandId = u.getBranchId();
+		String branchId = u.getBranchId();
 		//
 		List<Map<String, Object>> list = Service.lookup(IMINDataBaseService.class)
 												.getMybatisMapper(LongContractMapper.class)
@@ -219,7 +228,7 @@ public class TemplateExportAction implements IMINAction {
 													.selectByExample(example);
 		List<Map<String, String>> newlist = new ArrayList<>();
 		
-		if(!CommonUtil.isYHL(brandId)){//铝产品部
+		if(!CommonUtil.isYHL(branchId)){//铝产品部
 			//查询合同
 			ApContractInfExample ex  = new ApContractInfExample();
 			ex.createCriteria().andIdEqualTo(acicId);
@@ -320,12 +329,12 @@ public class TemplateExportAction implements IMINAction {
         List<RowRenderData> datas = new ArrayList<RowRenderData>();
         
         
-        if (!CommonUtil.isYHL(brandId)) {
+        if (!CommonUtil.isYHL(branchId)) {
         	allweight = "0";
         	allamt = "0";
         }
     	for(int i = 0;i < newlist.size();i++) {
-    		if(!CommonUtil.isYHL(brandId)){
+    		if(!CommonUtil.isYHL(branchId)){
     			allweight = CommonUtil.add(allweight, CommonUtil.objToString(newlist.get(i).get("reaWeight")),4);
     			allamt = CommonUtil.add(allamt, CommonUtil.multiply(CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice"))),2);
     			RowRenderData rowDto = RowRenderData.build(CommonUtil.objToString(newlist.get(i).get("abfName")), CommonUtil.objToString(newlist.get(i).get("value")), CommonUtil.objToString(newlist.get(i).get("warehouseName")), CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice")), CommonUtil.multiply(CommonUtil.objToString(newlist.get(i).get("reaWeight")),CommonUtil.objToString(newlist.get(i).get("sjPrice")),2));
@@ -374,7 +383,7 @@ public class TemplateExportAction implements IMINAction {
 				String price = "";
 				if(newlist.size() > 0 && newlist != null){
 					proName = CommonUtil.objToString(newlist.get(0).get("apiName"));
-					if(!CommonUtil.isYHL(brandId)){
+					if(!CommonUtil.isYHL(branchId)){
 						price = CommonUtil.objToString(newlist.get(0).get("sjPrice"));
 						weight = CommonUtil.objToString(newlist.get(0).get("reaWeight"));
 					}else{
@@ -422,7 +431,14 @@ public class TemplateExportAction implements IMINAction {
 		        put("allamt", amtAll);//总金额
 		        put("allAmtTaxExclusive", CommonUtil.divide(amtAll, "1.13", 2));//不含税总金额
 		        put("chineseNb", chineseNb);//中文大写
-		        put("table", new MiniTableRenderData(header, datas));// 产品表格信息
+		        
+		        // 增加合计行
+		        if(!CommonUtil.isYHL(branchId)){
+		        	RowRenderData lastRenderData = RowRenderData.build("合计", "", "", weightAll, CommonUtil.divide(amtAll, weightAll, 2), amtAll);
+			        datas.add(lastRenderData);
+		        }
+		        MiniTableRenderData table = new MiniTableRenderData(header, datas);
+		        put("table", table);// 产品表格信息
 		        Date date = new Date();
 		        SimpleDateFormat sb = new SimpleDateFormat("yyyy年/MM月/dd日");
 		        put("payDate", sb.format(date));//支付日期
@@ -451,6 +467,13 @@ public class TemplateExportAction implements IMINAction {
 		        
 		}});
 		
+		// 合并合计单元格
+		if(!CommonUtil.isYHL(branchId)) {
+			NiceXWPFDocument xwpfDocument = template.getXWPFDocument();
+			XWPFTable table = xwpfDocument.getTableArray(0);
+			mergeCellsHorizontal(table, table.getRows().size() - 1, 0, 2);
+		}
+		
 		response.setContentType("multipart/form-data"); 
 	    String formFileName = new String(name.getBytes("UTF-8"), "ISO-8859-1");
 	    if (CommonUtil.isEmpty(formFileName)) {
@@ -515,4 +538,17 @@ public class TemplateExportAction implements IMINAction {
 		res.set(IMINBusinessConstant.F_PAGING_LAY, list);
 		 return res;
 	}
-}
+	
+	private void mergeCellsHorizontal(XWPFTable table, Integer row, Integer fromCell, Integer toCell) {
+	    for (int cellIndex = fromCell; cellIndex <= toCell; cellIndex++) {
+	        XWPFTableCell cell = table.getRow(row).getCell(cellIndex);
+	        if ( cellIndex == fromCell ) {
+	            // The first merged cell is set with RESTART merge value
+	            cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);
+	        } else {
+	            // Cells which join (merge) the first one, are set with CONTINUE
+	            cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
+	        }
+	    }
+	}
+}

+ 1 - 1
adm/src/main/webapp/admin/giveOutManage/receivingUnit.html

@@ -45,7 +45,7 @@
 			   	,elem: '#sendTable'
 			   	//,tbname:'orderManage'
 			   	,limit:10
-			   	,height:400
+			   	,height:500
 			   	,url: 'giveOutManageAction/queryreceivingUnit' //数据接口
 			   	,method: 'post'
 			   	,where:{MINView:"JSON"}

+ 2 - 2
adm/src/main/webapp/admin/stockManage/printCheckMore.html

@@ -117,8 +117,8 @@
 				
 				var jiesuanPrice = isEmpty(stockList[i].sjPrice)?stockList[i].ygPrice:stockList[i].sjPrice;
 				// 预估单价*实际重量
-				var amt  = accMul((isEmpty(jiesuanPrice)?0:jiesuanPrice),(isEmpty(stockList[i].reaWeight)?0:stockList[i].reaWeight),2);
-				totalAmt = accAdd(totalAmt,amt,2);
+				var amt  = accMul((isEmpty(jiesuanPrice)?0:jiesuanPrice),(isEmpty(stockList[i].reaWeight)?0:stockList[i].reaWeight));
+				totalAmt = accAdd(totalAmt,amt);
 				
 				var isContain = false;
 				for (var j=0;j < remark.length;j++) {