commit
This commit is contained in:
@@ -28,7 +28,7 @@ import javax.servlet.http.HttpSession;
|
||||
public class LoginUtil {
|
||||
|
||||
public enum LoginOrigin {
|
||||
APP, WEB, WEB_H5, CAS, QI_YE_WEI_XIN, WEI_XIN;
|
||||
APP, WEB, WEB_H5, CAS, QI_YE_WEI_XIN, WEI_XIN, SMS_CODE;
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -23,7 +23,9 @@ import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
@@ -265,4 +267,5 @@ public class MsgApi {
|
||||
return access_token;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import io.v.nutz.zhgh.msgNotify.models.Orm_Msg;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
@@ -9,7 +11,11 @@ import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -22,6 +28,7 @@ import java.util.List;
|
||||
* Created by wizzer on 2017/5/24.
|
||||
*/
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class RCSCloudAPI {
|
||||
/**
|
||||
* 账号
|
||||
@@ -50,10 +57,29 @@ public class RCSCloudAPI {
|
||||
*
|
||||
* String
|
||||
*/
|
||||
public static String sendTplSms(String tplId,String mobile,String content,String extno){
|
||||
/* DefaultHttpClient httpclient = new DefaultHttpClient();
|
||||
public static String sendTplSms(String tplId, String mobile, String content, String extno, Orm_Msg orm_msg) {
|
||||
String tplJson = queryTplById(tplId);
|
||||
NutMap tplJsonMap = Json.fromJson(NutMap.class, tplJson);
|
||||
NutMap tplContentMap = tplJsonMap.getAs("tpl", NutMap.class);
|
||||
String tplContent = tplContentMap.getString("content");
|
||||
|
||||
DefaultHttpClient httpclient = new DefaultHttpClient();
|
||||
String resultJson = "";
|
||||
try {
|
||||
String[] contentSplit = content.split("\\|\\|");
|
||||
for (int i = 0; i < contentSplit.length; i++) {
|
||||
String s = "@" + (i + 1) + "@=";
|
||||
String replace = contentSplit[i].replace(s, "");
|
||||
System.out.println(replace);
|
||||
tplContent = tplContent.replace("@" + (i + 1) + "@", replace);
|
||||
}
|
||||
if (!"暂无".equals(orm_msg.getMsgCode())){
|
||||
orm_msg.setContent(tplContent);
|
||||
Dao dao = Mvcs.getIoc().get(Dao.class);
|
||||
dao.insert(orm_msg);
|
||||
}
|
||||
|
||||
|
||||
//签名:Md5(sid+key+tplid+mobile+content)
|
||||
StringBuilder signStr = new StringBuilder();
|
||||
signStr.append(ACCOUNT_SID).append(ACCOUNT_APIKEY).append(tplId).append(mobile).append(content);
|
||||
@@ -62,7 +88,7 @@ public class RCSCloudAPI {
|
||||
String sign = md5Digest(changeCharset(signStr.toString(), "utf-8"));
|
||||
//String sign = md5Digest(changeCharset(signStr.toString(), "GB2312"));
|
||||
//创建HttpPost请求
|
||||
HttpPost httppost = new HttpPost(HttpUrl +"/sms/sendtplsms.json");//?sid="+ACCOUNT_SID+"&sign="+sign
|
||||
HttpPost httppost = new HttpPost(HttpUrl + "/sms/sendtplsms.json");//?sid="+ACCOUNT_SID+"&sign="+sign
|
||||
//构建form
|
||||
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
||||
nvps.add(new BasicNameValuePair("sid", ACCOUNT_SID));
|
||||
@@ -71,7 +97,7 @@ public class RCSCloudAPI {
|
||||
nvps.add(new BasicNameValuePair("mobile", mobile));
|
||||
nvps.add(new BasicNameValuePair("content", content));
|
||||
nvps.add(new BasicNameValuePair("extno", extno));
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nvps,CHARSET_UTF8);
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nvps, CHARSET_UTF8);
|
||||
httppost.setEntity(entity);
|
||||
|
||||
//设置请求表头信息,POST请求必须采用application/x-www-form-urlencoded否则提示415错误
|
||||
@@ -79,27 +105,29 @@ public class RCSCloudAPI {
|
||||
httppost.setHeader("Content-Encoding", CHARSET_UTF8);
|
||||
|
||||
|
||||
|
||||
//执行请求
|
||||
HttpResponse response = httpclient.execute(httppost);
|
||||
//获取响应Entity
|
||||
HttpEntity httpEntity = response.getEntity();
|
||||
//返回JSON字符串格式,用户根据实际业务进行解析处理
|
||||
if (httpEntity != null)
|
||||
if (httpEntity != null) {
|
||||
resultJson = EntityUtils.toString(httpEntity, CHARSET_UTF8);
|
||||
}
|
||||
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
} finally {
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" +resultJson);
|
||||
return resultJson;*/
|
||||
return "";
|
||||
log.info(resultJson);
|
||||
log.info("手机号="+mobile);
|
||||
log.info("发送成功==================");
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,16 +149,18 @@ public class RCSCloudAPI {
|
||||
HttpGet httpget = new HttpGet(url.toString());
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
resultJson = EntityUtils.toString(entity, CHARSET_UTF8);
|
||||
}
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" + resultJson);
|
||||
return resultJson;
|
||||
@@ -154,16 +184,18 @@ public class RCSCloudAPI {
|
||||
HttpGet httpget = new HttpGet(url.toString());
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
resultJson = EntityUtils.toString(entity, CHARSET_UTF8);
|
||||
}
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" + resultJson);
|
||||
return resultJson;
|
||||
@@ -187,16 +219,18 @@ public class RCSCloudAPI {
|
||||
HttpGet httpget = new HttpGet(url.toString());
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
resultJson = EntityUtils.toString(entity, CHARSET_UTF8);
|
||||
}
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" + resultJson);
|
||||
return resultJson;
|
||||
@@ -220,8 +254,9 @@ public class RCSCloudAPI {
|
||||
HttpGet httpget = new HttpGet(url.toString());
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
resultJson = EntityUtils.toString(entity, CHARSET_UTF8);
|
||||
}
|
||||
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
@@ -229,8 +264,9 @@ public class RCSCloudAPI {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" + resultJson);
|
||||
return resultJson;
|
||||
@@ -256,16 +292,18 @@ public class RCSCloudAPI {
|
||||
HttpGet httpget = new HttpGet(url.toString());
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
resultJson = EntityUtils.toString(entity, CHARSET_UTF8);
|
||||
}
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" + resultJson);
|
||||
return resultJson;
|
||||
@@ -293,16 +331,18 @@ public class RCSCloudAPI {
|
||||
HttpGet httpget = new HttpGet(url.toString());
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
resultJson = EntityUtils.toString(entity, CHARSET_UTF8);
|
||||
}
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" + resultJson);
|
||||
return resultJson;
|
||||
@@ -329,16 +369,18 @@ public class RCSCloudAPI {
|
||||
HttpGet httpget = new HttpGet(url.toString());
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null)
|
||||
if (entity != null) {
|
||||
resultJson = EntityUtils.toString(entity, CHARSET_UTF8);
|
||||
}
|
||||
EntityUtils.consume(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (httpclient != null)
|
||||
if (httpclient != null) {
|
||||
httpclient.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
System.out.println("resultJson=" + resultJson);
|
||||
return resultJson;
|
||||
@@ -363,8 +405,9 @@ public class RCSCloudAPI {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < b.length; ++i) {
|
||||
String s = Integer.toHexString(b[i] & 0xFF);
|
||||
if (s.length() == 1)
|
||||
if (s.length() == 1) {
|
||||
sb.append("0");
|
||||
}
|
||||
sb.append(s.toUpperCase());
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
@@ -12,13 +12,16 @@ import io.v.nutz.sys.services.SysRoleService;
|
||||
import io.v.nutz.sys.services.SysUnitService;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import io.v.nutz.web.commons.captcha.services.CaptchaService;
|
||||
import io.v.nutz.web.commons.exception.CaptchaException;
|
||||
import io.v.nutz.web.commons.exception.SmsException;
|
||||
import io.v.nutz.web.commons.ext.validate.ValidateService;
|
||||
import io.v.nutz.web.commons.shiro.exception.CaptchaEmptyException;
|
||||
import io.v.nutz.web.commons.shiro.exception.CaptchaIncorrectException;
|
||||
import io.v.nutz.web.commons.shiro.filter.PlatformAuthenticationFilter;
|
||||
import io.v.nutz.web.commons.slog.SLogService;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.*;
|
||||
@@ -73,6 +76,8 @@ public class SysLoginController {
|
||||
private ValidateService validateService;
|
||||
@Inject
|
||||
private LoginUtil loginUtil;
|
||||
@Inject
|
||||
private CaptchaService captchaService;
|
||||
|
||||
|
||||
@At("")
|
||||
@@ -157,6 +162,20 @@ public class SysLoginController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
public Object validVerify(String nonceStr, String value) {
|
||||
if(StringUtils.isBlank(nonceStr) || StringUtils.isBlank(value)) {
|
||||
return cn.wizzer.framework.base.Result.error("验证字符信息不能为空!");
|
||||
}
|
||||
String s = captchaService.checkImageCode(nonceStr, value);
|
||||
if(StringUtils.isNotBlank(s)) {
|
||||
return cn.wizzer.framework.base.Result.error(s);
|
||||
}
|
||||
return cn.wizzer.framework.base.Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登陆验证
|
||||
*
|
||||
@@ -167,10 +186,14 @@ public class SysLoginController {
|
||||
@At("/doLogin")
|
||||
@Ok("json")
|
||||
@Filters(@By(type = PlatformAuthenticationFilter.class))
|
||||
public Object doLogin(@Attr("platformLoginToken") AuthenticationToken token, HttpServletRequest req, HttpSession session) {
|
||||
public Object doLogin(@Attr("platformLoginToken") AuthenticationToken token,String loginType, HttpServletRequest req, HttpSession session) {
|
||||
int errCount = NumberUtils.toInt(Strings.sNull(SecurityUtils.getSubject().getSession(true).getAttribute("platformErrCount")));
|
||||
try {
|
||||
loginUtil.doLogin(token, req, session, LoginUtil.LoginOrigin.WEB);
|
||||
if ("SMS_CODE".equals(loginType)){
|
||||
loginUtil.doLogin(token, req, session, LoginUtil.LoginOrigin.SMS_CODE);
|
||||
} else {
|
||||
loginUtil.doLogin(token, req, session, LoginUtil.LoginOrigin.WEB);
|
||||
}
|
||||
return Result.success("login.success");
|
||||
} catch (CaptchaIncorrectException e) {
|
||||
return Result.error(1, "login.error.captcha");
|
||||
@@ -185,7 +208,7 @@ public class SysLoginController {
|
||||
} catch (AuthenticationException e) {
|
||||
errCount++;
|
||||
SecurityUtils.getSubject().getSession(true).setAttribute("platformErrCount", errCount);
|
||||
return Result.error(5, "login.error.user");
|
||||
return Result.error(5, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
errCount++;
|
||||
SecurityUtils.getSubject().getSession(true).setAttribute("platformErrCount", errCount);
|
||||
@@ -193,6 +216,7 @@ public class SysLoginController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出系统
|
||||
*/
|
||||
@@ -241,6 +265,28 @@ public class SysLoginController {
|
||||
return Result.success(validateService.getCode());
|
||||
}
|
||||
|
||||
|
||||
@At("/mobileCaptcha")
|
||||
@Ok("json")
|
||||
public Object mobileLoginSmsCode(String mobile) {
|
||||
try {
|
||||
return Result.success(validateService.getSMSCode(mobile));
|
||||
} catch (SmsException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
public Object validMobile(String mobile) {
|
||||
if(StringUtils.isBlank(mobile)) {
|
||||
return Result.error("手机号不能为空!");
|
||||
}
|
||||
int mobileCount = sysUserService.count(Cnd.where("mobile", "=", mobile));
|
||||
return mobileCount <= 0 ? Result.error("手机号不存在") : Result.success();
|
||||
}
|
||||
|
||||
|
||||
@At("/doReg")
|
||||
@Ok("json")
|
||||
public Object doReg(@Param("mobile") String mobile, @Param("password") String password, @Param("code") String code, HttpServletRequest req) {
|
||||
@@ -264,12 +310,14 @@ public class SysLoginController {
|
||||
user.setMenuTheme("left");
|
||||
user.setCreatedBy(ShiroUtil.getPlatformUid());
|
||||
Sys_unit unit = sysUnitService.fetch(Cnd.where("unitcode", "=", Globals.MyConfig.getString("AppDefaultUserUnit")));
|
||||
if (unit != null)
|
||||
if (unit != null) {
|
||||
user.setUnitid(unit.getId());
|
||||
}
|
||||
Sys_role role = sysRoleService.fetch(Cnd.where("code", "=", Globals.MyConfig.getString("AppDefaultUserRole")));
|
||||
sysUserService.insert(user);
|
||||
if (role != null)
|
||||
if (role != null) {
|
||||
sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId()).add("userId", user.getId()));
|
||||
}
|
||||
sysUserService.clearCache();
|
||||
return Result.success();
|
||||
} catch (CaptchaException e) {
|
||||
|
||||
@@ -323,7 +323,7 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
private String hobby;
|
||||
|
||||
@Column
|
||||
@Comment("婚否")
|
||||
@Comment("婚姻状况")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String marriage;
|
||||
|
||||
@@ -394,9 +394,17 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
|
||||
@Data
|
||||
public static class Family implements Serializable {
|
||||
//与本人关系
|
||||
private String relation;
|
||||
//姓名
|
||||
private String name;
|
||||
//是否慰问
|
||||
private String isCondolence;
|
||||
//慰问时间
|
||||
private String condolenceTime;
|
||||
//单位
|
||||
private String unit;
|
||||
//备注
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -661,6 +669,11 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
@ColDefine(type = ColType.DATE)
|
||||
private String workDate;
|
||||
|
||||
@Column
|
||||
@Comment("起薪日期")
|
||||
@ColDefine(type = ColType.DATE)
|
||||
private Date startSalaryDate;
|
||||
|
||||
/**
|
||||
* 前端菜单
|
||||
*/
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
package io.v.nutz.task.job.asset;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxService;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:AssetScrapJob
|
||||
* @Date 2024/6/12 17:44
|
||||
* @注释
|
||||
*/
|
||||
@IocBean
|
||||
public class AssetScrapJob implements Job {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.categoryName AS assetStatusName,
|
||||
CASE
|
||||
WHEN TIMESTAMPDIFF(MONTH, xx.storageDate, CURDATE()) < 1 THEN '不足1月'
|
||||
ELSE CONCAT(TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()),'年',
|
||||
TIMESTAMPDIFF(MONTH, xx.storageDate + INTERVAL TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()) YEAR, CURDATE()),'月')
|
||||
END AS yearsAndMonths
|
||||
FROM
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.assetStatus = lb.contentCode
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
//工会在用
|
||||
seg.or(new Static("JSON_CONTAINS(xx.assetStatus, CAST('\"%s\"' AS JSON), '$')".formatted("1001")));
|
||||
//异地在用
|
||||
seg.or(new Static("JSON_CONTAINS(xx.assetStatus, CAST('\"%s\"' AS JSON), '$')".formatted("1002")));
|
||||
cnd.and(seg);
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> list = baseService.listMap(sql);
|
||||
|
||||
List<Zgfw_Zcxx> zcList = new ArrayList<>();
|
||||
|
||||
list.forEach(v->{
|
||||
if (StrUtil.isBlank(v.getString("minimumUsageYear")) && StrUtil.isBlank(v.getString("yearsAndMonths"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
String minimumUsageYear = v.getString("minimumUsageYear");
|
||||
String yearsAndMonths = v.getString("yearsAndMonths");
|
||||
|
||||
boolean yearsAndMonthsExceeded = isYearsAndMonthsExceeded(minimumUsageYear, yearsAndMonths);
|
||||
if (yearsAndMonthsExceeded){
|
||||
Zgfw_Zcxx zgfwZcxx = new Zgfw_Zcxx();
|
||||
String assetStatus = v.getString("assetStatus");
|
||||
List<String> assetList = JSONUtil.parseArray(assetStatus).toList(String.class);
|
||||
assetList.add("1003");
|
||||
zgfwZcxx.setId(v.getString("id"));
|
||||
zgfwZcxx.setAssetStatus(assetList);
|
||||
zcList.add(zgfwZcxx);
|
||||
}
|
||||
});
|
||||
|
||||
baseService.dao().updateIgnoreNull(zcList);
|
||||
}
|
||||
|
||||
|
||||
public boolean isYearsAndMonthsExceeded(String minimumUsageYear, String yearsAndMonths) {
|
||||
// 提取yearsAndMonths中的年份部分
|
||||
String yearPart = yearsAndMonths.split("年")[0];
|
||||
|
||||
// 将提取的年份转换为整数
|
||||
int year = Integer.parseInt(yearPart);
|
||||
|
||||
// 将minimumUsageYear转换为整数
|
||||
int minimumYear = Integer.parseInt(minimumUsageYear);
|
||||
|
||||
// 比较年份
|
||||
return year > minimumYear;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package io.v.nutz.web.commons.captcha;
|
||||
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.web.commons.captcha.models.Captcha;
|
||||
import io.v.nutz.web.commons.captcha.services.CaptchaService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
@At("/captcha")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
public class CaptchaController {
|
||||
|
||||
@Inject
|
||||
private CaptchaService captchaService;
|
||||
|
||||
@At("/get-captcha")
|
||||
public Object getCaptcha(Captcha captcha) {
|
||||
captcha.setPlace(1);
|
||||
return Result.success(captchaService.getCaptcha(captcha));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package io.v.nutz.web.commons.captcha.models;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Captcha implements Serializable {
|
||||
|
||||
/**
|
||||
* 随机字符串
|
||||
**/
|
||||
private String nonceStr;
|
||||
/**
|
||||
* 验证值
|
||||
**/
|
||||
private String value;
|
||||
/**
|
||||
* 生成的画布的base64
|
||||
**/
|
||||
private String canvasSrc;
|
||||
/**
|
||||
* 画布宽度
|
||||
**/
|
||||
private Integer canvasWidth;
|
||||
/**
|
||||
* 画布高度
|
||||
**/
|
||||
private Integer canvasHeight;
|
||||
/**
|
||||
* 生成的阻塞块的base64
|
||||
**/
|
||||
private String blockSrc;
|
||||
/**
|
||||
* 阻塞块宽度
|
||||
**/
|
||||
private Integer blockWidth;
|
||||
/**
|
||||
* 阻塞块高度
|
||||
**/
|
||||
private Integer blockHeight;
|
||||
/**
|
||||
* 阻塞块凸凹半径
|
||||
**/
|
||||
private Integer blockRadius;
|
||||
/**
|
||||
* 阻塞块的横轴坐标
|
||||
**/
|
||||
private Integer blockX;
|
||||
/**
|
||||
* 阻塞块的纵轴坐标
|
||||
**/
|
||||
private Integer blockY;
|
||||
/**
|
||||
* 图片获取位置
|
||||
**/
|
||||
private Integer place;
|
||||
|
||||
public String getNonceStr() {
|
||||
return nonceStr;
|
||||
}
|
||||
|
||||
public void setNonceStr(String nonceStr) {
|
||||
this.nonceStr = nonceStr;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getCanvasSrc() {
|
||||
return canvasSrc;
|
||||
}
|
||||
|
||||
public void setCanvasSrc(String canvasSrc) {
|
||||
this.canvasSrc = canvasSrc;
|
||||
}
|
||||
|
||||
public Integer getCanvasWidth() {
|
||||
return canvasWidth;
|
||||
}
|
||||
|
||||
public void setCanvasWidth(Integer canvasWidth) {
|
||||
this.canvasWidth = canvasWidth;
|
||||
}
|
||||
|
||||
public Integer getCanvasHeight() {
|
||||
return canvasHeight;
|
||||
}
|
||||
|
||||
public void setCanvasHeight(Integer canvasHeight) {
|
||||
this.canvasHeight = canvasHeight;
|
||||
}
|
||||
|
||||
public String getBlockSrc() {
|
||||
return blockSrc;
|
||||
}
|
||||
|
||||
public void setBlockSrc(String blockSrc) {
|
||||
this.blockSrc = blockSrc;
|
||||
}
|
||||
|
||||
public Integer getBlockWidth() {
|
||||
return blockWidth;
|
||||
}
|
||||
|
||||
public void setBlockWidth(Integer blockWidth) {
|
||||
this.blockWidth = blockWidth;
|
||||
}
|
||||
|
||||
public Integer getBlockHeight() {
|
||||
return blockHeight;
|
||||
}
|
||||
|
||||
public void setBlockHeight(Integer blockHeight) {
|
||||
this.blockHeight = blockHeight;
|
||||
}
|
||||
|
||||
public Integer getBlockRadius() {
|
||||
return blockRadius;
|
||||
}
|
||||
|
||||
public void setBlockRadius(Integer blockRadius) {
|
||||
this.blockRadius = blockRadius;
|
||||
}
|
||||
|
||||
public Integer getBlockX() {
|
||||
return blockX;
|
||||
}
|
||||
|
||||
public void setBlockX(Integer blockX) {
|
||||
this.blockX = blockX;
|
||||
}
|
||||
|
||||
public Integer getBlockY() {
|
||||
return blockY;
|
||||
}
|
||||
|
||||
public void setBlockY(Integer blockY) {
|
||||
this.blockY = blockY;
|
||||
}
|
||||
|
||||
public Integer getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
||||
public void setPlace(Integer place) {
|
||||
this.place = place;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package io.v.nutz.web.commons.captcha.services;
|
||||
|
||||
import io.v.nutz.web.commons.captcha.models.Captcha;
|
||||
import io.v.nutz.web.commons.captcha.util.CaptchaUtils;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.UUID;
|
||||
|
||||
@IocBean
|
||||
public class CaptchaService {
|
||||
|
||||
/**
|
||||
* 拼图验证码允许偏差
|
||||
**/
|
||||
private static Integer ALLOW_DEVIATION = 3;
|
||||
|
||||
@Inject
|
||||
private RedisService stringRedisTemplate;
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
* @param imageKey
|
||||
* @param imageCode
|
||||
* @return boolean
|
||||
**/
|
||||
public String checkImageCode(String imageKey, String imageCode) {
|
||||
String text = stringRedisTemplate.get("imageCode:" + imageKey);
|
||||
if(Strings.isBlank(text)){
|
||||
return "验证码已失效,请刷新";
|
||||
}
|
||||
// 根据移动距离判断验证是否成功
|
||||
if (Math.abs(Integer.parseInt(text) - Integer.parseInt(imageCode)) > ALLOW_DEVIATION) {
|
||||
return "验证失败,请控制拼图对齐缺口";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 缓存验证码,有效期15分钟
|
||||
* @param key
|
||||
* @param code
|
||||
**/
|
||||
public void saveImageCode(String key, String code) {
|
||||
stringRedisTemplate.setex("imageCode:" + key, 60 * 15, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码拼图(生成的抠图和带抠图阴影的大图及抠图坐标)
|
||||
**/
|
||||
public Object getCaptcha(Captcha captcha) {
|
||||
//参数校验
|
||||
CaptchaUtils.checkCaptcha(captcha);
|
||||
//获取画布的宽高
|
||||
int canvasWidth = captcha.getCanvasWidth();
|
||||
int canvasHeight = captcha.getCanvasHeight();
|
||||
//获取阻塞块的宽高/半径
|
||||
int blockWidth = captcha.getBlockWidth();
|
||||
int blockHeight = captcha.getBlockHeight();
|
||||
int blockRadius = captcha.getBlockRadius();
|
||||
//获取资源图
|
||||
BufferedImage canvasImage = CaptchaUtils.getBufferedImage(captcha.getPlace());
|
||||
//调整原图到指定大小
|
||||
canvasImage = CaptchaUtils.imageResize(canvasImage, canvasWidth, canvasHeight);
|
||||
//随机生成阻塞块坐标
|
||||
int blockX = CaptchaUtils.getNonceByRange(blockWidth, canvasWidth - blockWidth - 10);
|
||||
int blockY = CaptchaUtils.getNonceByRange(10, canvasHeight - blockHeight + 1);
|
||||
//阻塞块
|
||||
BufferedImage blockImage = new BufferedImage(blockWidth, blockHeight, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
//新建的图像根据轮廓图颜色赋值,源图生成遮罩
|
||||
CaptchaUtils.cutByTemplate(canvasImage, blockImage, blockWidth, blockHeight, blockRadius, blockX, blockY);
|
||||
// 移动横坐标
|
||||
String nonceStr = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
// 缓存
|
||||
saveImageCode(nonceStr,String.valueOf(blockX));
|
||||
//设置返回参数
|
||||
captcha.setNonceStr(nonceStr);
|
||||
captcha.setBlockY(blockY);
|
||||
captcha.setBlockSrc(CaptchaUtils.toBase64(blockImage, "png"));
|
||||
captcha.setCanvasSrc(CaptchaUtils.toBase64(canvasImage, "png"));
|
||||
return captcha;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package io.v.nutz.web.commons.captcha.util;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import io.v.nutz.web.commons.captcha.models.Captcha;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
public class CaptchaUtils {
|
||||
|
||||
/**
|
||||
* 网络图片地址
|
||||
**/
|
||||
private final static String IMG_URL = "https://loyer.wang/view/ftp/wallpaper/%s.jpg";
|
||||
|
||||
/**
|
||||
* 本地图片地址
|
||||
**/
|
||||
private final static String IMG_PATH = "E:/wallpaper/%s.jpg";
|
||||
|
||||
/**
|
||||
* 入参校验设置默认值
|
||||
**/
|
||||
public static void checkCaptcha(Captcha captcha) {
|
||||
//设置画布宽度默认值
|
||||
if (captcha.getCanvasWidth() == null) {
|
||||
captcha.setCanvasWidth(320);
|
||||
}
|
||||
//设置画布高度默认值
|
||||
if (captcha.getCanvasHeight() == null) {
|
||||
captcha.setCanvasHeight(155);
|
||||
}
|
||||
//设置阻塞块宽度默认值
|
||||
if (captcha.getBlockWidth() == null) {
|
||||
captcha.setBlockWidth(65);
|
||||
}
|
||||
//设置阻塞块高度默认值
|
||||
if (captcha.getBlockHeight() == null) {
|
||||
captcha.setBlockHeight(55);
|
||||
}
|
||||
//设置阻塞块凹凸半径默认值
|
||||
if (captcha.getBlockRadius() == null) {
|
||||
captcha.setBlockRadius(9);
|
||||
}
|
||||
//设置图片来源默认值
|
||||
if (captcha.getPlace() == null) {
|
||||
captcha.setPlace(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定范围内的随机数
|
||||
**/
|
||||
public static int getNonceByRange(int start, int end) {
|
||||
Random random = new Random();
|
||||
return random.nextInt(end - start + 1) + start;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码资源图
|
||||
**/
|
||||
public static BufferedImage getBufferedImage(Integer place) {
|
||||
try {
|
||||
// //随机图片
|
||||
// int nonce = getNonceByRange(0, 6);
|
||||
// nonce = 0;
|
||||
// //获取网络资源图片
|
||||
// if (0 == place) {
|
||||
// String imgUrl = String.format(IMG_URL, getNonceByRange(0, 100));
|
||||
// URL url = new URL(imgUrl);
|
||||
// return ImageIO.read(url.openStream());
|
||||
// }
|
||||
// //获取本地图片
|
||||
// else {
|
||||
// String imgPath = String.format(IMG_PATH, nonce);
|
||||
// File file = new File(imgPath);
|
||||
// return ImageIO.read(file);
|
||||
// }
|
||||
String imgUrl = String.format(IMG_URL, getNonceByRange(0, 100));
|
||||
// 创建HttpRequest对象
|
||||
HttpRequest request = HttpRequest.get(imgUrl);
|
||||
// 发送请求并获取响应
|
||||
HttpResponse response = request.execute();
|
||||
// 获取输入流
|
||||
return ImageIO.read(response.bodyStream());
|
||||
} catch (Exception e) {
|
||||
System.out.println("获取拼图资源失败");
|
||||
//异常处理
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整图片大小
|
||||
**/
|
||||
public static BufferedImage imageResize(BufferedImage bufferedImage, int width, int height) {
|
||||
Image image = bufferedImage.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
BufferedImage resultImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics2D = resultImage.createGraphics();
|
||||
graphics2D.drawImage(image, 0, 0, null);
|
||||
graphics2D.dispose();
|
||||
return resultImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 抠图,并生成阻塞块
|
||||
**/
|
||||
public static void cutByTemplate(BufferedImage canvasImage, BufferedImage blockImage, int blockWidth, int blockHeight, int blockRadius, int blockX, int blockY) {
|
||||
BufferedImage waterImage = new BufferedImage(blockWidth, blockHeight, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
//阻塞块的轮廓图
|
||||
int[][] blockData = getBlockData(blockWidth, blockHeight, blockRadius);
|
||||
//创建阻塞块具体形状
|
||||
for (int i = 0; i < blockWidth; i++) {
|
||||
for (int j = 0; j < blockHeight; j++) {
|
||||
try {
|
||||
//原图中对应位置变色处理
|
||||
if (blockData[i][j] == 1) {
|
||||
//背景设置为黑色
|
||||
waterImage.setRGB(i, j, Color.BLACK.getRGB());
|
||||
blockImage.setRGB(i, j, canvasImage.getRGB(blockX + i, blockY + j));
|
||||
//轮廓设置为白色,取带像素和无像素的界点,判断该点是不是临界轮廓点
|
||||
if (blockData[i + 1][j] == 0 || blockData[i][j + 1] == 0 || blockData[i - 1][j] == 0 || blockData[i][j - 1] == 0) {
|
||||
blockImage.setRGB(i, j, Color.WHITE.getRGB());
|
||||
waterImage.setRGB(i, j, Color.WHITE.getRGB());
|
||||
}
|
||||
}
|
||||
//这里把背景设为透明
|
||||
else {
|
||||
blockImage.setRGB(i, j, Color.TRANSLUCENT);
|
||||
waterImage.setRGB(i, j, Color.TRANSLUCENT);
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
//防止数组下标越界异常
|
||||
}
|
||||
}
|
||||
}
|
||||
//在画布上添加阻塞块水印
|
||||
addBlockWatermark(canvasImage, waterImage, blockX, blockY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建拼图轮廓轨迹
|
||||
**/
|
||||
private static int[][] getBlockData(int blockWidth, int blockHeight, int blockRadius) {
|
||||
int[][] data = new int[blockWidth][blockHeight];
|
||||
double po = Math.pow(blockRadius, 2);
|
||||
//随机生成两个圆的坐标,在4个方向上 随机找到2个方向添加凸/凹
|
||||
//凸/凹1
|
||||
int face1 = RandomUtils.nextInt(0,4);
|
||||
//凸/凹2
|
||||
int face2;
|
||||
//保证两个凸/凹不在同一位置
|
||||
do {
|
||||
face2 = RandomUtils.nextInt(0,4);
|
||||
} while (face1 == face2);
|
||||
//获取凸/凹起位置坐标
|
||||
int[] circle1 = getCircleCoords(face1, blockWidth, blockHeight, blockRadius);
|
||||
int[] circle2 = getCircleCoords(face2, blockWidth, blockHeight, blockRadius);
|
||||
//随机凸/凹类型
|
||||
int shape = getNonceByRange(0, 1);
|
||||
//圆的标准方程 (x-a)²+(y-b)²=r²,标识圆心(a,b),半径为r的圆
|
||||
//计算需要的小图轮廓,用二维数组来表示,二维数组有两张值,0和1,其中0表示没有颜色,1有颜色
|
||||
for (int i = 0; i < blockWidth; i++) {
|
||||
for (int j = 0; j < blockHeight; j++) {
|
||||
data[i][j] = 0;
|
||||
//创建中间的方形区域
|
||||
if ((i >= blockRadius && i <= blockWidth - blockRadius && j >= blockRadius && j <= blockHeight - blockRadius)) {
|
||||
data[i][j] = 1;
|
||||
}
|
||||
double d1 = Math.pow(i - Objects.requireNonNull(circle1)[0], 2) + Math.pow(j - circle1[1], 2);
|
||||
double d2 = Math.pow(i - Objects.requireNonNull(circle2)[0], 2) + Math.pow(j - circle2[1], 2);
|
||||
//创建两个凸/凹
|
||||
if (d1 <= po || d2 <= po) {
|
||||
data[i][j] = shape;
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 根据朝向获取圆心坐标
|
||||
*/
|
||||
private static int[] getCircleCoords(int face, int blockWidth, int blockHeight, int blockRadius) {
|
||||
//上
|
||||
if (0 == face) {
|
||||
return new int[]{blockWidth / 2 - 1, blockRadius};
|
||||
}
|
||||
//左
|
||||
else if (1 == face) {
|
||||
return new int[]{blockRadius, blockHeight / 2 - 1};
|
||||
}
|
||||
//下
|
||||
else if (2 == face) {
|
||||
return new int[]{blockWidth / 2 - 1, blockHeight - blockRadius - 1};
|
||||
}
|
||||
//右
|
||||
else if (3 == face) {
|
||||
return new int[]{blockWidth - blockRadius - 1, blockHeight / 2 - 1};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 在画布上添加阻塞块水印
|
||||
*/
|
||||
private static void addBlockWatermark(BufferedImage canvasImage, BufferedImage blockImage, int x, int y) {
|
||||
Graphics2D graphics2D = canvasImage.createGraphics();
|
||||
graphics2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.8f));
|
||||
graphics2D.drawImage(blockImage, x, y, null);
|
||||
graphics2D.dispose();
|
||||
}
|
||||
/**
|
||||
* BufferedImage转BASE64
|
||||
*/
|
||||
public static String toBase64(BufferedImage bufferedImage, String type) {
|
||||
try {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, type, byteArrayOutputStream);
|
||||
String base64 = Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
|
||||
return String.format("data:image/%s;base64,%s", type, base64);
|
||||
} catch (Exception e) {
|
||||
System.out.println("图片资源转换BASE64失败");
|
||||
//异常处理
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
package io.v.nutz.web.commons.ext.validate;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.constant.RedisConstant;
|
||||
import io.v.nutz.base.utils.RCSCloudAPI;
|
||||
import io.v.nutz.web.commons.exception.CaptchaException;
|
||||
import io.v.nutz.web.commons.exception.SmsException;
|
||||
import io.v.nutz.web.commons.ext.sms.SmsService;
|
||||
import com.wf.captcha.ArithmeticCaptcha;
|
||||
import io.v.nutz.web.commons.shiro.exception.CaptchaEmptyException;
|
||||
import io.v.nutz.web.commons.shiro.exception.CaptchaIncorrectException;
|
||||
import io.v.nutz.zhgh.msgNotify.models.Orm_Msg;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
@@ -38,19 +43,31 @@ public class ValidateService {
|
||||
return NutMap.NEW().addv("key", uuid).addv("codeUrl", captcha.toBase64());
|
||||
}
|
||||
|
||||
public void getSMSCode(String mobile) throws SmsException {
|
||||
String text = R.captchaNumber(4);
|
||||
public NutMap getSMSCode(String mobile) throws SmsException {
|
||||
String text = R.captchaNumber(6);
|
||||
|
||||
String codeFromRedis = redisService.get(RedisConstant.REDIS_SMSCODE_KEY + mobile + ":LOCK");
|
||||
if (Strings.isNotBlank(codeFromRedis)) {
|
||||
throw new SmsException("请1分钟之后再试");
|
||||
}
|
||||
|
||||
if (smsService.sendCode(mobile, text)) {
|
||||
log.debug("sms code:::" + text);
|
||||
redisService.setex(RedisConstant.REDIS_SMSCODE_KEY + mobile, 300, text);
|
||||
redisService.setex(RedisConstant.REDIS_SMSCODE_KEY + mobile + ":LOCK", 60, text);
|
||||
if (redisService.exists(RedisConstant.REDIS_SMSCODE_KEY + mobile)){
|
||||
return NutMap.NEW().addv("key", RedisConstant.REDIS_SMSCODE_KEY + mobile);
|
||||
}
|
||||
|
||||
Orm_Msg ormMsgJsr = new Orm_Msg();
|
||||
ormMsgJsr.setMsgCode(DateUtil.current() + "-" + mobile);
|
||||
ormMsgJsr.setMobile(mobile);
|
||||
ormMsgJsr.setSendTime(DateUtil.now());
|
||||
String result = RCSCloudAPI.sendTplSms("beb041c66b654817927fb4bfc4dc327a", mobile, "@1@=" + text, null, ormMsgJsr);
|
||||
NutMap map = Json.fromJson(NutMap.class, result);
|
||||
if ("0".equals(map.getString("code"))) {
|
||||
log.debug("sms code:::" + text);
|
||||
redisService.setex(RedisConstant.REDIS_SMSCODE_KEY + mobile, 43200, text);
|
||||
redisService.setex(RedisConstant.REDIS_SMSCODE_KEY + mobile + ":LOCK", 60, text);
|
||||
return NutMap.NEW().addv("key", RedisConstant.REDIS_SMSCODE_KEY + mobile);
|
||||
}
|
||||
throw new SmsException("发送验证码失败,请联系管理员或稍后重试");
|
||||
}
|
||||
|
||||
public void checkCode(String key, String code) {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class NutShiroProcessor extends AbstractProcessor {
|
||||
String[] authIgnoreUrlArr = Lang.array("/",
|
||||
"/sso/login",
|
||||
"/platform/login",
|
||||
"/platform/login(/doLogin|/logout|/captcha)",
|
||||
"/platform/login(/doLogin|/logout|/captcha|/mobileLoginSmsCode|/validMobile|/validVerify|/mobileCaptcha)",
|
||||
"/platform/qywechat/.*",
|
||||
"/platform/home/(500|403|404|UnknownAccountError|LockedAccountError)",
|
||||
"/mobile/login",
|
||||
@@ -88,7 +88,8 @@ public class NutShiroProcessor extends AbstractProcessor {
|
||||
"/platform/fitnessWalk/punchLottery/getPunchWining",
|
||||
"/platform/fitnessWalk/punchLottery/doReadLottery",
|
||||
"/platform/fitnessWalk/stepWining/prizeOption",
|
||||
"/platform/fitnessWalk/stepWining/prizeUsers"
|
||||
"/platform/fitnessWalk/stepWining/prizeUsers",
|
||||
"/captcha/get-captcha"
|
||||
);
|
||||
if (Arrays.stream(authIgnoreUrlArr).noneMatch(v -> Pattern.compile(v).matcher(requestURI).matches())) {
|
||||
if (match) {
|
||||
|
||||
@@ -35,9 +35,13 @@ public class EasyCredentialsMatch extends HashedCredentialsMatcher {
|
||||
return true;
|
||||
}
|
||||
|
||||
Object tokenHashedCredentials = hashProvidedCredentials(token, info);
|
||||
Object accountCredentials = getCredentials(info);
|
||||
return equals(tokenHashedCredentials, accountCredentials);
|
||||
if (loginOrigin.equals(LoginUtil.LoginOrigin.SMS_CODE)) {
|
||||
return true;
|
||||
} else {
|
||||
Object tokenHashedCredentials = hashProvidedCredentials(token, info);
|
||||
Object accountCredentials = getCredentials(info);
|
||||
return equals(tokenHashedCredentials, accountCredentials);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.services.SysRoleService;
|
||||
import io.v.nutz.sys.services.SysUnionService;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.exception.CaptchaException;
|
||||
import io.v.nutz.web.commons.ext.validate.ValidateService;
|
||||
import io.v.nutz.web.commons.shiro.config.EasyCredentialsMatch;
|
||||
import io.v.nutz.web.commons.shiro.token.PlatformCaptchaToken;
|
||||
@@ -73,15 +74,34 @@ public class PlatformAuthorizingRealm extends AuthorizingRealm {
|
||||
|
||||
Session session = SecurityUtils.getSubject().getSession(true);
|
||||
|
||||
if (!loginOrigin.equals(LoginUtil.LoginOrigin.CAS) && !loginOrigin.equals(LoginUtil.LoginOrigin.QI_YE_WEI_XIN)) {
|
||||
Sys_user user = new Sys_user();
|
||||
|
||||
if (loginOrigin.equals(LoginUtil.LoginOrigin.SMS_CODE)){
|
||||
String mobile = "";
|
||||
try {
|
||||
int lastIndex = key.lastIndexOf(":");
|
||||
// 截取最后一个冒号之后的部分作为手机号
|
||||
mobile = lastIndex != -1 ? key.substring(lastIndex + 1) : null;
|
||||
if (StrUtil.isBlank(mobile)){
|
||||
throw Lang.makeThrow(AuthenticationException.class, "手机号不可为空");
|
||||
}
|
||||
try {
|
||||
validateService.checkSMSCode(mobile, captcha);
|
||||
} catch (CaptchaException e) {
|
||||
throw Lang.makeThrow(AuthenticationException.class, e.getMessage());
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw Lang.makeThrow(AuthenticationException.class, "验证码失效,请重新获取");
|
||||
}
|
||||
user = sysUserService.fetch(Cnd.NEW().and("mobile", "=", mobile));
|
||||
}else if (!loginOrigin.equals(LoginUtil.LoginOrigin.CAS) && !loginOrigin.equals(LoginUtil.LoginOrigin.QI_YE_WEI_XIN)) {
|
||||
validateService.checkCode(key, captcha);
|
||||
if (Strings.isBlank(loginname)) {
|
||||
throw Lang.makeThrow(AuthenticationException.class, "登录账号不可为空");
|
||||
}
|
||||
user = getUserService().fetch(Cnd.NEW().and("loginname", "=", loginname));
|
||||
}
|
||||
|
||||
if (Strings.isBlank(loginname)) {
|
||||
throw Lang.makeThrow(AuthenticationException.class, "登录账号不可为空");
|
||||
}
|
||||
|
||||
Sys_user user = getUserService().fetch(Cnd.NEW().and("loginname", "=", loginname));
|
||||
|
||||
if (Lang.isEmpty(user)) {
|
||||
throw Lang.makeThrow(UnknownAccountException.class, "账号不存在", loginname);
|
||||
@@ -137,8 +157,9 @@ public class PlatformAuthorizingRealm extends AuthorizingRealm {
|
||||
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
|
||||
info.addRoles(getUserService().getRoleCodeList(user));
|
||||
for (Sys_role role : user.getRoles()) {
|
||||
if (!role.isDisabled())
|
||||
if (!role.isDisabled()) {
|
||||
info.addStringPermissions(getRoleService().getPermissionNameList(role));
|
||||
}
|
||||
}
|
||||
return info;
|
||||
} else {
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
public class PlatformCaptchaToken extends UsernamePasswordToken {
|
||||
|
||||
private static final long serialVersionUID = 4676958151524148623L;
|
||||
private String mobile;
|
||||
private String captcha;
|
||||
private String key;
|
||||
private LoginUtil.LoginOrigin loginOrigin;
|
||||
@@ -28,6 +29,11 @@ public class PlatformCaptchaToken extends UsernamePasswordToken {
|
||||
this.captcha = captcha;
|
||||
}
|
||||
|
||||
public PlatformCaptchaToken(String username, String host, String key) {
|
||||
super(username, "", false, host);
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* cas免密登录
|
||||
*
|
||||
|
||||
+4
-4
@@ -165,9 +165,9 @@ public class ActivityRemindController {
|
||||
public Object sendRemind(@Param(value = "phone", required = false) String phone,
|
||||
@Param(value = "unionname", required = false) String unionname) {
|
||||
String[] pe = phone.split(",");
|
||||
for (String p : pe) {
|
||||
/*for (String p : pe) {
|
||||
RCSCloudAPI.sendTplSms("399ac7a7901c49df9f5939d0f10d566b", p, "@1@=" + unionname + "", "");
|
||||
}
|
||||
}*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -203,9 +203,9 @@ public class ActivityRemindController {
|
||||
return v.getInt("num") <= 0 && v.getString("telephone") != null;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
collect.forEach(v -> {
|
||||
/*collect.forEach(v -> {
|
||||
RCSCloudAPI.sendTplSms("399ac7a7901c49df9f5939d0f10d566b", v.getString("telephone"), "@1@=" + v.getString("unionname") + "", "");
|
||||
});
|
||||
});*/
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -73,11 +73,15 @@ public class MemberCommonController {
|
||||
}
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.*,unit.`name` unitname,un.unionname,unit.unionid
|
||||
u.*,unit.`name` unitname,un.unionname,unit.unionid,
|
||||
su.registeredResidence,
|
||||
su.homeAddress,
|
||||
su.specialSkill
|
||||
FROM
|
||||
$source u
|
||||
LEFT JOIN sys_unit unit ON u.unitid = unit.id
|
||||
left join sys_union un on unit.unionid = un.id
|
||||
left join sys_user su on su.id = u.id
|
||||
WHERE u.id = @id
|
||||
""").setVar("source", StringUtils.isEmpty(source) ? "user" : source).setParam("id", userId);
|
||||
NutMap user = sysUserViService.fetch(sql);
|
||||
@@ -296,4 +300,17 @@ public class MemberCommonController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 会员历史变更记录
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresAuthentication
|
||||
public Object memberHistoryRecords(String userId) {
|
||||
return memberService.memberHistoryRecordsByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package io.v.nutz.zhgh.member.controller.apply;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.OfficeTemplateUtil;
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.sys.models.Sys_signature;
|
||||
import io.v.nutz.sys.services.SysSignatureService;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import io.v.nutz.zhgh.member.constant.MemberApplyState;
|
||||
import io.v.nutz.zhgh.member.handle.MemberApplyAuditHandle;
|
||||
import io.v.nutz.zhgh.member.model.MemberApplyRecord;
|
||||
@@ -13,12 +21,15 @@ import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.ddr.poi.html.HtmlRenderPolicy;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
@@ -26,6 +37,10 @@ import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.trans.Trans;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@At("/platform/member/apply/submit")
|
||||
@@ -48,6 +63,12 @@ public class MemberApplyController {
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Inject
|
||||
private SysSignatureService sysSignatureService;
|
||||
|
||||
@Inject
|
||||
private OfficeTemplateUtil officeTemplateUtil;
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
@@ -63,6 +84,9 @@ public class MemberApplyController {
|
||||
u.username,
|
||||
u.loginname,
|
||||
u.member,
|
||||
u.unitid,
|
||||
u.nation,
|
||||
u.marriage,
|
||||
un.id unionid,
|
||||
un.unioncode,
|
||||
un.unionname,
|
||||
@@ -165,4 +189,84 @@ public class MemberApplyController {
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("member.apply.submit")
|
||||
public void exportApply(@Param(value = "userId", required = false) String userId, HttpServletResponse response) {
|
||||
try (ServletOutputStream os = response.getOutputStream()) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.username,
|
||||
u.sex,
|
||||
u.nation,
|
||||
u.education,
|
||||
concat(u.username, '、', u.jobTitle) as workUnit,
|
||||
u.marriage,
|
||||
u.academicDegree,
|
||||
u.political,
|
||||
u.idcard,
|
||||
u.mobile,
|
||||
u.registeredResidence,
|
||||
u.homeAddress,
|
||||
u.vita,
|
||||
u.specialSkill,
|
||||
u.family,
|
||||
mar.signId,
|
||||
mar.applyTime
|
||||
FROM
|
||||
sys_user u
|
||||
left join member_apply_record mar on mar.userId = u.id
|
||||
WHERE u.id = @id
|
||||
""").setParam("id", Strings.isNotBlank(userId) ? userId : ShiroUtil.getUserId());
|
||||
NutMap userMap = memberApplyRecordViService.fetch(sql);
|
||||
|
||||
MemberApplyRecord applyRecord = memberApplyRecordViService.fetch(Cnd.where("userId", "=", Strings.isNotBlank(userId) ? userId : ShiroUtil.getUserId()).desc("applyTime"));
|
||||
//and("stateId", "=", 30)
|
||||
memberApplyRecordViService.fetchLinks(applyRecord, null);
|
||||
|
||||
if (Strings.isNotBlank(userMap.getString("signId"))) {
|
||||
Sys_signature signature = sysSignatureService.fetch(userMap.getString("signId"));
|
||||
userMap.setv("userSign", signature != null ? Vi.getImg(signature.getData()) : null);
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(applyRecord) && applyRecord.getUnionAudit() != null) {
|
||||
userMap.put("unionOpinion", applyRecord.getUnionAudit().getAuditOpinion());
|
||||
userMap.put("unionUserName", applyRecord.getUnionAudit().getUsername());
|
||||
if (StrUtil.isNotBlank(applyRecord.getUnionAudit().getAuditSign())) {
|
||||
// userMap.put("unionUserSign", ViTool.poiBase64Image7030(applyRecord.getUnionAudit().getAuditSign()));
|
||||
userMap.put("unionUserSign", Vi.getImg(applyRecord.getUnionAudit().getAuditSign()));
|
||||
}
|
||||
userMap.put("unionDate", DateUtil.format(applyRecord.getUnionAudit().getAuditTime(), "yyyy年MM月dd日"));
|
||||
}
|
||||
|
||||
if (Lang.isNotEmpty(applyRecord) && applyRecord.getSchoolAudit() != null) {
|
||||
userMap.put("schoolOpinion", applyRecord.getSchoolAudit().getAuditOpinion());
|
||||
if (StrUtil.isNotBlank(applyRecord.getSchoolAudit().getAuditSign())) {
|
||||
// userMap.put("schoolSign", ViTool.poiBase64Image7030(applyRecord.getSchoolAudit().getAuditSign()));
|
||||
userMap.put("schoolSign", Vi.getImg(applyRecord.getSchoolAudit().getAuditSign()));
|
||||
}
|
||||
userMap.put("schoolDate", DateUtil.format(applyRecord.getSchoolAudit().getAuditTime(), "yyyy年MM月dd日"));
|
||||
}
|
||||
|
||||
Date applyTime = applyRecord.getApplyTime();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(applyTime);
|
||||
|
||||
userMap.put("year", DateUtil.year(userMap.getTime("applyTime")));
|
||||
userMap.put("month", DateUtil.month(userMap.getTime("applyTime")) + 1);
|
||||
userMap.put("day", DateUtil.dayOfMonth(userMap.getTime("applyTime")));
|
||||
userMap.put("schoolName", Globals.MyConfig.getString("GxName"));
|
||||
|
||||
ViTool.excelResponse(response, userMap.getString("username") + "-工会入会申请表.docx");
|
||||
HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
|
||||
Configure configure = Configure.builder().bind("vita", htmlRenderPolicy).build();
|
||||
|
||||
XWPFTemplate.compile(officeTemplateUtil.getPath("memberApply"), configure).render(userMap).writeAndClose(os);
|
||||
System.out.println(Json.toJson(userMap));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+170
-12
@@ -1,15 +1,23 @@
|
||||
package io.v.nutz.zhgh.member.controller.change;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import com.google.common.base.Joiner;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.PageUtil;
|
||||
import io.v.nutz.base.utils.RCSCloudAPI;
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.sys.models.*;
|
||||
import io.v.nutz.web.commons.slog.annotation.SLog;
|
||||
import io.v.nutz.zhgh.data.constant.UserChangeType;
|
||||
import io.v.nutz.base.lang.Lang;
|
||||
import io.v.nutz.zhgh.member.MemberMode;
|
||||
import io.v.nutz.zhgh.member.UserMode;
|
||||
import io.v.nutz.zhgh.member.WelfareMemberMode;
|
||||
@@ -17,18 +25,17 @@ import io.v.nutz.zhgh.member.constant.*;
|
||||
import io.v.nutz.zhgh.member.handle.MemberChangeAuditHandle;
|
||||
import io.v.nutz.zhgh.member.model.MemberChangeRecord;
|
||||
import io.v.nutz.zhgh.member.service.MemberService;
|
||||
import io.v.nutz.zhgh.member.template.MemberTemp;
|
||||
import io.v.nutz.zhgh.member.utils.MemberUtils;
|
||||
import io.v.nutz.base.model.Audit;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.AuditService;
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.sys.models.Sys_config;
|
||||
import io.v.nutz.sys.models.Sys_unit;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.sys.services.SysUnitService;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
@@ -42,18 +49,26 @@ import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
import org.nutz.trans.Trans;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@At("/platform/member/change/mange")
|
||||
@Ok("json:full")
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class MemberChangeManageController {
|
||||
|
||||
@At("")
|
||||
@@ -155,7 +170,7 @@ public class MemberChangeManageController {
|
||||
cnd.andEX("u.personType", "=", personType);
|
||||
cnd.andEX("u.userState", "=", userState);
|
||||
|
||||
if (Lang.notNull(changeDateBefore, changeDateEnd)) {
|
||||
if (StrUtil.isNotBlank(changeDateBefore) && StrUtil.isNotBlank(changeDateEnd)) {
|
||||
cnd.and(new Static(String.format("Date(his.changeTime) >= '%s' and Date(his.changeTime) <= '%s'", changeDateBefore, changeDateEnd)));
|
||||
}
|
||||
|
||||
@@ -163,10 +178,11 @@ public class MemberChangeManageController {
|
||||
cnd.orderBy((List.of("changeTime", "changeType", "changeTypes").contains(pageForm.getPageOrderName()) ? "his." : "u.") + pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy()));
|
||||
}
|
||||
|
||||
if (org.nutz.lang.Lang.isNotEmpty(changeTypes)) {
|
||||
|
||||
if (Lang.isNotEmpty(changeTypes)) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
for (Integer type : changeTypes) {
|
||||
seg.or(new Static("JSON_CONTAINS(his.changeTypes, CAST(%d AS JSON), '$')".formatted(type)));
|
||||
seg.or(new Static("JSON_CONTAINS(his.changeTypes, CAST(%d AS JSON), '$')".formatted(type)));
|
||||
}
|
||||
cnd.and(seg);
|
||||
}
|
||||
@@ -247,7 +263,7 @@ public class MemberChangeManageController {
|
||||
cnd.andEX("u.sex", "=", sex);
|
||||
cnd.andEX("u.personType", "=", personType);
|
||||
cnd.andEX("u.userState", "=", userState);
|
||||
if (Lang.notNull(changeDateBefore, changeDateEnd)) {
|
||||
if (StrUtil.isNotBlank(changeDateBefore) && StrUtil.isNotBlank(changeDateEnd)) {
|
||||
cnd.and(new Static(String.format("Date(his.changeTime) >= '%s' and Date(his.changeTime) <= '%s'", changeDateBefore, changeDateEnd)));
|
||||
}
|
||||
cnd.andEX("his.changeType", "=", changeType);
|
||||
@@ -312,9 +328,9 @@ public class MemberChangeManageController {
|
||||
@RequiresPermissions("member.change.mange")
|
||||
public Object sendSms(String userid) {
|
||||
Sys_user user = userService.fetch(userid);
|
||||
if (Strings.isNotBlank(user.getMobile())) {
|
||||
/*if (Strings.isNotBlank(user.getMobile())) {
|
||||
RCSCloudAPI.sendTplSms("9159ed9ef1654c0ea2d7475520049a6f", user.getMobile(), "@1@=" + user.getUsername(), "");
|
||||
}
|
||||
}*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -546,4 +562,146 @@ public class MemberChangeManageController {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
public void downloadImport(HttpServletResponse response) {
|
||||
try {
|
||||
ViTool.excelResponse(response, "会员导入模版.xlsx");
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("工号", "loginname", 20));
|
||||
entityList.add(new ExcelExportEntity("姓名", "username", 20));
|
||||
entityList.add(new ExcelExportEntity("性别", "sex", 10));
|
||||
entityList.add(new ExcelExportEntity("单位名称", "unitName", 20));
|
||||
entityList.add(new ExcelExportEntity("联系方式", "mobile", 20));
|
||||
if (ShiroUtil.hasAnyRoles("sysadmin,A06")) {
|
||||
entityList.add(new ExcelExportEntity("身份证号", "idcard", 30));
|
||||
}
|
||||
entityList.add(new ExcelExportEntity("在职状态", "userState", 20));
|
||||
entityList.add(new ExcelExportEntity("人员类型", "personType", 20));
|
||||
entityList.add(new ExcelExportEntity("入会时间", "memberJoinTime", 20));
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, new ArrayList<>());
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock(true);
|
||||
|
||||
@At
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SLog(type = "会员管理系统", tag = "信息维护-会员高级管理", msg = "导入会员", param = true, result = true)
|
||||
public Object doImport(TempFile file) {
|
||||
try {
|
||||
lock.lock();
|
||||
List<MemberTemp> memberImportList = ExcelImportUtil.importExcel(file.getFile(), MemberTemp.class, new ImportParams());
|
||||
//获取系统用户
|
||||
List<Sys_user> dataUserList = dao.query(Sys_user.class, Cnd.NEW());
|
||||
Map<String, Sys_user> userMap = dataUserList.stream().collect(Collectors.toMap(Sys_user::getLoginname, v -> v));
|
||||
|
||||
List<Sys_unit> unitList = sysUnitService.query(Cnd.where("unitlevel","=",2));
|
||||
|
||||
//判断单位
|
||||
Map<String, String> unitMap = unitList.stream().collect(Collectors.toMap(Sys_unit::getName, Sys_unit::getId));
|
||||
|
||||
//系统中有此用户,修改
|
||||
List<String> needUpdateUserIds = new ArrayList<>();
|
||||
|
||||
//系统中没有,新增
|
||||
List<Sys_user> needInsertUser = new ArrayList<>();
|
||||
|
||||
//赋予角色
|
||||
List<Sys_user_role> userRoles = new ArrayList<>();
|
||||
|
||||
//返回错误记录
|
||||
List<MemberTemp> errorInfos = new ArrayList<>();
|
||||
|
||||
List<Sys_user> needUpdateUser = new ArrayList<>();
|
||||
|
||||
memberImportList.forEach(v -> {
|
||||
|
||||
//判断是否填写单位、单位是否存在
|
||||
String unitId = unitMap.get(v.getUnitName());
|
||||
if (Strings.isNotBlank(v.getUnitName()) && Strings.isBlank(unitId)) {
|
||||
v.setErrorInfo("获取不到该用户的单位信息!");
|
||||
errorInfos.add(v);
|
||||
return;
|
||||
}
|
||||
|
||||
//判断是否在系统中
|
||||
Sys_user user = userMap.get(v.getLoginname());
|
||||
Sys_user_role userRole = new Sys_user_role();
|
||||
if (org.nutz.lang.Lang.isNotEmpty(user)) {
|
||||
user.setUnitid(unitId);
|
||||
user.setSex(v.getSex());
|
||||
user.setMobile(v.getMobile());
|
||||
user.setMember(1);
|
||||
user.setUserState(v.getUserState());
|
||||
user.setPersonType(v.getPersonType());
|
||||
if (StrUtil.isNotBlank(v.getIdcard())) {
|
||||
user.setIdcard(v.getIdcard());
|
||||
}
|
||||
userRole.setUserId(user.getId());
|
||||
needUpdateUser.add(user);
|
||||
needUpdateUserIds.add(user.getId());
|
||||
} else {
|
||||
//不在就初始化新用户,工号用导入表中的
|
||||
Sys_user initUser = UserMode.initUser(new Sys_user());
|
||||
initUser.setUnitid(unitId);
|
||||
initUser.setUsername(v.getUsername());
|
||||
initUser.setLoginname(v.getLoginname());
|
||||
initUser.setMember(1);
|
||||
initUser.setSex(v.getSex());
|
||||
initUser.setMobile(v.getMobile());
|
||||
initUser.setUserState(v.getUserState());
|
||||
initUser.setPersonType(v.getPersonType());
|
||||
if (StrUtil.isNotBlank(v.getIdcard())) {
|
||||
initUser.setIdcard(v.getIdcard());
|
||||
}
|
||||
userRole.setUserId(initUser.getId());
|
||||
needInsertUser.add(initUser);
|
||||
}
|
||||
userRole.setRoleId(Roles.MEMBER);
|
||||
userRoles.add(userRole);
|
||||
});
|
||||
|
||||
//需要删除角色的用户ID
|
||||
List<String> doCleanRoleUsers = needInsertUser.stream().map(Sys_user::getId).collect(Collectors.toList());
|
||||
doCleanRoleUsers.addAll(needUpdateUserIds);
|
||||
sysUnitService.dao().clear(Sys_user_role.class, Cnd.where("userId", "in", doCleanRoleUsers).and("roleId", "=", Roles.MEMBER));
|
||||
//新增会员角色
|
||||
sysUnitService.dao().insert(userRoles);
|
||||
//系统中存在就修改
|
||||
sysUnitService.dao().update(Sys_user.class, Chain.make("member", 1), Cnd.where("id", "in", needUpdateUserIds));
|
||||
//系统中不存在就新增
|
||||
sysUnitService.dao().insert(needInsertUser);
|
||||
|
||||
sysUnitService.dao().updateIgnoreNull(needUpdateUser);
|
||||
|
||||
//如果有错误数据就返回给前端
|
||||
if (org.nutz.lang.Lang.isNotEmpty(errorInfos)) {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("totalCount", memberImportList.size());
|
||||
nutMap.setv("successCount", doCleanRoleUsers.size());
|
||||
nutMap.setv("errorCount", errorInfos.size());
|
||||
nutMap.setv("errorList", errorInfos.stream().map(v -> {
|
||||
return NutMap.NEW().addv("工号", v.getLoginname()).addv("姓名", v.getUsername()).addv("错误原因", v.getErrorInfo());
|
||||
}).collect(Collectors.toList()));
|
||||
return io.v.nutz.base.result.Result.success(nutMap);
|
||||
}
|
||||
|
||||
sysUnitService.dao().clear(Sys_user.class,Cnd.where("loginname","is",null));
|
||||
lock.unlock();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,4 +34,11 @@ public interface MemberService extends ViService<Sys_user> {
|
||||
* @return
|
||||
*/
|
||||
Pagination memberChangeRecords(PageForm pageForm, CndPlus cnd);
|
||||
|
||||
/**
|
||||
* 某会员历史变更记录
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> memberHistoryRecordsByUserId(String userId);
|
||||
}
|
||||
|
||||
@@ -76,4 +76,43 @@ public class MemberServiceImpl extends ViServiceImpl<Sys_user> implements Member
|
||||
Sql sql = Sqls.create(MEMBER_CHANGE_RECORDS).setCondition(cnd);
|
||||
return list(pageForm, sql);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<NutMap> memberHistoryRecordsByUserId(String userId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
his.id,
|
||||
his.changeTime,
|
||||
his.loginname,
|
||||
his.username,
|
||||
his.mobile,
|
||||
his.birthday,
|
||||
his.userState,
|
||||
his.personType,
|
||||
his.sex,
|
||||
his.changeTypes,
|
||||
his.changeOrigin,
|
||||
his.changeOperator,
|
||||
his.memberChangeRecordId,
|
||||
his.changeReason,
|
||||
his.lastHistoryId,
|
||||
u.unitname,
|
||||
u.unionname,
|
||||
mcr.stateId,
|
||||
state.stateName,
|
||||
state.stateColor
|
||||
FROM
|
||||
`user_history` his
|
||||
LEFT JOIN member_change_record mcr ON mcr.id = his.memberChangeRecordId
|
||||
LEFT JOIN audit_state state ON mcr.stateId = state.stateId
|
||||
LEFT JOIN `user` u ON u.loginname = his.loginname
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("u.id", "=", userId);
|
||||
cnd.desc("his.changeTime");
|
||||
sql.setCondition(cnd);
|
||||
return listMap(sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package io.v.nutz.zhgh.member.template;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MemberTemp {
|
||||
|
||||
@Excel(name = "工号")
|
||||
private String loginname;
|
||||
|
||||
@Excel(name = "姓名")
|
||||
private String username;
|
||||
|
||||
@Excel(name = "性别")
|
||||
private String sex;
|
||||
|
||||
@Excel(name = "单位名称")
|
||||
private String unitName;
|
||||
|
||||
@Excel(name = "联系方式")
|
||||
private String mobile;
|
||||
|
||||
@Excel(name = "身份证号")
|
||||
private String idcard;
|
||||
|
||||
@Excel(name = "在职状态")
|
||||
private String userState;
|
||||
|
||||
@Excel(name = "人员类型")
|
||||
private String personType;
|
||||
|
||||
@Excel(name = "入会时间")
|
||||
private String memberJoinTime;
|
||||
|
||||
private String errorInfo;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class MemberMobileController {
|
||||
|
||||
@At("/query")
|
||||
@Ok("beetl:/mobile/member/query.html")
|
||||
@RequiresRoles(value = {"H04", "A06"}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {"H04", "A06", "sysadmin"}, logical = Logical.OR)
|
||||
public void query() {
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class MemberMobileController {
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresRoles(value = {"H04", "A06"}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {"H04", "A06", "sysadmin"}, logical = Logical.OR)
|
||||
public Object getMemberData(PageForm pageForm, String unionId, String unitId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
@@ -119,13 +119,13 @@ public class MemberMobileController {
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresRoles(value = {"H04", "A06"}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {"H04", "A06", "sysadmin"}, logical = Logical.OR)
|
||||
public Object viewInfo(String id) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.username,
|
||||
u.sex,
|
||||
u.age,
|
||||
u.birthday,
|
||||
u.nation,
|
||||
u.education,
|
||||
u.political,
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package io.v.nutz.zhgh.msgNotify.models;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:Orm_Msg
|
||||
* @Date 2024/7/23 10:16
|
||||
* @注释
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
public class Orm_Msg {
|
||||
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("短信编号")
|
||||
private String msgCode;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("接收人姓名")
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("接收人工号")
|
||||
private String loginname;
|
||||
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("接收人工会")
|
||||
private String schoolName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("接收人工会id")
|
||||
private String schoolId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("接收人二级工会id")
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("接收人二级工会")
|
||||
private String unitName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("接收人手机号")
|
||||
private String mobile;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 300)
|
||||
@Comment("发送内容")
|
||||
private String content;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("发送时间")
|
||||
private String sendTime;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("发送人")
|
||||
private String senderUsername;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class ProposalUrgeServiceImpl extends ViServiceImpl<ProposalUrge> impleme
|
||||
if (!list.isEmpty()) {
|
||||
list.forEach(v -> {
|
||||
if (Strings.isNotBlank(v.getString("mobile"))) {
|
||||
RCSCloudAPI.sendTplSms("002595a3587449738e458d8766738317", v.getString("mobile"), "@1@=" + "[" + fetch.getProposalName() + "]", " ");
|
||||
// RCSCloudAPI.sendTplSms("002595a3587449738e458d8766738317", v.getString("mobile"), "@1@=" + "[" + fetch.getProposalName() + "]", " ");
|
||||
} else {
|
||||
arrayList.add(v.getString("unitName"));
|
||||
}
|
||||
|
||||
+2
-2
@@ -311,13 +311,13 @@ public class TheRapyRecuperationAuditController {
|
||||
Sys_user user = auditService.dao().fetch(Sys_user.class, Cnd.where("loginname", "=", loginName));
|
||||
TheRapyRecuperationLine theRapyRecuperationLine = auditService.dao().fetch(TheRapyRecuperationLine.class, Cnd.where("id", "=", takePartInLineId));
|
||||
AuditState auditState = auditService.dao().fetch(AuditState.class, Cnd.where("stateId", "=", stateId));
|
||||
if (stateId.equals(TheRapyRecuperationState.UNITFAIL)) {
|
||||
/*if (stateId.equals(TheRapyRecuperationState.UNITFAIL)) {
|
||||
RCSCloudAPI.sendTplSms("3a96eeb38ca7406aaf39dcf305507816", user.getMobile(), "@1@=" + user.getUsername() + "||@2@=" + theRapyRecuperationLine.getLineName() + "||@3@=" + auditState.getStateName() + "", "");
|
||||
} else if (stateId.equals(TheRapyRecuperationState.LINEUNITFAIL)) {
|
||||
RCSCloudAPI.sendTplSms("3a96eeb38ca7406aaf39dcf305507816", user.getMobile(), "@1@=" + user.getUsername() + "||@2@=" + theRapyRecuperationLine.getLineName() + "||@3@=" + auditState.getStateName() + "", "");
|
||||
} else if (stateId.equals(TheRapyRecuperationState.PASS)) {
|
||||
RCSCloudAPI.sendTplSms("3a96eeb38ca7406aaf39dcf305507816", user.getMobile(), "@1@=" + user.getUsername() + "||@2@=" + theRapyRecuperationLine.getLineName() + "||@3@=" + auditState.getStateName() + "", "");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import io.v.nutz.zhgh.zc.model.ZcPdPlan;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
/**
|
||||
* @ClassName ZcDjPlanController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/2/27 14:13
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/zcgl/zcdj/plan")
|
||||
public class ZcPdPlanController {
|
||||
|
||||
@Inject("ZcPdPlan")
|
||||
private ViService<ZcPdPlan> viService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zcgl/zcPdPlan.html")
|
||||
@RequiresPermissions("zc.pdPlan")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object pageData(PageForm page, String year) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.andEX("year", "=", year);
|
||||
cnd.asc("startDate");
|
||||
return viService.list(page, cnd);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object doSubmit(ZcPdPlan zcPdPlan) {
|
||||
zcPdPlan.setCreateDate(DateUtil.now());
|
||||
viService.insertOrUpdate(zcPdPlan);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object doDelete(String id) {
|
||||
viService.delete(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,48 +1,36 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.sys.models.Sys_union;
|
||||
import io.v.nutz.sys.models.Sys_unit;
|
||||
import io.v.nutz.base.annontation.ViReturn;import io.v.nutz.sys.models.Sys_union;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.sys.services.SysUnionService;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.model.zcDepreciationRecord;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
@@ -50,6 +38,8 @@ import java.util.List;
|
||||
* 资产登记
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@RequiresAuthentication
|
||||
@At("/platform/zcgl/zcdj")
|
||||
public class ZgfwAddZcxxController {
|
||||
|
||||
@@ -65,89 +55,156 @@ public class ZgfwAddZcxxController {
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zcgl/addzcxx.html")
|
||||
@RequiresPermissions("zc.dj")
|
||||
public void index() {
|
||||
public void index(String id, HttpSession session) {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.dj")
|
||||
public Object findOne(String id) {
|
||||
if (Strings.isNotBlank(id)) {
|
||||
return zgfwZcxxService.fetch(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@ViReturn
|
||||
public Object findOne(String id) {
|
||||
if (Strings.isBlank(id)) {
|
||||
@At("/SearchUserByName")
|
||||
@RequiresPermissions("zc.dj")
|
||||
public Object SearchUserByName(String query) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (query.length() == 32) {
|
||||
List<Sys_user> sys_users = sysUserService.query(Cnd.where("id", "=", query));
|
||||
return Result.success().addData(sys_users);
|
||||
} else {
|
||||
cnd.and("username", "like", "%" + query + "%").or("loginname", "like", "%" + query + "%");
|
||||
io.v.nutz.base.page.Pagination pagination = sysUserService.listPage(1, 10, cnd, "^id|username|loginname$");
|
||||
return Result.success().addData(pagination.getList());
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
return zgfwZcxxService.fetch(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取excel内容
|
||||
*
|
||||
* @param tempFile
|
||||
* @return
|
||||
*/
|
||||
@At("/readExcel")
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
@Ok("json:full")
|
||||
@ViReturn
|
||||
public Object readExcel(@Param("file") TempFile tempFile) {
|
||||
ImportParams params = new ImportParams();
|
||||
List<Zgfw_Zcxx> importList = ExcelImportUtil.importExcel(tempFile.getFile(), Zgfw_Zcxx.class, params);
|
||||
return zgfwZcxxService.matchAssetSataus(importList);
|
||||
@At("/SearchUnitByName")
|
||||
@RequiresPermissions("zc.dj")
|
||||
public Object SearchUnitByName(String query) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (query.length() == 32) {
|
||||
List<Sys_union> list = sysUnionService.query(Cnd.where("id", "=", query));
|
||||
return Result.success().addData(list);
|
||||
} else {
|
||||
cnd.and("unionname", "like", "%" + query + "%").or("dwcode", "like", "%" + query + "%");
|
||||
Pagination pagination = sysUnionService.listPage(1, 10, cnd, "^id|unionname|dwcode$");
|
||||
return Result.success().addData(pagination.getList());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@At("/doSubmit")
|
||||
@RequiresPermissions("zc.dj")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@ViReturn
|
||||
public Object doSubmit(Zgfw_Zcxx zcxx) {
|
||||
List<String> unitIds = new ArrayList<>();
|
||||
unitIds.add(zcxx.getUnitId());
|
||||
unitIds.add(zcxx.getThreeUnitId());
|
||||
|
||||
List<Sys_unit> units = sysUserService.dao().query(Sys_unit.class, Cnd.where("id", "in", unitIds));
|
||||
if (StrUtil.isNotBlank(zcxx.getRecipientUserId())) {
|
||||
Sys_user user = sysUserService.fetch(zcxx.getRecipientUserId());
|
||||
zcxx.setRecipientUsername(user.getUsername());
|
||||
zcxx.setRecipientLoginName(user.getLoginname());
|
||||
|
||||
LocalDate rkLocalDate = zcxx.getDepreciationDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
Period period = Period.between(LocalDate.now(), rkLocalDate);
|
||||
|
||||
// 定义日期格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// 使用定义的格式解析字符串
|
||||
LocalDate zcgzrqLocalData = LocalDate.parse(zcxx.getZcgzrq(), formatter);
|
||||
// 计算两个日期之间的差异
|
||||
Period allMonths = Period.between(zcgzrqLocalData, rkLocalDate);
|
||||
// 获取月份数
|
||||
int months = allMonths.getYears() * 12 + allMonths.getMonths();
|
||||
Double zcDjDouble = Double.parseDouble(zcxx.getZcdj());
|
||||
Double monthsZcDj = zcDjDouble / months;
|
||||
int surplusMonths = Math.max(period.getYears() * 12 + period.getMonths(), 0);
|
||||
|
||||
int year = Calendar.getInstance().get(Calendar.YEAR);
|
||||
if (StrUtil.isBlank(zcxx.getZcbh())) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT count(1) FROM `zgfw_zcxx` where LEFT(zcbh,4) = @year and LENGTH(zcbh) = 8
|
||||
""").setParam("year", year);
|
||||
int count = zgfwZcxxService.count(sql);
|
||||
String bh = String.format("%04d", count + 1);
|
||||
zcxx.setZcbh(year + bh);
|
||||
}
|
||||
zcxx.setUnitName(units.stream().filter(v->v.getId().equals(zcxx.getUnitId())).findFirst().get().getName());
|
||||
zcxx.setThreeUnitName(units.stream().filter(v->v.getId().equals(zcxx.getThreeUnitId())).findFirst().get().getName());
|
||||
zcxx.setAllMoney(zcDjDouble * zcxx.getSl());
|
||||
zcxx.setSurplusMoney(NumberUtil.round(surplusMonths * monthsZcDj * zcxx.getSl(), 2).doubleValue());
|
||||
zgfwZcxxService.insert(zcxx);
|
||||
if (period.getYears() * 12 + period.getMonths() >= 0) {
|
||||
zcDepreciationRecord record = new zcDepreciationRecord();
|
||||
record.setZcid(zcxx.getZcid());
|
||||
record.setOperationTime(DateUtil.now());
|
||||
record.setDepreciationDate(zcxx.getDepreciationDate());
|
||||
record.setSurplus(surplusMonths);
|
||||
record.setSurplusMoney(NumberUtil.round(surplusMonths * monthsZcDj * zcxx.getSl(), 2).doubleValue());
|
||||
zgfwZcxxService.insert(record);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@ViReturn
|
||||
public Object doEdit(Zgfw_Zcxx zcxx) {
|
||||
zgfwZcxxService.updateIgnoreNull(zcxx);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载模板
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
@At("/downLoadTemp")
|
||||
@Ok("void")
|
||||
public void downLoadTemp(HttpServletResponse response) {
|
||||
@RequiresPermissions("zc.dj")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Object doEdit(Zgfw_Zcxx zcxx, HttpSession session) {
|
||||
try {
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
List<Zgfw_Zcxx> list = new ArrayList<>();
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, Zgfw_Zcxx.class, list);
|
||||
ViTool.excelResponse(response, "资产导入模板.xlsx");
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
LocalDate rkLocalDate = zcxx.getDepreciationDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
Period period = Period.between(LocalDate.now(), rkLocalDate);
|
||||
|
||||
// 定义日期格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// 使用定义的格式解析字符串
|
||||
LocalDate zcgzrqLocalData = LocalDate.parse(zcxx.getZcgzrq(), formatter);
|
||||
// 计算两个日期之间的差异
|
||||
Period allMonths = Period.between(zcgzrqLocalData, rkLocalDate);
|
||||
// 获取月份数
|
||||
int months = allMonths.getYears() * 12 + allMonths.getMonths();
|
||||
Double zcDjDouble = Double.parseDouble(zcxx.getZcdj());
|
||||
Double monthsZcDj = zcDjDouble / months;
|
||||
int surplusMonths = Math.max(period.getYears() * 12 + period.getMonths(), 0);
|
||||
|
||||
if (period.getYears() * 12 + period.getMonths() >= 0) {
|
||||
zgfwZcxxService.dao().clear(zcDepreciationRecord.class, Cnd.where("zcid", "=", zcxx.getZcid()));
|
||||
zcDepreciationRecord record = new zcDepreciationRecord();
|
||||
record.setZcid(zcxx.getZcid());
|
||||
record.setOperationTime(DateUtil.now());
|
||||
record.setDepreciationDate(zcxx.getDepreciationDate());
|
||||
record.setSurplus(surplusMonths);
|
||||
record.setSurplusMoney(NumberUtil.round(surplusMonths * monthsZcDj * zcxx.getSl(), 2).doubleValue());
|
||||
zgfwZcxxService.insert(record);
|
||||
}
|
||||
|
||||
zcxx.setAllMoney(zcDjDouble * zcxx.getSl());
|
||||
zcxx.setSurplusMoney(NumberUtil.round(surplusMonths * monthsZcDj * zcxx.getSl(), 2).doubleValue());
|
||||
zgfwZcxxService.updateIgnoreNull(zcxx);
|
||||
session.removeAttribute("id");
|
||||
|
||||
return Result.success().addMsg("修改成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("zc.dj")
|
||||
@ViReturn
|
||||
public Object doExcelSubmit(@Param(value = "data", required = false) Zgfw_Zcxx[] zxccList) {
|
||||
|
||||
@@ -155,12 +212,5 @@ public class ZgfwAddZcxxController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@At("/readExcelTable")
|
||||
@Ok("json:full")
|
||||
@ViReturn
|
||||
public Object readExcelTable(@Param(value = "zxccList", required = false) Zgfw_Zcxx[] zxccList) {
|
||||
// return zgfwZcxxService.matchUserId(zxccList);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,38 +1,60 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
|
||||
import cn.afterturn.easypoi.entity.ImageEntity;
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import io.v.nutz.base.annontation.ViReturn;import io.v.nutz.base.utils.OfficeTemplateUtil;
|
||||
import io.v.nutz.base.utils.Vi;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.zc.model.ZcPdPlan;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx_bdxx;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxBdService;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.boot.starter.ftp.FtpService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 资产变更
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/zcgl/gdzcbg")
|
||||
public class ZgfwGdzcbgController {
|
||||
@Inject
|
||||
@@ -43,6 +65,12 @@ public class ZgfwGdzcbgController {
|
||||
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private FtpService ftpService;
|
||||
|
||||
@Inject
|
||||
private OfficeTemplateUtil officeTemplateUtil;
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zcgl/gdzcbg.html")
|
||||
@@ -52,156 +80,272 @@ public class ZgfwGdzcbgController {
|
||||
}
|
||||
|
||||
@At("/data")
|
||||
@Ok("json")
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.bg")
|
||||
public Object data(@Param("pageNumber") Integer pageNumber, @Param("pageSize") Integer pageSize, @Param("searchName") String searchName, @Param("searchKeyword") String searchKeyword,
|
||||
public Object data(PageForm pageForm,
|
||||
Integer isPd,
|
||||
String zcpdid,
|
||||
@Param(value = "zcghlx", required = false) String zcghlx,
|
||||
@Param(value = "zcgzrq", required = false) String zcgzrq,
|
||||
@Param(value = "zclydwh", required = false) String zclydwh,
|
||||
@Param(value = "zcrksj", required = false) String zcrksj, String pageOrderName, String pageOrderBy) {
|
||||
@Param(value = "zcrksj", required = false) String zcrksj,
|
||||
@Param(value = "zczt", required = false) String zczt,
|
||||
@Param(value = "contentCode", required = false) String contentCode) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.content,
|
||||
bd.zcbdid,
|
||||
COUNT(bd.zcid) AS isPd
|
||||
FROM
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zcxx_bdxx bd ON bd.pdPlanId=@zcpdid and bd.zcid = xx.zcid
|
||||
LEFT JOIN zgfw_zclb lb ON xx.contentCode = lb.contentCode
|
||||
$condition
|
||||
""").setParam("zcpdid", zcpdid);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword()) && StrUtil.isNotBlank(pageForm.getSearchName())) {
|
||||
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
|
||||
}
|
||||
cnd.andEX("xx.zczt", "=", zczt);
|
||||
cnd.andEX("xx.contentCode", "=", contentCode);
|
||||
cnd.andEX("xx.zcghlx", "=", zcghlx);
|
||||
cnd.andEX("xx.zcgzrq", "=", zcgzrq);
|
||||
cnd.andEX("xx.zclydwh", "=", zclydwh);
|
||||
cnd.andEX("xx.zcrksj", "=", zcrksj);
|
||||
if (isPd != 0) {
|
||||
cnd.and("( SELECT COUNT(*) FROM zgfw_zcxx_bdxx WHERE pdPlanId = '%s' AND zcid = xx.zcid )".formatted(zcpdid), isPd == 1 ? ">=" : "<", 1);
|
||||
}
|
||||
if (StrUtil.isNotBlank(pageForm.getPageOrderBy()) && StrUtil.isNotBlank(pageForm.getPageOrderName())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equals("desc") ? "desc" : "asc");
|
||||
} else {
|
||||
cnd.desc("xx.zcghlx");
|
||||
}
|
||||
cnd.groupBy("xx.zcid");
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = zgfwZcxxService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return pagination;
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
public Object queryChangeData(String zcid) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
shr.`username` shrname,
|
||||
bd.*
|
||||
FROM
|
||||
zgfw_zcxx_bdxx bd
|
||||
LEFT JOIN sys_user oldlyr ON bd.zcoldlyrid = oldlyr.`id`
|
||||
LEFT JOIN sys_union oldlydw ON bd.`zcoldlydwh` = oldlydw.`id`
|
||||
LEFT JOIN sys_user nowlyr ON bd.`zcnowlyrid` = nowlyr.`id`
|
||||
LEFT JOIN sys_union nowlydw ON bd.`zcnowlydwh` = nowlydw.`id`
|
||||
LEFT JOIN sys_user shr ON bd.`zcbdshrid` = shr.`id`
|
||||
WHERE
|
||||
bd.`zcid` = @zcid and bd.pdzt is not null
|
||||
ORDER BY
|
||||
bd.`zcbdsj` DESC
|
||||
""").setParam("zcid", zcid);
|
||||
return zgfwZcxxBdService.list(sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@ViReturn
|
||||
public Object doSubmit(Zgfw_Zcxx_bdxx zcxxBdxx, String zclyrname, String zclyrgh, String zclydwh, String zclydwhid, String zclyrid) {
|
||||
Zgfw_Zcxx zcxx = zgfwZcxxService.fetch(zcxxBdxx.getZcid());
|
||||
zgfwZcxxBdService.insert(zcxxBdxx);
|
||||
|
||||
zcxx.setZczt(zcxxBdxx.getZczt());
|
||||
zcxx.setZclyrid(zclyrid);
|
||||
zcxx.setZclyrname(zclyrname);
|
||||
zcxx.setZclyrgh(zclyrgh);
|
||||
zcxx.setZclydwh(zclydwh);
|
||||
zcxx.setZccfdmc(zcxxBdxx.getZcnowcfdmc());
|
||||
zcxx.setZclydwhid(zclydwhid);
|
||||
zgfwZcxxService.update(zcxx);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@ViReturn
|
||||
public Object doPdDelete(String zcbdid) {
|
||||
zgfwZcxxBdService.delete(zcbdid);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@ViReturn
|
||||
public Object getPdPlan(String year) {
|
||||
return zgfwZcxxService.dao().query(ZcPdPlan.class, Cnd.NEW().andEX("year", "=", year).desc("startDate"));
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresAuthentication
|
||||
public void doExcel(String zcpdid, String zcghlx, HttpServletResponse response) {
|
||||
String unitname = "校工会";
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
zc.zcdj,
|
||||
zc.sl,
|
||||
zc.zczt
|
||||
FROM
|
||||
zgfw_zcxx zc
|
||||
LEFT JOIN zgfw_zcxx_bdxx bd ON bd.zcid=zc.zcid AND bd.pdPlanId=@zcpdid
|
||||
left join sys_unit it on it.id=zc.zclydwhid
|
||||
LEFT JOIN `user` u ON u.id=bd.zcbdshrid
|
||||
$condition
|
||||
""").setParam("zcpdid", zcpdid);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
|
||||
cnd.andEX("zc.zcghlx", "=", "1");
|
||||
cnd.andEX("zc.zclydwhid", "=", Vi.getUnionId());
|
||||
unitname = Vi.getUnit().getName();
|
||||
|
||||
}
|
||||
cnd.andEX("zc.zcghlx", "=", zcghlx);
|
||||
cnd.groupBy("zc.zcbh");
|
||||
cnd.asc("zc.zcbh");
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> maps = sysUserService.listMap(sql);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
int zSl = maps.stream().mapToInt(m -> m.getInt("sl")).sum();
|
||||
String zZcdj = String.format("%.2f", maps.stream().mapToDouble(m -> m.getFloat("zcdj")).sum());
|
||||
map.put("zSl", zSl);
|
||||
map.put("zZcdj", zZcdj);
|
||||
Map<String, String> zcLxMap = Map.of("one", "正常",
|
||||
"two", "损坏",
|
||||
"three", "丢失",
|
||||
"four", "待报废",
|
||||
"five", "使用信息不符",
|
||||
"six", "盘盈");
|
||||
|
||||
zcLxMap.forEach((k, v) -> {
|
||||
String slName = k + "Sl";
|
||||
String zcdjName = k + "Zcdj";
|
||||
int sl = maps.stream().filter(m -> m.getString("zczt").equals(v))
|
||||
.mapToInt(m -> m.getInt("sl")).sum();
|
||||
String zcdj = String.format("%.2f", maps.stream().filter(m -> m.getString("zczt").equals(v))
|
||||
.mapToDouble(m -> m.getFloat("zcdj")).sum());
|
||||
map.put(slName, sl);
|
||||
map.put(zcdjName, zcdj);
|
||||
});
|
||||
|
||||
System.out.println();
|
||||
if (Lang.isNotEmpty(maps)) {
|
||||
map.put("unitname", unitname);
|
||||
}
|
||||
map.put("schoolName", Globals.MyConfig.getString("GxName"));
|
||||
String fileName = Globals.MyConfig.getString("GxName") + "资产清查统计表";
|
||||
Configure config = Configure.builder().build();
|
||||
|
||||
try {
|
||||
response.addHeader("Content-Type", "application/octet-stream");
|
||||
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\".docx");
|
||||
XWPFTemplate.compile(officeTemplateUtil.getPath("zcQc"), config).render(map, response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresAuthentication
|
||||
public void doHzExcel(String zcpdid, String zcghlx, HttpServletResponse response) {
|
||||
try {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String unitname = "校工会";
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
zc.*,
|
||||
lyrur.username lyr,
|
||||
jsrur.username jsr,
|
||||
ut.unionname
|
||||
zc.zcbh,
|
||||
zc.zcmc,
|
||||
bd.zcgzrq,
|
||||
u.username,
|
||||
bd.mobile,
|
||||
zc.zccfdmc,
|
||||
bd.pdzt,
|
||||
bd.wpdzt,
|
||||
bd.zczt,
|
||||
it.name unitname,
|
||||
bd.zcFile
|
||||
FROM
|
||||
zgfw_zcxx zc
|
||||
LEFT JOIN sys_user lyrur ON zc.zclyrid = lyrur.id
|
||||
LEFT JOIN sys_user jsrur ON zc.zcjsrid = jsrur.id
|
||||
LEFT JOIN sys_union ut ON ut.`id` = zc.zclydwh $condition
|
||||
""");
|
||||
CndPlus cndPlus = CndPlus.create();
|
||||
cndPlus.andEx(searchName, "like", "%" + searchKeyword + "%");
|
||||
cndPlus.andEx("zc.zcghlx", "=", zcghlx);
|
||||
cndPlus.andEx("zc.zcgzrq", "=", zcgzrq);
|
||||
cndPlus.andEx("zc.zclydwh", "=", zclydwh);
|
||||
cndPlus.andEx("zc.zcrksj", "=", zcrksj);
|
||||
if (StrUtil.isNotBlank(pageOrderName) && StrUtil.isNotBlank(pageOrderBy)) {
|
||||
cndPlus.orderBy(pageOrderName, pageOrderBy.equals("desc") ? "desc" : "asc");
|
||||
} else {
|
||||
cndPlus.desc("zc.zcghlx");
|
||||
}
|
||||
sql.setCondition(cndPlus);
|
||||
Pagination pagination = zgfwZcxxService.listPage(pageNumber, pageSize, sql);
|
||||
return Result.success().addData(pagination);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
LEFT JOIN zgfw_zcxx_bdxx bd ON bd.zcid=zc.zcid AND bd.pdPlanId=@zcpdid
|
||||
left join sys_unit it on it.id=zc.zclydwhid
|
||||
LEFT JOIN `user` u ON u.id=bd.zcbdshrid
|
||||
$condition
|
||||
""").setParam("zcpdid", zcpdid);
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) {
|
||||
/*if (ShiroUtil.hasRole("H04")) {
|
||||
cnd.andEX("zc.zcghlx", "=", "1");
|
||||
cnd.andEX("zc.zclydwhid", "=", Vi.getUnionId());
|
||||
unitname = Vi.getUnit().getName();
|
||||
} else {
|
||||
cnd.andEX("zc.zcghlx", "=", "2");
|
||||
}*/
|
||||
cnd.andEX("zc.zcghlx", "=", "1");
|
||||
cnd.andEX("zc.zclydwhid", "=", Vi.getUnionId());
|
||||
unitname = Vi.getUnit().getName();
|
||||
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
public Object doChange(@Param("..") Zgfw_Zcxx_bdxx zcxxBdxx, String zczt) {
|
||||
try {
|
||||
Zgfw_Zcxx zcxx = zgfwZcxxService.fetch(zcxxBdxx.getZcid());
|
||||
Sys_user user = null;
|
||||
if (zczt.equals("报废") || zczt.equals("待报废")) {
|
||||
zcxxBdxx.setZcnowlyrid(Strings.isBlank(zcxxBdxx.getZcnowlyrid()) ? zcxxBdxx.getZcoldlyrid() : zcxxBdxx.getZcnowlyrid());
|
||||
zcxxBdxx.setZcnowlydwh(Strings.isBlank(zcxxBdxx.getZcnowlydwh()) ? zcxxBdxx.getZcoldlydwh() : zcxxBdxx.getZcnowlydwh());
|
||||
zcxxBdxx.setZcnowcfdmc(Strings.isBlank(zcxxBdxx.getZcnowcfdmc()) ? zcxxBdxx.getZcoldcfdmc() : zcxxBdxx.getZcnowcfdmc());
|
||||
} else {
|
||||
user = zgfwZcxxBdService.dao().fetch(Sys_user.class, zcxxBdxx.getZcnowlyrid());
|
||||
zcxxBdxx.setZcnowlyrid(Strings.isBlank(zcxxBdxx.getZcnowlyrid()) ? zcxxBdxx.getZcoldlyrid() : zcxxBdxx.getZcnowlyrid());
|
||||
zcxxBdxx.setZcnowlydwh(Strings.isBlank(zcxxBdxx.getZcnowlydwh()) ? zcxxBdxx.getZcoldlydwh() : zcxxBdxx.getZcnowlydwh());
|
||||
zcxxBdxx.setZcnowcfdmc(Strings.isBlank(zcxxBdxx.getZcnowcfdmc()) ? zcxxBdxx.getZcoldcfdmc() : zcxxBdxx.getZcnowcfdmc());
|
||||
}
|
||||
// zcxxBdxx.setZcoldlyrid(zcxx.getZclyrid());
|
||||
// zcxxBdxx.setZcbdsj(DateUtil.now());
|
||||
// zcxxBdxx.setZcbdshrid(ShiroUtil.getPrincipalProperty("id").toString());
|
||||
// zgfwZcxxBdService.insert(zcxxBdxx);
|
||||
// zcxx.setZclyrid(zcxxBdxx.getZcnowlyrid());
|
||||
// zcxx.setZclydwh(zcxxBdxx.getZcnowlydwh());
|
||||
// zcxx.setZccfdmc(zcxxBdxx.getZcnowcfdmc());
|
||||
// zcxx.setZclyrname(user == null ? null : user.getUsername());
|
||||
// zcxx.setZclyrgh(user == null ? null : user.getLoginname());
|
||||
// zcxx.setZczt(zczt);
|
||||
// zcxx.setZcjsrid(ShiroUtil.getPrincipalProperty("id").toString());
|
||||
// zcxx.setZcjsrname(ShiroUtil.getPrincipalProperty("username").toString());
|
||||
// zcxx.setZcjsrgh(Vi.getUnion().getUnionname());
|
||||
// zgfwZcxxService.update(zcxx);
|
||||
return Result.success();
|
||||
cnd.andEX("zc.zcghlx", "=", zcghlx);
|
||||
cnd.groupBy("zc.zcbh");
|
||||
cnd.asc("zc.zcbh");
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> maps = sysUserService.listMap(sql);
|
||||
|
||||
for (int i = 0; i < maps.size(); i++) {
|
||||
maps.get(i).put("index", i + 1);
|
||||
String zcFile1 = maps.get(i).getString("zcFile");
|
||||
if (StrUtil.isNotBlank(zcFile1)) {
|
||||
List<NutMap> zcFile = Json.fromJsonAsList(NutMap.class, zcFile1);
|
||||
ByteArrayOutputStream signOs = new ByteArrayOutputStream();
|
||||
ftpService.download(zcFile.get(0).getString("filepath"), signOs);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(signOs.toByteArray());
|
||||
BufferedImage bufferImg = ImageIO.read(bais);
|
||||
ImageIO.write(bufferImg, "jpg", signOs);
|
||||
ImageEntity imageEntity = new ImageEntity(signOs.toByteArray(), 200, 1000);
|
||||
maps.get(i).put("img", imageEntity);
|
||||
} else {
|
||||
maps.get(i).put("img", null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
map.put("maplist", maps);
|
||||
map.put("applyDate", DateUtil.format(new Date(), "yyyy年MM月dd日"));
|
||||
if (Lang.isNotEmpty(maps)) {
|
||||
map.put("unitname", unitname);
|
||||
}
|
||||
map.put("schoolName", Globals.MyConfig.getString("GxName"));
|
||||
|
||||
// String templateUrl = "C:\\Users\\mayn\\Desktop\\pdHz.xlsx";
|
||||
String templateUrl = officeTemplateUtil.getPath("pdHz");
|
||||
response.setContentType("application/octet-stream");
|
||||
ViTool.excelResponse(response, Globals.MyConfig.getString("GxName") + "固定资产盘点汇总表.xlsx");
|
||||
TemplateExportParams params = new TemplateExportParams(
|
||||
templateUrl);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(params, map);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("zc.bg")
|
||||
public Object queryChangeData(String zcid) {
|
||||
try {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
bd.`zcoldcfdmc` oldcfd,
|
||||
bd.`zcnowcfdmc` nowcfd,
|
||||
shr.`username` shrname,
|
||||
bd.`zcbdsj`,
|
||||
bd.zcnowlydwh,
|
||||
bd.zcoldlydwh,
|
||||
oldlyr.username oldlyrusername,
|
||||
nowlyr.username nowlyrusername
|
||||
FROM
|
||||
zgfw_zcxx_bdxx bd
|
||||
LEFT JOIN `sys_user` oldlyr ON bd.zcoldlyrid = oldlyr.`id`
|
||||
LEFT JOIN `sys_user` nowlyr ON bd.`zcnowlyrid` = nowlyr.`id`
|
||||
LEFT JOIN sys_user shr ON bd.`zcbdshrid` = shr.`id`
|
||||
WHERE
|
||||
bd.`zcid` = @zcid
|
||||
ORDER BY
|
||||
bd.`zcbdsj` DESC
|
||||
""").setParam("zcid", zcid);
|
||||
return Result.success().addData(zgfwZcxxBdService.list(sql));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
public Object queryDw(String query) {
|
||||
try {
|
||||
Sql sql = Sqls.create("SELECT * FROM sys_union WHERE unionname LIKE @query").setParam("query", "%" + query + "%");
|
||||
return Result.success().addData(sysUserService.list(sql));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
public Object queryUser(String username, String excUserId) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.where().andLike("username", username).orLike("loginname", username);
|
||||
if (Strings.isNotBlank(excUserId)) {
|
||||
cnd.and("id", "!=", excUserId);
|
||||
}
|
||||
return Result.success().addData(sysUserService.query(cnd));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("zc.bg")
|
||||
public Object openEditData(String zcid) {
|
||||
try {
|
||||
Sql sql = Sqls.create("SELECT xx.*,u.`username`,un.`unionname` FROM zgfw_zcxx xx \n" +
|
||||
"LEFT JOIN sys_user u ON xx.`zclyrid` = u.`id`\n" +
|
||||
"LEFT JOIN sys_union un ON xx.`zclydwh` = un.`id` WHERE xx.zcid=@zcid").setParam("zcid", zcid);
|
||||
Record record = zgfwZcxxService.list(sql).get(0);
|
||||
return Result.success().addData(record);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
|
||||
import io.v.nutz.base.annontation.ViReturn;import io.v.nutz.base.utils.OfficeTemplateUtil;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx_bdxx;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxBdService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName ZgfwZcBfListController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/7/16 14:22
|
||||
*/
|
||||
@At("/platform/zcgl/bfList")
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
public class ZgfwZcBfListController {
|
||||
|
||||
|
||||
@Inject
|
||||
private ZgfwZcxxBdService zgfwZcxxBdService;
|
||||
|
||||
@Inject
|
||||
private OfficeTemplateUtil officeTemplateUtil;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zcgl/bfList.html")
|
||||
@RequiresPermissions("zc.bfList")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.bfList")
|
||||
public Object pageData(PageForm pageForm, Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
zcbdid,
|
||||
zcbdsj,
|
||||
COUNT( zcbdsj ) bfNum
|
||||
FROM
|
||||
`zgfw_zcxx_bdxx`
|
||||
WHERE
|
||||
YEAR ( zcbdsj )= @year
|
||||
GROUP BY
|
||||
zcbdsj
|
||||
ORDER BY
|
||||
zcbdsj
|
||||
""").setParam("year", year);
|
||||
|
||||
Pagination pagination = zgfwZcxxBdService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
List<NutMap> ListMap = pagination.getList();
|
||||
|
||||
List<Zgfw_Zcxx_bdxx> bdxxes = zgfwZcxxBdService.query(Cnd.where("YEAR(zcbdsj)", "=", year));
|
||||
List<Zgfw_Zcxx> zcxxList = zgfwZcxxBdService.dao().query(Zgfw_Zcxx.class, Cnd.NEW());
|
||||
|
||||
ListMap.forEach(v -> {
|
||||
String zcbdsj = v.getString("zcbdsj");
|
||||
List<Zgfw_Zcxx_bdxx> bdxxList = bdxxes.stream().filter(b -> b.getZcbdsj().equals(zcbdsj)).collect(Collectors.toList());
|
||||
List<String> zcids = bdxxList.stream().map(Zgfw_Zcxx_bdxx::getZcid).collect(Collectors.toList());
|
||||
|
||||
List<Zgfw_Zcxx> zcxxs = zcxxList.stream().filter(z -> zcids.contains(z.getZcid())).collect(Collectors.toList());
|
||||
int slSum = zcxxs.stream().mapToInt(z -> z.getSl()).sum();
|
||||
double djSum = zcxxs.stream().mapToDouble(z -> Double.parseDouble(z.getZcdj())).sum();
|
||||
v.setv("slSum", slSum);
|
||||
v.setv("djSum", djSum);
|
||||
v.setv("zcxxs", zcxxs);
|
||||
|
||||
|
||||
});
|
||||
|
||||
pagination.setList(ListMap);
|
||||
return pagination;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public void exportDetails(String zcbdid, HttpServletResponse response) {
|
||||
Zgfw_Zcxx_bdxx bdxx = zgfwZcxxBdService.fetch(zcbdid);
|
||||
List<Zgfw_Zcxx_bdxx> bdxxes = zgfwZcxxBdService.query(Cnd.where("zcbdsj", "=", bdxx.getZcbdsj()).groupBy("zcbdsj"));
|
||||
List<String> ids = bdxxes.stream().map(Zgfw_Zcxx_bdxx::getZcid).collect(Collectors.toList());
|
||||
List<Zgfw_Zcxx> zcxxes = zgfwZcxxBdService.dao().query(Zgfw_Zcxx.class, Cnd.where("zcid", "in", ids));
|
||||
|
||||
List<NutMap> zcxxList = new ArrayList<>();
|
||||
NutMap map = new NutMap();
|
||||
String fileName = Globals.MyConfig.getString("GxName") + "仪器设备报废申请表";
|
||||
|
||||
int zsl = 0;
|
||||
Double zje = 0.00;
|
||||
for (int i = 0; i < zcxxes.size(); i++) {
|
||||
Zgfw_Zcxx zcxx = zcxxes.get(i);
|
||||
NutMap xxMap = new NutMap();
|
||||
Double zcdj = Double.parseDouble(zcxx.getZcdj());
|
||||
int sl = zcxx.getSl() == null ? 1 : zcxx.getSl();
|
||||
xxMap.setv("index", i + 1);
|
||||
xxMap.setv("zcbh", zcxx.getZcbh());
|
||||
xxMap.setv("zcmc", zcxx.getZcmc());
|
||||
xxMap.setv("zcxh", zcxx.getZcxh());
|
||||
xxMap.setv("zcsl", sl);
|
||||
xxMap.setv("zcdj", zcdj);
|
||||
xxMap.setv("zccj", zcxx.getZccj());
|
||||
xxMap.setv("zccfdmc", zcxx.getZccfdmc());
|
||||
xxMap.setv("zcgzrq", zcxx.getZcgzrq());
|
||||
|
||||
zcxxList.add(xxMap);
|
||||
zsl = zsl + sl;
|
||||
zje = zje + sl * zcdj;
|
||||
}
|
||||
|
||||
if (zcxxes.get(0).getZcghlx().equals("2")) {
|
||||
map.setv("unionName", "工会");
|
||||
} else {
|
||||
String zclyrgh = zcxxes.get(0).getZclyrgh();
|
||||
User user = zgfwZcxxBdService.dao().fetch(User.class, Cnd.where("loginname", "=", zclyrgh));
|
||||
map.setv("unionName", user.getUnionname());
|
||||
}
|
||||
map.setv("zsl", zsl);
|
||||
map.setv("zje", String.format("%.2f", zje));
|
||||
map.setv("zcxxList", zcxxList);
|
||||
map.setv("fileName", fileName);
|
||||
map.setv("bfyy", bdxx.getWpdzt());
|
||||
map.setv("userName", ShiroUtil.getPlatformUsername());
|
||||
map.setv("applyDate", DateUtil.today());
|
||||
map.setv("djh", DateUtil.thisYear() + String.format("%03d", bdxxes.size()));
|
||||
|
||||
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
|
||||
Configure config = Configure.newBuilder().bind("zcxxList", policy).build();
|
||||
|
||||
try {
|
||||
response.addHeader("Content-Type", "application/octet-stream");
|
||||
response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1) + "\".docx");
|
||||
XWPFTemplate.compile(officeTemplateUtil.getPath("zcmxb"), config).render(map, response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.annontation.ViReturn;import io.v.nutz.sys.services.SysDictService;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.model.zgfwZclb;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxBdService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
@@ -26,21 +30,27 @@ public class ZgfwZcSjkbController {
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zcgl/zcsjkb.html")
|
||||
@RequiresPermissions("zc.sjkb")
|
||||
public void index(){}
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private ZgfwZcxxBdService zgfwZcxxBdService;
|
||||
@Inject
|
||||
private SysDictService sysDictService;
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("zc.sjkb")
|
||||
public Object data(){
|
||||
public Object data() {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
SUM(CASE WHEN assetStatus = '1001' THEN 1 ELSE 0 END) AS zy,
|
||||
SUM(CASE WHEN assetStatus = '1002' THEN 1 ELSE 0 END) AS ydcf,
|
||||
SUM(CASE WHEN assetStatus = '1003' THEN 1 ELSE 0 END) AS dbf,
|
||||
SUM(CASE WHEN assetStatus = '1004' THEN 1 ELSE 0 END) AS ybf
|
||||
count( CASE WHEN zczt = '在用' THEN '在用' END ) AS zy,
|
||||
count( CASE WHEN zczt = '闲置' THEN '闲置' END ) AS xz,
|
||||
count( CASE WHEN zczt = '未使用' THEN '未使用' END ) AS wsy,
|
||||
count( CASE WHEN zczt = '待报废' THEN '待报废' END ) AS dbf,
|
||||
count( CASE WHEN zczt = '校外转入' THEN '校外转入' END ) AS xwzr,
|
||||
count( CASE WHEN zczt = '校内转入' THEN '校内转入' END ) AS xnzr,
|
||||
count( CASE WHEN zczt = '其它' THEN '其它' END ) AS qt
|
||||
FROM
|
||||
zgfw_zcxx
|
||||
""");
|
||||
@@ -61,17 +71,42 @@ public class ZgfwZcSjkbController {
|
||||
|
||||
List<Record> list = zgfwZcxxBdService.list(Sqls.create("SELECT SUBSTR(MIN(zcgzrq),1,4) ksnf,SUBSTR(MAX(zcgzrq),1,4) jsnf FROM zgfw_zcxx"));
|
||||
Record record = list.get(0);
|
||||
List nftj=new ArrayList();
|
||||
for (int i = record.getInt("ksnf"); i <=record.getInt("jsnf") ; i++) {
|
||||
List nftj = new ArrayList();
|
||||
for (int i = record.getInt("ksnf"); i <= record.getInt("jsnf"); i++) {
|
||||
List<Record> nf = zgfwZcxxBdService.list(Sqls.create("SELECT count(*) sl," + i + " YEAR FROM zgfw_zcxx WHERE zcgzrq LIKE '" + i + "%'"));
|
||||
nftj.add(nf.get(0));
|
||||
}
|
||||
|
||||
NutMap nutMap=new NutMap();
|
||||
nutMap.put("fghtj",new ArrayList<Record>());
|
||||
nutMap.put("zttj",zttj);
|
||||
nutMap.put("jgtj",jgtj);
|
||||
nutMap.put("nftj",nftj);
|
||||
NutMap nutMap = new NutMap();
|
||||
nutMap.put("fghtj", new ArrayList<Record>());
|
||||
nutMap.put("zttj", zttj);
|
||||
nutMap.put("jgtj", jgtj);
|
||||
nutMap.put("nftj", nftj);
|
||||
return Result.success().addData(nutMap);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.sjkb")
|
||||
public Object pageData(String zczt) {
|
||||
|
||||
List<zgfwZclb> zclbList = zgfwZcxxBdService.dao().query(zgfwZclb.class, Cnd.NEW().asc("contentCode"));
|
||||
|
||||
List<Zgfw_Zcxx> zcxxList = zgfwZcxxBdService.dao().query(Zgfw_Zcxx.class, Cnd.NEW().andEX("zczt", "=", zczt));
|
||||
|
||||
List<NutMap> list = new ArrayList<>();
|
||||
zclbList.forEach(z -> {
|
||||
int sl = zcxxList.stream().filter(zc -> zc.getContentCode().equals(z.getContentCode())).mapToInt(zc -> zc.getSl()).sum();
|
||||
Double je = zcxxList.stream().filter(zc -> zc.getContentCode().equals(z.getContentCode())).mapToDouble(Zgfw_Zcxx::getAllMoney).sum();
|
||||
NutMap map = new NutMap();
|
||||
map.setv("typeCode", z.getContentCode());
|
||||
map.setv("type", z.getContent());
|
||||
map.setv("sl", sl);
|
||||
map.setv("je", String.format("%.2f", je));
|
||||
list.add(map);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,56 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.utils.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.v.nutz.base.annontation.ViReturn;import io.v.nutz.base.utils.DateUtil;
|
||||
import io.v.nutz.base.utils.OfficeTemplateUtil;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.model.zcDepreciationRecord;
|
||||
import io.v.nutz.sys.models.Sys_dict;
|
||||
import io.v.nutz.sys.services.SysDictService;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import io.v.nutz.zhgh.zc.model.*;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxBdService;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
import org.nutz.mvc.upload.UploadAdaptor;
|
||||
import org.nutz.trans.Trans;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 台账管理
|
||||
@@ -66,61 +74,47 @@ public class ZgfwZcTzglController {
|
||||
@Inject
|
||||
private ZgfwZcxxBdService zgfwZcxxBdService;
|
||||
|
||||
@Inject
|
||||
private SysDictService sysDictService;
|
||||
|
||||
@Inject
|
||||
private OfficeTemplateUtil officeTemplateUtil;
|
||||
|
||||
|
||||
/**
|
||||
* @param pageForm
|
||||
* @param assetStatus 资产状态
|
||||
* @param purchaseDate 购置日期
|
||||
* @param storageDate 入库日期
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "assetStatus", required = false) String assetStatus,
|
||||
@Param(value = "purchaseDate", required = false) String purchaseDate,
|
||||
@Param(value = "storageDate", required = false) String storageDate) {
|
||||
public Object data(PageForm pageForm,
|
||||
@Param(value = "zcghlx", required = false) String zcghlx,
|
||||
@Param(value = "zcgzrq", required = false) String zcgzrq,
|
||||
@Param(value = "zclydwh", required = false) String zclydwh,
|
||||
@Param(value = "zcrksj", required = false) String zcrksj,
|
||||
@Param(value = "zczt", required = false) String zczt,
|
||||
@Param(value = "contentCode", required = false) String contentCode) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.categoryName AS assetStatusName,
|
||||
CASE
|
||||
WHEN TIMESTAMPDIFF(MONTH, xx.storageDate, CURDATE()) < 1 THEN '不足1月'
|
||||
ELSE
|
||||
CONCAT(
|
||||
TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()),
|
||||
'年',
|
||||
TIMESTAMPDIFF(MONTH, xx.storageDate + INTERVAL TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()) YEAR, CURDATE()),
|
||||
'月'
|
||||
)
|
||||
END AS yearsAndMonths
|
||||
xx.*,
|
||||
lb.content
|
||||
FROM
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.assetStatus = lb.contentCode
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.contentCode = lb.contentCode
|
||||
$condition
|
||||
ORDER BY CASE WHEN xx.zczt = '报废' THEN 1 ELSE 0 END, zczt
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword()) && StrUtil.isNotBlank(pageForm.getSearchName())) {
|
||||
cnd.andEX(pageForm.getSearchName(), "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
|
||||
}
|
||||
|
||||
// cnd.andEX("xx.assetStatus", "=", assetStatus);
|
||||
|
||||
if (StrUtil.isNotBlank(assetStatus)) {
|
||||
cnd.and(new Static("JSON_CONTAINS(xx.assetStatus, CAST('\"%s\"' AS JSON), '$')".formatted(assetStatus)));
|
||||
}
|
||||
|
||||
cnd.andEX("xx.purchaseDate", "=", purchaseDate);
|
||||
cnd.andEX("xx.storageDate", "=", storageDate);
|
||||
if (StrUtil.isNotBlank(pageForm.getPageOrderBy()) && StrUtil.isNotBlank(pageForm.getPageOrderName())) {
|
||||
cnd.andEX("xx.contentCode", "=", contentCode);
|
||||
cnd.andEX("xx.zcghlx", "=", zcghlx);
|
||||
cnd.andEX("xx.zcgzrq", "=", zcgzrq);
|
||||
cnd.andEX("xx.zclydwh", "=", zclydwh);
|
||||
cnd.andEX("xx.zcrksj", "=", zcrksj);
|
||||
cnd.andEX("xx.zczt", "=", zczt);
|
||||
/* if (StrUtil.isNotBlank(pageForm.getPageOrderBy()) && StrUtil.isNotBlank(pageForm.getPageOrderName())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equals("desc") ? "desc" : "asc");
|
||||
} else {
|
||||
cnd.asc("lb.contentCode");
|
||||
}
|
||||
cnd.desc("xx.zcghlx");
|
||||
}*/
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = zgfwZcxxService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success().addData(pagination);
|
||||
@@ -128,12 +122,11 @@ public class ZgfwZcTzglController {
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object doDel(String id) {
|
||||
Trans.exec(() -> {
|
||||
zgfwZcxxService.delete(id);
|
||||
zgfwZcxxBdService.clear(Cnd.where("zcid", "=", id));
|
||||
});
|
||||
zgfwZcxxService.delete(id);
|
||||
zgfwZcxxBdService.clear(Cnd.where("zcid", "=", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -142,7 +135,7 @@ public class ZgfwZcTzglController {
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object bgzt(String zcid, String zczt) {
|
||||
Zgfw_Zcxx fetch = zgfwZcxxService.fetch(zcid);
|
||||
// fetch.setZczt(zczt);
|
||||
fetch.setZczt(zczt);
|
||||
zgfwZcxxService.updateIgnoreNull(fetch);
|
||||
return null;
|
||||
}
|
||||
@@ -182,70 +175,184 @@ public class ZgfwZcTzglController {
|
||||
public Object doZj() {
|
||||
Trans.exec(() -> {
|
||||
|
||||
List<Zgfw_Zcxx> zgfw_zcxxes = zgfwZcxxService.query(Cnd.where("depreciationDate", "!=", DateUtil.getDate()));
|
||||
List<Zgfw_Zcxx> zgfw_zcxxes = zgfwZcxxService.query(Cnd.where("depreciationDate", "!=", DateUtil.getDate()).and("zczt", "not in", List.of("报废")));
|
||||
zgfw_zcxxes.forEach(v -> {
|
||||
// LocalDate rkLocalDate = v.getDepreciationDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
// Period period = Period.between(LocalDate.now(), rkLocalDate);
|
||||
// zcDepreciationRecord zcDepreciationRecord = zgfwZcxxService.dao().fetch(zcDepreciationRecord.class, Cnd.where("zcid", "=", v.getZcid()).and("date_format( operationTime, '%Y-%m' )", "=", cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM")));
|
||||
// if (zcDepreciationRecord == null && v.getDepreciationDate() != null && (period.getYears() * 12 + period.getMonths()) > 0) {
|
||||
// zcDepreciationRecord record = new zcDepreciationRecord();
|
||||
// record.setZcid(v.getZcid());
|
||||
// record.setOperationTime(cn.hutool.core.date.DateUtil.now());
|
||||
// record.setDepreciationDate(v.getDepreciationDate());
|
||||
// record.setSurplus(Math.max(period.getYears() * 12 + period.getMonths(), 0));
|
||||
// zgfwZcxxService.insert(record);
|
||||
// }
|
||||
LocalDate rkLocalDate = v.getDepreciationDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
Period period = Period.between(LocalDate.now(), rkLocalDate);
|
||||
zcDepreciationRecord zcDepreciationRecord = zgfwZcxxService.dao().fetch(zcDepreciationRecord.class,
|
||||
Cnd.where("zcid", "=", v.getZcid())
|
||||
.and("date_format( operationTime, '%Y-%m' )", "=", cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM"))
|
||||
);
|
||||
if (!List.of("报废", "丢失").contains(v.getZczt()) && zcDepreciationRecord == null && v.getDepreciationDate() != null && (period.getYears() * 12 + period.getMonths()) > 0) {
|
||||
String zcdj = v.getZcdj();
|
||||
Integer sl = v.getSl();
|
||||
String zcgzrq = v.getZcgzrq();
|
||||
// 定义日期格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// 使用定义的格式解析字符串
|
||||
LocalDate zcgzrqLocalData = LocalDate.parse(zcgzrq, formatter);
|
||||
// 计算两个日期之间的差异
|
||||
Period allMonths = Period.between(zcgzrqLocalData, rkLocalDate);
|
||||
// 获取月份数
|
||||
int months = allMonths.getYears() * 12 + allMonths.getMonths();
|
||||
//得到了这个物品使用的月,通过金额/月就等于每个月多少钱
|
||||
Double zcDjDouble = Double.parseDouble(zcdj);
|
||||
Double monthsZcDj = zcDjDouble / months;
|
||||
int surplusMonths = Math.max(period.getYears() * 12 + period.getMonths(), 0);
|
||||
|
||||
zcDepreciationRecord record = new zcDepreciationRecord();
|
||||
record.setZcid(v.getZcid());
|
||||
record.setOperationTime(cn.hutool.core.date.DateUtil.now());
|
||||
record.setDepreciationDate(v.getDepreciationDate());
|
||||
record.setSurplus(surplusMonths);
|
||||
record.setSurplusMoney(NumberUtil.round(surplusMonths * monthsZcDj * sl, 2).doubleValue());
|
||||
zgfwZcxxService.insert(record);
|
||||
|
||||
v.setSurplusMoney(NumberUtil.round(surplusMonths * monthsZcDj * sl, 2).doubleValue());
|
||||
} else {
|
||||
v.setSurplusMoney(null);
|
||||
}
|
||||
});
|
||||
zgfwZcxxService.update(zgfw_zcxxes);
|
||||
});
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
/**
|
||||
* 下载模板
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
@At("/downLoadTemp")
|
||||
@Ok("void")
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object findAssetById(String id) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.categoryName AS assetStatusName,
|
||||
CASE
|
||||
WHEN TIMESTAMPDIFF(MONTH, xx.storageDate, CURDATE()) = 0 THEN '不足1月'
|
||||
WHEN TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()) = 0 THEN CONCAT(TIMESTAMPDIFF(MONTH, xx.storageDate, CURDATE()), '月')
|
||||
ELSE CONCAT(TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()), '年', TIMESTAMPDIFF(MONTH, xx.storageDate, CURDATE()), '月')
|
||||
END AS yearsAndMonths
|
||||
FROM
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.assetStatus = lb.contentCode
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("xx.id", "=", id);
|
||||
sql.setCondition(cnd);
|
||||
return Daos.query(zgfwZcxxService.dao(), sql.toString(), Sqls.callback.map());
|
||||
public void downLoadTemp(HttpServletResponse response) {
|
||||
try {
|
||||
|
||||
Class<ZgfwZcxxTemp> excelModeClass = ZgfwZcxxTemp.class;
|
||||
Field[] excelModeClassDeclaredFields = excelModeClass.getDeclaredFields();
|
||||
//字段过滤
|
||||
List<Field> needAddReplaceFields = Arrays.stream(excelModeClassDeclaredFields)
|
||||
.filter(v -> List.of("zczt", "fundingSubject", "contentCode", "zcghlx").contains(v.getName())).collect(Collectors.toList());
|
||||
|
||||
List<Sys_dict> zcztList = sysDictService.getSubListByCode("zczt");
|
||||
List<String> zczztCodeList = zcztList.stream().map(v -> v.getCode() + "_" + v.getCode()).collect(Collectors.toList());
|
||||
String[] zczztCodeArrs = zczztCodeList.toArray(new String[zczztCodeList.size()]);
|
||||
|
||||
List<zgfwZclb> zgfwZclbList = sysDictService.dao().query(zgfwZclb.class, Cnd.NEW().asc("contentCode"));
|
||||
List<String> contentList = zgfwZclbList.stream().map(v -> v.getContent() + "_" + v.getContentCode()).collect(Collectors.toList());
|
||||
String[] contentArrs = contentList.toArray(new String[contentList.size()]);
|
||||
|
||||
for (Field field : needAddReplaceFields) {
|
||||
Excel excelAnnotation = field.getAnnotation(Excel.class);
|
||||
if (Lang.isNotEmpty(excelAnnotation)) {
|
||||
InvocationHandler invocationHandler = Proxy.getInvocationHandler(excelAnnotation);
|
||||
Field memberValues = invocationHandler.getClass().getDeclaredField("memberValues");
|
||||
memberValues.setAccessible(true);
|
||||
Map e = (Map) memberValues.get(invocationHandler);
|
||||
e.put("addressList", true);
|
||||
if (field.getName().equals("zczt")) {
|
||||
e.put("replace", zczztCodeArrs);
|
||||
} else if (field.getName().equals("fundingSubject")) {
|
||||
e.put("replace", new String[]{"行政_行政", "自筹_自筹"});
|
||||
} else if (field.getName().equals("contentCode")) {
|
||||
e.put("replace", contentArrs);
|
||||
} else if (field.getName().equals("zcghlx")) {
|
||||
e.put("replace", new String[]{"院级工会_1", "校工会_2"});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ZgfwZcxxTemp.class, new ArrayList<>());
|
||||
ViTool.excelResponse(response, "固定资产模板.xlsx");
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 报废资产
|
||||
* @param ids
|
||||
* 读取excel内容
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@At("/readExcel")
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object doScrap(@Param("ids") String ids,@Param("flag")Boolean flag) {
|
||||
List<String> idList = JSONUtil.parseArray(ids).toList(String.class);
|
||||
if (Lang.isEmpty(idList)) return Result.error();
|
||||
List<String> assetList = new ArrayList<>();
|
||||
if (flag){
|
||||
assetList.add("1004");
|
||||
} else {
|
||||
assetList.add("1005");
|
||||
}
|
||||
zgfwZcxxService.update(Chain.make("assetStatus",assetList),Cnd.where("id","in",idList));
|
||||
return Result.success();
|
||||
@AdaptBy(type = UploadAdaptor.class, args = {"ioc:fileUpload"})
|
||||
public Object readExcel(TempFile file) {
|
||||
ImportParams params = new ImportParams();
|
||||
List<ZgfwZcxxTemp> importList = ExcelImportUtil.importExcel(file.getFile(), ZgfwZcxxTemp.class, params);
|
||||
ZgfwZcxxTemp[] zxccList = importList.stream().toArray(ZgfwZcxxTemp[]::new);
|
||||
return zgfwZcxxService.matchUserId(zxccList);
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object doExcelData(Zgfw_Zcxx[] excelData) {
|
||||
zgfwZcxxService.insert(excelData);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object getExcelLyr(String[] userNames) {
|
||||
if (Lang.isEmpty(userNames)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Sql sql = Sqls.create("select id,username,loginname,unionid,unionname from `user` where username in (@usernames)").setParam("usernames", JSON.toJSON(userNames));
|
||||
List<Record> list = zgfwZcxxService.list(sql);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object findOne(String id) {
|
||||
return zgfwZcxxService.findOne(id);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.tzgl")
|
||||
public Object doBatchBf(String[] ids, String bfyy) {
|
||||
if (Lang.isEmpty(ids)) {
|
||||
return Result.error("请勾选所要报废的资产");
|
||||
}
|
||||
List<Zgfw_Zcxx> zcxxList = zgfwZcxxService.query(Cnd.where("zcid", "in", ids));
|
||||
List<Zgfw_Zcxx_bdxx> zcxxBdxxes = new ArrayList<>();
|
||||
zcxxList.forEach(v -> {
|
||||
Zgfw_Zcxx_bdxx bdxx = new Zgfw_Zcxx_bdxx();
|
||||
bdxx.setZcid(v.getZcid());
|
||||
bdxx.setZcnowlydwh(v.getZclydwh());
|
||||
bdxx.setZcnowcfdmc(v.getZccfdmc());
|
||||
bdxx.setZcbdsj(DateUtil.getDate());
|
||||
bdxx.setZcbdshrid(ShiroUtil.getUserId());
|
||||
bdxx.setZczt("报废");
|
||||
bdxx.setWpdzt(bfyy);
|
||||
v.setZczt("报废");
|
||||
zcxxBdxxes.add(bdxx);
|
||||
});
|
||||
|
||||
zgfwZcxxService.insert(zcxxBdxxes);
|
||||
zgfwZcxxService.update(zcxxList);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.sys.models.Sys_union;
|
||||
import io.v.nutz.sys.services.SysUnionService;
|
||||
import io.v.nutz.base.utils.ViTool;
|
||||
import io.v.nutz.zhgh.zc.model.ZgfwZclb;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxBdService;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxService;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@@ -24,7 +17,6 @@ import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.Static;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
@@ -35,7 +27,6 @@ import org.nutz.mvc.annotation.Param;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 综合查询
|
||||
@@ -67,160 +58,105 @@ public class ZgfwZcZhcxController {
|
||||
@Ok("json")
|
||||
@ViReturn
|
||||
@RequiresPermissions("zc.zhcx")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "assetStatus", required = false) String assetStatus,
|
||||
@Param(value = "purchaseStartTime", required = false) String purchaseStartTime,
|
||||
@Param(value = "purchaseEndTime", required = false) String purchaseEndTime,
|
||||
@Param(value = "storageStartTime", required = false) String storageStartTime,
|
||||
@Param(value = "storageEndTime", required = false) String storageEndTime) {
|
||||
public Object data(@Param(value = "pageNumber", required = false) Integer pageNumber,
|
||||
@Param(value = "pageSize", required = false) Integer pageSize,
|
||||
@Param(value = "searchName", required = false) String searchName,
|
||||
@Param(value = "searchKeyword", required = false) String searchKeyword,
|
||||
@Param(value = "zczt", required = false) String zczt,
|
||||
@Param(value = "startTime", required = false) String startTime,
|
||||
@Param(value = "endTime", required = false) String endTime,
|
||||
@Param(value = "zcghlx", required = false) String zcghlx,
|
||||
@Param(value = "zcrksj", required = false) String zcrksj,
|
||||
@Param(value = "ghid", required = false) String ghid,
|
||||
@Param(value = "pageOrderName", required = false) String pageOrderName,
|
||||
@Param(value = "pageOrderBy", required = false) String pageOrderBy) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.categoryName AS assetStatusName,
|
||||
CASE
|
||||
WHEN TIMESTAMPDIFF(MONTH, xx.storageDate, CURDATE()) < 1 THEN '不足1月'
|
||||
ELSE
|
||||
CONCAT(
|
||||
TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()),
|
||||
'年',
|
||||
TIMESTAMPDIFF(MONTH, xx.storageDate + INTERVAL TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()) YEAR, CURDATE()),
|
||||
'月'
|
||||
)
|
||||
END AS yearsAndMonths
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.content
|
||||
FROM
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.assetStatus = lb.contentCode
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.contentCode = lb.contentCode
|
||||
LEFT JOIN sys_union us ON us.id = xx.zclydwhid
|
||||
$condition
|
||||
""");
|
||||
CndPlus cnd = CndPlus.create();
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchName()) && StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and(Cnd.likeEX(pageForm.getSearchName(), pageForm.getSearchKeyword()));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(pageForm.getPageOrderBy()) && StrUtil.isNotBlank(pageForm.getPageOrderName())) {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equals("desc") ? "desc" : "asc");
|
||||
CndPlus cndPlus = CndPlus.create();
|
||||
cndPlus.andEx(searchName, "like", "%" + searchKeyword + "%");
|
||||
cndPlus.andEx("xx.zczt", "=", zczt);
|
||||
cndPlus.andEx("xx.zcghlx", "=", zcghlx);
|
||||
cndPlus.andEx("xx.zczt", "=", zczt);
|
||||
cndPlus.andEx("xx.zcrksj", "=", zcrksj);
|
||||
cndPlus.andEx("us.id", "=", ghid);
|
||||
if (StrUtil.isNotBlank(pageOrderName) && StrUtil.isNotBlank(pageOrderBy)) {
|
||||
cndPlus.orderBy(pageOrderName, pageOrderBy.equals("desc") ? "desc" : "asc");
|
||||
} else {
|
||||
cnd.asc("lb.contentCode");
|
||||
cndPlus.desc("xx.zcghlx");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(assetStatus)) {
|
||||
cnd.and(new Static("JSON_CONTAINS(xx.assetStatus, CAST('\"%s\"' AS JSON), '$')".formatted(assetStatus)));
|
||||
if (StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)) {
|
||||
cndPlus.and(Cnd.cri().where().andBetween("zcgzrq", startTime, endTime));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(purchaseStartTime) && StrUtil.isNotBlank(purchaseEndTime)) {
|
||||
cnd.and(Cnd.cri().where().andBetween("xx.purchaseDate", purchaseStartTime, purchaseEndTime));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(storageEndTime) && StrUtil.isNotBlank(storageStartTime)) {
|
||||
cnd.and(Cnd.cri().where().andBetween("xx.storageDate", storageStartTime, storageEndTime));
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
return zgfwZcxxService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
sql.setCondition(cndPlus);
|
||||
return zgfwZcxxService.listPageMap(pageNumber, pageSize, sql);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
public Object getUnion() {
|
||||
List<Sys_union> query = sysUnionService.query();
|
||||
return Result.success().addData(query);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("zc.zhcx")
|
||||
public void doExport(@Param(value = "searchName",required = false) String searchName,
|
||||
@Param(value = "searchKeyword",required = false) String searchKeyword,
|
||||
@Param(value = "assetStatus",required = false)String assetStatus,
|
||||
@Param(value = "purchaseStartTime",required = false) String purchaseStartTime,
|
||||
@Param(value = "purchaseEndTime",required = false) String purchaseEndTime,
|
||||
@Param(value = "purchaseStartTime",required = false) String storageStartTime,
|
||||
@Param(value = "purchaseEndTime",required = false) String storageEndTime,
|
||||
@Param(value = "purchaseDate",required = false) String purchaseDate,
|
||||
@Param(value = "storageDate",required = false) String storageDate,
|
||||
HttpServletResponse response) {
|
||||
public void doExport(String searchKeyword, String searchName, String zczt, String zcghlx, String ghid, String startTime, String endTime, HttpServletResponse response) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.categoryName AS assetStatusName,
|
||||
CASE
|
||||
WHEN TIMESTAMPDIFF(MONTH, xx.storageDate, CURDATE()) < 1 THEN '不足1月'
|
||||
ELSE
|
||||
CONCAT(
|
||||
TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()),
|
||||
'年',
|
||||
TIMESTAMPDIFF(MONTH, xx.storageDate + INTERVAL TIMESTAMPDIFF(YEAR, xx.storageDate, CURDATE()) YEAR, CURDATE()),
|
||||
'月'
|
||||
)
|
||||
END AS yearsAndMonths
|
||||
SELECT
|
||||
xx.*
|
||||
FROM
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.assetStatus = lb.contentCode
|
||||
LEFT JOIN `user` us ON us.loginname = xx.zclyrgh
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
cnd.andEX(searchName, "like", "%" + searchKeyword + "%");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(assetStatus)) {
|
||||
cnd.and(new Static("JSON_CONTAINS(xx.assetStatus, CAST('\"%s\"' AS JSON), '$')".formatted(assetStatus)));
|
||||
cnd.andEX("xx.zczt", "=", zczt);
|
||||
cnd.andEX("xx.zcghlx", "=", zcghlx);
|
||||
cnd.andEX("xx.zczt", "=", zczt);
|
||||
cnd.andEX("us.unionid", "=", ghid);
|
||||
if (StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)) {
|
||||
cnd.and(Cnd.cri().where().andBetween("zcgzrq", startTime, endTime));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(purchaseStartTime) && StrUtil.isNotBlank(purchaseEndTime)) {
|
||||
cnd.and(Cnd.cri().where().andBetween("xx.purchaseDate", purchaseStartTime, purchaseEndTime));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(storageEndTime) && StrUtil.isNotBlank(storageStartTime)) {
|
||||
cnd.and(Cnd.cri().where().andBetween("xx.storageDate", storageStartTime, storageEndTime));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(storageDate)) {
|
||||
cnd.and("xx.storageDate","=", storageDate);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(purchaseDate)) {
|
||||
cnd.and("xx.purchaseDate","=", purchaseDate);
|
||||
}
|
||||
|
||||
sql.setCondition(cnd);
|
||||
List<Record> list = zgfwZcxxService.list(sql);
|
||||
|
||||
List<ZgfwZclb> lbList = dao.query(ZgfwZclb.class, Cnd.NEW());
|
||||
list.forEach(v->{
|
||||
String assetCode = v.getString("assetStatus");
|
||||
List<String> assetList = JSONUtil.parseArray(assetCode).toList(String.class);
|
||||
String assetStatusName = lbList.stream().filter(item -> assetList.contains(item.getContentCode()))
|
||||
.map(item -> item.getCategoryName()).collect(Collectors.joining(","));
|
||||
v.set("assetStatusName", assetStatusName);
|
||||
});
|
||||
|
||||
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||
entityList.add(new ExcelExportEntity("资产编号", "assetNumber", 20));
|
||||
entityList.add(new ExcelExportEntity("资产名称", "assetName", 20));
|
||||
entityList.add(new ExcelExportEntity("财政六大类名称", "financeSixName", 20));
|
||||
// entityList.add(new ExcelExportEntity("所属学院", "unitName", 20));
|
||||
// entityList.add(new ExcelExportEntity("领用单位", "threeUnitName", 20));
|
||||
entityList.add(new ExcelExportEntity("型号", "assetModel", 20));
|
||||
entityList.add(new ExcelExportEntity("原值", "originalValue", 20));
|
||||
entityList.add(new ExcelExportEntity("资产来源", "assetSources", 20));
|
||||
entityList.add(new ExcelExportEntity("现状", "assetStatusName", 20));
|
||||
entityList.add(new ExcelExportEntity("最低使用年限", "yearsAndMonths", 20));
|
||||
entityList.add(new ExcelExportEntity("领用人", "recipientUsername", 20));
|
||||
entityList.add(new ExcelExportEntity("存放地", "storageLocation", 20));
|
||||
// entityList.add(new ExcelExportEntity("购置日期", "purchaseDate", 20));
|
||||
entityList.add(new ExcelExportEntity("入库日期", "storageDate", 20));
|
||||
entityList.add(new ExcelExportEntity("已使用年限", "yearsAndMonths", 20));
|
||||
entityList.add(new ExcelExportEntity("备注", "remark", 30));
|
||||
// entityList.add(new ExcelExportEntity("主管部门备注", "competentDepartmentRemark", 30));
|
||||
|
||||
entityList.add(new ExcelExportEntity("领用单位号", "zclydwh", 20));
|
||||
entityList.add(new ExcelExportEntity("仪器编号", "zcbh", 20));
|
||||
entityList.add(new ExcelExportEntity("仪器名称", "zcmc", 20));
|
||||
entityList.add(new ExcelExportEntity("型号", "zcxh", 20));
|
||||
entityList.add(new ExcelExportEntity("规格", "zcgg", 20));
|
||||
entityList.add(new ExcelExportEntity("单价", "zcdj", 20));
|
||||
entityList.add(new ExcelExportEntity("厂家", "zccj", 20));
|
||||
entityList.add(new ExcelExportEntity("出厂号", "zccch", 20));
|
||||
entityList.add(new ExcelExportEntity("购置日期", "zcgzrq", 20));
|
||||
entityList.add(new ExcelExportEntity("现状", "zczt", 20));
|
||||
entityList.add(new ExcelExportEntity("存放地名称", "zccfdmc", 20));
|
||||
entityList.add(new ExcelExportEntity("领用人", "zclyrname", 20));
|
||||
entityList.add(new ExcelExportEntity("经手人", "zcjsrname", 20));
|
||||
entityList.add(new ExcelExportEntity("入库时间", "zcrksj", 20));
|
||||
entityList.add(new ExcelExportEntity("单据号", "zcdjh", 20));
|
||||
entityList.add(new ExcelExportEntity("合同号", "zchth", 20));
|
||||
entityList.add(new ExcelExportEntity("经费卡号", "zcjfkh", 20));
|
||||
entityList.add(new ExcelExportEntity("经费卡金额", "zcjfkje", 20));
|
||||
entityList.add(new ExcelExportEntity("国标分类号", "zcgbflh", 20));
|
||||
entityList.add(new ExcelExportEntity("国别", "zcgb", 20));
|
||||
entityList.add(new ExcelExportEntity("发票号", "zcfph", 20));
|
||||
entityList.add(new ExcelExportEntity("供货商", "zcghs", 20));
|
||||
|
||||
try {
|
||||
ViTool.excelResponse(response, "资产总账表.xlsx");
|
||||
ViTool.excelResponse(response, "资产总账表.xls");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, list);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.zhgh.zc.model.ZgfwZclb;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @Author zhf
|
||||
* @Date 2022/10/25 9:51
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/zcgl/zclb")
|
||||
public class ZgfwZclbController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zcgl/zclb.html")
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object pageData(PageForm pageForm,
|
||||
@Param(value = "categoryName", required = false) String categoryName) {
|
||||
Sql sql = Sqls.create("SELECT * FROM `zgfw_zclb` $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(categoryName)) {
|
||||
cnd.and(Cnd.likeEX("categoryName", categoryName));
|
||||
}
|
||||
cnd.asc("contentCode");
|
||||
sql.setCondition(cnd);
|
||||
return baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object doEdit(ZgfwZclb zgfw_zclb) {
|
||||
ZgfwZclb zgfwZclb = baseService.dao().fetch(ZgfwZclb.class, Cnd.where("contentCode", "=", zgfw_zclb.getContentCode())
|
||||
.and("id","!=",zgfw_zclb.getId()));
|
||||
if (Lang.isNotEmpty(zgfwZclb)) {
|
||||
return Result.error("编号重复");
|
||||
}
|
||||
baseService.dao().update(zgfw_zclb);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object doAdd(ZgfwZclb zgfw_zclb) {
|
||||
int count = baseService.dao().count(ZgfwZclb.class, Cnd.where("contentCode", "=", zgfw_zclb.getContentCode()));
|
||||
if (count > 0) {
|
||||
return Result.error("编号重复");
|
||||
}
|
||||
zgfw_zclb.setId(R.UU32());
|
||||
baseService.dao().fastInsert(zgfw_zclb);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object doDelete(String id) {
|
||||
baseService.dao().clear(ZgfwZclb.class, Cnd.where("id", "=", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object queryLb() {
|
||||
return baseService.dao().query(ZgfwZclb.class, Cnd.NEW().asc("contentCode"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.v.nutz.zhgh.zc.controller.mobile;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
/**
|
||||
* @ClassName ZcPdMobileController
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/3/3 15:44
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/mobile/zc/zcPd")
|
||||
public class ZcPdMobileController {
|
||||
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/mobile/zc/zcPd.html")
|
||||
@RequiresPermissions("zc.bg")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+23
-5
@@ -1,9 +1,9 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.base.annontation.ViReturn;import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.model.zcDepreciationRecord;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
@@ -15,6 +15,9 @@ import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 资产折旧列表
|
||||
@@ -25,7 +28,7 @@ import org.nutz.mvc.annotation.Param;
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/zcgl/zjlb")
|
||||
public class ZczjlbController {
|
||||
public class zczjlbController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
@@ -43,12 +46,13 @@ public class ZczjlbController {
|
||||
@Param(value = "year", required = false) Integer year) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
zdr.id,
|
||||
zdr.id AS zjjlId,
|
||||
zdr.surplus,
|
||||
zdr.operationTime,
|
||||
zc.* ,
|
||||
lb.content,
|
||||
zdr.depreciationDate zdrDepreciationDate
|
||||
zdr.depreciationDate zdrDepreciationDate,
|
||||
zdr.surplusMoney zdrSurplusMoney
|
||||
FROM
|
||||
`zc_depreciation_record` zdr
|
||||
LEFT JOIN zgfw_zcxx zc ON zdr.zcid = zc.zcid
|
||||
@@ -76,5 +80,19 @@ public class ZczjlbController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zjlb")
|
||||
public Object getZcMoney(@Param(value = "contentCode", required = false) String contentCode) {
|
||||
List<Zgfw_Zcxx> zcxxes = baseService.dao().query(Zgfw_Zcxx.class, Cnd.NEW().andEX("contentCode", "=", contentCode));
|
||||
//资产原值
|
||||
Double allMoney = zcxxes.stream().mapToDouble(Zgfw_Zcxx::getAllMoney).sum();
|
||||
//固定资产净值
|
||||
Double surplusMoney = zcxxes.stream().filter(z -> !List.of("报废", "丢失").contains(z.getZczt())).mapToDouble(Zgfw_Zcxx::getSurplusMoney).sum();
|
||||
//累计折旧
|
||||
Double depreciationMoney = allMoney - surplusMoney;
|
||||
return Map.of("allMoney", allMoney, "surplusMoney", surplusMoney, "depreciationMoney", depreciationMoney);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package io.v.nutz.zhgh.zc.controller;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.annontation.ViReturn;import io.v.nutz.base.service.BaseService;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.model.zgfwZclb;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @Author zhf
|
||||
* @Date 2022/10/25 9:51
|
||||
*/
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/zcgl/zclb")
|
||||
public class zgfwZclbController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zcgl/zclb.html")
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object doEdit(zgfwZclb zgfw_zclb,
|
||||
@Param(value = "oldContentCode", required = false) String oldContentCode,
|
||||
@Param(value = "oldDepreciationYear", required = false) String oldDepreciationYear) {
|
||||
if (!oldContentCode.equals(zgfw_zclb.getContentCode())) {
|
||||
zgfwZclb zgfwZclb = baseService.dao().fetch(zgfwZclb.class, Cnd.where("contentCode", "=", zgfw_zclb.getContentCode()));
|
||||
if (zgfwZclb != null) {
|
||||
return Result.error("编号重复");
|
||||
}
|
||||
}
|
||||
if (!oldDepreciationYear.equals(zgfw_zclb.getDepreciationYear())) {
|
||||
List<Zgfw_Zcxx> zcxxList = baseService.dao().query(Zgfw_Zcxx.class, Cnd.where("contentCode", "=", zgfw_zclb.getContentCode()));
|
||||
if (zcxxList != null) {
|
||||
zcxxList.forEach(v -> {
|
||||
LocalDate rkLocalDate = v.getDepreciationDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
Period period = Period.between(LocalDate.now(), rkLocalDate);
|
||||
if ((period.getYears() * 12 + period.getMonths()) > 0) {
|
||||
DateTime dateTime = DateUtil.parse(v.getZcgzrq(), "yyyy-MM-dd");
|
||||
DateTime offsetDateTime = DateUtil.offset(dateTime, DateField.YEAR, zgfw_zclb.getDepreciationYear());
|
||||
v.setDepreciationDate(offsetDateTime);
|
||||
baseService.updateIgnoreNull(v);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
baseService.update(zgfw_zclb);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object doAdd(zgfwZclb zgfw_zclb) {
|
||||
zgfwZclb zgfwZclb = baseService.dao().fetch(zgfwZclb.class, Cnd.where("contentCode", "=", zgfw_zclb.getContentCode()));
|
||||
if (zgfwZclb != null) {
|
||||
return Result.error("编号重复");
|
||||
}
|
||||
baseService.insert(zgfw_zclb);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object pageData(PageForm page,
|
||||
@Param(value = "category", required = false) String category) {
|
||||
Sql sql = Sqls.create("SELECT * FROM `zgfw_zclb` $condition");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(page.getSearchName()) && StrUtil.isNotBlank(page.getSearchKeyword())) {
|
||||
cnd.and(Cnd.likeEX(page.getSearchName(), page.getSearchKeyword()));
|
||||
}
|
||||
cnd.andEX("category", "=", category);
|
||||
cnd.asc("contentCode");
|
||||
sql.setCondition(cnd);
|
||||
return baseService.listPageMap(page.getPageNumber(), page.getPageSize(), sql);
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object doDelete(String id) {
|
||||
baseService.dao().clear(zgfwZclb.class, Cnd.where("id", "=", id));
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("zcgl.zclb")
|
||||
public Object queryLb() {
|
||||
return baseService.dao().query(zgfwZclb.class, Cnd.NEW().asc("contentCode"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package io.v.nutz.zhgh.zc.model;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
/**
|
||||
* @ClassName ZcDJPlan
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/2/27 14:16
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
public class ZcPdPlan {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Prev(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("年度")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String year;
|
||||
|
||||
@Column
|
||||
@Comment("开始时间")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String startDate;
|
||||
|
||||
@Column
|
||||
@Comment("时间")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String endDate;
|
||||
|
||||
@Column
|
||||
@Comment("说明")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 300)
|
||||
private String note;
|
||||
|
||||
@Column
|
||||
@Comment("创建时间")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String createDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package io.v.nutz.zhgh.zc.model;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName ZgfwZcxxTemp
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/5/23 17:42
|
||||
*/
|
||||
@Data
|
||||
public class ZgfwZcxxTemp {
|
||||
|
||||
@Excel(name = "资产编号", width = 20)
|
||||
private String zcbh;
|
||||
|
||||
@Excel(name = "分类号", width = 20)
|
||||
private String zcgbflh;
|
||||
|
||||
@Excel(name = "资产名称", width = 20)
|
||||
private String zcmc;
|
||||
|
||||
@Excel(name = "型号规格", width = 20)
|
||||
private String zcxh;
|
||||
|
||||
@Excel(name = "资产所属类别", width = 20)
|
||||
private String contentCode;
|
||||
|
||||
@Excel(name = "数量", width = 10)
|
||||
private Integer sl;
|
||||
|
||||
@Excel(name = "单价", width = 10)
|
||||
private String zcdj;
|
||||
|
||||
@Excel(name = "厂家", width = 20)
|
||||
private String zccj;
|
||||
|
||||
@Excel(name = "购置日期", importFormat = "yyyy-MM-dd", exportFormat = "yyyy-MM-dd", width = 20)
|
||||
private String zcgzrq;
|
||||
|
||||
@Excel(name = "经费科目", width = 15)
|
||||
private String fundingSubject;
|
||||
|
||||
@Excel(name = "存放地点", width = 20)
|
||||
private String zccfdmc;
|
||||
|
||||
@Excel(name = "资产状态", width = 15)
|
||||
private String zczt;
|
||||
|
||||
@Excel(name = "资产类型", width = 15)
|
||||
private String zcghlx;
|
||||
|
||||
@Excel(name = "领用人", width = 20)
|
||||
private String zclyrname;
|
||||
|
||||
private String zclyrid;
|
||||
|
||||
private String zclyrgh;
|
||||
|
||||
private String zclydwh;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
package io.v.nutz.zhgh.zc.model;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Comment("资产信息")
|
||||
@Table("Zgfw_Zcxx")
|
||||
public class Zgfw_Zcxx implements Serializable {
|
||||
|
||||
@@ -19,187 +16,182 @@ public class Zgfw_Zcxx implements Serializable {
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Prev(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
private String zcid;
|
||||
|
||||
@Column
|
||||
@Comment("编号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Excel(name = "编号", width = 20)
|
||||
private String assetNumber;
|
||||
private String zcbh;
|
||||
|
||||
@Column
|
||||
@Comment("名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Excel(name = "名称", width = 20)
|
||||
private String assetName;
|
||||
|
||||
@Column
|
||||
@Comment("财政六大类名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Excel(name = "财政六大类名称", width = 20)
|
||||
private String financeSixName;
|
||||
|
||||
@Column
|
||||
@Comment("领用单位id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String threeUnitId;
|
||||
|
||||
@Column
|
||||
@Comment("领用单位")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
// @Excel(name = "领用单位", width = 20)
|
||||
private String threeUnitName;
|
||||
|
||||
@Column
|
||||
@Comment("所属学院id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@Comment("所属学院")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
// @Excel(name = "所属学院", width = 20)
|
||||
private String unitName;
|
||||
private String zcmc;
|
||||
|
||||
@Column
|
||||
@Comment("型号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Excel(name = "型号", width = 20)
|
||||
private String assetModel;
|
||||
private String zcxh;
|
||||
|
||||
@Column
|
||||
@Comment("原值")
|
||||
@ColDefine(customType = "decimal", width = 10, precision = 2)
|
||||
@Excel(name = "原值", width = 20)
|
||||
private BigDecimal originalValue;
|
||||
@Comment("规格")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zcgg;
|
||||
|
||||
@Column
|
||||
@Comment("资产来源")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Excel(name = "资产来源", width = 50)
|
||||
private String assetSources;
|
||||
@Comment("单价")
|
||||
@ColDefine(type = ColType.FLOAT, width = 30)
|
||||
private String zcdj;
|
||||
|
||||
@Column
|
||||
@Comment("现状")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
@Excel(name = "现状", width = 20)
|
||||
private List<String> assetStatus;
|
||||
@Comment("厂家")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zccj;
|
||||
|
||||
@Column
|
||||
@Comment("最低使用年限")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
@Excel(name = "最低使用年限", width = 20)
|
||||
private String minimumUsageYear;
|
||||
@Comment("出厂号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zccch;
|
||||
|
||||
@Column
|
||||
@Comment("购置日期")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String zcgzrq;
|
||||
|
||||
@Column
|
||||
@Comment("存放地名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zccfdmc;
|
||||
|
||||
@Column
|
||||
@Comment("领用人id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String recipientUserId;
|
||||
private String zclyrid;
|
||||
|
||||
@Column
|
||||
@Comment("领用人姓名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@Excel(name = "领用人姓名", width = 20)
|
||||
private String recipientUsername;
|
||||
|
||||
@Column
|
||||
@Comment("领用人工号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String recipientLoginName;
|
||||
|
||||
|
||||
@Column
|
||||
@Comment("存放地")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Excel(name = "存放地", width = 20)
|
||||
private String storageLocation;
|
||||
private String zclyrname;
|
||||
|
||||
@Column
|
||||
@Comment("购置日期")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
// @Excel(name = "购置日期", importFormat = "yyyy-MM-dd", exportFormat = "yyyy-MM-dd", width = 30)
|
||||
private String purchaseDate;
|
||||
@Comment("领用人工资号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zclyrgh;
|
||||
|
||||
@Column
|
||||
@Comment("入库日期")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Excel(name = "入库日期", importFormat = "yyyy-MM-dd", exportFormat = "yyyy-MM-dd", width = 30)
|
||||
private String storageDate;
|
||||
@Comment("经手人id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String zcjsrid;
|
||||
|
||||
@Column
|
||||
@Comment("主管部门备注")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
// @Excel(name = "主管部门备注", width = 20)
|
||||
private String competentDepartmentRemark;
|
||||
@Comment("经手人姓名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zcjsrname;
|
||||
|
||||
@Column
|
||||
@Comment("备注")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
@Excel(name = "备注", width = 20)
|
||||
private String remark;
|
||||
@Comment("经手人工号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zcjsrgh;
|
||||
|
||||
// @Column
|
||||
// @Comment("规格")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
// private String zcgg;
|
||||
@Column
|
||||
@Comment("入库时间")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String zcrksj;
|
||||
|
||||
// @Column
|
||||
// @Comment("单价")
|
||||
// @ColDefine(type = ColType.FLOAT, width = 30)
|
||||
// @Excel(name = "单价", width = 30)
|
||||
// private String zcdj;
|
||||
@Column
|
||||
@Comment("单据号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zcdjh;
|
||||
|
||||
// @Column
|
||||
// @Comment("厂家")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
// private String zccj;
|
||||
@Column
|
||||
@Comment("合同号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zchth;
|
||||
|
||||
// @Column
|
||||
// @Comment("出厂号")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
// private String zccch;
|
||||
@Column
|
||||
@Comment("经费卡号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zcjfkh;
|
||||
|
||||
// @Column
|
||||
// @Comment("领用人id")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
// private String zclyrid;
|
||||
@Column
|
||||
@Comment("经费卡金额")
|
||||
@ColDefine(type = ColType.FLOAT, width = 30)
|
||||
private BigDecimal zcjfkje;
|
||||
|
||||
// @Column
|
||||
// @Comment("领用人姓名")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
// private String zclyrname;
|
||||
@Column
|
||||
@Comment("国标分类号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String zcgbflh;
|
||||
|
||||
// @Column
|
||||
// @Comment("领用人工资号")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
// private String zclyrgh;
|
||||
@Column
|
||||
@Comment("分类号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String zcflh;
|
||||
|
||||
// @Column
|
||||
// @Comment("经手人id")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
// private String zcjsrid;
|
||||
//
|
||||
// @Column
|
||||
// @Comment("经手人姓名")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
// private String zcjsrname;
|
||||
//
|
||||
// @Column
|
||||
// @Comment("经手人工号")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
// private String zcjsrgh;
|
||||
@Column
|
||||
@Comment("国别")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String zcgb;
|
||||
|
||||
// @Column
|
||||
// @Comment("分工会资产、校工会资产")
|
||||
// @ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
// @Excel(name = "所属工会类型", width = 30)
|
||||
// private String zcghlx;
|
||||
@Column
|
||||
@Comment("发票号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zcfph;
|
||||
|
||||
// @Column
|
||||
// @Comment("数量")
|
||||
// @ColDefine(type = ColType.INT)
|
||||
// @Excel(name = "数量", width = 30)
|
||||
// private Integer sl;
|
||||
@Column
|
||||
@Comment("供货商")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String zcghs;
|
||||
|
||||
@Column
|
||||
@Comment("状态")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String zczt;
|
||||
|
||||
@Column
|
||||
@Comment("领用单位")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String zclydwh;
|
||||
|
||||
@Column
|
||||
@Comment("领用单位id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String zclydwhid;
|
||||
|
||||
@Column
|
||||
@Comment("分工会资产、校工会资产")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String zcghlx;
|
||||
|
||||
@Column
|
||||
@Comment("数量")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer sl;
|
||||
|
||||
@Column
|
||||
@Comment("资产所属类别")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String contentCode;
|
||||
|
||||
@Column
|
||||
@Comment("经费科目")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String fundingSubject;
|
||||
|
||||
@Column
|
||||
@Comment("资产折旧到期时间")
|
||||
@ColDefine(type = ColType.DATE)
|
||||
private Date depreciationDate;
|
||||
|
||||
@Column
|
||||
@Comment("剩余价值")
|
||||
@ColDefine(type = ColType.DOUBLE)
|
||||
private Double surplusMoney;
|
||||
|
||||
@Column
|
||||
@Comment("资产全部的价值")
|
||||
@ColDefine(type = ColType.DOUBLE)
|
||||
private Double allMoney;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,143 +1,114 @@
|
||||
package io.v.nutz.zhgh.zc.model;
|
||||
|
||||
import io.v.nutz.sys.models.Sys_file;
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Comment("资产变更信息表")
|
||||
/**
|
||||
* 表的字段名称以前端页面显示为准
|
||||
*/
|
||||
@Data
|
||||
@Table("Zgfw_Zcxx_bdxx")
|
||||
public class Zgfw_Zcxx_bdxx implements Serializable {
|
||||
|
||||
@Name
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Prev(els = {@EL("uuid()")})
|
||||
@Comment("资产变动信息id")
|
||||
private String zcbdid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("资产id")
|
||||
private String zcid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("原先领用人id")
|
||||
private String zcoldlyrid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("原先单位id")
|
||||
private String zcoldlydwh;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 100)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Comment("原先存放地点")
|
||||
private String zcoldcfdmc;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("现在领用人id")
|
||||
private String zcnowlyrid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("现在单位id")
|
||||
private String zcnowlydwh;
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("现在单位id")
|
||||
private String zcnowlydwhid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 100)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
@Comment("现在存放地点")
|
||||
private String zcnowcfdmc;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 20)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("变动日期")
|
||||
private String zcbdsj;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR,width = 32)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Comment("变动审核人")
|
||||
private String zcbdshrid;
|
||||
|
||||
@Column
|
||||
@Comment("购置时间")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String zcgzrq;
|
||||
|
||||
public String getZcbdid() {
|
||||
return zcbdid;
|
||||
}
|
||||
@Column
|
||||
@Comment("账面价值")
|
||||
@ColDefine(type = ColType.FLOAT, width = 10, precision = 2)
|
||||
private Integer zmjz;
|
||||
|
||||
public void setZcbdid(String zcbdid) {
|
||||
this.zcbdid = zcbdid;
|
||||
}
|
||||
@Column
|
||||
@Comment("联系电话")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
private String mobile;
|
||||
|
||||
public String getZcid() {
|
||||
return zcid;
|
||||
}
|
||||
@Column
|
||||
@Comment("盘点状态")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String pdzt;
|
||||
|
||||
public void setZcid(String zcid) {
|
||||
this.zcid = zcid;
|
||||
}
|
||||
@Column
|
||||
@Comment("未盘点原因")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String wpdzt;
|
||||
|
||||
public String getZcoldlyrid() {
|
||||
return zcoldlyrid;
|
||||
}
|
||||
@Column
|
||||
@Comment("状态")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String zczt;
|
||||
|
||||
public void setZcoldlyrid(String zcoldlyrid) {
|
||||
this.zcoldlyrid = zcoldlyrid;
|
||||
}
|
||||
@Column
|
||||
@Comment("盘点计划id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String pdPlanId;
|
||||
|
||||
public String getZcoldlydwh() {
|
||||
return zcoldlydwh;
|
||||
}
|
||||
@Column
|
||||
@Comment("资产照片")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private List<Sys_file> zcFile;
|
||||
|
||||
public void setZcoldlydwh(String zcoldlydwh) {
|
||||
this.zcoldlydwh = zcoldlydwh;
|
||||
}
|
||||
|
||||
public String getZcoldcfdmc() {
|
||||
return zcoldcfdmc;
|
||||
}
|
||||
|
||||
public void setZcoldcfdmc(String zcoldcfdmc) {
|
||||
this.zcoldcfdmc = zcoldcfdmc;
|
||||
}
|
||||
|
||||
public String getZcnowlyrid() {
|
||||
return zcnowlyrid;
|
||||
}
|
||||
|
||||
public void setZcnowlyrid(String zcnowlyrid) {
|
||||
this.zcnowlyrid = zcnowlyrid;
|
||||
}
|
||||
|
||||
public String getZcnowlydwh() {
|
||||
return zcnowlydwh;
|
||||
}
|
||||
|
||||
public void setZcnowlydwh(String zcnowlydwh) {
|
||||
this.zcnowlydwh = zcnowlydwh;
|
||||
}
|
||||
|
||||
public String getZcnowcfdmc() {
|
||||
return zcnowcfdmc;
|
||||
}
|
||||
|
||||
public void setZcnowcfdmc(String zcnowcfdmc) {
|
||||
this.zcnowcfdmc = zcnowcfdmc;
|
||||
}
|
||||
|
||||
public String getZcbdsj() {
|
||||
return zcbdsj;
|
||||
}
|
||||
|
||||
public void setZcbdsj(String zcbdsj) {
|
||||
this.zcbdsj = zcbdsj;
|
||||
}
|
||||
|
||||
public String getZcbdshrid() {
|
||||
return zcbdshrid;
|
||||
}
|
||||
|
||||
public void setZcbdshrid(String zcbdshrid) {
|
||||
this.zcbdshrid = zcbdshrid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@Table
|
||||
@Comment("资产折旧记录表")
|
||||
public class zcDepreciationRecord {
|
||||
|
||||
@Column
|
||||
@@ -35,6 +34,11 @@ public class zcDepreciationRecord {
|
||||
@ColDefine(type = ColType.INT, width = 30)
|
||||
private int surplus;
|
||||
|
||||
@Column
|
||||
@Comment("剩余价值")
|
||||
@ColDefine(type = ColType.DOUBLE)
|
||||
private Double surplusMoney;
|
||||
|
||||
|
||||
@Column
|
||||
@Comment("操作日期")
|
||||
|
||||
+9
-4
@@ -11,8 +11,7 @@ import org.nutz.dao.entity.annotation.*;
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@Comment("资产类型")
|
||||
public class ZgfwZclb {
|
||||
public class zgfwZclb {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@@ -32,8 +31,14 @@ public class ZgfwZclb {
|
||||
private String contentCode;
|
||||
|
||||
@Column
|
||||
@Comment("状态名称")
|
||||
@Comment("所属类别")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String categoryName;
|
||||
private String category;
|
||||
|
||||
@Column
|
||||
@Comment("折旧年限(年)")
|
||||
@ColDefine(type = ColType.INT, width = 30)
|
||||
private int depreciationYear;
|
||||
|
||||
|
||||
}
|
||||
@@ -2,9 +2,9 @@ package io.v.nutz.zhgh.zc.service;
|
||||
|
||||
|
||||
import cn.wizzer.framework.base.service.BaseService;
|
||||
import io.v.nutz.zhgh.zc.model.ZgfwZcxxTemp;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
|
||||
import java.util.List;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
public interface ZgfwZcxxService extends BaseService<Zgfw_Zcxx> {
|
||||
/**
|
||||
@@ -27,14 +27,16 @@ public interface ZgfwZcxxService extends BaseService<Zgfw_Zcxx> {
|
||||
* @param zgfw_zcxxes
|
||||
* @return
|
||||
*/
|
||||
List<Zgfw_Zcxx> matchAssetSataus(List<Zgfw_Zcxx> zgfw_zcxxes);
|
||||
ZgfwZcxxTemp[] matchUserId(ZgfwZcxxTemp[] zgfw_zcxxes);
|
||||
|
||||
/**
|
||||
* 不解释
|
||||
*
|
||||
* @param userName 不解释
|
||||
* @param loginName 不解释
|
||||
* @param userName 不解释
|
||||
* @return
|
||||
*/
|
||||
String getUserId(String userName, String loginName);
|
||||
Object getUserId(String userName);
|
||||
|
||||
|
||||
NutMap findOne(String id);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
package io.v.nutz.zhgh.zc.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.zhgh.zc.model.ZgfwZclb;
|
||||
import io.v.nutz.zhgh.zc.model.ZgfwZcxxTemp;
|
||||
import io.v.nutz.zhgh.zc.model.Zgfw_Zcxx;
|
||||
import io.v.nutz.zhgh.zc.service.ZgfwZcxxService;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class ZgfwZcxxServiceImpl extends ViServiceImpl<Zgfw_Zcxx> implements ZgfwZcxxService {
|
||||
@@ -30,18 +19,12 @@ public class ZgfwZcxxServiceImpl extends ViServiceImpl<Zgfw_Zcxx> implements Zgf
|
||||
super(dao);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void doAddByExcelImport(Zgfw_Zcxx[] zxccList) {
|
||||
|
||||
Arrays.stream(zxccList).forEach(v->{
|
||||
if (v.getOriginalValue() != null && !v.getOriginalValue().equals(BigDecimal.ZERO)) {
|
||||
BigDecimal originalValue = v.getOriginalValue().setScale(2, RoundingMode.HALF_UP);
|
||||
v.setOriginalValue(originalValue);
|
||||
}
|
||||
});
|
||||
|
||||
for (Zgfw_Zcxx zgfw_zcxx : zxccList) {
|
||||
zgfw_zcxx.setZcghlx(zgfw_zcxx.getZcghlx().equals("院级工会固定资产") ? "1" : "2");
|
||||
}
|
||||
dao().insert(zxccList);
|
||||
}
|
||||
|
||||
@@ -51,24 +34,49 @@ public class ZgfwZcxxServiceImpl extends ViServiceImpl<Zgfw_Zcxx> implements Zgf
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Zgfw_Zcxx> matchAssetSataus(List<Zgfw_Zcxx> zxccList) {
|
||||
List<ZgfwZclb> query = dao().query(ZgfwZclb.class, Cnd.NEW());
|
||||
zxccList.forEach(v->{
|
||||
List<String> collect = query.stream().filter(item -> v.getAssetStatus()
|
||||
.contains(item.getCategoryName())).map(ZgfwZclb::getContentCode).collect(Collectors.toList());
|
||||
if (Lang.isNotEmpty(collect)) return;
|
||||
v.setAssetStatus(collect);
|
||||
});
|
||||
public ZgfwZcxxTemp[] matchUserId(ZgfwZcxxTemp[] zxccList) {
|
||||
for (ZgfwZcxxTemp zcxx : zxccList) {
|
||||
if (StrUtil.isNotBlank(zcxx.getZclyrname())) {
|
||||
NutMap user = getUserId(zcxx.getZclyrname());
|
||||
zcxx.setZclyrid(user.getString("id"));
|
||||
zcxx.setZclyrgh(user.getString("loginname"));
|
||||
}
|
||||
if (StrUtil.isNotBlank(zcxx.getZcghlx())) {
|
||||
if (zcxx.getZcghlx().equals("1")) {
|
||||
} else if (zcxx.getZcghlx().equals("2")) {
|
||||
zcxx.setZclydwh("工会");
|
||||
}
|
||||
}
|
||||
}
|
||||
return zxccList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserId(String userName, String loginName) {
|
||||
public NutMap getUserId(String userName) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT id FROM sys_user where username = @username and loginname = @loginname
|
||||
SELECT id,loginname FROM sys_user where username = @username
|
||||
""");
|
||||
sql.setParam("username", userName);
|
||||
sql.setParam("loginname", loginName);
|
||||
return (String) Daos.query(dao(), sql.toString(), Sqls.callback.str());
|
||||
return fetch(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NutMap findOne(String id) {
|
||||
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
xx.*,
|
||||
lb.content
|
||||
FROM
|
||||
`zgfw_zcxx` xx
|
||||
LEFT JOIN zgfw_zclb lb ON xx.contentCode = lb.contentCode
|
||||
WHERE xx.zcid=@id
|
||||
""").setParam("id", id);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao().execute(sql);
|
||||
NutMap viewData = sql.getObject(NutMap.class);
|
||||
|
||||
|
||||
return viewData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user