Sfoglia il codice sorgente

发票添加负数红冲关联已开发票信息

user5 10 mesi fa
parent
commit
1b0dc9b427

+ 168 - 0
src/main/java/com/jeeplus/common/utils/excel/ImportExcel.java

@@ -430,6 +430,174 @@ public class ImportExcel {
 	}
 
 	/**
+	 * 获取导入数据列表
+	 * @param cls 导入对象类型
+	 * @param groups 导入分组
+	 */
+	public <E> List<E> getNewDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException{
+		List<Object[]> annotationList = Lists.newArrayList();
+		// Get annotation field
+		Field[] fs = cls.getDeclaredFields();
+		for (Field f : fs){
+			ExcelField ef = f.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==2)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, f});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, f});
+				}
+			}
+		}
+		// Get annotation method
+		Method[] ms = cls.getDeclaredMethods();
+		for (Method m : ms){
+			ExcelField ef = m.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==2)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, m});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, m});
+				}
+			}
+		}
+		// Field sorting
+		Collections.sort(annotationList, new Comparator<Object[]>() {
+			public int compare(Object[] o1, Object[] o2) {
+				return new Integer(((ExcelField)o1[0]).sort()).compareTo(
+						new Integer(((ExcelField)o2[0]).sort()));
+			};
+		});
+		//log.debug("Import column count:"+annotationList.size());
+		// Get excel data
+		List<E> dataList = Lists.newArrayList();
+		for (int i = this.getDataRowNum(); i <= this.getLastDataRowNum(); i++) {
+			E e = (E)cls.newInstance();
+			int column = 0;
+			Row row = this.getRow(i);
+			StringBuilder sb = new StringBuilder();
+			for (Object[] os : annotationList){
+                ExcelField ef = (ExcelField)os[0];
+                Object val = null;
+                if (ef.colNum()!=0) {
+                    val = this.getCellValue(row, ef.colNum());
+                }else {
+                    val = this.getCellValue(row, column++);
+                }
+				if (val != null){
+
+					// If is dict type, get dict value
+					if (StringUtils.isNotBlank(ef.dictType())){
+						val = DictUtils.getDictValue(val.toString(), ef.dictType(), "");
+						//log.debug("Dictionary type value: ["+i+","+colunm+"] " + val);
+					}
+					if (StringUtils.isNotBlank(ef.mainDictType())){
+						val = DictUtils.getMainDictValue(val.toString(), ef.mainDictType(), "");
+						//log.debug("Dictionary type value: ["+i+","+colunm+"] " + val);
+					}
+					// Get param type and type cast
+					Class<?> valType = Class.class;
+					if (os[1] instanceof Field){
+						valType = ((Field)os[1]).getType();
+					}else if (os[1] instanceof Method){
+						Method method = ((Method)os[1]);
+						if ("get".equals(method.getName().substring(0, 3))){
+							valType = method.getReturnType();
+						}else if("set".equals(method.getName().substring(0, 3))){
+							valType = ((Method)os[1]).getParameterTypes()[0];
+						}
+					}
+					//log.debug("Import value type: ["+i+","+column+"] " + valType);
+					try {
+						//如果导入的java对象,需要在这里自己进行变换。
+						if (valType == String.class){
+							String s = String.valueOf(val.toString());
+							if(StringUtils.endsWith(s, ".0")){
+								val = StringUtils.substringBefore(s, ".0");
+							}else{
+								val = String.valueOf(val.toString());
+							}
+						}else if (valType == Integer.class){
+							val = Double.valueOf(val.toString()).intValue();
+						}else if (valType == Long.class){
+							val = Double.valueOf(val.toString()).longValue();
+						}else if (valType == Double.class){
+                            if(val instanceof String){
+                                val = ((String) val).replaceAll(",","");
+                            }
+							val = Double.valueOf(val.toString());
+						}else if (valType == Float.class){
+							val = Float.valueOf(val.toString());
+						}else if (valType == Date.class){
+							SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
+							val=sdf.parse(val.toString());
+						}else if (valType == User.class){
+							val = UserUtils.getByUserName(val.toString());
+						}else if (valType == Office.class){
+							val = UserUtils.getByOfficeName(val.toString());
+						}else if (valType == Area.class){
+							val = UserUtils.getByAreaName(val.toString());
+						}else if (valType == WorkJobGrade.class){
+							val = UserUtils.getByWorkJobGradeName(val.toString());
+						}else{
+							if (ef.fieldType() != Class.class){
+								val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString());
+							}else{
+								val = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
+										"fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString());
+							}
+						}
+					} catch (Exception ex) {
+						log.info("Get cell value ["+i+","+column+"] error: " + ex.toString());
+						val = null;
+					}
+					// set entity value
+					if (os[1] instanceof Field){
+						Reflections.invokeSetter(e, ((Field)os[1]).getName(), val);
+					}else if (os[1] instanceof Method){
+						String mthodName = ((Method)os[1]).getName();
+						if ("get".equals(mthodName.substring(0, 3))){
+							mthodName = "set"+StringUtils.substringAfter(mthodName, "get");
+						}
+						try {
+                            Reflections.invokeMethod(e, mthodName, new Class[]{valType}, new Object[]{val});
+                        }catch (Exception e3){
+						    log.error("解析Excel失败。",e3);
+                        }
+					}
+				}
+				sb.append(val+", ");
+			}
+			dataList.add(e);
+			log.debug("Read success: ["+i+"] "+sb.toString());
+		}
+		return dataList;
+	}
+
+	/**
 	 * 客户的报表数据
 	 * @param cls
 	 * @param groups

+ 32 - 4
src/main/java/com/jeeplus/modules/ruralprojectrecords/web/RuralProjectSignatureOldMessageDisposeController.java

@@ -6,7 +6,9 @@ import com.jeeplus.common.config.Global;
 import com.jeeplus.common.utils.FreemarkerUtil;
 import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.common.utils.excel.ImportExcel;
 import com.jeeplus.common.web.BaseController;
+import com.jeeplus.modules.pojectMaterialsWarehouse.entity.ProjectMaterialCollectInfo;
 import com.jeeplus.modules.projectAccessory.dao.ProjectTemplateDao;
 import com.jeeplus.modules.projectAccessory.entity.ProjectTemplateInfo;
 import com.jeeplus.modules.projectcontentinfo.dao.ProjectReportRecordDao;
@@ -29,6 +31,7 @@ import com.jeeplus.modules.sys.utils.UserUtils;
 import com.jeeplus.modules.tools.utils.SignaturePostUtil;
 import com.jeeplus.modules.utils.SftpClientUtil;
 import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
+import com.jeeplus.modules.workinvoice.entity.TemporaryInvoiceInfo;
 import com.jeeplus.modules.workinvoice.service.WorkInvoiceService;
 import freemarker.template.Configuration;
 import freemarker.template.Template;
@@ -710,12 +713,12 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
         Map<String,Object> map = new HashMap<>();
         Integer year = 2024;
         long l1 = System.currentTimeMillis();
-        logger.info("-----------公司级—月度报表(开始)------------------");
+        /*logger.info("-----------公司级—月度报表(开始)------------------");
         workInvoiceService.exportInvoiceDataInfoByYear(year);
-        logger.info("------------公司级—月度报表(结束)------------------");
-        /*logger.info("-----------超期未收款发票信息提醒通知(开始)------------------");
+        logger.info("------------公司级—月度报表(结束)------------------");*/
+        logger.info("-----------超期未收款发票信息提醒通知(开始)------------------");
         workInvoiceService.getOverDueGatheringInvoiceList();
-        logger.info("-----------超期未收款发票信息提醒通知(结束)------------------");*/
+        logger.info("-----------超期未收款发票信息提醒通知(结束)------------------");
 
         map.put("msgMonth","月度报表处理完成");
         long l2 = System.currentTimeMillis();
@@ -723,4 +726,29 @@ public class RuralProjectSignatureOldMessageDisposeController extends BaseContro
         return map;
     }
 
+    /**
+     * 报表处理
+     * @return
+     */
+    @RequestMapping(value = "/invoiceUpdateRedNumber")
+    @ResponseBody
+    @Transactional(readOnly = false)
+    public Map<String,Object> invoiceUpdateRedNumber(MultipartFile file){
+        Map<String,Object> map = new HashMap<>();
+        try {
+            ImportExcel ei = new ImportExcel(file, 0, 0);
+            List<TemporaryInvoiceInfo> invoiceInfoList = ei.getNewDataList(TemporaryInvoiceInfo.class);
+            workInvoiceService.disposeInvoiceRedInfo(invoiceInfoList);
+            for (TemporaryInvoiceInfo invoiceInfo : invoiceInfoList) {
+                System.out.println(invoiceInfo.getNumber());
+                System.out.println(invoiceInfo.getRedNumber());
+            }
+
+        } catch (Exception e){
+
+        }
+        map.put("msgMonth","月度报表处理完成");
+        return map;
+    }
+
 }

+ 14 - 0
src/main/java/com/jeeplus/modules/workinvoice/dao/WorkInvoiceDao.java

@@ -206,4 +206,18 @@ public interface WorkInvoiceDao extends CrudDao<WorkInvoice> {
 	 * @return
 	 */
 	Integer queryCountOnRedInvoice(WorkInvoice workInvoice);
+
+	/**
+	 * 根据发票申请编号查询数据信息(最近的一条有效数据)
+	 * @param number
+	 * @return
+	 */
+	WorkInvoice getByNumber(String number);
+
+	/**
+	 * 修改红冲数据关联数据信息
+	 * @param workInvoice
+	 * @return
+	 */
+	Integer updateInvoceOnRed(WorkInvoice workInvoice);
 }

+ 30 - 0
src/main/java/com/jeeplus/modules/workinvoice/entity/TemporaryInvoiceInfo.java

@@ -0,0 +1,30 @@
+package com.jeeplus.modules.workinvoice.entity;
+
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+
+/**
+ * @author: 徐滕
+ * @version: 2024-08-19 09:49
+ */
+public class TemporaryInvoiceInfo {
+    private String number;
+    private String redNumber;
+
+    @ExcelField(title="发票申请编号", align=2, sort=1)
+    public String getNumber() {
+        return number;
+    }
+
+    public void setNumber(String number) {
+        this.number = number;
+    }
+
+    @ExcelField(title="发票申请关联编号", align=2, sort=2)
+    public String getRedNumber() {
+        return redNumber;
+    }
+
+    public void setRedNumber(String redNumber) {
+        this.redNumber = redNumber;
+    }
+}

+ 28 - 0
src/main/java/com/jeeplus/modules/workinvoice/entity/WorkInvoiceExport.java

@@ -96,6 +96,9 @@ public class WorkInvoiceExport extends ActEntity<WorkInvoiceExport> {
 	private List<Workattachment> workAttachments;//附件
 	private Double receiptMoneyD; //已收款金额
 	private Double notReceiptMoneyD; //未收款金额
+	private Integer redInvoiceFlag; //是否红字发票
+	private String redInvoiceRelevancyId;	//红字发票关联其他发票id
+	private String redInvoiceRelevancyNumber;	//红字发票关联其他发票编号
 
 
 	@Override
@@ -681,4 +684,29 @@ public class WorkInvoiceExport extends ActEntity<WorkInvoiceExport> {
 	public void setNotReceiptMoneyD(Double notReceiptMoneyD) {
 		this.notReceiptMoneyD = notReceiptMoneyD;
 	}
+
+	public Integer getRedInvoiceFlag() {
+		return redInvoiceFlag;
+	}
+
+	public void setRedInvoiceFlag(Integer redInvoiceFlag) {
+		this.redInvoiceFlag = redInvoiceFlag;
+	}
+
+	public String getRedInvoiceRelevancyId() {
+		return redInvoiceRelevancyId;
+	}
+
+	public void setRedInvoiceRelevancyId(String redInvoiceRelevancyId) {
+		this.redInvoiceRelevancyId = redInvoiceRelevancyId;
+	}
+
+	@ExcelField(title="红字关联发票编号", align=2, sort=18)
+	public String getRedInvoiceRelevancyNumber() {
+		return redInvoiceRelevancyNumber;
+	}
+
+	public void setRedInvoiceRelevancyNumber(String redInvoiceRelevancyNumber) {
+		this.redInvoiceRelevancyNumber = redInvoiceRelevancyNumber;
+	}
 }

+ 33 - 2
src/main/java/com/jeeplus/modules/workinvoice/service/WorkInvoiceService.java

@@ -42,6 +42,7 @@ import com.jeeplus.modules.workclientinfo.entity.WorkClientLinkman;
 import com.jeeplus.modules.workcontractinfo.service.WorkContractInfoService;
 import com.jeeplus.modules.workinvoice.dao.WorkInvoiceDao;
 import com.jeeplus.modules.workinvoice.dao.WorkInvoiceReceiptDao;
+import com.jeeplus.modules.workinvoice.entity.TemporaryInvoiceInfo;
 import com.jeeplus.modules.workinvoice.entity.WorkInvoice;
 import com.jeeplus.modules.workinvoice.entity.WorkInvoiceProjectRelation;
 import com.jeeplus.modules.workinvoice.entity.WorkInvoiceReceipt;
@@ -63,6 +64,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -3710,6 +3712,9 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 		//发票idlist转String 方便判断
 		String workInvoiceIds = String.join(",", workInvoiceIdList);
 
+		// 定义日期格式
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+
 		for (WorkInvoice workInvoice : overDueGatheringInvoiceList) {
 			//如果发票不在红冲的数据中,则需要进行通知
 			if(!workInvoiceIds.contains(workInvoice.getId())){
@@ -3741,8 +3746,12 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 				WorkProjectNotify notify = new WorkProjectNotify();
 				notify.setNotifyId(workInvoice.getId());
 
-				String notifyStr = "项目【"+ projectNameStr +"】。发票申请编号:" + workInvoice.getNumber() + "未收款。";
-				String titleStr = "项目【"+ projectNameStr +"】。发票申请编号:" + workInvoice.getNumber() + "未收款。开票距今:"+workInvoice.getAdventDate() + "天。";
+
+				// 将Date对象格式化为指定格式的字符串
+				String returnInvoiceDate = dateFormat.format(workInvoice.getInvoiceDate());
+
+				String notifyStr = "项目【"+ projectNameStr +"】。发票申请编号:" + workInvoice.getNumber() + "未收款。开票日期:" + returnInvoiceDate;
+				String titleStr = "项目【"+ projectNameStr +"】。发票申请编号:" + workInvoice.getNumber() + "未收款。开票日期:" + returnInvoiceDate + "。开票距今:"+workInvoice.getAdventDate() + "天。";
 
 				//根据标题查询通知信息中是否存在未读的信息,有则进行更新并对重复数量进行+1操作
 				WorkProjectNotify byTitleAndUnread = workProjectNotifyService.getByTitleAndUnread(notifyStr,workInvoice.getCreateBy().getId());
@@ -3963,4 +3972,26 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 		map.put("endDate",endDate);
 		return map;
 	}
+
+
+	public void disposeInvoiceRedInfo(List<TemporaryInvoiceInfo> list){
+		for (TemporaryInvoiceInfo info : list) {
+			if(StringUtils.isNotBlank(info.getNumber()) && StringUtils.isNotBlank(info.getRedNumber())){
+				//根据申请编号查询最近的一条有效的发票数据
+				//根据关联申请编号查询最近的一条有效的发票数据
+				WorkInvoice invoice = workInvoiceDao.getByNumber(info.getNumber());
+				if(null != invoice){
+					//将关联的发票申请编号填入需要修改的发票数据中并保存
+					WorkInvoice relevanceInvoice = workInvoiceDao.getByNumber(info.getRedNumber());
+					if(null != relevanceInvoice){
+						invoice.setRedInvoiceFlag(1);
+						invoice.setRedInvoiceRelevancyId(relevanceInvoice.getId());
+						invoice.setRedInvoiceRelevancyNumber(relevanceInvoice.getNumber());
+						workInvoiceDao.updateInvoceOnRed(invoice);
+					}
+				}
+			}
+		}
+	}
+
 }

+ 15 - 1
src/main/java/com/jeeplus/modules/workprojectnotify/web/WorkProjectNotifyController.java

@@ -2302,7 +2302,7 @@ public class WorkProjectNotifyController extends BaseController {
 						return "modules/workinvoice/workInvoiceModify";
 					}
 				} else if (workProjectNotify.getType().equals("216")) {    //发票超期未收款
-					getOverDueGatheringInvoiceList(workProjectNotify,model);
+					return this.getOverDueGatheringInvoiceList(workProjectNotify,model);
 				} else if (workProjectNotify.getType().equals("212")) {    //开票管理
 					WorkInvoice workInvoice = workInvoiceService.get(workProjectNotify.getNotifyId());
 					if (StringUtils.isNotBlank(workInvoice.getId())) {
@@ -10711,6 +10711,20 @@ public class WorkProjectNotifyController extends BaseController {
 		} else {
 			workInvoice.setHome("home");
 		}
+		List<MainDictDetail> billingContentList = DictUtils.getMainDictList("billing_content");
+		for (MainDictDetail dictDetail : billingContentList) {
+			if (workInvoice.getBillingContent().equals(dictDetail.getValue())) {
+				workInvoice.setBillingContent(dictDetail.getLabel());
+				break;
+			}
+		}
+		List<MainDictDetail> receiptTypeList = DictUtils.getMainDictList("receipt_type");
+		for (MainDictDetail dictDetail : receiptTypeList) {
+			if (workInvoice.getChargeType().equals(dictDetail.getValue())) {
+				workInvoice.setChargeType(dictDetail.getLabel());
+				break;
+			}
+		}
 		workInvoice.setAct(getByAct(workInvoice.getProcessInstanceId()));
 		String taskDefKey = workInvoice.getAct().getTaskDefKey();
 		model.addAttribute("workInvoice", workInvoice);

+ 37 - 4
src/main/resources/mappings/modules/workinvoice/WorkInvoiceDao.xml

@@ -550,7 +550,10 @@
 				AND so.id  = #{officeId}
 			</if>-->
 			<if test="money != null and money != ''">
-				AND a.money = #{money}
+				AND a.money LIKE
+				<if test="dbName == 'oracle'">'%'||#{money}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{money}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{money},'%')</if>
 			</if>
 			<!--<if test="submitterId != null and submitterId != ''">
 				AND a.create_by = #{submitterId}
@@ -1122,7 +1125,10 @@
 		WHERE wipr1.invoice_id = a.id) as reportNumber,
 		/*(select wir.receipt_date from work_invoice_receipt wir where wir.invoice_id = a.id order by wir.receipt_date desc limit 1 ) as "receiptMoneyDate",*/
 		ifnull(( SELECT wir.receipt_date FROM work_invoice_receipt wir WHERE wir.invoice_id = a.id ORDER BY wir.receipt_date DESC LIMIT 1 ),a.receipt_money_date) AS "receiptMoneyDate",
-		ifnull((select sum(wir.money) from work_invoice_receipt wir where wir.invoice_id = a.id ),0) as "receiptMoneyD"
+		ifnull((select sum(wir.money) from work_invoice_receipt wir where wir.invoice_id = a.id ),0) as "receiptMoneyD",
+		a.red_invoice_flag as "redInvoiceFlag",
+		a.red_invoice_relevancy_id as "redInvoiceRelevancyId",
+		a.red_invoice_relevancy_number as "redInvoiceRelevancyNumber"
 		FROM work_invoice a
 		LEFT JOIN sys_user su ON su.id = a.create_by
 		LEFT JOIN work_client_info w ON  w.id = a.client_id
@@ -1518,7 +1524,10 @@
 				AND a.receipt_money = #{receiptMoney}
 			</if>
 			<if test="money != null and money != ''">
-				AND a.money = #{money}
+				AND a.money LIKE
+				<if test="dbName == 'oracle'">'%'||#{money}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{money}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{money},'%')</if>
 			</if>
 			<if test="invoiceType != null and invoiceType != ''">
 				AND a.invoice_type = #{invoiceType}
@@ -2985,7 +2994,10 @@
 		a.actual_drawer_email_address as "actualDrawerEmailAddress",
 		a.actual_drawer_id as "actualDrawerId",
 		a.electronic_invoice_flag as "electronicInvoiceFlag",
-		datediff(now(), a.invoice_date) as adventDate
+		datediff(now(), a.invoice_date) as adventDate,
+		a.red_invoice_flag as "redInvoiceFlag",
+		a.red_invoice_relevancy_id as "redInvoiceRelevancyId",
+		a.red_invoice_relevancy_number as "redInvoiceRelevancyNumber"
 		from work_invoice a
 		<where>
 			a.invoice_date &lt;= #{invoiceDate}
@@ -3049,4 +3061,25 @@
 
 		</where>
 	</select>
+
+	<select id="getByNumber" resultType="WorkInvoice">
+		SELECT
+		<include refid="workInvoiceColumns"/>
+		,
+		acu.name as "accountCheckingUserName"
+		,actu.name as "actualDrawerName"
+		FROM work_invoice a
+		<include refid="workInvoiceJoins"/>
+		WHERE a.number = #{number} and a.del_flag = 0 order by a.invoice_date desc limit 1
+	</select>
+
+	<update id="updateInvoceOnRed">
+		UPDATE work_invoice SET
+			red_invoice_flag = #{redInvoiceFlag},
+			red_invoice_relevancy_id = #{redInvoiceRelevancyId},
+			red_invoice_relevancy_number = #{redInvoiceRelevancyNumber}
+		WHERE id = #{id}
+	</update>
+
+
 </mapper>

+ 1 - 1
src/main/webapp/webpage/modules/workinvoice/workInvoiceView.jsp

@@ -228,7 +228,7 @@
 						<input id="redInvoiceRelevancyNumber"  style="background-color: #f1f1f1" name="redInvoiceRelevancyNumber" htmlEscape="false" readonly="true"   class="form-control layui-input" value="${workInvoice.redInvoiceRelevancyNumber}"/>
 					</div>
 				</div>
-				<div class="layui-item layui-col-sm6">
+				<div class="layui-item layui-col-sm12">
 					<label class="layui-form-label">开票内容要求:</label>
 					<div class="layui-input-block">
 						<input htmlEscape="false" readonly="true" style="background-color: #f1f1f1"  class="form-control layui-input" value="${workInvoice.content}"/>